2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2021 Oracle. All Rights Reserved.
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
12 _begin_fstest auto quick volume trim
14 # Import common functions.
18 # real QA test starts here
20 _require_btrfs_forget_or_module_loadable
21 _require_scratch_dev_pool 2
23 _scratch_dev_pool_get 2
24 dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
26 _scratch_pool_mkfs "-m raid1 -d raid1"
28 _require_batched_discard $SCRATCH_MNT
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
33 # Unmount the filesystem.
36 # Mount the filesystem in degraded mode
37 _btrfs_forget_or_module_reload
38 _mount -o degraded $dev1 $SCRATCH_MNT
40 # Run fstrim, it should skip on the missing device.
41 $FSTRIM_PROG $SCRATCH_MNT
43 # Verify data integrity as in the golden output.
45 od -A d -t x1 $SCRATCH_MNT/foo