- Small fixes

This commit is contained in:
Faruk Kasumovic 2017-12-07 09:54:07 +01:00
parent a7726113d4
commit 006e8a798a
3 changed files with 78 additions and 87 deletions

12
zfs.h
View File

@ -17,17 +17,6 @@ typedef struct zfs_share {
uint64_t z_sharemax; /* max length of share string */ uint64_t z_sharemax; /* max length of share string */
} zfs_share_t; } zfs_share_t;
struct drr_begin {
uint64_t drr_magic;
uint64_t drr_versioninfo; /* was drr_version */
uint64_t drr_creation_time;
dmu_objset_type_t drr_type;
uint32_t drr_flags;
uint64_t drr_toguid;
uint64_t drr_fromguid;
char drr_toname[MAXNAMELEN];
} drr_begin;
/* /*
* A limited number of zpl level stats are retrievable * A limited number of zpl level stats are retrievable
* with an ioctl. zfs diff is the current consumer. * with an ioctl. zfs diff is the current consumer.
@ -97,7 +86,6 @@ typedef struct zfs_cmd {
uint64_t zc_iflags; /* internal to zfs(7fs) */ uint64_t zc_iflags; /* internal to zfs(7fs) */
zfs_share_t zc_share; zfs_share_t zc_share;
dmu_objset_stats_t zc_objset_stats; dmu_objset_stats_t zc_objset_stats;
struct drr_begin zc_begin_record;
zinject_record_t zc_inject_record; zinject_record_t zc_inject_record;
uint32_t zc_defer_destroy; uint32_t zc_defer_destroy;
uint32_t zc_flags; uint32_t zc_flags;

View File

@ -266,6 +266,9 @@ func PoolImportSearch(searchpaths []string) (epools []ExportedPool, err error) {
} }
ep.State = PoolState(C.get_zpool_state(config)) ep.State = PoolState(C.get_zpool_state(config))
if ep.State != PoolStateExported {
continue
}
if cname = C.get_zpool_name(config); cname == nil { if cname = C.get_zpool_name(config); cname == nil {
err = fmt.Errorf("Failed to fetch %s", C.ZPOOL_CONFIG_POOL_NAME) err = fmt.Errorf("Failed to fetch %s", C.ZPOOL_CONFIG_POOL_NAME)
@ -351,8 +354,8 @@ func poolSearchImport(q string, searchpaths []string, guid bool) (name string,
} }
name = C.GoString(cname) name = C.GoString(cname)
} }
if retcode := C.zpool_import(C.libzfsHandle, config, cname, if retcode := C.zpool_import_props(C.libzfsHandle, config, cname,
nil); retcode != 0 { nil, C.ZFS_IMPORT_NORMAL); retcode != 0 {
err = LastError() err = LastError()
return return
} }

146
zpool.h
View File

@ -67,79 +67,79 @@ const char *get_zpool_comment(nvlist_ptr nv);
nvlist_ptr get_zpool_vdev_tree(nvlist_ptr nv); nvlist_ptr get_zpool_vdev_tree(nvlist_ptr nv);
char *sZPOOL_CONFIG_VERSION; extern char *sZPOOL_CONFIG_VERSION;
char *sZPOOL_CONFIG_POOL_NAME; extern char *sZPOOL_CONFIG_POOL_NAME;
char *sZPOOL_CONFIG_POOL_STATE; extern char *sZPOOL_CONFIG_POOL_STATE;
char *sZPOOL_CONFIG_POOL_TXG; extern char *sZPOOL_CONFIG_POOL_TXG;
char *sZPOOL_CONFIG_POOL_GUID; extern char *sZPOOL_CONFIG_POOL_GUID;
char *sZPOOL_CONFIG_CREATE_TXG; extern char *sZPOOL_CONFIG_CREATE_TXG;
char *sZPOOL_CONFIG_TOP_GUID; extern char *sZPOOL_CONFIG_TOP_GUID;
char *sZPOOL_CONFIG_VDEV_TREE; extern char *sZPOOL_CONFIG_VDEV_TREE;
char *sZPOOL_CONFIG_TYPE; extern char *sZPOOL_CONFIG_TYPE;
char *sZPOOL_CONFIG_CHILDREN; extern char *sZPOOL_CONFIG_CHILDREN;
char *sZPOOL_CONFIG_ID; extern char *sZPOOL_CONFIG_ID;
char *sZPOOL_CONFIG_GUID; extern char *sZPOOL_CONFIG_GUID;
char *sZPOOL_CONFIG_PATH; extern char *sZPOOL_CONFIG_PATH;
char *sZPOOL_CONFIG_DEVID; extern char *sZPOOL_CONFIG_DEVID;
char *sZPOOL_CONFIG_METASLAB_ARRAY; extern char *sZPOOL_CONFIG_METASLAB_ARRAY;
char *sZPOOL_CONFIG_METASLAB_SHIFT; extern char *sZPOOL_CONFIG_METASLAB_SHIFT;
char *sZPOOL_CONFIG_ASHIFT; extern char *sZPOOL_CONFIG_ASHIFT;
char *sZPOOL_CONFIG_ASIZE; extern char *sZPOOL_CONFIG_ASIZE;
char *sZPOOL_CONFIG_DTL; extern char *sZPOOL_CONFIG_DTL;
char *sZPOOL_CONFIG_SCAN_STATS; extern char *sZPOOL_CONFIG_SCAN_STATS;
char *sZPOOL_CONFIG_VDEV_STATS; extern char *sZPOOL_CONFIG_VDEV_STATS;
char *sZPOOL_CONFIG_WHOLE_DISK; extern char *sZPOOL_CONFIG_WHOLE_DISK;
char *sZPOOL_CONFIG_ERRCOUNT; extern char *sZPOOL_CONFIG_ERRCOUNT;
char *sZPOOL_CONFIG_NOT_PRESENT; extern char *sZPOOL_CONFIG_NOT_PRESENT;
char *sZPOOL_CONFIG_SPARES; extern char *sZPOOL_CONFIG_SPARES;
char *sZPOOL_CONFIG_IS_SPARE; extern char *sZPOOL_CONFIG_IS_SPARE;
char *sZPOOL_CONFIG_NPARITY; extern char *sZPOOL_CONFIG_NPARITY;
char *sZPOOL_CONFIG_HOSTID; extern char *sZPOOL_CONFIG_HOSTID;
char *sZPOOL_CONFIG_HOSTNAME; extern char *sZPOOL_CONFIG_HOSTNAME;
char *sZPOOL_CONFIG_LOADED_TIME; extern char *sZPOOL_CONFIG_LOADED_TIME;
char *sZPOOL_CONFIG_UNSPARE; extern char *sZPOOL_CONFIG_UNSPARE;
char *sZPOOL_CONFIG_PHYS_PATH; extern char *sZPOOL_CONFIG_PHYS_PATH;
char *sZPOOL_CONFIG_IS_LOG; extern char *sZPOOL_CONFIG_IS_LOG;
char *sZPOOL_CONFIG_L2CACHE; extern char *sZPOOL_CONFIG_L2CACHE;
char *sZPOOL_CONFIG_HOLE_ARRAY; extern char *sZPOOL_CONFIG_HOLE_ARRAY;
char *sZPOOL_CONFIG_VDEV_CHILDREN; extern char *sZPOOL_CONFIG_VDEV_CHILDREN;
char *sZPOOL_CONFIG_IS_HOLE; extern char *sZPOOL_CONFIG_IS_HOLE;
char *sZPOOL_CONFIG_DDT_HISTOGRAM; extern char *sZPOOL_CONFIG_DDT_HISTOGRAM;
char *sZPOOL_CONFIG_DDT_OBJ_STATS; extern char *sZPOOL_CONFIG_DDT_OBJ_STATS;
char *sZPOOL_CONFIG_DDT_STATS; extern char *sZPOOL_CONFIG_DDT_STATS;
char *sZPOOL_CONFIG_SPLIT; extern char *sZPOOL_CONFIG_SPLIT;
char *sZPOOL_CONFIG_ORIG_GUID; extern char *sZPOOL_CONFIG_ORIG_GUID;
char *sZPOOL_CONFIG_SPLIT_GUID; extern char *sZPOOL_CONFIG_SPLIT_GUID;
char *sZPOOL_CONFIG_SPLIT_LIST; extern char *sZPOOL_CONFIG_SPLIT_LIST;
char *sZPOOL_CONFIG_REMOVING; extern char *sZPOOL_CONFIG_REMOVING;
char *sZPOOL_CONFIG_RESILVER_TXG; extern char *sZPOOL_CONFIG_RESILVER_TXG;
char *sZPOOL_CONFIG_COMMENT; extern char *sZPOOL_CONFIG_COMMENT;
char *sZPOOL_CONFIG_SUSPENDED; extern char *sZPOOL_CONFIG_SUSPENDED;
char *sZPOOL_CONFIG_TIMESTAMP; extern char *sZPOOL_CONFIG_TIMESTAMP;
char *sZPOOL_CONFIG_BOOTFS; extern char *sZPOOL_CONFIG_BOOTFS;
char *sZPOOL_CONFIG_MISSING_DEVICES; extern char *sZPOOL_CONFIG_MISSING_DEVICES;
char *sZPOOL_CONFIG_LOAD_INFO; extern char *sZPOOL_CONFIG_LOAD_INFO;
char *sZPOOL_CONFIG_REWIND_INFO; extern char *sZPOOL_CONFIG_REWIND_INFO;
char *sZPOOL_CONFIG_UNSUP_FEAT; extern char *sZPOOL_CONFIG_UNSUP_FEAT;
char *sZPOOL_CONFIG_ENABLED_FEAT; extern char *sZPOOL_CONFIG_ENABLED_FEAT;
char *sZPOOL_CONFIG_CAN_RDONLY; extern char *sZPOOL_CONFIG_CAN_RDONLY;
char *sZPOOL_CONFIG_FEATURES_FOR_READ; extern char *sZPOOL_CONFIG_FEATURES_FOR_READ;
char *sZPOOL_CONFIG_FEATURE_STATS; extern char *sZPOOL_CONFIG_FEATURE_STATS;
char *sZPOOL_CONFIG_ERRATA; extern char *sZPOOL_CONFIG_ERRATA;
char *sZPOOL_CONFIG_OFFLINE; extern char *sZPOOL_CONFIG_OFFLINE;
char *sZPOOL_CONFIG_FAULTED; extern char *sZPOOL_CONFIG_FAULTED;
char *sZPOOL_CONFIG_DEGRADED; extern char *sZPOOL_CONFIG_DEGRADED;
char *sZPOOL_CONFIG_REMOVED; extern char *sZPOOL_CONFIG_REMOVED;
char *sZPOOL_CONFIG_FRU; extern char *sZPOOL_CONFIG_FRU;
char *sZPOOL_CONFIG_AUX_STATE; extern char *sZPOOL_CONFIG_AUX_STATE;
char *sZPOOL_REWIND_POLICY; extern char *sZPOOL_REWIND_POLICY;
char *sZPOOL_REWIND_REQUEST; extern char *sZPOOL_REWIND_REQUEST;
char *sZPOOL_REWIND_REQUEST_TXG; extern char *sZPOOL_REWIND_REQUEST_TXG;
char *sZPOOL_REWIND_META_THRESH; extern char *sZPOOL_REWIND_META_THRESH;
char *sZPOOL_REWIND_DATA_THRESH; extern char *sZPOOL_REWIND_DATA_THRESH;
char *sZPOOL_CONFIG_LOAD_TIME; extern char *sZPOOL_CONFIG_LOAD_TIME;
char *sZPOOL_CONFIG_LOAD_DATA_ERRORS; extern char *sZPOOL_CONFIG_LOAD_DATA_ERRORS;
char *sZPOOL_CONFIG_REWIND_TIME; extern char *sZPOOL_CONFIG_REWIND_TIME;
#endif #endif