zfs_set_prop_nvlist: make it easier to spot the call to dsl_props_set

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <christian.schwarz@nutanix.com>
Closes #12963
This commit is contained in:
Christian Schwarz 2022-02-04 20:52:10 +01:00 committed by GitHub
parent db87580076
commit 2f14adacaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 36 deletions

View File

@ -2558,6 +2558,7 @@ zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
nvpair_t *pair; nvpair_t *pair;
nvpair_t *propval; nvpair_t *propval;
int rv = 0; int rv = 0;
int err;
uint64_t intval; uint64_t intval;
const char *strval; const char *strval;
boolean_t should_update_mount_cache = B_FALSE; boolean_t should_update_mount_cache = B_FALSE;
@ -2569,7 +2570,7 @@ retry:
while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) { while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) {
const char *propname = nvpair_name(pair); const char *propname = nvpair_name(pair);
zfs_prop_t prop = zfs_name_to_prop(propname); zfs_prop_t prop = zfs_name_to_prop(propname);
int err = 0; err = 0;
/* decode the property value */ /* decode the property value */
propval = pair; propval = pair;
@ -2668,23 +2669,30 @@ retry:
goto retry; goto retry;
} }
if (!nvlist_empty(genericnvl) && if (nvlist_empty(genericnvl))
dsl_props_set(dsname, source, genericnvl) != 0) { goto out;
/* /*
* If this fails, we still want to set as many properties as we * Try to set them all in one batch.
*/
err = dsl_props_set(dsname, source, genericnvl);
if (err == 0)
goto out;
/*
* If batching fails, we still want to set as many properties as we
* can, so try setting them individually. * can, so try setting them individually.
*/ */
pair = NULL; pair = NULL;
while ((pair = nvlist_next_nvpair(genericnvl, pair)) != NULL) { while ((pair = nvlist_next_nvpair(genericnvl, pair)) != NULL) {
const char *propname = nvpair_name(pair); const char *propname = nvpair_name(pair);
int err = 0; err = 0;
propval = pair; propval = pair;
if (nvpair_type(pair) == DATA_TYPE_NVLIST) { if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
nvlist_t *attrs; nvlist_t *attrs;
attrs = fnvpair_value_nvlist(pair); attrs = fnvpair_value_nvlist(pair);
propval = fnvlist_lookup_nvpair(attrs, propval = fnvlist_lookup_nvpair(attrs, ZPROP_VALUE);
ZPROP_VALUE);
} }
if (nvpair_type(propval) == DATA_TYPE_STRING) { if (nvpair_type(propval) == DATA_TYPE_STRING) {
@ -2692,8 +2700,7 @@ retry:
err = dsl_prop_set_string(dsname, propname, err = dsl_prop_set_string(dsname, propname,
source, strval); source, strval);
} else if (nvpair_type(propval) == DATA_TYPE_BOOLEAN) { } else if (nvpair_type(propval) == DATA_TYPE_BOOLEAN) {
err = dsl_prop_inherit(dsname, propname, err = dsl_prop_inherit(dsname, propname, source);
source);
} else { } else {
intval = fnvpair_value_uint64(propval); intval = fnvpair_value_uint64(propval);
err = dsl_prop_set_int(dsname, propname, source, err = dsl_prop_set_int(dsname, propname, source,
@ -2702,13 +2709,13 @@ retry:
if (err != 0) { if (err != 0) {
if (errlist != NULL) { if (errlist != NULL) {
fnvlist_add_int32(errlist, propname, fnvlist_add_int32(errlist, propname, err);
err);
} }
rv = err; rv = err;
} }
} }
}
out:
if (should_update_mount_cache) if (should_update_mount_cache)
zfs_ioctl_update_mount_cache(dsname); zfs_ioctl_update_mount_cache(dsname);