generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 242
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2021 Oracle. All Rights Reserved.
4 #
5 # FS QA Test 242
6 #
7 # Test that fstrim can run on the degraded filesystem
8 #   Kernel requires fix for the null pointer deref in btrfs_trim_fs()
9 #     [patch] btrfs: check for missing device in btrfs_trim_fs
10
11 . ./common/preamble
12 _begin_fstest auto quick volume trim
13
14 # Import common functions.
15 . ./common/filter
16 . ./common/module
17
18 # real QA test starts here
19 _supported_fs btrfs
20 _require_btrfs_forget_or_module_loadable
21 _require_scratch_dev_pool 2
22
23 _scratch_dev_pool_get 2
24 dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
25
26 _scratch_pool_mkfs "-m raid1 -d raid1"
27 _scratch_mount
28 _require_batched_discard $SCRATCH_MNT
29
30 # Add a test file with some data.
31 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
32
33 # Unmount the filesystem.
34 _scratch_unmount
35
36 # Mount the filesystem in degraded mode
37 _btrfs_forget_or_module_reload
38 _mount -o degraded $dev1 $SCRATCH_MNT
39
40 # Run fstrim, it should skip on the missing device.
41 $FSTRIM_PROG $SCRATCH_MNT
42
43 # Verify data integrity as in the golden output.
44 echo "File foo data:"
45 od -A d -t x1 $SCRATCH_MNT/foo
46
47 _scratch_dev_pool_put
48
49 status=0
50 exit