btrfs/079: fix failure to umount scratch fs due to running filefrag process
[xfstests-dev.git] / tests / btrfs / 184
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 SUSE LLC. All Rights Reserved.
4 #
5 # FS QA Test 184
6 #
7 # Verify that when a device is removed from a multi-device
8 # filesystem its superblock copies are correctly deleted
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 rm -f $seqres.full
30
31 # real QA test starts here
32 _supported_fs btrfs
33 _supported_os Linux
34 _require_scratch
35 _require_scratch_dev_pool 2
36 _require_btrfs_command inspect-internal dump-super
37
38 _scratch_dev_pool_get 2
39
40 # Explicitly use raid0 mode to ensure at least one of the devices can be
41 # removed.
42 _scratch_pool_mkfs "-d raid0 -m raid0" >> $seqres.full 2>&1 || _fail "mkfs failed"
43 _scratch_mount
44
45 # pick last dev in the list
46 dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
47 $BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
48 for i in {0..2}; do
49         output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
50         $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
51         ret=$?
52         if [[ "$output" != "" && $ret -eq 1 ]]; then
53                 _fail "Deleted dev superblocks not scratched"
54         fi
55 done
56 _scratch_unmount
57
58 _scratch_dev_pool_put
59
60 # success, all done
61 echo "Silence is golden"
62 status=0
63 exit