mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-28 08:02:54 +00:00
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 reverted399b98198
.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 <behlendorf1@llnl.gov> Reviewed-by: George Wilson <george.wilson@delphix.com> Original-patch-by: George Wilson <george.wilson@delphix.com> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Sponsored-by: Klara, Inc. Closes #14597
This commit is contained in:
parent
ff73574cd8
commit
baca06c258
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -8855,7 +8855,7 @@ check_unsupp_fs(zfs_handle_t *zhp, void *unsupp_fs)
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
zfs_iter_filesystems(zhp, 0, check_unsupp_fs, unsupp_fs);
|
||||
zfs_iter_filesystems_v2(zhp, 0, check_unsupp_fs, unsupp_fs);
|
||||
|
||||
zfs_close(zhp);
|
||||
|
||||
|
@ -535,8 +535,8 @@ zfs_key_config_get_dataset(zfs_key_config_t *config)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
(void) zfs_iter_filesystems(zhp, 0, find_dsname_by_prop_value,
|
||||
config);
|
||||
(void) zfs_iter_filesystems_v2(zhp, 0,
|
||||
find_dsname_by_prop_value, config);
|
||||
zfs_close(zhp);
|
||||
char *dsname = config->dsname;
|
||||
config->dsname = NULL;
|
||||
|
@ -656,17 +656,29 @@ _LIBZFS_H void zprop_print_one_property(const char *, zprop_get_cbdata_t *,
|
||||
|
||||
typedef int (*zfs_iter_f)(zfs_handle_t *, void *);
|
||||
_LIBZFS_H int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_children(zfs_handle_t *, int, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_dependents(zfs_handle_t *, int, boolean_t, zfs_iter_f,
|
||||
_LIBZFS_H int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f,
|
||||
void *);
|
||||
_LIBZFS_H int zfs_iter_filesystems(zfs_handle_t *, int, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_snapshots(zfs_handle_t *, int, zfs_iter_f, void *,
|
||||
_LIBZFS_H int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *,
|
||||
uint64_t, uint64_t);
|
||||
_LIBZFS_H int zfs_iter_snapshots_sorted(zfs_handle_t *, int, zfs_iter_f, void *,
|
||||
_LIBZFS_H int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *,
|
||||
uint64_t, uint64_t);
|
||||
_LIBZFS_H int zfs_iter_snapspec(zfs_handle_t *, int, const char *, zfs_iter_f,
|
||||
_LIBZFS_H int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f,
|
||||
void *);
|
||||
_LIBZFS_H int zfs_iter_bookmarks(zfs_handle_t *, int, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_bookmarks(zfs_handle_t *, zfs_iter_f, void *);
|
||||
|
||||
_LIBZFS_H int zfs_iter_children_v2(zfs_handle_t *, int, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_dependents_v2(zfs_handle_t *, int, boolean_t, zfs_iter_f,
|
||||
void *);
|
||||
_LIBZFS_H int zfs_iter_filesystems_v2(zfs_handle_t *, int, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_snapshots_v2(zfs_handle_t *, int, zfs_iter_f, void *,
|
||||
uint64_t, uint64_t);
|
||||
_LIBZFS_H int zfs_iter_snapshots_sorted_v2(zfs_handle_t *, int, zfs_iter_f,
|
||||
void *, uint64_t, uint64_t);
|
||||
_LIBZFS_H int zfs_iter_snapspec_v2(zfs_handle_t *, int, const char *,
|
||||
zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_bookmarks_v2(zfs_handle_t *, int, zfs_iter_f, void *);
|
||||
_LIBZFS_H int zfs_iter_mounted(zfs_handle_t *, zfs_iter_f, void *);
|
||||
|
||||
typedef struct get_all_cb {
|
||||
|
@ -339,14 +339,21 @@
|
||||
<elf-symbol name='zfs_is_shared' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_isnumber' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_bookmarks' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_bookmarks_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_children' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_children_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_dependents' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_dependents_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_filesystems' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_filesystems_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_mounted' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_root' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_snapshots' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_snapshots_sorted' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_snapshots_sorted_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_snapshots_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_snapspec' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_iter_snapspec_v2' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_mod_supported' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_mount' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
<elf-symbol name='zfs_mount_at' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||
@ -2261,18 +2268,31 @@
|
||||
<return type-id='9c313c2d'/>
|
||||
</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'/>
|
||||
<parameter type-id='95e97e5e'/>
|
||||
<parameter type-id='d8e49ab9'/>
|
||||
<parameter type-id='eaa32e2f'/>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_children_v2' mangled-name='zfs_iter_children_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_children_v2'>
|
||||
<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'/>
|
||||
<parameter type-id='95e97e5e'/>
|
||||
<parameter type-id='c19b74c3'/>
|
||||
<parameter type-id='d8e49ab9'/>
|
||||
<parameter type-id='eaa32e2f'/>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='c19b74c3' name='allowrecursion'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_dependents_v2' mangled-name='zfs_iter_dependents_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_dependents_v2'>
|
||||
<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'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_mounted' mangled-name='zfs_iter_mounted' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_mounted'>
|
||||
@ -3305,10 +3325,16 @@
|
||||
<return type-id='80f4b756'/>
|
||||
</function-decl>
|
||||
<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'/>
|
||||
<parameter type-id='95e97e5e'/>
|
||||
<parameter type-id='d8e49ab9'/>
|
||||
<parameter type-id='eaa32e2f'/>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_filesystems_v2' mangled-name='zfs_iter_filesystems_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_filesystems_v2'>
|
||||
<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_parent_name' mangled-name='zfs_parent_name' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_parent_name'>
|
||||
@ -3882,19 +3908,34 @@
|
||||
<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'/>
|
||||
<parameter type-id='95e97e5e'/>
|
||||
<parameter type-id='d8e49ab9'/>
|
||||
<parameter type-id='eaa32e2f'/>
|
||||
<parameter type-id='9c313c2d'/>
|
||||
<parameter type-id='9c313c2d'/>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='c19b74c3' name='simple'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<parameter type-id='9c313c2d' name='min_txg'/>
|
||||
<parameter type-id='9c313c2d' name='max_txg'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_snapshots_v2' mangled-name='zfs_iter_snapshots_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_snapshots_v2'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<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'/>
|
||||
<parameter type-id='9c313c2d' name='max_txg'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</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'/>
|
||||
<parameter type-id='95e97e5e'/>
|
||||
<parameter type-id='d8e49ab9'/>
|
||||
<parameter type-id='eaa32e2f'/>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_bookmarks_v2' mangled-name='zfs_iter_bookmarks_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_bookmarks_v2'>
|
||||
<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_destroy_snaps_nvl_os' mangled-name='zfs_destroy_snaps_nvl_os' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_destroy_snaps_nvl_os'>
|
||||
@ -5091,6 +5132,14 @@
|
||||
<return type-id='9200a744'/>
|
||||
</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='d8e49ab9' name='callback'/>
|
||||
<parameter type-id='eaa32e2f' name='data'/>
|
||||
<parameter type-id='9c313c2d' name='min_txg'/>
|
||||
<parameter type-id='9c313c2d' name='max_txg'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_snapshots_sorted_v2' mangled-name='zfs_iter_snapshots_sorted_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_snapshots_sorted_v2'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='d8e49ab9' name='callback'/>
|
||||
@ -5100,6 +5149,13 @@
|
||||
<return type-id='95e97e5e'/>
|
||||
</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='80f4b756' name='spec_orig'/>
|
||||
<parameter type-id='d8e49ab9' name='func'/>
|
||||
<parameter type-id='eaa32e2f' name='arg'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_iter_snapspec_v2' mangled-name='zfs_iter_snapspec_v2' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_iter_snapspec_v2'>
|
||||
<parameter type-id='9200a744' name='fs_zhp'/>
|
||||
<parameter type-id='95e97e5e' name='flags'/>
|
||||
<parameter type-id='80f4b756' name='spec_orig'/>
|
||||
|
@ -552,7 +552,7 @@ change_one(zfs_handle_t *zhp, void *data)
|
||||
}
|
||||
|
||||
if (!clp->cl_alldependents)
|
||||
ret = zfs_iter_children(zhp, 0, change_one, data);
|
||||
ret = zfs_iter_children_v2(zhp, 0, change_one, data);
|
||||
|
||||
/*
|
||||
* If we added the handle to the changelist, we will re-use it
|
||||
@ -721,11 +721,12 @@ 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, 0, B_TRUE, change_one, clp) != 0) {
|
||||
if (zfs_iter_dependents_v2(zhp, 0, B_TRUE, change_one,
|
||||
clp) != 0) {
|
||||
changelist_free(clp);
|
||||
return (NULL);
|
||||
}
|
||||
} else if (zfs_iter_children(zhp, 0, change_one, clp) != 0) {
|
||||
} else if (zfs_iter_children_v2(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, 0, load_keys_cb, cb);
|
||||
(void) zfs_iter_filesystems_v2(zhp, 0, load_keys_cb, cb);
|
||||
zfs_close(zhp);
|
||||
|
||||
/* always return 0, since this function is best effort */
|
||||
|
@ -757,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, 0, zfs_open_bookmarks_cb,
|
||||
if ((zfs_iter_bookmarks_v2(pzhp, 0, zfs_open_bookmarks_cb,
|
||||
&cb_data) == 0) && (cb_data.zhp == NULL)) {
|
||||
(void) zfs_error(hdl, EZFS_NOENT, errbuf);
|
||||
zfs_close(pzhp);
|
||||
@ -2476,7 +2476,7 @@ get_clones_cb(zfs_handle_t *zhp, void *arg)
|
||||
}
|
||||
|
||||
out:
|
||||
(void) zfs_iter_children(zhp, 0, get_clones_cb, gca);
|
||||
(void) zfs_iter_children_v2(zhp, 0, get_clones_cb, gca);
|
||||
zfs_close(zhp);
|
||||
return (0);
|
||||
}
|
||||
@ -3925,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, 0, zfs_check_snap_cb, dd);
|
||||
rv = zfs_iter_filesystems_v2(zhp, 0, zfs_check_snap_cb, dd);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
@ -4163,7 +4163,7 @@ zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
|
||||
|
||||
fnvlist_add_boolean(sd->sd_nvl, name);
|
||||
|
||||
rv = zfs_iter_filesystems(zhp, 0, zfs_snapshot_cb, sd);
|
||||
rv = zfs_iter_filesystems_v2(zhp, 0, zfs_snapshot_cb, sd);
|
||||
}
|
||||
zfs_close(zhp);
|
||||
|
||||
@ -4340,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, 0, B_FALSE,
|
||||
cbp->cb_error |= zfs_iter_dependents_v2(zhp, 0, B_FALSE,
|
||||
rollback_destroy_dependent, cbp);
|
||||
|
||||
cbp->cb_error |= zfs_destroy(zhp, B_FALSE);
|
||||
@ -4380,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, 0, rollback_destroy, &cb,
|
||||
(void) zfs_iter_snapshots_v2(zhp, 0, rollback_destroy, &cb,
|
||||
min_txg, 0);
|
||||
|
||||
(void) zfs_iter_bookmarks(zhp, 0, rollback_destroy, &cb);
|
||||
(void) zfs_iter_bookmarks_v2(zhp, 0, rollback_destroy, &cb);
|
||||
|
||||
if (cb.cb_error)
|
||||
return (-1);
|
||||
@ -4964,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, 0, zfs_hold_one, ha);
|
||||
rv = zfs_iter_filesystems_v2(zhp, 0, zfs_hold_one, ha);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
@ -5095,7 +5095,7 @@ zfs_release_one(zfs_handle_t *zhp, void *arg)
|
||||
}
|
||||
|
||||
if (ha->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, 0, zfs_release_one, ha);
|
||||
rv = zfs_iter_filesystems_v2(zhp, 0, zfs_release_one, ha);
|
||||
zfs_close(zhp);
|
||||
return (rv);
|
||||
}
|
||||
|
@ -103,7 +103,14 @@ zfs_do_list_ioctl(zfs_handle_t *zhp, int arg, zfs_cmd_t *zc)
|
||||
* Iterate over all child filesystems
|
||||
*/
|
||||
int
|
||||
zfs_iter_filesystems(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data)
|
||||
zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data)
|
||||
{
|
||||
return (zfs_iter_filesystems_v2(zhp, 0, func, data));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_filesystems_v2(zfs_handle_t *zhp, int flags, zfs_iter_f func,
|
||||
void *data)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
zfs_handle_t *nzhp;
|
||||
@ -143,7 +150,15 @@ zfs_iter_filesystems(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data)
|
||||
* Iterate over all snapshots
|
||||
*/
|
||||
int
|
||||
zfs_iter_snapshots(zfs_handle_t *zhp, int flags, zfs_iter_f func,
|
||||
zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
|
||||
void *data, uint64_t min_txg, uint64_t max_txg)
|
||||
{
|
||||
return (zfs_iter_snapshots_v2(zhp, simple ? ZFS_ITER_SIMPLE : 0, func,
|
||||
data, min_txg, max_txg));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_snapshots_v2(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"};
|
||||
@ -197,7 +212,13 @@ zfs_iter_snapshots(zfs_handle_t *zhp, int flags, zfs_iter_f func,
|
||||
* Iterate over all bookmarks
|
||||
*/
|
||||
int
|
||||
zfs_iter_bookmarks(zfs_handle_t *zhp, int flags __maybe_unused,
|
||||
zfs_iter_bookmarks(zfs_handle_t *zhp, zfs_iter_f func, void *data)
|
||||
{
|
||||
return (zfs_iter_bookmarks_v2(zhp, 0, func, data));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_bookmarks_v2(zfs_handle_t *zhp, int flags __maybe_unused,
|
||||
zfs_iter_f func, void *data)
|
||||
{
|
||||
zfs_handle_t *nzhp;
|
||||
@ -305,7 +326,15 @@ zfs_snapshot_compare(const void *larg, const void *rarg)
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_snapshots_sorted(zfs_handle_t *zhp, int flags, zfs_iter_f callback,
|
||||
zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback,
|
||||
void *data, uint64_t min_txg, uint64_t max_txg)
|
||||
{
|
||||
return (zfs_iter_snapshots_sorted_v2(zhp, 0, callback, data,
|
||||
min_txg, max_txg));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_snapshots_sorted_v2(zfs_handle_t *zhp, int flags, zfs_iter_f callback,
|
||||
void *data, uint64_t min_txg, uint64_t max_txg)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -316,7 +345,7 @@ zfs_iter_snapshots_sorted(zfs_handle_t *zhp, int flags, zfs_iter_f callback,
|
||||
avl_create(&avl, zfs_snapshot_compare,
|
||||
sizeof (zfs_node_t), offsetof(zfs_node_t, zn_avlnode));
|
||||
|
||||
ret = zfs_iter_snapshots(zhp, flags, zfs_sort_snaps, &avl, min_txg,
|
||||
ret = zfs_iter_snapshots_v2(zhp, flags, zfs_sort_snaps, &avl, min_txg,
|
||||
max_txg);
|
||||
|
||||
for (node = avl_first(&avl); node != NULL; node = AVL_NEXT(&avl, node))
|
||||
@ -379,7 +408,14 @@ snapspec_cb(zfs_handle_t *zhp, void *arg)
|
||||
* return ENOENT at the end.
|
||||
*/
|
||||
int
|
||||
zfs_iter_snapspec(zfs_handle_t *fs_zhp, int flags, const char *spec_orig,
|
||||
zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
|
||||
zfs_iter_f func, void *arg)
|
||||
{
|
||||
return (zfs_iter_snapspec_v2(fs_zhp, 0, spec_orig, func, arg));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_snapspec_v2(zfs_handle_t *fs_zhp, int flags, const char *spec_orig,
|
||||
zfs_iter_f func, void *arg)
|
||||
{
|
||||
char *buf, *comma_separated, *cp;
|
||||
@ -419,7 +455,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, int flags, const char *spec_orig,
|
||||
}
|
||||
}
|
||||
|
||||
err = zfs_iter_snapshots_sorted(fs_zhp, flags,
|
||||
err = zfs_iter_snapshots_sorted_v2(fs_zhp, flags,
|
||||
snapspec_cb, &ssa, 0, 0);
|
||||
if (ret == 0)
|
||||
ret = err;
|
||||
@ -456,14 +492,20 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, int flags, const char *spec_orig,
|
||||
* and as close as possible.
|
||||
*/
|
||||
int
|
||||
zfs_iter_children(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data)
|
||||
zfs_iter_children(zfs_handle_t *zhp, zfs_iter_f func, void *data)
|
||||
{
|
||||
return (zfs_iter_children_v2(zhp, 0, func, data));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_children_v2(zfs_handle_t *zhp, int flags, zfs_iter_f func, void *data)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((ret = zfs_iter_snapshots(zhp, flags, func, data, 0, 0)) != 0)
|
||||
if ((ret = zfs_iter_snapshots_v2(zhp, flags, func, data, 0, 0)) != 0)
|
||||
return (ret);
|
||||
|
||||
return (zfs_iter_filesystems(zhp, flags, func, data));
|
||||
return (zfs_iter_filesystems_v2(zhp, flags, func, data));
|
||||
}
|
||||
|
||||
|
||||
@ -524,10 +566,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, ida->flags,
|
||||
err = zfs_iter_filesystems_v2(zhp, ida->flags,
|
||||
iter_dependents_cb, ida);
|
||||
if (err == 0)
|
||||
err = zfs_iter_snapshots(zhp, ida->flags,
|
||||
err = zfs_iter_snapshots_v2(zhp, ida->flags,
|
||||
iter_dependents_cb, ida, 0, 0);
|
||||
ida->stack = isf.next;
|
||||
}
|
||||
@ -541,7 +583,14 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg)
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_dependents(zfs_handle_t *zhp, int flags, boolean_t allowrecursion,
|
||||
zfs_iter_dependents(zfs_handle_t *zhp, boolean_t allowrecursion,
|
||||
zfs_iter_f func, void *data)
|
||||
{
|
||||
return (zfs_iter_dependents_v2(zhp, 0, allowrecursion, func, data));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_iter_dependents_v2(zfs_handle_t *zhp, int flags, boolean_t allowrecursion,
|
||||
zfs_iter_f func, void *data)
|
||||
{
|
||||
iter_dependents_arg_t ida;
|
||||
|
@ -940,7 +940,7 @@ zfs_iter_cb(zfs_handle_t *zhp, void *data)
|
||||
}
|
||||
|
||||
libzfs_add_handle(cbp, zhp);
|
||||
if (zfs_iter_filesystems(zhp, 0, zfs_iter_cb, cbp) != 0) {
|
||||
if (zfs_iter_filesystems_v2(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, 0, zfs_iter_cb, &cb) != 0)
|
||||
if (zfs_iter_filesystems_v2(zfsp, 0, zfs_iter_cb, &cb) != 0)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
|
@ -288,7 +288,7 @@ send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv);
|
||||
|
||||
/*
|
||||
* Collect guid, valid props, optionally holds, etc. of a snapshot.
|
||||
* This interface is intended for use as a zfs_iter_snapshots_sorted visitor.
|
||||
* This interface is intended for use as a zfs_iter_snapshots_v2_sorted visitor.
|
||||
*/
|
||||
static int
|
||||
send_iterate_snap(zfs_handle_t *zhp, void *arg)
|
||||
@ -619,8 +619,8 @@ 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, 0, send_iterate_snap, sd,
|
||||
min_txg, max_txg);
|
||||
(void) zfs_iter_snapshots_sorted_v2(zhp, 0, send_iterate_snap,
|
||||
sd, min_txg, max_txg);
|
||||
} else {
|
||||
char snapname[MAXPATHLEN] = { 0 };
|
||||
zfs_handle_t *snap;
|
||||
@ -662,7 +662,7 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
|
||||
|
||||
/* Iterate over children. */
|
||||
if (sd->recursive)
|
||||
rv = zfs_iter_filesystems(zhp, 0, send_iterate_fs, sd);
|
||||
rv = zfs_iter_filesystems_v2(zhp, 0, send_iterate_fs, sd);
|
||||
|
||||
out:
|
||||
/* Restore saved fields. */
|
||||
@ -1083,7 +1083,7 @@ send_print_verbose(FILE *fout, const char *tosnap, const char *fromsnap,
|
||||
|
||||
/*
|
||||
* Send a single filesystem snapshot, updating the send dump data.
|
||||
* This interface is intended for use as a zfs_iter_snapshots_sorted visitor.
|
||||
* This interface is intended for use as a zfs_iter_snapshots_v2_sorted visitor.
|
||||
*/
|
||||
static int
|
||||
dump_snapshot(zfs_handle_t *zhp, void *arg)
|
||||
@ -1293,7 +1293,7 @@ dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd)
|
||||
zhp->zfs_name, sdd->tosnap);
|
||||
}
|
||||
}
|
||||
rv = zfs_iter_snapshots_sorted(zhp, 0, dump_snapshot, sdd,
|
||||
rv = zfs_iter_snapshots_sorted_v2(zhp, 0, dump_snapshot, sdd,
|
||||
min_txg, max_txg);
|
||||
} else {
|
||||
char snapname[MAXPATHLEN] = { 0 };
|
||||
@ -3162,9 +3162,9 @@ guid_to_name_cb(zfs_handle_t *zhp, void *arg)
|
||||
return (EEXIST);
|
||||
}
|
||||
|
||||
err = zfs_iter_children(zhp, 0, guid_to_name_cb, gtnd);
|
||||
err = zfs_iter_children_v2(zhp, 0, guid_to_name_cb, gtnd);
|
||||
if (err != EEXIST && gtnd->bookmark_ok)
|
||||
err = zfs_iter_bookmarks(zhp, 0, guid_to_name_cb, gtnd);
|
||||
err = zfs_iter_bookmarks_v2(zhp, 0, guid_to_name_cb, gtnd);
|
||||
zfs_close(zhp);
|
||||
return (err);
|
||||
}
|
||||
@ -3218,9 +3218,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, 0, guid_to_name_cb, >nd);
|
||||
err = zfs_iter_children_v2(zhp, 0, guid_to_name_cb,
|
||||
>nd);
|
||||
if (err != EEXIST && bookmark_ok)
|
||||
err = zfs_iter_bookmarks(zhp, 0, guid_to_name_cb,
|
||||
err = zfs_iter_bookmarks_v2(zhp, 0, guid_to_name_cb,
|
||||
>nd);
|
||||
zfs_close(zhp);
|
||||
if (err == EEXIST)
|
||||
|
Loading…
Reference in New Issue
Block a user