generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 225
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Oracle. All Rights Reserved.
4 #
5 # FS QA Test 225
6 #
7 # Test for seed device-delete on a sprouted FS.
8 #
9 # Steps:
10 #  Create a seed FS. Add a RW device to make it sprout FS and then delete
11 #  the seed device.
12
13 . ./common/preamble
14 _begin_fstest auto quick volume seed
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19         cd /
20         rm -f $tmp.*
21         _btrfs_rescan_devices
22 }
23
24 # Import common functions.
25 . ./common/filter
26
27 # real QA test starts here
28
29 # Modify as appropriate.
30 _supported_fs btrfs
31 _fixed_by_kernel_commit b5ddcffa3777 \
32         "btrfs: fix put of uninitialized kobject after seed device delete"
33 _require_test
34 _require_scratch_dev_pool 2
35 _require_btrfs_forget_or_module_loadable
36
37 _scratch_dev_pool_get 2
38
39 seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
40 sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
41
42 _mkfs_dev $seed
43 _mount $seed $SCRATCH_MNT
44
45 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
46 _scratch_unmount
47 $BTRFS_TUNE_PROG -S 1 $seed
48
49 # Mount the seed device and add the rw device
50 _mount -o ro $seed $SCRATCH_MNT
51 $BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT >> $seqres.full
52 _scratch_unmount
53
54 # Now remount
55 _mount $sprout $SCRATCH_MNT
56 $XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null
57
58 echo --- before delete ----
59 od -x $SCRATCH_MNT/foo
60 od -x $SCRATCH_MNT/bar
61
62 $BTRFS_UTIL_PROG device delete $seed $SCRATCH_MNT
63 _scratch_unmount
64 _btrfs_forget_or_module_reload
65 _mount $sprout $SCRATCH_MNT
66
67 echo --- after delete ----
68 od -x $SCRATCH_MNT/foo
69 od -x $SCRATCH_MNT/bar
70
71 _scratch_dev_pool_put
72 _btrfs_rescan_devices
73
74 # success, all done
75 status=0
76 exit