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.
41 _require_scratch_dev_pool 3
42 _require_btrfs_dev_del_by_devid
44 # We need exactly 3 disks to form a fixed stripe layout for this test.
45 _scratch_dev_pool_get 3
47 # create raid1 for data
48 _scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
50 # we need an empty data chunk, so nospace_cache is required.
51 _scratch_mount -onospace_cache
53 # if data chunk is empty, 'btrfs device remove' can change raid1 to
55 $BTRFS_UTIL_PROG device delete 2 $SCRATCH_MNT >> $seqres.full 2>&1
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}'