mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-27 04:32:16 +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.
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Closes #11080
This commit is contained in:
@@ -597,7 +597,7 @@ 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] = { 0 };
|
||||
@@ -640,7 +640,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:
|
||||
sd->parent_fromsnap_guid = parent_fromsnap_guid_save;
|
||||
@@ -1212,7 +1212,7 @@ dump_filesystem(zfs_handle_t *zhp, void *arg)
|
||||
if (!sdd->replicate && sdd->tosnap != NULL)
|
||||
max_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name,
|
||||
sdd->tosnap);
|
||||
rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, arg,
|
||||
rv = zfs_iter_snapshots_sorted(zhp, 0, dump_snapshot, arg,
|
||||
min_txg, max_txg);
|
||||
} else {
|
||||
char snapname[MAXPATHLEN] = { 0 };
|
||||
@@ -2959,9 +2959,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);
|
||||
}
|
||||
@@ -3015,9 +3015,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