mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
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:
parent
db87580076
commit
2f14adacaa
@ -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;
|
||||
if (nvlist_empty(genericnvl))
|
||||
goto out;
|
||||
|
||||
propval = pair;
|
||||
if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
|
||||
nvlist_t *attrs;
|
||||
attrs = fnvpair_value_nvlist(pair);
|
||||
propval = fnvlist_lookup_nvpair(attrs,
|
||||
ZPROP_VALUE);
|
||||
}
|
||||
/*
|
||||
* Try to set them all in one batch.
|
||||
*/
|
||||
err = dsl_props_set(dsname, source, genericnvl);
|
||||
if (err == 0)
|
||||
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);
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
if (err != 0) {
|
||||
if (errlist != NULL) {
|
||||
fnvlist_add_int32(errlist, propname,
|
||||
err);
|
||||
}
|
||||
rv = err;
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user