btrfs/139: require 2GB scratch dev
[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 _supported_os Linux
40 _require_scratch
41 _require_scratch_dev_pool 3
42 _require_btrfs_dev_del_by_devid
43
44 # We need exactly 3 disks to form a fixed stripe layout for this test.
45 _scratch_dev_pool_get 3
46
47 # create raid1 for data
48 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
49
50 # we need an empty data chunk, so nospace_cache is required.
51 _scratch_mount -onospace_cache
52
53 # if data chunk is empty, 'btrfs device remove' can change raid1 to
54 # single.
55 $BTRFS_UTIL_PROG device delete 2 $SCRATCH_MNT >> $seqres.full 2>&1
56
57 # save btrfs filesystem df output for debug purpose
58 $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT 2>&1 | \
59     tee -a $seqres.full | $AWK_PROG -F ':' '/Data,/ {print $1}'
60
61 _scratch_dev_pool_put
62
63 # success, all done
64 status=0
65 exit