1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2019, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/zvol/zvol_common.shlib 19. $STF_SUITE/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib 20 21# 22# DESCRIPTION: 23# Verify 'zfs rename' works on a ZVOL already in use as block device 24# 25# STRATEGY: 26# 1. Create a ZVOL 27# 2. Create a filesystem on the ZVOL device and mount it 28# 3. Rename the ZVOL dataset 29# 4. Receive a send stream with the same name as the old ZVOL dataset and verify 30# we don't trigger any issue like the one reported in #6263 31# 32 33verify_runnable "global" 34 35function cleanup 36{ 37 log_must umount "$MNTPFS" 38 log_must rmdir "$MNTPFS" 39 for ds in "$SENDFS" "$ZVOL" "$ZVOL-renamed"; do 40 destroy_dataset "$ds" '-rf' 41 done 42 block_device_wait 43} 44 45log_assert "Verify 'zfs rename' works on a ZVOL already in use as block device" 46log_onexit cleanup 47 48ZVOL="$TESTPOOL/vol.$$" 49ZDEV="$ZVOL_DEVDIR/$ZVOL" 50MNTPFS="$TESTDIR/zvol_inuse_rename" 51SENDFS="$TESTPOOL/sendfs.$$" 52 53# 1. Create a ZVOL 54log_must zfs create -V $VOLSIZE "$ZVOL" 55 56# 2. Create a filesystem on the ZVOL device and mount it 57block_device_wait "$ZDEV" 58log_must eval "new_fs $ZDEV >/dev/null 2>&1" 59log_must mkdir "$MNTPFS" 60log_must mount "$ZDEV" "$MNTPFS" 61 62# 3. Rename the ZVOL dataset 63log_must zfs rename "$ZVOL" "$ZVOL-renamed" 64 65# 4. Receive a send stream with the same name as the old ZVOL dataset and verify 66# we don't trigger any issue like the one reported in #6263 67log_must zfs create "$SENDFS" 68log_must zfs snap "$SENDFS@snap" 69log_must eval "zfs send $SENDFS@snap | zfs recv $ZVOL" 70 71log_pass "Renaming in use ZVOL works successfully" 72