2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook. All Rights Reserved.
7 # Regression test for the problem fixed by the patch
9 # btrfs: init device stats for seed devices
11 # Make a seed device, add a sprout to it, and then make sure we can still read
12 # the device stats for both devices after we remount with the new sprout device.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
32 . ./common/filter.btrfs
34 # remove previous $seqres.full before test
37 # real QA test starts here
39 # Modify as appropriate.
42 _require_scratch_dev_pool 2
44 _scratch_dev_pool_get 2
46 dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
47 dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
49 # Create the seed device
51 _mount $dev_seed $SCRATCH_MNT
52 $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
53 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
54 _filter_btrfs_filesystem_show
56 $BTRFS_TUNE_PROG -S 1 $dev_seed
58 # Mount the seed device and add the rw device
59 _mount -o ro $dev_seed $SCRATCH_MNT
60 _run_btrfs_util_prog device add -f $dev_sprout $SCRATCH_MNT
61 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_scratch_pool
64 # Now remount, validate the device stats do not fail
65 _mount $dev_sprout $SCRATCH_MNT
66 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_scratch_pool