mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-13 11:40:25 +03:00
Remove requirement for -d 1 for zfs list and zfs get with bookmarks
df58307
removed the need to specify -d 1 when zfs list and zfs get are
called with -t snapshot on a datset. This commit extends the same
behaviour to -t bookmark.
This commit also introduces the 'snap' shorthand for snapshots from
zfs list to zfs get.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9589
This commit is contained in:
parent
20e124dd71
commit
7191f049d5
@ -1882,7 +1882,7 @@ zfs_do_get(int argc, char **argv)
|
|||||||
flags &= ~ZFS_ITER_PROP_LISTSNAPS;
|
flags &= ~ZFS_ITER_PROP_LISTSNAPS;
|
||||||
while (*optarg != '\0') {
|
while (*optarg != '\0') {
|
||||||
static char *type_subopts[] = { "filesystem",
|
static char *type_subopts[] = { "filesystem",
|
||||||
"volume", "snapshot", "bookmark",
|
"volume", "snapshot", "snap", "bookmark",
|
||||||
"all", NULL };
|
"all", NULL };
|
||||||
|
|
||||||
switch (getsubopt(&optarg, type_subopts,
|
switch (getsubopt(&optarg, type_subopts,
|
||||||
@ -1894,12 +1894,13 @@ zfs_do_get(int argc, char **argv)
|
|||||||
types |= ZFS_TYPE_VOLUME;
|
types |= ZFS_TYPE_VOLUME;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
case 3:
|
||||||
types |= ZFS_TYPE_SNAPSHOT;
|
types |= ZFS_TYPE_SNAPSHOT;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 4:
|
||||||
types |= ZFS_TYPE_BOOKMARK;
|
types |= ZFS_TYPE_BOOKMARK;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 5:
|
||||||
types = ZFS_TYPE_DATASET |
|
types = ZFS_TYPE_DATASET |
|
||||||
ZFS_TYPE_BOOKMARK;
|
ZFS_TYPE_BOOKMARK;
|
||||||
break;
|
break;
|
||||||
@ -1932,11 +1933,11 @@ zfs_do_get(int argc, char **argv)
|
|||||||
fields = argv[0];
|
fields = argv[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle users who want to get all snapshots of the current
|
* Handle users who want to get all snapshots or bookmarks
|
||||||
* dataset (ex. 'zfs get -t snapshot refer <dataset>').
|
* of a dataset (ex. 'zfs get -t snapshot refer <dataset>').
|
||||||
*/
|
*/
|
||||||
if (types == ZFS_TYPE_SNAPSHOT && argc > 1 &&
|
if ((types == ZFS_TYPE_SNAPSHOT || types == ZFS_TYPE_BOOKMARK) &&
|
||||||
(flags & ZFS_ITER_RECURSE) == 0 && limit == 0) {
|
argc > 1 && (flags & ZFS_ITER_RECURSE) == 0 && limit == 0) {
|
||||||
flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
|
flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
|
||||||
limit = 1;
|
limit = 1;
|
||||||
}
|
}
|
||||||
@ -3436,11 +3437,11 @@ zfs_do_list(int argc, char **argv)
|
|||||||
types &= ~ZFS_TYPE_SNAPSHOT;
|
types &= ~ZFS_TYPE_SNAPSHOT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle users who want to list all snapshots of the current
|
* Handle users who want to list all snapshots or bookmarks
|
||||||
* dataset (ex. 'zfs list -t snapshot <dataset>').
|
* of the current dataset (ex. 'zfs list -t snapshot <dataset>').
|
||||||
*/
|
*/
|
||||||
if (types == ZFS_TYPE_SNAPSHOT && argc > 0 &&
|
if ((types == ZFS_TYPE_SNAPSHOT || types == ZFS_TYPE_BOOKMARK) &&
|
||||||
(flags & ZFS_ITER_RECURSE) == 0 && limit == 0) {
|
argc > 0 && (flags & ZFS_ITER_RECURSE) == 0 && limit == 0) {
|
||||||
flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
|
flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
|
||||||
limit = 1;
|
limit = 1;
|
||||||
}
|
}
|
||||||
|
@ -92,5 +92,16 @@ log_must eval "zfs get -H -t snapshot -o name creation $DEPTH_FS > $DEPTH_OUTPUT
|
|||||||
log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
|
log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
|
||||||
log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
|
log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
|
||||||
|
|
||||||
|
# Ensure 'zfs get -t snap' works as a shorthand for 'zfs get -t snapshot'
|
||||||
|
log_must eval "zfs get -H -t snap -d 1 -o name creation $DEPTH_FS > $DEPTH_OUTPUT"
|
||||||
|
log_must eval "zfs get -H -t snapshot -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
|
||||||
|
log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
|
||||||
|
|
||||||
|
# Ensure 'zfs get -t bookmark <dataset>' works as though -d 1 was specified
|
||||||
|
log_must eval "zfs get -H -t bookmark -o name creation $DEPTH_FS > $DEPTH_OUTPUT"
|
||||||
|
log_must eval "zfs get -H -t bookmark -d 1 -o name creation $DEPTH_FS > $EXPECT_OUTPUT"
|
||||||
|
log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT
|
||||||
|
|
||||||
|
|
||||||
log_pass "'zfs get -d <n>' should get expected output."
|
log_pass "'zfs get -d <n>' should get expected output."
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ set -A depth_options "d 0" "d 1" "d 2" "d 4" "d 32"
|
|||||||
set -A depth_array 0 1 2 4 32
|
set -A depth_array 0 1 2 4 32
|
||||||
|
|
||||||
#
|
#
|
||||||
# Setup multiple depths datasets, including fs, volume and snapshot.
|
# Setup multiple depths datasets, including fs, volumes, snapshots and bookmarks.
|
||||||
#
|
#
|
||||||
function depth_fs_setup
|
function depth_fs_setup
|
||||||
{
|
{
|
||||||
@ -65,6 +65,7 @@ function depth_fs_setup
|
|||||||
log_must zfs create -V 8M $fs/vol_"$j"_depth"$i"
|
log_must zfs create -V 8M $fs/vol_"$j"_depth"$i"
|
||||||
fi
|
fi
|
||||||
log_must zfs snapshot $fs@snap_"$j"_depth"$i"
|
log_must zfs snapshot $fs@snap_"$j"_depth"$i"
|
||||||
|
log_must zfs bookmark $fs@snap_"$j"_depth"$i" '#bookmark'_"$j"_depth"$i"
|
||||||
(( j=j+1 ))
|
(( j=j+1 ))
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user