generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 249
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Anand Jain.  All Rights Reserved.
4 # Copyright (c) 2021 Oracle.  All Rights Reserved.
5 #
6 # FS QA Test 249
7 #
8 # Validate if the command 'btrfs filesystem usage' works with missing seed
9 # device
10 # Steps:
11 #  Create a degraded raid1 seed device
12 #  Create a sprout filesystem (an rw device on top of a seed device)
13 #  Dump 'btrfs filesystem usage', check it didn't fail
14 #
15 # Tests btrfs-progs bug fixed by the kernel patch and a btrfs-prog patch
16 #   btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
17 #   btrfs-progs: read fsid from the sysfs in device_is_seed
18
19 . ./common/preamble
20 _begin_fstest auto quick seed volume
21
22 # Import common functions.
23 # . ./common/filter
24
25 # real QA test starts here
26
27 # Modify as appropriate.
28 _supported_fs btrfs
29 _require_scratch_dev_pool 3
30 _require_command "$WIPEFS_PROG" wipefs
31 _require_btrfs_forget_or_module_loadable
32
33 _scratch_dev_pool_get 2
34 # use the scratch devices as seed devices
35 seed_dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
36 seed_dev2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $2 }')
37
38 # use the spare device as a sprout device
39 _spare_dev_get
40 sprout_dev=$SPARE_DEV
41
42 # create raid1 seed filesystem
43 _scratch_pool_mkfs "-draid1 -mraid1" >> $seqres.full 2>&1
44 $BTRFS_TUNE_PROG -S 1 $seed_dev1
45 $WIPEFS_PROG -a $seed_dev1 >> $seqres.full 2>&1
46 _btrfs_forget_or_module_reload
47 _mount -o degraded $seed_dev2 $SCRATCH_MNT >> $seqres.full 2>&1
48
49 # create a sprout device
50 $BTRFS_UTIL_PROG device add -f $SPARE_DEV $SCRATCH_MNT >> $seqres.full 2>&1
51
52 # dump filesystem usage if it fails error goes to the bad.out file
53 $BTRFS_UTIL_PROG filesystem usage $SCRATCH_MNT >> $seqres.full
54 # also check for the error code
55 ret=$?
56 if [ $ret != 0 ]; then
57 _fail "FAILED: btrfs filesystem usage, ret $ret. Check btrfs.ko and btrfs-progs version."
58 fi
59
60 _scratch_unmount
61 _spare_dev_put
62 _scratch_dev_pool_put
63
64 echo "Silence is golden"
65 # success, all done
66 status=0
67 exit