xfs: Check for extent overflow when trivally adding a new extent
[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 _require_scratch
34 _require_scratch_dev_pool 2
35 _require_btrfs_command inspect-internal dump-super
36
37 _scratch_dev_pool_get 2
38
39 # Explicitly use raid0 mode to ensure at least one of the devices can be
40 # removed.
41 _scratch_pool_mkfs "-d raid0 -m raid0" >> $seqres.full 2>&1 || _fail "mkfs failed"
42 _scratch_mount
43
44 # pick last dev in the list
45 dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
46 $BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
47 for i in {0..2}; do
48         output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
49         $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
50         ret=$?
51         if [[ "$output" != "" && $ret -eq 1 ]]; then
52                 _fail "Deleted dev superblocks not scratched"
53         fi
54 done
55 _scratch_unmount
56
57 _scratch_dev_pool_put
58
59 # success, all done
60 echo "Silence is golden"
61 status=0
62 exit