aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/zfs/zfs_iter.c15
-rw-r--r--cmd/zfs/zfs_iter.h1
-rw-r--r--cmd/zfs/zfs_main.c9
-rw-r--r--lib/libzfs/libzfs_dataset.c14
-rw-r--r--module/zfs/zfs_ioctl.c2
5 files changed, 33 insertions, 8 deletions
diff --git a/cmd/zfs/zfs_iter.c b/cmd/zfs/zfs_iter.c
index b7ddf63df..a0a80d481 100644
--- a/cmd/zfs/zfs_iter.c
+++ b/cmd/zfs/zfs_iter.c
@@ -218,6 +218,13 @@ zfs_sort_only_by_name(const zfs_sort_column_t *sc)
sc->sc_prop == ZFS_PROP_NAME);
}
+int
+zfs_sort_only_by_createtxg(const zfs_sort_column_t *sc)
+{
+ return (sc != NULL && sc->sc_next == NULL &&
+ sc->sc_prop == ZFS_PROP_CREATETXG);
+}
+
static int
zfs_compare(const void *larg, const void *rarg)
{
@@ -301,7 +308,7 @@ zfs_sort(const void *larg, const void *rarg, void *data)
for (psc = sc; psc != NULL; psc = psc->sc_next) {
char lbuf[ZFS_MAXPROPLEN], rbuf[ZFS_MAXPROPLEN];
char *lstr, *rstr;
- uint64_t lnum, rnum;
+ uint64_t lnum = 0, rnum = 0;
boolean_t lvalid, rvalid;
int ret = 0;
@@ -352,11 +359,9 @@ zfs_sort(const void *larg, const void *rarg, void *data)
zfs_get_type(r), B_FALSE);
if (lvalid)
- (void) zfs_prop_get_numeric(l, psc->sc_prop,
- &lnum, NULL, NULL, 0);
+ lnum = zfs_prop_get_int(l, psc->sc_prop);
if (rvalid)
- (void) zfs_prop_get_numeric(r, psc->sc_prop,
- &rnum, NULL, NULL, 0);
+ rnum = zfs_prop_get_int(r, psc->sc_prop);
}
if (!lvalid && !rvalid)
diff --git a/cmd/zfs/zfs_iter.h b/cmd/zfs/zfs_iter.h
index d77002dec..effb22ded 100644
--- a/cmd/zfs/zfs_iter.h
+++ b/cmd/zfs/zfs_iter.h
@@ -53,6 +53,7 @@ int zfs_for_each(int, char **, int options, zfs_type_t,
int zfs_add_sort_column(zfs_sort_column_t **, const char *, boolean_t);
void zfs_free_sort_columns(zfs_sort_column_t *);
int zfs_sort_only_by_name(const zfs_sort_column_t *);
+int zfs_sort_only_by_createtxg(const zfs_sort_column_t *);
#ifdef __cplusplus
}
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 3165883b6..88aa7c91f 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -3654,11 +3654,14 @@ found3:;
argv += optind;
/*
- * If we are only going to list snapshot names and sort by name,
- * then we can use faster version.
+ * If we are only going to list snapshot names and sort by name or
+ * by createtxg, then we can use faster version.
*/
- if (strcmp(fields, "name") == 0 && zfs_sort_only_by_name(sortcol))
+ if (strcmp(fields, "name") == 0 &&
+ (zfs_sort_only_by_name(sortcol) ||
+ zfs_sort_only_by_createtxg(sortcol))) {
flags |= ZFS_ITER_SIMPLE;
+ }
/*
* If "-o space" and no types were specified, don't display snapshots.
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:
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index 0c4334550..571e55573 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -2322,6 +2322,8 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
}
if (zc->zc_simple) {
+ zc->zc_objset_stats.dds_creation_txg =
+ dsl_get_creationtxg(ds);
dsl_dataset_rele(ds, FTAG);
break;
}