stopall
- [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
+ if [[ "$mds1_FSTYPE" == zfs ]]; then
+ import_zpool mds1 || return ${PIPESTATUS[0]}
+ fi
+
# Check that parameters are added correctly
echo "tunefs --param $key=$val1"
- do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
+ do_facet mds1 "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
error "tunefs --param $key=$val1 failed"
- params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
+ params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
error "tunefs --dryrun failed"
params=${params##*Parameters:}
params=${params%%exiting*}
# Check that parameters replace existing instances when added
echo "tunefs --param $key=$val2"
- do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
+ do_facet mds1 "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
error "tunefs --param $key=$val2 failed"
- params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
+ params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
error "tunefs --dryrun failed"
params=${params##*Parameters:}
params=${params%%exiting*}
# Check that a parameter is erased properly
echo "tunefs --erase-param $key"
- do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
+ do_facet mds1 "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
error "tunefs --erase-param $key failed"
- params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
+ params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
error "tunefs --dryrun failed"
params=${params##*Parameters:}
params=${params%%exiting*}
error "on-disk parameter not erased correctly via tunefs"
# Check that all the parameters are erased
+ do_facet mds1 "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
+ error "tunefs --param $key=$val1 failed"
echo "tunefs --erase-params"
- do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
+ do_facet mds1 "$TUNEFS --erase-params $mdsdev >/dev/null" ||
error "tunefs --erase-params failed"
- params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
+ params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
error "tunefs --dryrun failed"
params=${params##*Parameters:}
params=${params%%exiting*}
- [ -z $params ] ||
- error "all on-disk parameters not erased correctly via tunefs"
+ params=$(echo $params | tr ' ' '\n')
+ [ -z "$params" ] ||
+ error "all on-disk parameters not erased correctly via tunefs $params"
# Check the order of options --erase-params and --param
echo "tunefs --param $key=$val1 --erase-params"
- do_facet mds \
+ do_facet mds1 \
"$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
error "tunefs --param $key=$val1 --erase-params failed"
- params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
+ params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
error "tunefs --dryrun failed"
params=${params##*Parameters:}
params=${params%%exiting*}
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
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;