zfs 0.8 support (#15)

* Rename Rewind-Policy to Load-Policy

See 8a393be353 (diff-f29552ad5ed97006cc80fc2b453cbe39R726) for details.

Signed-off-by: steigr <me@stei.gr>

* Use threadpool for zpool_search_import.

See e89f1295d4 (diff-24bf46767aadc66215cb194bdba266e7) for details.

Signed-off-by: steigr <me@stei.gr>

* Use sendflags struct.

See 835db58592 for details.

Signed-off-by: steigr <me@stei.gr>

* Added new pool properties `Checkpoint` and `LoadGuid`

OpenZFS 9166 - zfs storage pool checkpoint: d2734cce68
read/write kstats per dataset: a448a2557e

Signed-off-by: steigr <me@stei.gr>
This commit is contained in:
steigr 2019-06-20 21:17:31 +02:00 committed by Faruk Kasumovic
parent 99406fb402
commit b16d96b1a8
4 changed files with 42 additions and 34 deletions

View File

@ -178,6 +178,8 @@ const (
PoolPropTName PoolPropTName
PoolPropMaxNodeSize PoolPropMaxNodeSize
PoolPropMultiHost PoolPropMultiHost
PoolPropCheckpoint
PoolPropLoadGuid
PoolNumProps PoolNumProps
) )

View File

@ -131,7 +131,7 @@ func (d *Dataset) send(FromName string, outf *os.File, flags *SendFlags) (err er
func (d *Dataset) SendOne(FromName string, outf *os.File, flags *SendFlags) (err error) { func (d *Dataset) SendOne(FromName string, outf *os.File, flags *SendFlags) (err error) {
var cfromname, ctoname *C.char var cfromname, ctoname *C.char
var dpath string var dpath string
var lzc_send_flags uint32 var lzc_send_flags C.struct_sendflags
if d.Type == DatasetTypeSnapshot || (len(FromName) > 0 && !strings.Contains(FromName, "#")) { if d.Type == DatasetTypeSnapshot || (len(FromName) > 0 && !strings.Contains(FromName, "#")) {
err = fmt.Errorf( err = fmt.Errorf(
@ -144,10 +144,10 @@ func (d *Dataset) SendOne(FromName string, outf *os.File, flags *SendFlags) (err
} }
if flags.LargeBlock { if flags.LargeBlock {
lzc_send_flags |= C.LZC_SEND_FLAG_LARGE_BLOCK lzc_send_flags.largeblock = booleanT(true)
} }
if flags.EmbedData { if flags.EmbedData {
lzc_send_flags |= C.LZC_SEND_FLAG_EMBED_DATA lzc_send_flags.embed_data = booleanT(true)
} }
// if (flags.Compress) // if (flags.Compress)
// lzc_send_flags |= LZC_SEND_FLAG_COMPRESS; // lzc_send_flags |= LZC_SEND_FLAG_COMPRESS;

30
zpool.c
View File

@ -6,6 +6,8 @@ typedef unsigned long int rlim64_t;
#include <libzfs.h> #include <libzfs.h>
#include <libzfs/sys/zfs_context.h> #include <libzfs/sys/zfs_context.h>
#include <libzutil.h>
#include <thread_pool.h>
#include <memory.h> #include <memory.h>
#include <string.h> #include <string.h>
@ -79,11 +81,11 @@ char *sZPOOL_CONFIG_DEGRADED = ZPOOL_CONFIG_DEGRADED;
char *sZPOOL_CONFIG_REMOVED = ZPOOL_CONFIG_REMOVED; char *sZPOOL_CONFIG_REMOVED = ZPOOL_CONFIG_REMOVED;
char *sZPOOL_CONFIG_FRU = ZPOOL_CONFIG_FRU; char *sZPOOL_CONFIG_FRU = ZPOOL_CONFIG_FRU;
char *sZPOOL_CONFIG_AUX_STATE = ZPOOL_CONFIG_AUX_STATE; char *sZPOOL_CONFIG_AUX_STATE = ZPOOL_CONFIG_AUX_STATE;
char *sZPOOL_REWIND_POLICY = ZPOOL_REWIND_POLICY; char *sZPOOL_LOAD_POLICY = ZPOOL_LOAD_POLICY;
char *sZPOOL_REWIND_REQUEST = ZPOOL_REWIND_REQUEST; char *sZPOOL_LOAD_REWIND_POLICY = ZPOOL_LOAD_REWIND_POLICY;
char *sZPOOL_REWIND_REQUEST_TXG = ZPOOL_REWIND_REQUEST_TXG; char *sZPOOL_LOAD_REQUEST_TXG = ZPOOL_LOAD_REQUEST_TXG;
char *sZPOOL_REWIND_META_THRESH = ZPOOL_REWIND_META_THRESH; char *sZPOOL_LOAD_META_THRESH = ZPOOL_LOAD_META_THRESH;
char *sZPOOL_REWIND_DATA_THRESH = ZPOOL_REWIND_DATA_THRESH; char *sZPOOL_LOAD_DATA_THRESH = ZPOOL_LOAD_DATA_THRESH;
char *sZPOOL_CONFIG_LOAD_TIME = ZPOOL_CONFIG_LOAD_TIME; char *sZPOOL_CONFIG_LOAD_TIME = ZPOOL_CONFIG_LOAD_TIME;
char *sZPOOL_CONFIG_LOAD_DATA_ERRORS = ZPOOL_CONFIG_LOAD_DATA_ERRORS; char *sZPOOL_CONFIG_LOAD_DATA_ERRORS = ZPOOL_CONFIG_LOAD_DATA_ERRORS;
char *sZPOOL_CONFIG_REWIND_TIME = ZPOOL_CONFIG_REWIND_TIME; char *sZPOOL_CONFIG_REWIND_TIME = ZPOOL_CONFIG_REWIND_TIME;
@ -248,8 +250,6 @@ property_list_t *read_zpool_properties(zpool_list_ptr pool) {
root = read_append_zpool_property(pool, root, ZPOOL_PROP_EXPANDSZ); root = read_append_zpool_property(pool, root, ZPOOL_PROP_EXPANDSZ);
root = read_append_zpool_property(pool, root, ZPOOL_PROP_FREEING); root = read_append_zpool_property(pool, root, ZPOOL_PROP_FREEING);
list = new_property_list(); list = new_property_list();
list->property = ZPOOL_NUM_PROPS; list->property = ZPOOL_NUM_PROPS;
sprintf(list->value, "%d", ZPOOL_NUM_PROPS); sprintf(list->value, "%d", ZPOOL_NUM_PROPS);
@ -501,18 +501,24 @@ nvlist_ptr go_zpool_search_import(libzfs_handle_ptr zfsh, int paths, char **path
idata.paths = paths; idata.paths = paths;
// idata.scan = 0; // idata.scan = 0;
thread_init(); tpool_t *t;
pools = zpool_search_import(zfsh, &idata); t = tpool_create(1, 5 * sysconf(_SC_NPROCESSORS_ONLN), 0, NULL);
thread_fini(); if (t == NULL)
return NULL;
pools = zpool_search_import(zfsh, &idata, &libzfs_config_ops);
tpool_wait(t);
tpool_destroy(t);
return pools; return pools;
} }
int do_zpool_clear(zpool_list_t *pool, const char *device, u_int32_t rewind_policy) { int do_zpool_clear(zpool_list_t *pool, const char *device, u_int32_t load_policy) {
nvlist_t *policy = NULL; nvlist_t *policy = NULL;
int ret = 0; int ret = 0;
if (nvlist_alloc(&policy, NV_UNIQUE_NAME, 0) != 0 || if (nvlist_alloc(&policy, NV_UNIQUE_NAME, 0) != 0 ||
nvlist_add_uint32(policy, ZPOOL_REWIND_REQUEST, rewind_policy) != 0) nvlist_add_uint32(policy, ZPOOL_LOAD_POLICY, load_policy) != 0)
return (1); return (1);
if (zpool_clear(pool->zph, device, policy) != 0) if (zpool_clear(pool->zph, device, policy) != 0)

10
zpool.h
View File

@ -149,11 +149,11 @@ extern char *sZPOOL_CONFIG_DEGRADED;
extern char *sZPOOL_CONFIG_REMOVED; extern char *sZPOOL_CONFIG_REMOVED;
extern char *sZPOOL_CONFIG_FRU; extern char *sZPOOL_CONFIG_FRU;
extern char *sZPOOL_CONFIG_AUX_STATE; extern char *sZPOOL_CONFIG_AUX_STATE;
extern char *sZPOOL_REWIND_POLICY; extern char *sZPOOL_LOAD_POLICY;
extern char *sZPOOL_REWIND_REQUEST; extern char *sZPOOL_LOAD_REWIND_POLICY;
extern char *sZPOOL_REWIND_REQUEST_TXG; extern char *sZPOOL_LOAD_REQUEST_TXG;
extern char *sZPOOL_REWIND_META_THRESH; extern char *sZPOOL_LOAD_META_THRESH;
extern char *sZPOOL_REWIND_DATA_THRESH; extern char *sZPOOL_LOAD_DATA_THRESH;
extern char *sZPOOL_CONFIG_LOAD_TIME; extern char *sZPOOL_CONFIG_LOAD_TIME;
extern char *sZPOOL_CONFIG_LOAD_DATA_ERRORS; extern char *sZPOOL_CONFIG_LOAD_DATA_ERRORS;
extern char *sZPOOL_CONFIG_REWIND_TIME; extern char *sZPOOL_CONFIG_REWIND_TIME;