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.
47 # Use thin device as replay device, which requires $SCRATCH_DEV
48 _require_scratch_nocheck
49 # and we need extra device as log device
51 _require_dm_target thin-pool
53 cat >$fio_config <<EOF
62 for i in $(seq 0 49); do
63 echo "[foo$i]" >> $fio_config
64 echo "filename=$SCRATCH_MNT/$i/file" >> $fio_config
67 _require_fio $fio_config
69 cat $fio_config >> $seqres.full
71 # Use a thin device to provide deterministic discard behavior. Discards are used
72 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
74 _log_writes_init $DMTHIN_VOL_DEV
75 _log_writes_mkfs >> $seqres.full 2>&1
80 # First create all the subvolumes
81 for i in $(seq 0 49); do
82 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/$i" > /dev/null
85 $FIO_PROG $fio_config > /dev/null 2>&1
89 prev=$(_log_writes_mark_to_entry_number mkfs)
90 [ -z "$prev" ] && _fail "failed to locate entry mark 'mkfs'"
91 cur=$(_log_writes_find_next_fua $prev)
92 [ -z "$cur" ] && _fail "failed to locate next FUA write"
94 while [ ! -z "$cur" ]; do
95 _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full
97 # We need to mount the fs because btrfsck won't bother checking the log.
102 cur=$(_log_writes_find_next_fua $(($cur + 1)))
103 [ -z "$cur" ] && break
106 echo "Silence is golden"