5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy is of the CDDL is also available via the Internet
12 # at http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2019 iXsystems, Inc.
21 . $STF_SUITE/include/libtest.shlib
25 # zfs rename -u should rename datasets without unmounting them
28 # 1. Create a set of nested datasets.
29 # 2. Verify datasets are mounted.
30 # 3. Rename with -u and verify all datasets stayed mounted.
33 verify_runnable "both"
35 function rename_cleanup
38 zfs destroy -fR $TESTPOOL/rename_test
39 zfs destroy -fR $TESTPOOL/renamed
43 log_onexit rename_cleanup
45 log_must zfs create $TESTPOOL/rename_test
46 log_must zfs create $TESTPOOL/rename_test/child
47 log_must zfs create $TESTPOOL/rename_test/child/grandchild
49 if ! ismounted $TESTPOOL/rename_test; then
50 log_fail "$TESTPOOL/rename_test is not mounted"
52 if ! ismounted $TESTPOOL/rename_test/child; then
53 log_fail "$TESTPOOL/rename_test/child is not mounted"
55 if ! ismounted $TESTPOOL/rename_test/child/grandchild; then
56 log_fail "$TESTPOOL/rename_test/child/grandchild is not mounted"
59 mntp_p=$(get_prop mountpoint $TESTPOOL/rename_test)
60 mntp_c=$(get_prop mountpoint $TESTPOOL/rename_test/child)
61 mntp_g=$(get_prop mountpoint $TESTPOOL/rename_test/child/grandchild)
64 log_mustnot zfs rename $TESTPOOL/rename_test $TESTPOOL/renamed
65 log_must zfs rename -u $TESTPOOL/rename_test $TESTPOOL/renamed
67 log_mustnot zfs list $TESTPOOL/rename_test
68 log_mustnot zfs list $TESTPOOL/rename_test/child
69 log_mustnot zfs list $TESTPOOL/rename_test/child/grandchild
71 log_must zfs list $TESTPOOL/renamed
72 log_must zfs list $TESTPOOL/renamed/child
73 log_must zfs list $TESTPOOL/renamed/child/grandchild
75 missing=$(zfs mount | awk -v pat=$TESTPOOL/renamed '$1 ~ pat' | awk \
79 BEGIN { p = c = g = 0 }
80 $2 == mntp_p { p = 1 }
81 $2 == mntp_c { c = 1 }
82 $2 == mntp_g { g = 1 }
91 [[ -z "$missing" ]] || log_fail "Mountpoints no longer mounted: $missing"
93 log_pass "Verified rename -u does not unmount datasets"