xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / btrfs / 176
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 176
6 #
7 # Test device remove/replace with an active swap file.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs btrfs
35 _supported_os Linux
36 _require_scratch_dev_pool 3
37 _require_scratch_swapfile
38
39 # We check the filesystem manually because we move devices around.
40 rm -f "${RESULT_DIR}/require_scratch"
41
42 scratch_dev1="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $1 }')"
43 scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $2 }')"
44 scratch_dev3="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $3 }')"
45
46 echo "Remove device"
47 _scratch_mkfs >> $seqres.full 2>&1
48 _scratch_mount
49 _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
50 $BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT"
51 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
52 # We know the swap file is on device 1 because we added device 2 after it was
53 # already created.
54 $BTRFS_UTIL_PROG device delete "$scratch_dev1" "$SCRATCH_MNT" 2>&1 | grep -o "Text file busy"
55 # Deleting/readding device 2 should still work.
56 $BTRFS_UTIL_PROG device delete "$scratch_dev2" "$SCRATCH_MNT"
57 $BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT"
58 swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
59 # Deleting device 1 should work again after swapoff.
60 $BTRFS_UTIL_PROG device delete "$scratch_dev1" "$SCRATCH_MNT"
61 _scratch_unmount
62 _check_scratch_fs "$scratch_dev2"
63
64 echo "Replace device"
65 _scratch_mkfs >> $seqres.full 2>&1
66 _scratch_mount
67 _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
68 $BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT"
69 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
70 # Again, we know the swap file is on device 1.
71 $BTRFS_UTIL_PROG replace start -fB "$scratch_dev1" "$scratch_dev3" "$SCRATCH_MNT" 2>&1 | grep -o "Text file busy"
72 # Replacing device 2 should still work.
73 $BTRFS_UTIL_PROG replace start -fB "$scratch_dev2" "$scratch_dev3" "$SCRATCH_MNT"
74 swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
75 # Replacing device 1 should work again after swapoff.
76 $BTRFS_UTIL_PROG replace start -fB "$scratch_dev1" "$scratch_dev2" "$SCRATCH_MNT"
77 _scratch_unmount
78 _check_scratch_fs "$scratch_dev2"
79
80 # success, all done
81 status=0
82 exit