2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
7 # XFS v5 supers carry an LSN in various on-disk structures to track when
8 # associated metadata was last written to disk. These metadata LSNs must always
9 # be behind the current LSN as dictated by the log to ensure log recovery
10 # correctness after a potential crash. This test uses xfs_db to intentionally
11 # put the current LSN behind metadata LSNs and verifies that the kernel and
12 # xfs_repair detect the problem.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # get standard environment, filters and checks
34 # real QA test starts here
36 # Modify as appropriate.
39 _require_scratch_xfs_crc
40 _require_xfs_db_command "logformat"
42 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
44 # push the log cycle ahead so we have room to move it backwards later
45 _scratch_xfs_db -x -c "logformat -c 3" >> $seqres.full 2>&1
47 # do some work on the fs to update metadata LSNs
49 $FSSTRESS_PROG -d $SCRATCH_MNT -n 999 -p 4 -w >> $seqres.full 2>&1
52 # Reformat to the current cycle and try to mount. This fails in most cases
53 # because the sb LSN is ahead of the current LSN. If it doesn't fail, push the
54 # cycle back further and try again.
55 _scratch_xfs_db -x -c "logformat" >> $seqres.full 2>&1
56 _try_scratch_mount >> $seqres.full 2>&1
58 echo mount failure detected
61 _scratch_xfs_db -x -c "logformat -c 2" >> $seqres.full 2>&1
62 _try_scratch_mount >> $seqres.full 2>&1 || echo mount failure detected
65 # verify that repair detects invalid LSNs as well
66 _scratch_xfs_repair -n >> $seqres.full 2>&1 || \
67 echo repair failure detected
69 # repair for real so the post-test check can verify repair fixed things up
70 _scratch_xfs_repair >> $seqres.full 2>&1