diff options
author | Ameer Hamza <[email protected]> | 2022-07-26 02:04:46 +0500 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-25 14:04:46 -0700 |
commit | 3a1ce4914172ce4c1e39123cd31b1e5245765a5e (patch) | |
tree | fe4a619ebd1ed65e02fb7931a09eb339232789fd /lib | |
parent | 8792dd24cd9599cf506d45bcaed3af78c8cd888d (diff) |
Add createtxg sort support for simple snapshot iterator
- When iterating snapshots with name only, e.g., "-o name -s name",
libzfs uses simple snapshot iterator and results are displayed
in alphabetic order. This PR adds support for faster version of
createtxg sort by avoiding nvlist parsing for properties. Flags
"-o name -s createtxg" will enable createtxg sort while using
simple snapshot iterator.
- Added support to read createtxg property directly from zfs handle
for filesystem, volume and snapshot types instead of parsing nvlist.
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Ameer Hamza <[email protected]>
Closes #13577
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_dataset.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index a478fb31c..a8b94f758 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -527,6 +527,7 @@ 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; return (zhp); } @@ -2283,6 +2284,19 @@ 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_CREATETXG: + /* + * We can directly read createtxg property from zfs + * handle for Filesystem, Snapshot and ZVOL types. + */ + if ((zhp->zfs_type == ZFS_TYPE_FILESYSTEM) || + (zhp->zfs_type == ZFS_TYPE_SNAPSHOT) || + (zhp->zfs_type == ZFS_TYPE_VOLUME)) { + *val = zhp->zfs_dmustats.dds_creation_txg; + break; + } + zfs_fallthrough; + default: switch (zfs_prop_get_type(prop)) { case PROP_TYPE_NUMBER: |