mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +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:
+56
-8
@@ -144,19 +144,20 @@ 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, zfs_callback, data);
|
||||
(void) zfs_iter_filesystems(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 & ZFS_ITER_SIMPLE) != 0,
|
||||
(void) zfs_iter_snapshots(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, zfs_callback, data);
|
||||
(void) zfs_iter_bookmarks(zhp, cb->cb_flags,
|
||||
zfs_callback, data);
|
||||
}
|
||||
|
||||
cb->cb_depth--;
|
||||
@@ -212,11 +213,58 @@ zfs_free_sort_columns(zfs_sort_column_t *sc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
zfs_sort_only_by_name(const zfs_sort_column_t *sc)
|
||||
/*
|
||||
* Return true if all of the properties to be sorted are populated by
|
||||
* dsl_dataset_fast_stat(). Note that sc == NULL (no sort) means we
|
||||
* don't need any extra properties, so returns true.
|
||||
*/
|
||||
boolean_t
|
||||
zfs_sort_only_by_fast(const zfs_sort_column_t *sc)
|
||||
{
|
||||
return (sc != NULL && sc->sc_next == NULL &&
|
||||
sc->sc_prop == ZFS_PROP_NAME);
|
||||
while (sc != NULL) {
|
||||
switch (sc->sc_prop) {
|
||||
case ZFS_PROP_NAME:
|
||||
case ZFS_PROP_GUID:
|
||||
case ZFS_PROP_CREATETXG:
|
||||
case ZFS_PROP_NUMCLONES:
|
||||
case ZFS_PROP_INCONSISTENT:
|
||||
case ZFS_PROP_REDACTED:
|
||||
case ZFS_PROP_ORIGIN:
|
||||
break;
|
||||
default:
|
||||
return (B_FALSE);
|
||||
}
|
||||
sc = sc->sc_next;
|
||||
}
|
||||
|
||||
return (B_TRUE);
|
||||
}
|
||||
|
||||
boolean_t
|
||||
zfs_list_only_by_fast(const zprop_list_t *p)
|
||||
{
|
||||
if (p == NULL) {
|
||||
/* NULL means 'all' so we can't use simple mode */
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
while (p != NULL) {
|
||||
switch (p->pl_prop) {
|
||||
case ZFS_PROP_NAME:
|
||||
case ZFS_PROP_GUID:
|
||||
case ZFS_PROP_CREATETXG:
|
||||
case ZFS_PROP_NUMCLONES:
|
||||
case ZFS_PROP_INCONSISTENT:
|
||||
case ZFS_PROP_REDACTED:
|
||||
case ZFS_PROP_ORIGIN:
|
||||
break;
|
||||
default:
|
||||
return (B_FALSE);
|
||||
}
|
||||
p = p->pl_next;
|
||||
}
|
||||
|
||||
return (B_TRUE);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
|
||||
Reference in New Issue
Block a user