mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
zfs receive and rollback can skew filesystem_count
This commit fixes a small issue which causes both zfs receive and rollback operations to incorrectly increase the "filesystem_count" property value. This change also adds a new test group "limits" to the ZFS Test Suite to exercise both filesystem_count/limit and snapshot_count/limit functionality. Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #8232
This commit is contained in:
parent
f384c045d8
commit
0f5f23869a
@ -290,6 +290,7 @@ AC_CONFIG_FILES([
|
||||
tests/zfs-tests/tests/functional/largest_pool/Makefile
|
||||
tests/zfs-tests/tests/functional/link_count/Makefile
|
||||
tests/zfs-tests/tests/functional/libzfs/Makefile
|
||||
tests/zfs-tests/tests/functional/limits/Makefile
|
||||
tests/zfs-tests/tests/functional/migration/Makefile
|
||||
tests/zfs-tests/tests/functional/mmap/Makefile
|
||||
tests/zfs-tests/tests/functional/mmp/Makefile
|
||||
|
@ -792,14 +792,8 @@ dsl_dir_destroy_sync(uint64_t ddobj, dmu_tx_t *tx)
|
||||
|
||||
ASSERT0(dsl_dir_phys(dd)->dd_head_dataset_obj);
|
||||
|
||||
/*
|
||||
* Decrement the filesystem count for all parent filesystems.
|
||||
*
|
||||
* When we receive an incremental stream into a filesystem that already
|
||||
* exists, a temporary clone is created. We never count this temporary
|
||||
* clone, whose name begins with a '%'.
|
||||
*/
|
||||
if (dd->dd_myname[0] != '%' && dd->dd_parent != NULL)
|
||||
/* Decrement the filesystem count for all parent filesystems. */
|
||||
if (dd->dd_parent != NULL)
|
||||
dsl_fs_ss_count_adjust(dd->dd_parent, -1,
|
||||
DD_FIELD_FILESYSTEM_COUNT, tx);
|
||||
|
||||
|
@ -616,6 +616,11 @@ pre =
|
||||
post =
|
||||
tags = ['functional', 'largest_pool']
|
||||
|
||||
[tests/functional/limits]
|
||||
tests = ['filesystem_count', 'filesystem_limit', 'snapshot_count',
|
||||
'snapshot_limit']
|
||||
tags = ['functional', 'limits']
|
||||
|
||||
[tests/functional/link_count]
|
||||
tests = ['link_count_001']
|
||||
tags = ['functional', 'link_count']
|
||||
|
@ -32,6 +32,7 @@ SUBDIRS = \
|
||||
large_files \
|
||||
largest_pool \
|
||||
libzfs \
|
||||
limits \
|
||||
pyzfs \
|
||||
link_count \
|
||||
migration \
|
||||
|
9
tests/zfs-tests/tests/functional/limits/Makefile.am
Normal file
9
tests/zfs-tests/tests/functional/limits/Makefile.am
Normal file
@ -0,0 +1,9 @@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/limits
|
||||
dist_pkgdata_SCRIPTS = \
|
||||
setup.ksh \
|
||||
cleanup.ksh \
|
||||
filesystem_count.ksh \
|
||||
filesystem_limit.ksh \
|
||||
snapshot_count.ksh \
|
||||
snapshot_limit.ksh
|
||||
|
19
tests/zfs-tests/tests/functional/limits/cleanup.ksh
Executable file
19
tests/zfs-tests/tests/functional/limits/cleanup.ksh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
default_cleanup
|
123
tests/zfs-tests/tests/functional/limits/filesystem_count.ksh
Executable file
123
tests/zfs-tests/tests/functional/limits/filesystem_count.ksh
Executable file
@ -0,0 +1,123 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# ZFS 'filesystem_count' property is handled correctly by various actions
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Verify 'zfs create' and 'zfs clone' increment 'filesystem_count' value
|
||||
# 2. Verify 'zfs destroy' decrements the value
|
||||
# 3. Verify 'zfs rename' updates counts across different hierarchies
|
||||
# 4. Verify 'zfs promote' preserves counts within different hierarchies
|
||||
# 5. Verify 'zfs receive' correct behaviour
|
||||
# 6. Verify 'zfs rollback' does not update 'filesystem_count' value
|
||||
# 7. Verify 'zfs diff' does not update 'filesystem_count' value
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
function setup
|
||||
{
|
||||
log_must zfs create "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_UTIL"
|
||||
# Set filesystem_limit just to activate the filesystem_count property
|
||||
log_must zfs set filesystem_limit=100 "$DATASET_TEST"
|
||||
}
|
||||
|
||||
function cleanup
|
||||
{
|
||||
destroy_dataset "$DATASET_TEST" "-Rf"
|
||||
destroy_dataset "$DATASET_UTIL" "-Rf"
|
||||
rm -f $ZSTREAM
|
||||
}
|
||||
|
||||
log_assert "Verify 'filesystem_count' is handled correctly by various actions"
|
||||
log_onexit cleanup
|
||||
|
||||
DATASET_TEST="$TESTPOOL/$TESTFS/filesystem_count_test"
|
||||
DATASET_UTIL="$TESTPOOL/$TESTFS/filesystem_count_util"
|
||||
ZSTREAM="$TEST_BASE_DIR/filesystem_count.$$"
|
||||
|
||||
# 1. Verify 'zfs create' and 'zfs clone' increment 'filesystem_count' value
|
||||
setup
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "0"
|
||||
log_must zfs create "$DATASET_TEST/create_clone"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
log_must zfs snapshot "$DATASET_TEST/create_clone@snap"
|
||||
log_must zfs clone "$DATASET_TEST/create_clone@snap" "$DATASET_TEST/clone"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "2"
|
||||
cleanup
|
||||
|
||||
# 2. Verify 'zfs destroy' decrements the value
|
||||
setup
|
||||
log_must zfs create "$DATASET_TEST/destroy"
|
||||
log_must zfs destroy "$DATASET_TEST/destroy"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "0"
|
||||
cleanup
|
||||
|
||||
# 3. Verify 'zfs rename' updates counts across different hierarchies
|
||||
setup
|
||||
log_must zfs create "$DATASET_TEST/rename"
|
||||
log_must zfs rename "$DATASET_TEST/rename" "$DATASET_UTIL/renamed"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "0"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_UTIL")" == "1"
|
||||
cleanup
|
||||
|
||||
# 4. Verify 'zfs promote' preserves counts within different hierarchies
|
||||
setup
|
||||
log_must zfs create "$DATASET_UTIL/promote"
|
||||
log_must zfs snapshot "$DATASET_UTIL/promote@snap"
|
||||
log_must zfs clone "$DATASET_UTIL/promote@snap" "$DATASET_TEST/promoted"
|
||||
log_must zfs promote "$DATASET_TEST/promoted"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_UTIL")" == "1"
|
||||
cleanup
|
||||
|
||||
# 5. Verify 'zfs receive' correct behaviour
|
||||
setup
|
||||
log_must zfs create "$DATASET_UTIL/send"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap1"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap2"
|
||||
log_must eval "zfs send $DATASET_UTIL/send@snap1 > $ZSTREAM"
|
||||
log_must eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
log_must eval "zfs send -i @snap1 $DATASET_UTIL/send@snap2 > $ZSTREAM"
|
||||
log_must eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
cleanup
|
||||
|
||||
# 6. Verify 'zfs rollback' does not update 'filesystem_count' value
|
||||
setup
|
||||
log_must zfs create "$DATASET_TEST/rollback"
|
||||
log_must zfs snapshot "$DATASET_TEST/rollback@snap"
|
||||
log_must zfs rollback "$DATASET_TEST/rollback@snap"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
cleanup
|
||||
|
||||
# 7. Verify 'zfs diff' does not update 'filesystem_count' value
|
||||
setup
|
||||
log_must zfs create "$DATASET_TEST/diff"
|
||||
log_must zfs snapshot "$DATASET_TEST/diff@snap1"
|
||||
log_must zfs snapshot "$DATASET_TEST/diff@snap2"
|
||||
log_must zfs diff "$DATASET_TEST/diff@snap1" "$DATASET_TEST/diff@snap2"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
log_must zfs diff "$DATASET_TEST/diff@snap2"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "1"
|
||||
|
||||
log_pass "'filesystem_count' property is handled correctly"
|
84
tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh
Executable file
84
tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# ZFS 'filesystem_limit' is enforced when executing various actions
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Verify 'zfs create' and 'zfs clone' cannot exceed the filesystem_limit
|
||||
# 2. Verify 'zfs rename' cannot move filesystems exceeding the limit
|
||||
# 3. Verify 'zfs receive' cannot exceed the limit
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
function setup
|
||||
{
|
||||
log_must zfs create "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_UTIL"
|
||||
}
|
||||
|
||||
function cleanup
|
||||
{
|
||||
destroy_dataset "$DATASET_TEST" "-Rf"
|
||||
destroy_dataset "$DATASET_UTIL" "-Rf"
|
||||
rm -f $ZSTREAM
|
||||
}
|
||||
|
||||
log_assert "Verify 'filesystem_limit' is enforced executing various actions"
|
||||
log_onexit cleanup
|
||||
|
||||
DATASET_TEST="$TESTPOOL/$TESTFS/filesystem_limit_test"
|
||||
DATASET_UTIL="$TESTPOOL/$TESTFS/filesystem_limit_util"
|
||||
ZSTREAM="$TEST_BASE_DIR/filesystem_limit.$$"
|
||||
|
||||
# 1. Verify 'zfs create' and 'zfs clone' cannot exceed the filesystem_limit
|
||||
setup
|
||||
log_must zfs set filesystem_limit=1 "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_TEST/create"
|
||||
log_mustnot zfs create "$DATASET_TEST/create_exceed"
|
||||
log_mustnot datasetexists "$DATASET_TEST/create_exceed"
|
||||
log_must zfs set filesystem_limit=2 "$DATASET_TEST"
|
||||
log_must zfs snapshot "$DATASET_TEST/create@snap"
|
||||
log_must zfs clone "$DATASET_TEST/create@snap" "$DATASET_TEST/clone"
|
||||
log_mustnot zfs clone "$DATASET_TEST/create@snap" "$DATASET_TEST/clone_exceed"
|
||||
log_mustnot datasetexists "$DATASET_TEST/clone_exceed"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "2"
|
||||
cleanup
|
||||
|
||||
# 2. Verify 'zfs rename' cannot move filesystems exceeding the limit
|
||||
setup
|
||||
log_must zfs set filesystem_limit=0 "$DATASET_UTIL"
|
||||
log_must zfs create "$DATASET_TEST/rename"
|
||||
log_mustnot zfs rename "$DATASET_TEST/rename" "$DATASET_UTIL/renamed"
|
||||
log_mustnot datasetexists "$DATASET_UTIL/renamed"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_UTIL")" == "0"
|
||||
cleanup
|
||||
|
||||
# 3. Verify 'zfs receive' cannot exceed the limit
|
||||
setup
|
||||
log_must zfs set filesystem_limit=0 "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_UTIL/send"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap1"
|
||||
log_must eval "zfs send $DATASET_UTIL/send@snap1 > $ZSTREAM"
|
||||
log_mustnot eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_mustnot datasetexists "$DATASET_TEST/received"
|
||||
log_must test "$(get_prop 'filesystem_count' "$DATASET_TEST")" == "0"
|
||||
|
||||
log_pass "'filesystem_limit' property is enforced"
|
21
tests/zfs-tests/tests/functional/limits/setup.ksh
Executable file
21
tests/zfs-tests/tests/functional/limits/setup.ksh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
|
||||
default_volume_setup $DISK
|
100
tests/zfs-tests/tests/functional/limits/snapshot_count.ksh
Executable file
100
tests/zfs-tests/tests/functional/limits/snapshot_count.ksh
Executable file
@ -0,0 +1,100 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# ZFS 'snapshot_count' property is handled correctly by various actions
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Verify 'zfs snapshot' increments 'snapshot_count' value
|
||||
# 2. Verify 'zfs destroy' decrements the value
|
||||
# 3. Verify 'zfs rename' updates counts across different hierarchies
|
||||
# 4. Verify 'zfs promote' updates counts across different hierarchies
|
||||
# 5. Verify 'zfs receive' correct behaviour
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
function setup
|
||||
{
|
||||
log_must zfs create "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_UTIL"
|
||||
# Set snapshot_limit just to activate the snapshot_count property
|
||||
log_must zfs set snapshot_limit=100 "$DATASET_TEST"
|
||||
}
|
||||
|
||||
function cleanup
|
||||
{
|
||||
destroy_dataset "$DATASET_TEST" "-Rf"
|
||||
destroy_dataset "$DATASET_UTIL" "-Rf"
|
||||
rm -f $ZSTREAM
|
||||
}
|
||||
|
||||
log_assert "Verify 'snapshot_count' is handled correctly by various actions"
|
||||
log_onexit cleanup
|
||||
|
||||
DATASET_TEST="$TESTPOOL/$TESTFS/snapshot_count_test"
|
||||
DATASET_UTIL="$TESTPOOL/$TESTFS/snapshot_count_util"
|
||||
ZSTREAM="$TEST_BASE_DIR/snapshot_count.$$"
|
||||
|
||||
# 1. Verify 'zfs snapshot' increments 'snapshot_count' value
|
||||
setup
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "0"
|
||||
log_must zfs snapshot "$DATASET_TEST@snap"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "1"
|
||||
cleanup
|
||||
|
||||
# 2. Verify 'zfs destroy' decrements the value
|
||||
setup
|
||||
log_must zfs snapshot "$DATASET_TEST@snap"
|
||||
log_must zfs destroy "$DATASET_TEST@snap"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "0"
|
||||
cleanup
|
||||
|
||||
# 3. Verify 'zfs rename' updates counts across different hierarchies
|
||||
setup
|
||||
log_must zfs create "$DATASET_TEST/renamed"
|
||||
log_must zfs snapshot "$DATASET_TEST/renamed@snap"
|
||||
log_must zfs rename "$DATASET_TEST/renamed" "$DATASET_UTIL/renamed"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "0"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_UTIL")" == "1"
|
||||
cleanup
|
||||
|
||||
# 4. Verify 'zfs promote' updates counts across different hierarchies
|
||||
setup
|
||||
log_must zfs create "$DATASET_UTIL/promote"
|
||||
log_must zfs snapshot "$DATASET_UTIL/promote@snap"
|
||||
log_must zfs clone "$DATASET_UTIL/promote@snap" "$DATASET_TEST/promoted"
|
||||
log_must zfs promote "$DATASET_TEST/promoted"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "1"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_UTIL")" == "0"
|
||||
cleanup
|
||||
|
||||
# 5. Verify 'zfs receive' correct behaviour
|
||||
setup
|
||||
log_must zfs create "$DATASET_UTIL/send"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap1"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap2"
|
||||
log_must eval "zfs send $DATASET_UTIL/send@snap1 > $ZSTREAM"
|
||||
log_must eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "1"
|
||||
log_must eval "zfs send -i @snap1 $DATASET_UTIL/send@snap2 > $ZSTREAM"
|
||||
log_must eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "2"
|
||||
|
||||
log_pass "'snapshot_count' property is handled correctly"
|
99
tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh
Executable file
99
tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh
Executable file
@ -0,0 +1,99 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# ZFS 'snapshot_limit' is enforced when executing various actions
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Verify 'zfs snapshot' cannot exceed the snapshot_limit
|
||||
# 2. Verify 'zfs rename' cannot move snapshots exceeding the limit
|
||||
# 3. Verify 'zfs promote' cannot exceed the limit
|
||||
# 4. Verify 'zfs receive' cannot exceed the limit
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
function setup
|
||||
{
|
||||
log_must zfs create "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_UTIL"
|
||||
}
|
||||
|
||||
function cleanup
|
||||
{
|
||||
destroy_dataset "$DATASET_TEST" "-Rf"
|
||||
destroy_dataset "$DATASET_UTIL" "-Rf"
|
||||
rm -f $ZSTREAM
|
||||
}
|
||||
|
||||
log_assert "Verify 'snapshot_limit' is enforced when executing various actions"
|
||||
log_onexit cleanup
|
||||
|
||||
DATASET_TEST="$TESTPOOL/$TESTFS/snapshot_limit_test"
|
||||
DATASET_UTIL="$TESTPOOL/$TESTFS/snapshot_limit_util"
|
||||
ZSTREAM="$TEST_BASE_DIR/snapshot_limit.$$"
|
||||
|
||||
# 1. Verify 'zfs snapshot' cannot exceed the snapshot_limit
|
||||
setup
|
||||
log_must zfs set snapshot_limit=1 "$DATASET_TEST"
|
||||
log_must zfs snapshot "$DATASET_TEST@snap"
|
||||
log_mustnot zfs snapshot "$DATASET_TEST@snap_exceed"
|
||||
log_mustnot datasetexists "$DATASET_TEST@snap_exceed"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "1"
|
||||
cleanup
|
||||
|
||||
# 2. Verify 'zfs rename' cannot move snapshots exceeding the limit
|
||||
setup
|
||||
log_must zfs set snapshot_limit=0 "$DATASET_UTIL"
|
||||
log_must zfs create "$DATASET_TEST/rename"
|
||||
log_must zfs snapshot "$DATASET_TEST/rename@snap"
|
||||
log_mustnot zfs rename "$DATASET_TEST/rename" "$DATASET_UTIL/renamed"
|
||||
log_mustnot datasetexists "$DATASET_UTIL/renamed"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_UTIL")" == "0"
|
||||
cleanup
|
||||
|
||||
# 3. Verify 'zfs promote' cannot exceed the limit
|
||||
setup
|
||||
log_must zfs set snapshot_limit=0 "$DATASET_UTIL"
|
||||
log_must zfs create "$DATASET_TEST/promote"
|
||||
log_must zfs snapshot "$DATASET_TEST/promote@snap"
|
||||
log_must zfs clone "$DATASET_TEST/promote@snap" "$DATASET_UTIL/promoted"
|
||||
log_mustnot zfs promote "$DATASET_UTIL/promoted"
|
||||
log_mustnot datasetexists "$DATASET_UTIL/promoted@snap"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_UTIL")" == "0"
|
||||
cleanup
|
||||
|
||||
# 4. Verify 'zfs receive' cannot exceed the limit
|
||||
setup
|
||||
log_must zfs set snapshot_limit=0 "$DATASET_TEST"
|
||||
log_must zfs create "$DATASET_UTIL/send"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap1"
|
||||
log_must eval "zfs send $DATASET_UTIL/send@snap1 > $ZSTREAM"
|
||||
log_mustnot eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_mustnot datasetexists "$DATASET_TEST/received"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "0"
|
||||
log_must zfs set snapshot_limit=1 "$DATASET_TEST"
|
||||
log_must eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_must zfs snapshot "$DATASET_UTIL/send@snap2"
|
||||
log_must eval "zfs send -i @snap1 $DATASET_UTIL/send@snap2 > $ZSTREAM"
|
||||
log_mustnot eval "zfs receive $DATASET_TEST/received < $ZSTREAM"
|
||||
log_mustnot datasetexists "$DATASET_TEST/received@snap2"
|
||||
log_must test "$(get_prop 'snapshot_count' "$DATASET_TEST")" == "1"
|
||||
|
||||
log_pass "'snapshot_limit' property is enforced"
|
Loading…
Reference in New Issue
Block a user