Skip to content

Commit 219a89c

Browse files
author
Umer Saleem
authored
Skip iterating over snapshots for share properties
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. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Umer Saleem <[email protected]> Closes #16877
1 parent f00a57a commit 219a89c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/libzfs/libzfs_changelist.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,15 @@ change_one(zfs_handle_t *zhp, void *data)
563563
cn = NULL;
564564
}
565565

566-
if (!clp->cl_alldependents)
567-
ret = zfs_iter_children_v2(zhp, 0, change_one, data);
566+
if (!clp->cl_alldependents) {
567+
if (clp->cl_prop != ZFS_PROP_MOUNTPOINT) {
568+
ret = zfs_iter_filesystems_v2(zhp, 0,
569+
change_one, data);
570+
} else {
571+
ret = zfs_iter_children_v2(zhp, 0, change_one,
572+
data);
573+
}
574+
}
568575

569576
/*
570577
* If we added the handle to the changelist, we will re-use it
@@ -738,6 +745,11 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
738745
changelist_free(clp);
739746
return (NULL);
740747
}
748+
} else if (clp->cl_prop != ZFS_PROP_MOUNTPOINT) {
749+
if (zfs_iter_filesystems_v2(zhp, 0, change_one, clp) != 0) {
750+
changelist_free(clp);
751+
return (NULL);
752+
}
741753
} else if (zfs_iter_children_v2(zhp, 0, change_one, clp) != 0) {
742754
changelist_free(clp);
743755
return (NULL);

0 commit comments

Comments
 (0)