4 # XFS v5 supers carry an LSN in various on-disk structures to track when
5 # associated metadata was last written to disk. These metadata LSNs must always
6 # be behind the current LSN as dictated by the log to ensure log recovery
7 # correctness after a potential crash. This test uses xfs_db to intentionally
8 # put the current LSN behind metadata LSNs and verifies that the kernel and
9 # xfs_repair detect the problem.
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
46 # get standard environment, filters and checks
49 # real QA test starts here
51 # Modify as appropriate.
55 _require_scratch_xfs_crc
56 _require_xfs_db_command "logformat"
58 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
60 # push the log cycle ahead so we have room to move it backwards later
61 _scratch_xfs_db -x -c "logformat -c 3" >> $seqres.full 2>&1
63 # do some work on the fs to update metadata LSNs
65 $FSSTRESS_PROG -d $SCRATCH_MNT -n 999 -p 4 -w >> $seqres.full 2>&1
68 # Reformat to the current cycle and try to mount. This fails in most cases
69 # because the sb LSN is ahead of the current LSN. If it doesn't fail, push the
70 # cycle back further and try again.
71 _scratch_xfs_db -x -c "logformat" >> $seqres.full 2>&1
72 _scratch_mount >> $seqres.full 2>&1
74 echo mount failure detected
77 _scratch_xfs_db -x -c "logformat -c 2" >> $seqres.full 2>&1
78 _scratch_mount >> $seqres.full 2>&1 || echo mount failure detected
81 # verify that repair detects invalid LSNs as well
82 $XFS_REPAIR_PROG -n $SCRATCH_DEV >> $seqres.full 2>&1 || \
83 echo repair failure detected
85 # repair for real so the post-test check can verify repair fixed things up
86 $XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1