mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
zfs list: Allow more fields in ZFS_ITER_SIMPLE mode
If the fields to be listed and sorted by are constrained to those
populated by dsl_dataset_fast_stat(), then zfs list is much faster,
as it does not need to open each objset and reads its properties.
A previous optimization by Pawel Dawidek
(0cee24064a) took advantage
of this to make listing snapshot names sorted only by name much faster.
However, it was limited to `-o name -s name`, this work extends this
optimization to work with:
- name
- guid
- createtxg
- numclones
- inconsistent
- redacted
- origin
and could be further extended to any other properties supported by
dsl_dataset_fast_stat() or similar, that do not require extra locking
or reading from disk.
This was committed before (9a9e2e343dfa2af28bf7910de77ae73aa006de62),
but was reverted due to a regression when used with an older kernel.
If the kernel does not populate zc->zc_objset_stats, we now fallback
to getting the properties via the slower interface, to avoid problems
with newer userland and older kernels.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Closes #14110
This commit is contained in:
@@ -2925,13 +2925,14 @@
|
||||
<abi-instr address-size='64' path='lib/libzfs/libzfs_iter.c' language='LANG_C99'>
|
||||
<function-decl name='zfs_iter_filesystems' mangled-name='zfs_iter_filesystems' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_filesystems'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_snapshots' mangled-name='zfs_iter_snapshots' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_snapshots'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='c19b74c3' name='simple'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<parameter type-id='9c313c2d' name='min_txg'/>
|
||||
@@ -2940,12 +2941,14 @@
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_bookmarks' mangled-name='zfs_iter_bookmarks' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_bookmarks'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_snapshots_sorted' mangled-name='zfs_iter_snapshots_sorted' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_snapshots_sorted'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='d8e49ab9' name='callback'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<parameter type-id='9c313c2d' name='min_txg'/>
|
||||
@@ -2954,6 +2957,7 @@
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_snapspec' mangled-name='zfs_iter_snapspec' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_snapspec'>
|
||||
<parameter type-id='9200a744' name='fs_zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='80f4b756' name='spec_orig'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='arg'/>
|
||||
@@ -2961,12 +2965,14 @@
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_children' mangled-name='zfs_iter_children' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_children'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_dependents' mangled-name='zfs_iter_dependents' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_dependents'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='c19b74c3' name='allowrecursion'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
|
||||
@@ -552,7 +552,7 @@ change_one(zfs_handle_t *zhp, void *data)
|
||||
}
|
||||
|
||||
if (!clp->cl_alldependents)
|
||||
ret = zfs_iter_children(zhp, change_one, data);
|
||||
ret = zfs_iter_children(zhp, 0, change_one, data);
|
||||
|
||||
/*
|
||||
* If we added the handle to the changelist, we will re-use it
|
||||
@@ -721,11 +721,11 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
|
||||
return (NULL);
|
||||
}
|
||||
} else if (clp->cl_alldependents) {
|
||||
if (zfs_iter_dependents(zhp, B_TRUE, change_one, clp) != 0) {
|
||||
if (zfs_iter_dependents(zhp, 0, B_TRUE, change_one, clp) != 0) {
|
||||
changelist_free(clp);
|
||||
return (NULL);
|
||||
}
|
||||
} else if (zfs_iter_children(zhp, change_one, clp) != 0) {
|
||||
} else if (zfs_iter_children(zhp, 0, change_one, clp) != 0) {
|
||||
changelist_free(clp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@@ -1226,7 +1226,7 @@ load_keys_cb(zfs_handle_t *zhp, void *arg)
|
||||
cb->cb_numfailed++;
|
||||
|
||||
out:
|
||||
(void) zfs_iter_filesystems(zhp, load_keys_cb, cb);
|
||||
(void) zfs_iter_filesystems(zhp, 0, load_keys_cb, cb);
|
||||
zfs_close(zhp);
|
||||
|
||||
/* always return 0, since this function is best effort */
|
||||
|
||||
+54
-15
@@ -527,7 +527,30 @@ make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc)
|
||||
zhp->zfs_head_type = pzhp->zfs_type;
|
||||
zhp->zfs_type = ZFS_TYPE_SNAPSHOT;
|
||||
zhp->zpool_hdl = zpool_handle(zhp);
|
||||
zhp->zfs_dmustats = zc->zc_objset_stats;
|
||||
|
||||
if (zc->zc_objset_stats.dds_creation_txg != 0) {
|
||||
/* structure assignment */
|
||||
zhp->zfs_dmustats = zc->zc_objset_stats;
|
||||
} else {
|
||||
if (get_stats_ioctl(zhp, zc) == -1) {
|
||||
zcmd_free_nvlists(zc);
|
||||
free(zhp);
|
||||
return (NULL);
|
||||
}
|
||||
if (make_dataset_handle_common(zhp, zc) == -1) {
|
||||
zcmd_free_nvlists(zc);
|
||||
free(zhp);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (zhp->zfs_dmustats.dds_is_snapshot ||
|
||||
strchr(zc->zc_name, '@') != NULL)
|
||||
zhp->zfs_type = ZFS_TYPE_SNAPSHOT;
|
||||
else if (zhp->zfs_dmustats.dds_type == DMU_OST_ZVOL)
|
||||
zhp->zfs_type = ZFS_TYPE_VOLUME;
|
||||
else if (zhp->zfs_dmustats.dds_type == DMU_OST_ZFS)
|
||||
zhp->zfs_type = ZFS_TYPE_FILESYSTEM;
|
||||
|
||||
return (zhp);
|
||||
}
|
||||
@@ -734,7 +757,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types)
|
||||
* Iterate bookmarks to find the right one.
|
||||
*/
|
||||
errno = 0;
|
||||
if ((zfs_iter_bookmarks(pzhp, zfs_open_bookmarks_cb,
|
||||
if ((zfs_iter_bookmarks(pzhp, 0, zfs_open_bookmarks_cb,
|
||||
&cb_data) == 0) && (cb_data.zhp == NULL)) {
|
||||
(void) zfs_error(hdl, EZFS_NOENT, errbuf);
|
||||
zfs_close(pzhp);
|
||||
@@ -2086,7 +2109,8 @@ getprop_string(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
|
||||
static boolean_t
|
||||
zfs_is_recvd_props_mode(zfs_handle_t *zhp)
|
||||
{
|
||||
return (zhp->zfs_props == zhp->zfs_recvd_props);
|
||||
return (zhp->zfs_props != NULL &&
|
||||
zhp->zfs_props == zhp->zfs_recvd_props);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2288,19 +2312,28 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
|
||||
*val = zhp->zfs_dmustats.dds_redacted;
|
||||
break;
|
||||
|
||||
case ZFS_PROP_GUID:
|
||||
if (zhp->zfs_dmustats.dds_guid != 0)
|
||||
*val = zhp->zfs_dmustats.dds_guid;
|
||||
else
|
||||
*val = getprop_uint64(zhp, prop, source);
|
||||
break;
|
||||
|
||||
case ZFS_PROP_CREATETXG:
|
||||
/*
|
||||
* We can directly read createtxg property from zfs
|
||||
* handle for Filesystem, Snapshot and ZVOL types.
|
||||
*/
|
||||
if ((zhp->zfs_type == ZFS_TYPE_FILESYSTEM) ||
|
||||
if (((zhp->zfs_type == ZFS_TYPE_FILESYSTEM) ||
|
||||
(zhp->zfs_type == ZFS_TYPE_SNAPSHOT) ||
|
||||
(zhp->zfs_type == ZFS_TYPE_VOLUME)) {
|
||||
(zhp->zfs_type == ZFS_TYPE_VOLUME)) &&
|
||||
(zhp->zfs_dmustats.dds_creation_txg != 0)) {
|
||||
*val = zhp->zfs_dmustats.dds_creation_txg;
|
||||
break;
|
||||
} else {
|
||||
*val = getprop_uint64(zhp, prop, source);
|
||||
}
|
||||
zfs_fallthrough;
|
||||
|
||||
default:
|
||||
switch (zfs_prop_get_type(prop)) {
|
||||
case PROP_TYPE_NUMBER:
|
||||
@@ -2443,7 +2476,7 @@ get_clones_cb(zfs_handle_t *zhp, void *arg)
|
||||
}
|
||||
|
||||
out:
|
||||
(void) zfs_iter_children(zhp, get_clones_cb, gca);
|
||||
(void) zfs_iter_children(zhp, 0, get_clones_cb, gca);
|
||||
zfs_close(zhp);
|
||||
return (0);
|
||||
}
|
||||
@@ -2728,7 +2761,13 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
|
||||
break;
|
||||
|
||||
case ZFS_PROP_ORIGIN:
|
||||
str = getprop_string(zhp, prop, &source);
|
||||
if (*zhp->zfs_dmustats.dds_origin != '\0') {
|
||||
str = (char *)&zhp->zfs_dmustats.dds_origin;
|
||||
} else {
|
||||
str = getprop_string(zhp, prop, &source);
|
||||
}
|
||||
if (str == NULL || *str == '\0')
|
||||
str = zfs_prop_default_string(prop);
|
||||
if (str == NULL)
|
||||
return (-1);
|
||||
(void) strlcpy(propbuf, str, proplen);
|
||||
@@ -3886,7 +3925,7 @@ zfs_check_snap_cb(zfs_handle_t *zhp, void *arg)
|
||||
if (lzc_exists(name))
|
||||
fnvlist_add_boolean(dd->nvl, name);
|
||||
|
||||
rv = zfs_iter_filesystems(zhp, zfs_check_snap_cb, dd);
|
||||
rv = zfs_iter_filesystems(zhp, 0, zfs_check_snap_cb, dd);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
@@ -4124,7 +4163,7 @@ zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
|
||||
|
||||
fnvlist_add_boolean(sd->sd_nvl, name);
|
||||
|
||||
rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd);
|
||||
rv = zfs_iter_filesystems(zhp, 0, zfs_snapshot_cb, sd);
|
||||
}
|
||||
zfs_close(zhp);
|
||||
|
||||
@@ -4301,7 +4340,7 @@ rollback_destroy(zfs_handle_t *zhp, void *data)
|
||||
rollback_data_t *cbp = data;
|
||||
|
||||
if (zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) > cbp->cb_create) {
|
||||
cbp->cb_error |= zfs_iter_dependents(zhp, B_FALSE,
|
||||
cbp->cb_error |= zfs_iter_dependents(zhp, 0, B_FALSE,
|
||||
rollback_destroy_dependent, cbp);
|
||||
|
||||
cbp->cb_error |= zfs_destroy(zhp, B_FALSE);
|
||||
@@ -4341,10 +4380,10 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
|
||||
if (cb.cb_create > 0)
|
||||
min_txg = cb.cb_create;
|
||||
|
||||
(void) zfs_iter_snapshots(zhp, B_FALSE, rollback_destroy, &cb,
|
||||
(void) zfs_iter_snapshots(zhp, 0, rollback_destroy, &cb,
|
||||
min_txg, 0);
|
||||
|
||||
(void) zfs_iter_bookmarks(zhp, rollback_destroy, &cb);
|
||||
(void) zfs_iter_bookmarks(zhp, 0, rollback_destroy, &cb);
|
||||
|
||||
if (cb.cb_error)
|
||||
return (-1);
|
||||
@@ -4925,7 +4964,7 @@ zfs_hold_one(zfs_handle_t *zhp, void *arg)
|
||||
fnvlist_add_string(ha->nvl, name, ha->tag);
|
||||
|
||||
if (ha->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, zfs_hold_one, ha);
|
||||
rv = zfs_iter_filesystems(zhp, 0, zfs_hold_one, ha);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
@@ -5056,7 +5095,7 @@ zfs_release_one(zfs_handle_t *zhp, void *arg)
|
||||
}
|
||||
|
||||
if (ha->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, zfs_release_one, ha);
|
||||
rv = zfs_iter_filesystems(zhp, 0, zfs_release_one, ha);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
+32
-21
@@ -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;
|
||||
|
||||
@@ -940,7 +940,7 @@ zfs_iter_cb(zfs_handle_t *zhp, void *data)
|
||||
}
|
||||
|
||||
libzfs_add_handle(cbp, zhp);
|
||||
if (zfs_iter_filesystems(zhp, zfs_iter_cb, cbp) != 0) {
|
||||
if (zfs_iter_filesystems(zhp, 0, zfs_iter_cb, cbp) != 0) {
|
||||
zfs_close(zhp);
|
||||
return (-1);
|
||||
}
|
||||
@@ -1289,7 +1289,7 @@ zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags)
|
||||
* over all child filesystems.
|
||||
*/
|
||||
libzfs_add_handle(&cb, zfsp);
|
||||
if (zfs_iter_filesystems(zfsp, zfs_iter_cb, &cb) != 0)
|
||||
if (zfs_iter_filesystems(zfsp, 0, zfs_iter_cb, &cb) != 0)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
|
||||
@@ -616,10 +616,10 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
|
||||
min_txg = fromsnap_txg;
|
||||
if (!sd->replicate && tosnap_txg != 0)
|
||||
max_txg = tosnap_txg;
|
||||
(void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd,
|
||||
(void) zfs_iter_snapshots_sorted(zhp, 0, send_iterate_snap, sd,
|
||||
min_txg, max_txg);
|
||||
} else {
|
||||
char snapname[MAXPATHLEN];
|
||||
char snapname[MAXPATHLEN] = { 0 };
|
||||
zfs_handle_t *snap;
|
||||
|
||||
(void) snprintf(snapname, sizeof (snapname), "%s@%s",
|
||||
@@ -659,7 +659,7 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
|
||||
|
||||
/* Iterate over children. */
|
||||
if (sd->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, send_iterate_fs, sd);
|
||||
rv = zfs_iter_filesystems(zhp, 0, send_iterate_fs, sd);
|
||||
|
||||
out:
|
||||
/* Restore saved fields. */
|
||||
@@ -1274,7 +1274,7 @@ dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd)
|
||||
zhp->zfs_name, sdd->tosnap);
|
||||
}
|
||||
}
|
||||
rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, sdd,
|
||||
rv = zfs_iter_snapshots_sorted(zhp, 0, dump_snapshot, sdd,
|
||||
min_txg, max_txg);
|
||||
} else {
|
||||
char snapname[MAXPATHLEN] = { 0 };
|
||||
@@ -3125,9 +3125,9 @@ guid_to_name_cb(zfs_handle_t *zhp, void *arg)
|
||||
return (EEXIST);
|
||||
}
|
||||
|
||||
err = zfs_iter_children(zhp, guid_to_name_cb, gtnd);
|
||||
err = zfs_iter_children(zhp, 0, guid_to_name_cb, gtnd);
|
||||
if (err != EEXIST && gtnd->bookmark_ok)
|
||||
err = zfs_iter_bookmarks(zhp, guid_to_name_cb, gtnd);
|
||||
err = zfs_iter_bookmarks(zhp, 0, guid_to_name_cb, gtnd);
|
||||
zfs_close(zhp);
|
||||
return (err);
|
||||
}
|
||||
@@ -3181,9 +3181,10 @@ guid_to_name_redact_snaps(libzfs_handle_t *hdl, const char *parent,
|
||||
continue;
|
||||
int err = guid_to_name_cb(zfs_handle_dup(zhp), >nd);
|
||||
if (err != EEXIST)
|
||||
err = zfs_iter_children(zhp, guid_to_name_cb, >nd);
|
||||
err = zfs_iter_children(zhp, 0, guid_to_name_cb, >nd);
|
||||
if (err != EEXIST && bookmark_ok)
|
||||
err = zfs_iter_bookmarks(zhp, guid_to_name_cb, >nd);
|
||||
err = zfs_iter_bookmarks(zhp, 0, guid_to_name_cb,
|
||||
>nd);
|
||||
zfs_close(zhp);
|
||||
if (err == EEXIST)
|
||||
return (0);
|
||||
|
||||
Reference in New Issue
Block a user