aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_iter.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libzfs/libzfs_iter.c')
-rw-r--r--lib/libzfs/libzfs_iter.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/lib/libzfs/libzfs_iter.c b/lib/libzfs/libzfs_iter.c
index a716521ab..55cb7a8b5 100644
--- a/lib/libzfs/libzfs_iter.c
+++ b/lib/libzfs/libzfs_iter.c
@@ -39,7 +39,8 @@
#include "libzfs_impl.h"
static int
-zfs_iter_clones(zfs_handle_t *zhp, zfs_iter_f func, void *data)
+zfs_iter_clones(zfs_handle_t *zhp, int flags __maybe_unused, zfs_iter_f func,
+ void *data)
{
nvlist_t *nvl = zfs_get_clones_nvl(zhp);
nvpair_t *pair;
@@ -69,6 +70,7 @@ zfs_do_list_ioctl(zfs_handle_t *zhp, int arg, zfs_cmd_t *zc)
orig_cookie = zc->zc_cookie;
top:
(void) strlcpy(zc->zc_name, zhp->zfs_name, sizeof (zc->zc_name));
+ zc->zc_objset_stats.dds_creation_txg = 0;
rc = zfs_ioctl(zhp->zfs_hdl, arg, zc);
if (rc == -1) {
@@ -101,7 +103,7 @@ top:
* Iterate over all child filesystems
*/
int
-zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data)
+zfs_iter_filesystems(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data)
{
zfs_cmd_t zc = {"\0"};
zfs_handle_t *nzhp;
@@ -112,16 +114,21 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data)
zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
+ if ((flags & ZFS_ITER_SIMPLE) == ZFS_ITER_SIMPLE)
+ zc.zc_simple = B_TRUE;
+
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_DATASET_LIST_NEXT,
&zc)) == 0) {
+ if (zc.zc_simple)
+ nzhp = make_dataset_simple_handle_zc(zhp, &zc);
+ else
+ nzhp = make_dataset_handle_zc(zhp->zfs_hdl, &zc);
/*
* Silently ignore errors, as the only plausible explanation is
* that the pool has since been removed.
*/
- if ((nzhp = make_dataset_handle_zc(zhp->zfs_hdl,
- &zc)) == NULL) {
+ if (nzhp == NULL)
continue;
- }
if ((ret = func(nzhp, data)) != 0) {
zcmd_free_nvlists(&zc);
@@ -136,7 +143,7 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data)
* Iterate over all snapshots
*/
int
-zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
+zfs_iter_snapshots(zfs_handle_t *zhp, int flags, zfs_iter_f func,
void *data, uint64_t min_txg, uint64_t max_txg)
{
zfs_cmd_t zc = {"\0"};
@@ -148,7 +155,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
zhp->zfs_type == ZFS_TYPE_BOOKMARK)
return (0);
- zc.zc_simple = simple;
+ zc.zc_simple = (flags & ZFS_ITER_SIMPLE) != 0;
zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
@@ -168,7 +175,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT,
&zc)) == 0) {
- if (simple)
+ if (zc.zc_simple)
nzhp = make_dataset_simple_handle_zc(zhp, &zc);
else
nzhp = make_dataset_handle_zc(zhp->zfs_hdl, &zc);
@@ -190,7 +197,8 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
* Iterate over all bookmarks
*/
int
-zfs_iter_bookmarks(zfs_handle_t *zhp, zfs_iter_f func, void *data)
+zfs_iter_bookmarks(zfs_handle_t *zhp, int flags __maybe_unused,
+ zfs_iter_f func, void *data)
{
zfs_handle_t *nzhp;
nvlist_t *props = NULL;
@@ -297,8 +305,8 @@ zfs_snapshot_compare(const void *larg, const void *rarg)
}
int
-zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data,
- uint64_t min_txg, uint64_t max_txg)
+zfs_iter_snapshots_sorted(zfs_handle_t *zhp, int flags, zfs_iter_f callback,
+ void *data, uint64_t min_txg, uint64_t max_txg)
{
int ret = 0;
zfs_node_t *node;
@@ -308,7 +316,7 @@ zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data,
avl_create(&avl, zfs_snapshot_compare,
sizeof (zfs_node_t), offsetof(zfs_node_t, zn_avlnode));
- ret = zfs_iter_snapshots(zhp, B_FALSE, zfs_sort_snaps, &avl, min_txg,
+ ret = zfs_iter_snapshots(zhp, flags, zfs_sort_snaps, &avl, min_txg,
max_txg);
for (node = avl_first(&avl); node != NULL; node = AVL_NEXT(&avl, node))
@@ -371,7 +379,7 @@ snapspec_cb(zfs_handle_t *zhp, void *arg)
* return ENOENT at the end.
*/
int
-zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
+zfs_iter_snapspec(zfs_handle_t *fs_zhp, int flags, const char *spec_orig,
zfs_iter_f func, void *arg)
{
char *buf, *comma_separated, *cp;
@@ -411,7 +419,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
}
}
- err = zfs_iter_snapshots_sorted(fs_zhp,
+ err = zfs_iter_snapshots_sorted(fs_zhp, flags,
snapspec_cb, &ssa, 0, 0);
if (ret == 0)
ret = err;
@@ -448,14 +456,14 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
* and as close as possible.
*/
int
-zfs_iter_children(zfs_handle_t *zhp, zfs_iter_f func, void *data)
+zfs_iter_children(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data)
{
int ret;
- if ((ret = zfs_iter_snapshots(zhp, B_FALSE, func, data, 0, 0)) != 0)
+ if ((ret = zfs_iter_snapshots(zhp, flags, func, data, 0, 0)) != 0)
return (ret);
- return (zfs_iter_filesystems(zhp, func, data));
+ return (zfs_iter_filesystems(zhp, flags, func, data));
}
@@ -466,6 +474,7 @@ typedef struct iter_stack_frame {
typedef struct iter_dependents_arg {
boolean_t first;
+ int flags;
boolean_t allowrecursion;
iter_stack_frame_t *stack;
zfs_iter_f func;
@@ -481,7 +490,7 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg)
ida->first = B_FALSE;
if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT) {
- err = zfs_iter_clones(zhp, iter_dependents_cb, ida);
+ err = zfs_iter_clones(zhp, ida->flags, iter_dependents_cb, ida);
} else if (zhp->zfs_type != ZFS_TYPE_BOOKMARK) {
iter_stack_frame_t isf;
iter_stack_frame_t *f;
@@ -515,9 +524,10 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg)
isf.zhp = zhp;
isf.next = ida->stack;
ida->stack = &isf;
- err = zfs_iter_filesystems(zhp, iter_dependents_cb, ida);
+ err = zfs_iter_filesystems(zhp, ida->flags,
+ iter_dependents_cb, ida);
if (err == 0)
- err = zfs_iter_snapshots(zhp, B_FALSE,
+ err = zfs_iter_snapshots(zhp, ida->flags,
iter_dependents_cb, ida, 0, 0);
ida->stack = isf.next;
}
@@ -531,10 +541,11 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg)
}
int
-zfs_iter_dependents(zfs_handle_t *zhp, boolean_t allowrecursion,
+zfs_iter_dependents(zfs_handle_t *zhp, int flags, boolean_t allowrecursion,
zfs_iter_f func, void *data)
{
iter_dependents_arg_t ida;
+ ida.flags = flags;
ida.allowrecursion = allowrecursion;
ida.stack = NULL;
ida.func = func;