1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 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 8# 1.0 of the CDDL. 9# 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. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2019 iXsystems, Inc. 19# 20 21. $STF_SUITE/include/libtest.shlib 22 23# 24# DESCRIPTION: 25# zfs rename -u should rename datasets without unmounting them 26# 27# STRATEGY: 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. 31# 32 33verify_runnable "both" 34 35function rename_cleanup 36{ 37 cd $back 38 zfs destroy -fR $TESTPOOL/rename_test 39 zfs destroy -fR $TESTPOOL/renamed 40} 41 42back=$PWD 43log_onexit rename_cleanup 44 45log_must zfs create $TESTPOOL/rename_test 46log_must zfs create $TESTPOOL/rename_test/child 47log_must zfs create $TESTPOOL/rename_test/child/grandchild 48 49if ! ismounted $TESTPOOL/rename_test; then 50 log_fail "$TESTPOOL/rename_test is not mounted" 51fi 52if ! ismounted $TESTPOOL/rename_test/child; then 53 log_fail "$TESTPOOL/rename_test/child is not mounted" 54fi 55if ! ismounted $TESTPOOL/rename_test/child/grandchild; then 56 log_fail "$TESTPOOL/rename_test/child/grandchild is not mounted" 57fi 58 59mntp_p=$(get_prop mountpoint $TESTPOOL/rename_test) 60mntp_c=$(get_prop mountpoint $TESTPOOL/rename_test/child) 61mntp_g=$(get_prop mountpoint $TESTPOOL/rename_test/child/grandchild) 62 63log_must cd $mntp_g 64log_mustnot zfs rename $TESTPOOL/rename_test $TESTPOOL/renamed 65log_must zfs rename -u $TESTPOOL/rename_test $TESTPOOL/renamed 66 67log_mustnot zfs list $TESTPOOL/rename_test 68log_mustnot zfs list $TESTPOOL/rename_test/child 69log_mustnot zfs list $TESTPOOL/rename_test/child/grandchild 70 71log_must zfs list $TESTPOOL/renamed 72log_must zfs list $TESTPOOL/renamed/child 73log_must zfs list $TESTPOOL/renamed/child/grandchild 74 75missing=$(zfs mount | awk \ 76 -v genpat=$TESTPOOL/renamed \ 77 -v mntp_p=$mntp_p \ 78 -v mntp_c=$mntp_c \ 79 -v mntp_g=$mntp_g ' 80 BEGIN { p = c = g = 0 } 81 $1 ~ genpat && $2 == mntp_p { p = 1 } 82 $1 ~ genpat && $2 == mntp_c { c = 1 } 83 $1 ~ genpat && $2 == mntp_g { g = 1 } 84 END { 85 if (p != 1) 86 print mntp_p 87 if (c != 1) 88 print mntp_c 89 if (g != 1) 90 print mntp_g 91 }') 92[[ -z "$missing" ]] || log_fail "Mountpoints no longer mounted: $missing" 93 94log_pass "Verified rename -u does not unmount datasets" 95