generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 218
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 218
6 #
7 # Regression test for the problem fixed by the patch
8 #
9 #  btrfs: init device stats for seed devices
10 #
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.
13 #
14 . ./common/preamble
15 _begin_fstest auto quick volume
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/filter.btrfs
20
21 # real QA test starts here
22
23 # Modify as appropriate.
24 _supported_fs btrfs
25 _require_test
26 _require_scratch_dev_pool 2
27
28 _scratch_dev_pool_get 2
29
30 dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
31 dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
32
33 # Create the seed device
34 _mkfs_dev $dev_seed
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
39 _scratch_unmount
40 $BTRFS_TUNE_PROG -S 1 $dev_seed
41
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
46 _scratch_unmount
47
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
51
52 _scratch_dev_pool_put
53
54 # success, all done
55 status=0
56 exit