misc: tag all tests that examine crash recovery in a loop
[xfstests-dev.git] / tests / btrfs / 190
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 SUSE Linux Products GmbH.  All Rights Reserved.
4 #
5 # FS QA Test 190
6 #
7 # A general test to validate that balance and qgroups work correctly when
8 # balance needs to be resumed on mount.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick replay balance qgroup recoveryloop
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/dmlogwrites
16
17 # real QA test starts here
18
19 # Modify as appropriate.
20 _supported_fs btrfs
21 _require_scratch
22 # and we need extra device as log device
23 _require_log_writes
24
25 nr_files=512                            # enough metadata to bump tree height
26 file_size=2048                          # small enough to be inlined
27
28 _log_writes_init $SCRATCH_DEV
29 _log_writes_mkfs >> $seqres.full 2>&1
30
31 _log_writes_mount
32 $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT >> $seqres.full
33 $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
34
35 # Create enough metadata for later balance
36 for ((i = 0; i < $nr_files; i++)); do
37         _pwrite_byte 0xcd 0 $file_size $SCRATCH_MNT/file_$i > /dev/null
38 done
39
40 # Flush delalloc so that balance has work to do.
41 sync
42
43 # Balance metadata so we will have at least one transaction committed with
44 # valid reloc tree, and hopefully another commit with orphan reloc tree.
45 _run_btrfs_balance_start -f -m $SCRATCH_MNT >> $seqres.full
46
47 _log_writes_unmount
48 _log_writes_remove
49
50 cur=$(_log_writes_find_next_fua 0)
51 echo "cur=$cur" >> $seqres.full
52 while [ ! -z "$cur" ]; do
53         _log_writes_replay_log_range $cur $SCRATCH_DEV >> $seqres.full
54
55         # Test that no crashes happen or any other kind of failure.
56         _scratch_mount
57         _scratch_unmount
58
59         # Don't trigger fsck here, as relocation get paused,
60         # at that transistent state, qgroup number may differ
61         # and cause false alert.
62
63         prev=$cur
64         cur=$(_log_writes_find_next_fua $(($cur + 1)))
65         [ -z "$cur" ] && break
66 done
67
68 # Now the fs has finished its balance and qgroup should be consistent.
69 # Fstest will automatically check the fs and btrfs check will report
70 # any qgroup inconsistent if something went wrong.
71
72 echo "Silence is golden"
73
74 # success, all done
75 status=0
76 exit