aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zfs
diff options
context:
space:
mode:
authorRob N <[email protected]>2023-04-11 04:53:02 +1000
committerGitHub <[email protected]>2023-04-10 11:53:02 -0700
commitbaca06c258e07522165cb8e33ff2c0224ad0da57 (patch)
tree29e79b53588481635d4d1e37995a9ee22be852dd /cmd/zfs
parentff73574cd83580e4dd5905a43695bd5d0f4911b3 (diff)
libzfs: add v2 iterator interfaces
f6a0dac84 modified the zfs_iter_* functions to take a new "flags" parameter, and introduced a variety of flags to ask the kernel to limit the results in various ways, reducing the amount of work the caller needed to do to filter out things they didn't need. Unfortunately this change broke the ABI for existing clients (read: older versions of the `zfs` program), and was reverted 399b98198. dc95911d2 reintroduced the original patch, with the understanding that a backwards-compatible fix would be made before the 2.2 release branch was tagged. This commit is that fix. This introduces zfs_iter_*_v2 functions that have the new flags argument, and reverts the existing functions to not have the flags parameter, as they were before. The old functions are now reimplemented in terms of the new, with flags set to 0. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: George Wilson <[email protected]> Original-patch-by: George Wilson <[email protected]> Signed-off-by: Rob Norris <[email protected]> Sponsored-by: Klara, Inc. Closes #14597
Diffstat (limited to 'cmd/zfs')
-rw-r--r--cmd/zfs/zfs_iter.c6
-rw-r--r--cmd/zfs/zfs_main.c30
2 files changed, 18 insertions, 18 deletions
diff --git a/cmd/zfs/zfs_iter.c b/cmd/zfs/zfs_iter.c
index 6665627d4..202cb0e82 100644
--- a/cmd/zfs/zfs_iter.c
+++ b/cmd/zfs/zfs_iter.c
@@ -143,19 +143,19 @@ zfs_callback(zfs_handle_t *zhp, void *data)
(cb->cb_types &
(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME))) &&
zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) {
- (void) zfs_iter_filesystems(zhp, cb->cb_flags,
+ (void) zfs_iter_filesystems_v2(zhp, cb->cb_flags,
zfs_callback, data);
}
if (((zfs_get_type(zhp) & (ZFS_TYPE_SNAPSHOT |
ZFS_TYPE_BOOKMARK)) == 0) && include_snaps) {
- (void) zfs_iter_snapshots(zhp, cb->cb_flags,
+ (void) zfs_iter_snapshots_v2(zhp, cb->cb_flags,
zfs_callback, data, 0, 0);
}
if (((zfs_get_type(zhp) & (ZFS_TYPE_SNAPSHOT |
ZFS_TYPE_BOOKMARK)) == 0) && include_bmarks) {
- (void) zfs_iter_bookmarks(zhp, cb->cb_flags,
+ (void) zfs_iter_bookmarks_v2(zhp, cb->cb_flags,
zfs_callback, data);
}
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index d65b01579..e28f1d04f 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -1532,7 +1532,8 @@ destroy_print_snapshots(zfs_handle_t *fs_zhp, destroy_cbdata_t *cb)
int err;
assert(cb->cb_firstsnap == NULL);
assert(cb->cb_prevsnap == NULL);
- err = zfs_iter_snapshots_sorted(fs_zhp, 0, destroy_print_cb, cb, 0, 0);
+ err = zfs_iter_snapshots_sorted_v2(fs_zhp, 0, destroy_print_cb, cb, 0,
+ 0);
if (cb->cb_firstsnap != NULL) {
uint64_t used = 0;
if (err == 0) {
@@ -1558,7 +1559,7 @@ snapshot_to_nvl_cb(zfs_handle_t *zhp, void *arg)
if (!cb->cb_doclones && !cb->cb_defer_destroy) {
cb->cb_target = zhp;
cb->cb_first = B_TRUE;
- err = zfs_iter_dependents(zhp, 0, B_TRUE,
+ err = zfs_iter_dependents_v2(zhp, 0, B_TRUE,
destroy_check_dependent, cb);
}
@@ -1576,7 +1577,7 @@ gather_snapshots(zfs_handle_t *zhp, void *arg)
destroy_cbdata_t *cb = arg;
int err = 0;
- err = zfs_iter_snapspec(zhp, 0, cb->cb_snapspec,
+ err = zfs_iter_snapspec_v2(zhp, 0, cb->cb_snapspec,
snapshot_to_nvl_cb, cb);
if (err == ENOENT)
err = 0;
@@ -1590,7 +1591,7 @@ gather_snapshots(zfs_handle_t *zhp, void *arg)
}
if (cb->cb_recurse)
- err = zfs_iter_filesystems(zhp, 0, gather_snapshots, cb);
+ err = zfs_iter_filesystems_v2(zhp, 0, gather_snapshots, cb);
out:
zfs_close(zhp);
@@ -1615,7 +1616,7 @@ destroy_clones(destroy_cbdata_t *cb)
* false while destroying the clones.
*/
cb->cb_defer_destroy = B_FALSE;
- err = zfs_iter_dependents(zhp, 0, B_FALSE,
+ err = zfs_iter_dependents_v2(zhp, 0, B_FALSE,
destroy_callback, cb);
cb->cb_defer_destroy = defer;
zfs_close(zhp);
@@ -1825,9 +1826,8 @@ zfs_do_destroy(int argc, char **argv)
* Check for any dependents and/or clones.
*/
cb.cb_first = B_TRUE;
- if (!cb.cb_doclones &&
- zfs_iter_dependents(zhp, 0, B_TRUE, destroy_check_dependent,
- &cb) != 0) {
+ if (!cb.cb_doclones && zfs_iter_dependents_v2(zhp, 0, B_TRUE,
+ destroy_check_dependent, &cb) != 0) {
rv = 1;
goto out;
}
@@ -1837,7 +1837,7 @@ zfs_do_destroy(int argc, char **argv)
goto out;
}
cb.cb_batchedsnaps = fnvlist_alloc();
- if (zfs_iter_dependents(zhp, 0, B_FALSE, destroy_callback,
+ if (zfs_iter_dependents_v2(zhp, 0, B_FALSE, destroy_callback,
&cb) != 0) {
rv = 1;
goto out;
@@ -4065,7 +4065,7 @@ rollback_check(zfs_handle_t *zhp, void *data)
}
if (cbp->cb_recurse) {
- if (zfs_iter_dependents(zhp, 0, B_TRUE,
+ if (zfs_iter_dependents_v2(zhp, 0, B_TRUE,
rollback_check_dependent, cbp) != 0) {
zfs_close(zhp);
return (-1);
@@ -4164,10 +4164,10 @@ zfs_do_rollback(int argc, char **argv)
if (cb.cb_create > 0)
min_txg = cb.cb_create;
- if ((ret = zfs_iter_snapshots(zhp, 0, rollback_check, &cb,
+ if ((ret = zfs_iter_snapshots_v2(zhp, 0, rollback_check, &cb,
min_txg, 0)) != 0)
goto out;
- if ((ret = zfs_iter_bookmarks(zhp, 0, rollback_check, &cb)) != 0)
+ if ((ret = zfs_iter_bookmarks_v2(zhp, 0, rollback_check, &cb)) != 0)
goto out;
if ((ret = cb.cb_error) != 0)
@@ -4309,7 +4309,7 @@ zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
free(name);
if (sd->sd_recursive)
- rv = zfs_iter_filesystems(zhp, 0, zfs_snapshot_cb, sd);
+ rv = zfs_iter_filesystems_v2(zhp, 0, zfs_snapshot_cb, sd);
zfs_close(zhp);
return (rv);
}
@@ -6373,7 +6373,7 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un)
if (un && opts.recursive) {
struct deleg_perms data = { un, update_perm_nvl };
- if (zfs_iter_filesystems(zhp, 0, set_deleg_perms,
+ if (zfs_iter_filesystems_v2(zhp, 0, set_deleg_perms,
&data) != 0)
goto cleanup0;
}
@@ -6751,7 +6751,7 @@ get_one_dataset(zfs_handle_t *zhp, void *data)
/*
* Iterate over any nested datasets.
*/
- if (zfs_iter_filesystems(zhp, 0, get_one_dataset, data) != 0) {
+ if (zfs_iter_filesystems_v2(zhp, 0, get_one_dataset, data) != 0) {
zfs_close(zhp);
return (1);
}