fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / btrfs / 151
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test 151
6 #
7 # Test if it's losing data chunk's raid profile after 'btrfs device
8 # remove'.
9 #
10 # The fix is
11 #       Btrfs: avoid losing data raid profile when deleting a device
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # remove previous $seqres.full before test
33 rm -f $seqres.full
34
35 # real QA test starts here
36
37 # Modify as appropriate.
38 _supported_fs btrfs
39 _require_scratch
40 _require_scratch_dev_pool 3
41 _require_btrfs_dev_del_by_devid
42
43 # We need exactly 3 disks to form a fixed stripe layout for this test.
44 _scratch_dev_pool_get 3
45
46 # create raid1 for data
47 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
48
49 # we need an empty data chunk, so nospace_cache is required.
50 _scratch_mount -onospace_cache
51
52 # if data chunk is empty, 'btrfs device remove' can change raid1 to
53 # single.
54 $BTRFS_UTIL_PROG device delete 2 $SCRATCH_MNT >> $seqres.full 2>&1
55
56 # save btrfs filesystem df output for debug purpose
57 $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT 2>&1 | \
58     tee -a $seqres.full | $AWK_PROG -F ':' '/Data,/ {print $1}'
59
60 _scratch_dev_pool_put
61
62 # success, all done
63 status=0
64 exit