aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schwarz <[email protected]>2022-02-04 20:52:10 +0100
committerGitHub <[email protected]>2022-02-04 11:52:10 -0800
commit2f14adacaa8211f4d628f905986005246602b2ac (patch)
treec24d078cdf00ffcc4d12e6f49f3adcc12a5c8a96
parentdb875800765a013cda9957af9e54c2c963b3cca1 (diff)
zfs_set_prop_nvlist: make it easier to spot the call to dsl_props_set
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Christian Schwarz <[email protected]> Closes #12963
-rw-r--r--module/zfs/zfs_ioctl.c81
1 files changed, 44 insertions, 37 deletions
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index e004410ea..17eb7d497 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -2558,6 +2558,7 @@ zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
nvpair_t *pair;
nvpair_t *propval;
int rv = 0;
+ int err;
uint64_t intval;
const char *strval;
boolean_t should_update_mount_cache = B_FALSE;
@@ -2569,7 +2570,7 @@ retry:
while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) {
const char *propname = nvpair_name(pair);
zfs_prop_t prop = zfs_name_to_prop(propname);
- int err = 0;
+ err = 0;
/* decode the property value */
propval = pair;
@@ -2668,47 +2669,53 @@ retry:
goto retry;
}
- if (!nvlist_empty(genericnvl) &&
- dsl_props_set(dsname, source, genericnvl) != 0) {
- /*
- * If this fails, we still want to set as many properties as we
- * can, so try setting them individually.
- */
- pair = NULL;
- while ((pair = nvlist_next_nvpair(genericnvl, pair)) != NULL) {
- const char *propname = nvpair_name(pair);
- int err = 0;
-
- propval = pair;
- if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
- nvlist_t *attrs;
- attrs = fnvpair_value_nvlist(pair);
- propval = fnvlist_lookup_nvpair(attrs,
- ZPROP_VALUE);
- }
+ if (nvlist_empty(genericnvl))
+ goto out;
- if (nvpair_type(propval) == DATA_TYPE_STRING) {
- strval = fnvpair_value_string(propval);
- err = dsl_prop_set_string(dsname, propname,
- source, strval);
- } else if (nvpair_type(propval) == DATA_TYPE_BOOLEAN) {
- err = dsl_prop_inherit(dsname, propname,
- source);
- } else {
- intval = fnvpair_value_uint64(propval);
- err = dsl_prop_set_int(dsname, propname, source,
- intval);
- }
+ /*
+ * Try to set them all in one batch.
+ */
+ err = dsl_props_set(dsname, source, genericnvl);
+ if (err == 0)
+ goto out;
- if (err != 0) {
- if (errlist != NULL) {
- fnvlist_add_int32(errlist, propname,
- err);
- }
- rv = err;
+ /*
+ * If batching fails, we still want to set as many properties as we
+ * can, so try setting them individually.
+ */
+ pair = NULL;
+ while ((pair = nvlist_next_nvpair(genericnvl, pair)) != NULL) {
+ const char *propname = nvpair_name(pair);
+ err = 0;
+
+ propval = pair;
+ if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
+ nvlist_t *attrs;
+ attrs = fnvpair_value_nvlist(pair);
+ propval = fnvlist_lookup_nvpair(attrs, ZPROP_VALUE);
+ }
+
+ if (nvpair_type(propval) == DATA_TYPE_STRING) {
+ strval = fnvpair_value_string(propval);
+ err = dsl_prop_set_string(dsname, propname,
+ source, strval);
+ } else if (nvpair_type(propval) == DATA_TYPE_BOOLEAN) {
+ err = dsl_prop_inherit(dsname, propname, source);
+ } else {
+ intval = fnvpair_value_uint64(propval);
+ err = dsl_prop_set_int(dsname, propname, source,
+ intval);
+ }
+
+ if (err != 0) {
+ if (errlist != NULL) {
+ fnvlist_add_int32(errlist, propname, err);
}
+ rv = err;
}
}
+
+out:
if (should_update_mount_cache)
zfs_ioctl_update_mount_cache(dsname);