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.
17 # real QA test starts here
19 _require_btrfs_forget_or_module_loadable
20 _require_scratch_dev_pool 2
22 _scratch_dev_pool_get 2
23 dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
25 _scratch_pool_mkfs "-m raid1 -d raid1"
27 _require_batched_discard $SCRATCH_MNT
29 # Add a test file with some data.
30 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
32 # Unmount the filesystem.
35 # Mount the filesystem in degraded mode
36 _btrfs_forget_or_module_reload
37 _mount -o degraded $dev1 $SCRATCH_MNT
39 # Run fstrim, it should skip on the missing device.
40 $FSTRIM_PROG $SCRATCH_MNT
42 # Verify data integrity as in the golden output.
44 od -A d -t x1 $SCRATCH_MNT/foo