overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 137
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
4 #
5 # FS QA Test No. 137
6 #
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.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 rm -f $seqres.full
30
31 # get standard environment, filters and checks
32 . ./common/rc
33
34 # real QA test starts here
35
36 # Modify as appropriate.
37 _supported_fs xfs
38 _supported_os Linux
39 _require_scratch
40 _require_scratch_xfs_crc
41 _require_xfs_db_command "logformat"
42
43 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
44
45 # push the log cycle ahead so we have room to move it backwards later
46 _scratch_xfs_db -x -c "logformat -c 3" >> $seqres.full 2>&1
47
48 # do some work on the fs to update metadata LSNs
49 _scratch_mount
50 $FSSTRESS_PROG -d $SCRATCH_MNT -n 999 -p 4 -w >> $seqres.full 2>&1
51 _scratch_unmount
52
53 # Reformat to the current cycle and try to mount. This fails in most cases
54 # because the sb LSN is ahead of the current LSN. If it doesn't fail, push the
55 # cycle back further and try again.
56 _scratch_xfs_db -x -c "logformat" >> $seqres.full 2>&1
57 _try_scratch_mount >> $seqres.full 2>&1
58 if [ $? != 0 ]; then
59         echo mount failure detected
60 else
61         _scratch_unmount
62         _scratch_xfs_db -x -c "logformat -c 2" >> $seqres.full 2>&1
63         _try_scratch_mount >> $seqres.full 2>&1 || echo mount failure detected
64 fi
65
66 # verify that repair detects invalid LSNs as well
67 $XFS_REPAIR_PROG -n $SCRATCH_DEV >> $seqres.full 2>&1 || \
68         echo repair failure detected
69
70 # repair for real so the post-test check can verify repair fixed things up
71 $XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1
72
73 # success, all done
74 status=0
75 exit