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 of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16# Copyright (c) 2020 by Mariusz Zaborski <oshogbo@FreeBSD.org>. 17 18# 19# DESCRIPTION: 20# Verify 'zfs recv' can forcibly unmount filesystem while receiving 21# stream. 22# 23# STRATEGY: 24# 1. Create snapshot of file system 25# 2. Make a zfs filesystem mountpoint busy 26# 3. Receive filesystem with force flag. 27# 4. Verify that stream was received or failed on Linux. 28# 29 30. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib 31 32verify_runnable "both" 33 34function cleanup 35{ 36 cd $curpath 37 38 for snap in $init_snap $rst_snap; do 39 snapexists $snap && \ 40 destroy_snapshot $snap 41 done 42 43 datasetexists $rst_root && \ 44 destroy_dataset $rst_root 45 46 for file in $full_bkup 47 do 48 [[ -e $file ]] && \ 49 log_must rm -f $file 50 done 51 52 [[ -d $TESTDIR1 ]] && \ 53 log_must rm -rf $TESTDIR1 54} 55 56log_assert "Verify 'zfs recv' can forcibly unmount busy filesystem." 57log_onexit cleanup 58 59curpath=`dirname $0` 60init_snap=$TESTPOOL/$TESTFS@init_snap 61full_bkup=$TEST_BASE_DIR/fullbkup.$$ 62rst_root=$TESTPOOL/rst_ctr 63rst_snap=$rst_root@init_snap 64 65log_note "Verify 'zfs recv' can forcible unmount busy filesystem." 66 67# Preparation 68log_must zfs create $rst_root 69[[ ! -d $TESTDIR1 ]] && \ 70 log_must mkdir -p $TESTDIR1 71log_must zfs set mountpoint=$TESTDIR1 $rst_root 72 73log_must zfs snapshot $init_snap 74log_must eval "zfs send $init_snap > $full_bkup" 75 76# Test 77log_must cd $TESTDIR1 78if is_linux; then 79 # Linux does not support it. 80 log_mustnot zfs receive -MF $rst_snap < $full_bkup 81else 82 log_must zfs receive -MF $rst_snap < $full_bkup 83fi 84 85log_pass "The busy filesystem was unmounted or busy as expected." 86