xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / btrfs / 238
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
4 #
5 # FS QA Test 238
6 #
7 # Check seed device integrity after fstrim on the sprout device.
8 #
9 #  Kernel bug is fixed by the commit:
10 #    btrfs: fix unmountable seed device after fstrim
11
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35
36 # Modify as appropriate.
37 _supported_fs btrfs
38 _require_command "$BTRFS_TUNE_PROG" btrfstune
39 _require_fstrim
40 _require_scratch_dev_pool 2
41 _scratch_dev_pool_get 2
42
43 seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
44 sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
45
46 _mkfs_dev $seed
47 _mount $seed $SCRATCH_MNT
48
49 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
50 _scratch_unmount
51 $BTRFS_TUNE_PROG -S 1 $seed
52
53 # Mount the seed device and add the rw device
54 _mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
55 md5sum $SCRATCH_MNT/foo | _filter_scratch
56
57 $BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
58 _scratch_unmount
59
60 # Now remount writeable sprout device, create some data and run fstrim
61 _mount $sprout $SCRATCH_MNT
62 _require_batched_discard $SCRATCH_MNT
63
64 $FSTRIM_PROG $SCRATCH_MNT
65
66 _scratch_unmount
67
68 # Verify seed device is all ok
69 _mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
70 md5sum $SCRATCH_MNT/foo | _filter_scratch
71 _scratch_unmount
72
73 _check_btrfs_filesystem $seed
74
75 _scratch_dev_pool_put
76
77 # success, all done
78 status=0
79 exit