2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Facebook. All Rights Reserved.
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
10 # btrfs: fix incorrect updating of log root tree
12 # Will do log replay and check the filesystem.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
27 _log_writes_cleanup &> /dev/null
32 # get standard environment, filters and checks
36 . ./common/dmlogwrites
38 # remove previous $seqres.full before test
41 # real QA test starts here
43 # Modify as appropriate.
46 # Use thin device as replay device, which requires $SCRATCH_DEV
47 _require_scratch_nocheck
48 # and we need extra device as log device
50 _require_dm_target thin-pool
52 cat >$fio_config <<EOF
61 for i in $(seq 0 49); do
62 echo "[foo$i]" >> $fio_config
63 echo "filename=$SCRATCH_MNT/$i/file" >> $fio_config
66 _require_fio $fio_config
68 cat $fio_config >> $seqres.full
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.
73 _log_writes_init $DMTHIN_VOL_DEV
74 _log_writes_mkfs >> $seqres.full 2>&1
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
84 $FIO_PROG $fio_config > /dev/null 2>&1
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"
93 while [ ! -z "$cur" ]; do
94 _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full
96 # We need to mount the fs because btrfsck won't bother checking the log.
101 cur=$(_log_writes_find_next_fua $(($cur + 1)))
102 [ -z "$cur" ] && break
105 echo "Silence is golden"