generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / xfs / 098
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 098
6 #
7 # Create and populate an XFS filesystem, corrupt the journal, then see how
8 # the kernel and xfs_repair deal with it.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     #rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/attr
29 . ./common/populate
30
31 # real QA test starts here
32 _supported_fs xfs
33
34 # We corrupt XFS on purpose, and check if assert failures would crash system.
35 _require_no_xfs_bug_on_assert
36 _require_scratch
37 test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
38 _require_attrs
39 _require_populate_commands
40 _require_xfs_db_blocktrash_z_command
41 test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3"
42
43 rm -f $seqres.full
44
45 TESTDIR="${SCRATCH_MNT}/scratchdir"
46 TESTFILE="${TESTDIR}/testfile"
47
48 echo "+ create scratch fs"
49 _scratch_mkfs_xfs > /dev/null
50
51 echo "+ mount fs image"
52 _scratch_mount
53 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
54
55 echo "+ make some files"
56 mkdir -p "${TESTDIR}"
57 for x in `seq 1 1024`; do
58         touch "${SCRATCH_MNT}/junk.${x}"
59         inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")"
60         if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then
61                 mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1"
62                 break
63         fi
64 done
65 for x in `seq 2 64`; do
66         touch "${TESTFILE}.${x}"
67 done
68 inode="$(stat -c '%i' "${TESTFILE}.1")"
69 umount "${SCRATCH_MNT}"
70
71 echo "+ check fs"
72 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
73
74 echo "+ corrupt image"
75 logstart="$(_scratch_xfs_get_sb_field logstart)"
76 logstart="$(_scratch_xfs_db -c "convert fsblock ${logstart} byte" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
77 logblocks="$(_scratch_xfs_get_sb_field logblocks)"
78
79 if [ "$USE_EXTERNAL" = yes ] && [ ! -z "$SCRATCH_LOGDEV" ]; then
80         logdev=$SCRATCH_LOGDEV
81 else
82         logdev=$SCRATCH_DEV
83 fi
84 $XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" $logdev >> $seqres.full
85
86 echo "+ mount image"
87 _try_scratch_mount 2>/dev/null && _fail "mount should not succeed"
88
89 echo "+ repair fs"
90 _repair_scratch_fs >> $seqres.full 2>&1
91
92 # We may trigger assert related WARNINGs if we corrupt log on a
93 # CONFIG_XFS_WARN or CONFIG_XFS_DEBUG (CONFIG_XFS_ASSERT_FATAL is
94 # disabled) build, so filter them.
95 _check_dmesg _filter_assert_dmesg
96
97 echo "+ mount image (2)"
98 _scratch_mount
99
100 echo "+ chattr -R -i"
101 $CHATTR_PROG -R -f -i "${SCRATCH_MNT}/"
102
103 echo "+ modify files (2)"
104 broken=0
105 for x in `seq 1 64`; do
106         test -e "${TESTFILE}.${x}" || continue
107         echo moo | dd oflag=append conv=notrunc of="${TESTFILE}.${x}" 2>/dev/null
108         test $? -ne 0 && broken=1
109 done
110 echo "broken: ${broken}"
111 umount "${SCRATCH_MNT}"
112
113 echo "+ check fs (2)"
114 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
115
116 status=0
117 exit