Skip to content

Commit

Permalink
Skip iterating over snapshots for share properties
Browse files Browse the repository at this point in the history
Setting sharenfs and sharesmb properties on a dataset can become costly
if there are large number of snapshots, since setting the share
properties iterates over all snapshots present for a dataset. If it is
the root dataset for which we are trying to set the share property,
snapshots for all child datasets and their children will also be
iterated.

There is no need to iterate over snapshots for share properties
because we do not allow share properties or any other property,
to be set on a snapshot itself execpt for user properties.

This commit skips iterating over snapshots for share properties,
instead iterate over all child dataset and their children for share
properties.

Signed-off-by: Umer Saleem <[email protected]>
  • Loading branch information
usaleem-ix committed Dec 17, 2024
1 parent 882a809 commit 3d58c4e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/libzfs/libzfs_changelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,15 @@ change_one(zfs_handle_t *zhp, void *data)
cn = NULL;
}

if (!clp->cl_alldependents)
ret = zfs_iter_children_v2(zhp, 0, change_one, data);
if (!clp->cl_alldependents) {
if (clp->cl_prop != ZFS_PROP_MOUNTPOINT) {
ret = zfs_iter_filesystems_v2(zhp, 0,
change_one, data);
} else {
ret = zfs_iter_children_v2(zhp, 0, change_one,
data);
}
}

/*
* If we added the handle to the changelist, we will re-use it
Expand Down Expand Up @@ -738,6 +745,11 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
changelist_free(clp);
return (NULL);
}
} else if (clp->cl_prop != ZFS_PROP_MOUNTPOINT) {
if (zfs_iter_filesystems_v2(zhp, 0, change_one, clp) != 0) {
changelist_free(clp);
return (NULL);
}
} else if (zfs_iter_children_v2(zhp, 0, change_one, clp) != 0) {
changelist_free(clp);
return (NULL);
Expand Down

0 comments on commit 3d58c4e

Please sign in to comment.