diff options
author | loli10K <[email protected]> | 2019-01-08 19:17:46 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-01-08 10:17:46 -0800 |
commit | 0f5f23869a64ec12b1744ee3df25816c712667d2 (patch) | |
tree | 7b4da23a1250d4b528152140b5b34be9aa7ffef2 | |
parent | f384c045d8135adf6fa4858948cc42ddb580c652 (diff) |
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 <[email protected]>
Reviewed by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #8232
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | module/zfs/dsl_destroy.c | 10 | ||||
-rw-r--r-- | tests/runfiles/linux.run | 5 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/Makefile.am | 1 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/limits/Makefile.am | 9 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/limits/cleanup.ksh | 19 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/limits/filesystem_count.ksh | 123 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh | 84 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/limits/setup.ksh | 21 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/limits/snapshot_count.ksh | 100 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh | 99 |
11 files changed, 464 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index be3e556c1..cf0e1bf58 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/module/zfs/dsl_destroy.c b/module/zfs/dsl_destroy.c index 97d7befbd..465b3dfac 100644 --- a/module/zfs/dsl_destroy.c +++ b/module/zfs/dsl_destroy.c @@ -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); diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index 38f040126..0b41d087b 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -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'] diff --git a/tests/zfs-tests/tests/functional/Makefile.am b/tests/zfs-tests/tests/functional/Makefile.am index 961a34027..90f5e1821 100644 --- a/tests/zfs-tests/tests/functional/Makefile.am +++ b/tests/zfs-tests/tests/functional/Makefile.am @@ -32,6 +32,7 @@ SUBDIRS = \ large_files \ largest_pool \ libzfs \ + limits \ pyzfs \ link_count \ migration \ diff --git a/tests/zfs-tests/tests/functional/limits/Makefile.am b/tests/zfs-tests/tests/functional/limits/Makefile.am new file mode 100644 index 000000000..724559224 --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/Makefile.am @@ -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 + diff --git a/tests/zfs-tests/tests/functional/limits/cleanup.ksh b/tests/zfs-tests/tests/functional/limits/cleanup.ksh new file mode 100755 index 000000000..e78deacd5 --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/cleanup.ksh @@ -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 <[email protected]>. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/limits/filesystem_count.ksh b/tests/zfs-tests/tests/functional/limits/filesystem_count.ksh new file mode 100755 index 000000000..e9f839ca8 --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/filesystem_count.ksh @@ -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 <[email protected]>. 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" diff --git a/tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh b/tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh new file mode 100755 index 000000000..a65979254 --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh @@ -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 <[email protected]>. 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" diff --git a/tests/zfs-tests/tests/functional/limits/setup.ksh b/tests/zfs-tests/tests/functional/limits/setup.ksh new file mode 100755 index 000000000..af6edbe2b --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/setup.ksh @@ -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 <[email protected]>. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +DISK=${DISKS%% *} + +default_volume_setup $DISK diff --git a/tests/zfs-tests/tests/functional/limits/snapshot_count.ksh b/tests/zfs-tests/tests/functional/limits/snapshot_count.ksh new file mode 100755 index 000000000..ac4a47ddc --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/snapshot_count.ksh @@ -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 <[email protected]>. 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" diff --git a/tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh b/tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh new file mode 100755 index 000000000..fa4b6e8f2 --- /dev/null +++ b/tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh @@ -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 <[email protected]>. 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" |