libzfs_sendrecv: Style pass on send_iterate_prop
* Add a high level comment. * Move locals closer to point of use. * Use fnv* routines rather than explicit verification of success. * Factor out duplicated code by introducing isspacelimit to clarify behavior. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org> Closes #12967
This commit is contained in:
parent
dd59c422d3
commit
2b6b7111f4
|
@ -364,21 +364,23 @@ send_iterate_snap(zfs_handle_t *zhp, void *arg)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Collect all valid props from the handle snap into an nvlist.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv)
|
send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv)
|
||||||
{
|
{
|
||||||
nvlist_t *props = NULL;
|
nvlist_t *props;
|
||||||
nvpair_t *elem = NULL;
|
|
||||||
|
|
||||||
if (received_only)
|
if (received_only)
|
||||||
props = zfs_get_recvd_props(zhp);
|
props = zfs_get_recvd_props(zhp);
|
||||||
else
|
else
|
||||||
props = zhp->zfs_props;
|
props = zhp->zfs_props;
|
||||||
|
|
||||||
|
nvpair_t *elem = NULL;
|
||||||
while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
|
while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
|
||||||
char *propname = nvpair_name(elem);
|
char *propname = nvpair_name(elem);
|
||||||
zfs_prop_t prop = zfs_name_to_prop(propname);
|
zfs_prop_t prop = zfs_name_to_prop(propname);
|
||||||
nvlist_t *propnv;
|
|
||||||
|
|
||||||
if (!zfs_prop_user(propname)) {
|
if (!zfs_prop_user(propname)) {
|
||||||
/*
|
/*
|
||||||
|
@ -396,34 +398,26 @@ send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(nvpair_value_nvlist(elem, &propnv) == 0);
|
nvlist_t *propnv = fnvpair_value_nvlist(elem);
|
||||||
if (prop == ZFS_PROP_QUOTA || prop == ZFS_PROP_RESERVATION ||
|
|
||||||
|
boolean_t isspacelimit = (prop == ZFS_PROP_QUOTA ||
|
||||||
|
prop == ZFS_PROP_RESERVATION ||
|
||||||
prop == ZFS_PROP_REFQUOTA ||
|
prop == ZFS_PROP_REFQUOTA ||
|
||||||
prop == ZFS_PROP_REFRESERVATION) {
|
prop == ZFS_PROP_REFRESERVATION);
|
||||||
char *source;
|
if (isspacelimit && zhp->zfs_type == ZFS_TYPE_SNAPSHOT)
|
||||||
uint64_t value;
|
|
||||||
verify(nvlist_lookup_uint64(propnv,
|
|
||||||
ZPROP_VALUE, &value) == 0);
|
|
||||||
if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
char *source;
|
||||||
|
if (nvlist_lookup_string(propnv, ZPROP_SOURCE, &source) == 0) {
|
||||||
|
if (strcmp(source, zhp->zfs_name) != 0 &&
|
||||||
|
strcmp(source, ZPROP_SOURCE_VAL_RECVD) != 0)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
/*
|
/*
|
||||||
* May have no source before SPA_VERSION_RECVD_PROPS,
|
* May have no source before SPA_VERSION_RECVD_PROPS,
|
||||||
* but is still modifiable.
|
* but is still modifiable.
|
||||||
*/
|
*/
|
||||||
if (nvlist_lookup_string(propnv,
|
if (!isspacelimit)
|
||||||
ZPROP_SOURCE, &source) == 0) {
|
|
||||||
if ((strcmp(source, zhp->zfs_name) != 0) &&
|
|
||||||
(strcmp(source,
|
|
||||||
ZPROP_SOURCE_VAL_RECVD) != 0))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
char *source;
|
|
||||||
if (nvlist_lookup_string(propnv,
|
|
||||||
ZPROP_SOURCE, &source) != 0)
|
|
||||||
continue;
|
|
||||||
if ((strcmp(source, zhp->zfs_name) != 0) &&
|
|
||||||
(strcmp(source, ZPROP_SOURCE_VAL_RECVD) != 0))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue