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 _begin_fstest auto quick volume
17 # Import common functions.
19 . ./common/filter.btrfs
21 # real QA test starts here
23 # Modify as appropriate.
26 _require_scratch_dev_pool 2
28 _scratch_dev_pool_get 2
30 dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
31 dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
33 # Create the seed device
35 _mount $dev_seed $SCRATCH_MNT
36 $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
37 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
38 _filter_btrfs_filesystem_show
40 $BTRFS_TUNE_PROG -S 1 $dev_seed
42 # Mount the seed device and add the rw device
43 _mount -o ro $dev_seed $SCRATCH_MNT
44 _run_btrfs_util_prog device add -f $dev_sprout $SCRATCH_MNT >> $seqres.full
45 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_scratch_pool
48 # Now remount, validate the device stats do not fail
49 _mount $dev_sprout $SCRATCH_MNT
50 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_scratch_pool