generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / btrfs / 223
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/223
6 #
7 # Test that after replacing a device, if we run fstrim against the filesystem
8 # we do not trim/discard allocated chunks in the new device. We verify that
9 # allocated chunks in the new device were not trim/discarded by mounting the
10 # new device only in degraded mode, as this is the easiest way to verify it.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_scratch_dev_pool 3
33 _require_command "$WIPEFS_PROG" wipefs
34
35 rm -f $seqres.full
36
37 _scratch_dev_pool_get 2
38 _spare_dev_get
39 dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
40 dev2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $2 }')
41
42 _scratch_pool_mkfs "-m raid1 -d raid1"
43 _scratch_mount
44 _require_batched_discard $SCRATCH_MNT
45
46 # Add a test file with some data.
47 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
48
49 # Replace the first device, $dev1, with a new device.
50 $BTRFS_UTIL_PROG replace start -Bf $dev1 $SPARE_DEV $SCRATCH_MNT
51
52 # Run fstrim, it should not trim/discard allocated extents in the new device.
53 $FSTRIM_PROG $SCRATCH_MNT
54
55 # Unmount the filesystem.
56 _scratch_unmount
57
58 # Mount the filesystem in degraded mode using the new device and verify that the
59 # mount succeeds and our file exists, with a size of 10Mb and all its bytes have
60 # a value of 0xab.
61 $WIPEFS_PROG -a $dev1 $dev2 >> $seqres.full 2>&1
62 _mount -o degraded $SPARE_DEV $SCRATCH_MNT
63
64 echo "File foo data:"
65 od -A d -t x1 $SCRATCH_MNT/foo
66
67 _spare_dev_put
68 _scratch_dev_pool_put
69
70 status=0
71 exit