5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2016 by Delphix. All rights reserved.
27 . $STF_SUITE/include/libtest.shlib
31 # zfs rename should work on existing datasets that exceed
32 # zfs_max_dataset_nesting (our nesting limit) except in the
33 # scenario that we try to rename it to something deeper
37 # 1. Create a set of ZFS datasets within our nesting limit.
38 # 2. Try renaming one of them on top of the other so its
39 # children pass the limit - it should fail.
40 # 3. Increase the nesting limit.
41 # 4. Check that renaming a dataset on top of the other
42 # cannot exceed the new nesting limit but can exceed
44 # 5. Bring back the old nesting limit so you can simulate
45 # the scenario of existing datasets that exceed our
47 # 6. Make sure that 'zfs rename' can work only if we are
48 # trying to keep existing datasets that exceed the limit
49 # at the same nesting level or less. Making it even
50 # deeper should not work.
53 verify_runnable "both"
57 dsA49=$(printf 'a/%.0s' {1..48})"a"
60 dsB49=$(printf 'b/%.0s' {1..48})"b"
63 dsC16=$(printf 'c/%.0s' {1..15})"c"
65 dsB16A=$(printf 'b/%.0s' {1..16})"a"
66 dsB15A=$(printf 'b/%.0s' {1..15})"a"
68 dsB15A47A=$(printf 'b/%.0s' {1..15})$(printf 'a/%.0s' {1..47})"a"
69 dsB15A47C=$(printf 'b/%.0s' {1..15})$(printf 'a/%.0s' {1..47})"c"
71 dsB15A40B=$(printf 'b/%.0s' {1..15})$(printf 'a/%.0s' {1..40})"b"
72 dsB15A47B=$(printf 'b/%.0s' {1..15})$(printf 'a/%.0s' {1..47})"b"
74 function nesting_cleanup
76 log_must zfs destroy -fR $TESTPOOL/$dsA01
77 log_must zfs destroy -fR $TESTPOOL/$dsB01
78 log_must zfs destroy -fR $TESTPOOL/$dsC01
80 # If the test fails after increasing the limit and
81 # before resetting it, it will be left at the modified
82 # value for the remaining tests. That's the reason
83 # we reset it again here just in case.
84 log_must set_tunable_impl MAX_DATASET_NESTING 50 Z zcommon
87 log_onexit nesting_cleanup
89 log_must zfs create -p $TESTPOOL/$dsA49
90 log_must zfs create -p $TESTPOOL/$dsB49
91 log_must zfs create -p $TESTPOOL/$dsC16
93 log_mustnot zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB15A
96 log_must set_tunable_impl MAX_DATASET_NESTING 64 Z zcommon
98 log_mustnot zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB16A
99 log_must zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB15A
101 # bring back old limit
102 log_must set_tunable_impl MAX_DATASET_NESTING 50 Z zcommon
104 log_mustnot zfs rename $TESTPOOL/$dsC01 $TESTPOOL/$dsB15A47C
105 log_must zfs rename $TESTPOOL/$dsB15A47A $TESTPOOL/$dsB15A47B
106 log_must zfs rename $TESTPOOL/$dsB15A47B $TESTPOOL/$dsB15A40B
108 log_pass "Verify 'zfs rename' limits datasets so they don't pass " \
109 "the nesting limit. For existing ones that do, it should " \
110 "not allow them to grow anymore."