X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flibmount_utils_zfs.c;h=71966fc41aa1eea3dd3039a4cef937d1c7c0040e;hb=6b8e97b76c472068e7d6bc792e4f202b2f70ca67;hp=9e468ada0ae4b4d4eecff9685e3d49cd81ff9dde;hpb=56b4b112a497661de8dbf5a851c7a045d470deff;p=fs%2Flustre-release.git diff --git a/lustre/utils/libmount_utils_zfs.c b/lustre/utils/libmount_utils_zfs.c index 9e468ad..71966fc 100644 --- a/lustre/utils/libmount_utils_zfs.c +++ b/lustre/utils/libmount_utils_zfs.c @@ -173,24 +173,61 @@ static int zfs_erase_prop(zfs_handle_t *zhp, char *param) return zfs_remove_prop(zhp, nvl, propname); } +static int zfs_is_special_ldd_prop_param(char *name) +{ + int i; + + for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++) + if (!strcmp(name, special_ldd_prop_params[i].zlpb_prop_name)) + return 1; + + return 0; +} + static int zfs_erase_allprops(zfs_handle_t *zhp) { - nvlist_t *nvl; - nvpair_t *curr = NULL; + nvlist_t *props; + nvpair_t *nvp; + size_t str_size = 1024 * 1024; + char *strs, *cur; + int rc = 0; - nvl = zfs_get_user_props(zhp); - if (!nvl) + strs = malloc(str_size); + if (!strs) + return ENOMEM; + cur = strs; + + props = zfs_get_user_props(zhp); + if (props == NULL) { + free(strs); return ENOENT; + } + nvp = NULL; + while (nvp = nvlist_next_nvpair(props, nvp), nvp) { + if (strncmp(nvpair_name(nvp), LDD_PREFIX, strlen(LDD_PREFIX))) + continue; - curr = nvlist_next_nvpair(nvl, curr); - while (curr) { - nvpair_t *next = nvlist_next_nvpair(nvl, curr); + if (zfs_is_special_ldd_prop_param(nvpair_name(nvp))) + continue; - zfs_remove_prop(zhp, nvl, nvpair_name(curr)); - curr = next; + rc = snprintf(cur, str_size - (cur - strs), "%s", + nvpair_name(nvp)); + if (rc != strlen(nvpair_name(nvp))) { + fprintf(stderr, "%s: zfs has too many properties to erase, please repeat\n", + progname); + rc = EINVAL; + break; + } + cur += strlen(cur) + 1; + } + cur = strs; + while ( cur < (strs + str_size) && strlen(cur) > 0) { + zfs_prop_inherit(zhp, cur, false); + cur += strlen(cur) + 1; } - return 0; + free(strs); + return rc; } /* * ZFS on linux 0.7.0-rc5 commit 379ca9cf2beba802f096273e89e30914a2d6bafc @@ -482,17 +519,6 @@ static int zfs_get_prop_str(zfs_handle_t *zhp, char *prop, void *val) return ret; } -static int zfs_is_special_ldd_prop_param(char *name) -{ - int i; - - for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++) - if (!strcmp(name, special_ldd_prop_params[i].zlpb_prop_name)) - return 1; - - return 0; -} - static int zfs_get_prop_params(zfs_handle_t *zhp, char *param) { nvlist_t *props;