xfs: Add test for too-small device with stripe geometry
[xfstests-dev.git] / tests / btrfs / 196
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 196
6 #
7 # Test multi subvolume fsync to test a bug where we'd end up pointing at a block
8 # we haven't written.  This was fixed by the patch
9 #
10 # btrfs: fix incorrect updating of log root tree
11 #
12 # Will do log replay and check the filesystem.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 fio_config=$tmp.fio
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         _log_writes_cleanup &> /dev/null
28         _dmthin_cleanup
29         rm -f $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35 . ./common/dmthin
36 . ./common/dmlogwrites
37
38 # remove previous $seqres.full before test
39 rm -f $seqres.full
40
41 # real QA test starts here
42
43 # Modify as appropriate.
44 _supported_fs btrfs
45
46 # Use thin device as replay device, which requires $SCRATCH_DEV
47 _require_scratch_nocheck
48 # and we need extra device as log device
49 _require_log_writes
50 _require_dm_target thin-pool
51
52 cat >$fio_config <<EOF
53 [global]
54 readwrite=write
55 fallocate=none
56 bs=4k
57 fsync=1
58 size=128k
59 EOF
60
61 for i in $(seq 0 49); do
62         echo "[foo$i]" >> $fio_config
63         echo "filename=$SCRATCH_MNT/$i/file" >> $fio_config
64 done
65
66 _require_fio $fio_config
67
68 cat $fio_config >> $seqres.full
69
70 # Use a thin device to provide deterministic discard behavior. Discards are used
71 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
72 _dmthin_init
73 _log_writes_init $DMTHIN_VOL_DEV
74 _log_writes_mkfs >> $seqres.full 2>&1
75 _log_writes_mark mkfs
76
77 _log_writes_mount
78
79 # First create all the subvolumes
80 for i in $(seq 0 49); do
81         $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/$i" > /dev/null
82 done
83
84 $FIO_PROG $fio_config > /dev/null 2>&1
85 _log_writes_unmount
86
87 _log_writes_remove
88 prev=$(_log_writes_mark_to_entry_number mkfs)
89 [ -z "$prev" ] && _fail "failed to locate entry mark 'mkfs'"
90 cur=$(_log_writes_find_next_fua $prev)
91 [ -z "$cur" ] && _fail "failed to locate next FUA write"
92
93 while [ ! -z "$cur" ]; do
94         _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full
95
96         # We need to mount the fs because btrfsck won't bother checking the log.
97         _dmthin_mount
98         _dmthin_check_fs
99
100         prev=$cur
101         cur=$(_log_writes_find_next_fua $(($cur + 1)))
102         [ -z "$cur" ] && break
103 done
104
105 echo "Silence is golden"
106
107 # success, all done
108 status=0
109 exit