2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle. All Rights Reserved.
7 # Test if it's losing data chunk's raid profile after 'btrfs device
11 # Btrfs: avoid losing data raid profile when deleting a device
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
32 # remove previous $seqres.full before test
35 # real QA test starts here
37 # Modify as appropriate.
40 _require_scratch_dev_pool 3
41 _require_btrfs_dev_del_by_devid
43 # We need exactly 3 disks to form a fixed stripe layout for this test.
44 _scratch_dev_pool_get 3
46 # create raid1 for data
47 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
49 # we need an empty data chunk, so nospace_cache is required.
50 _scratch_mount -onospace_cache
52 # if data chunk is empty, 'btrfs device remove' can change raid1 to
54 $BTRFS_UTIL_PROG device delete 2 $SCRATCH_MNT >> $seqres.full 2>&1
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}'