xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / ext4 / 036
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. ext4/036
6 #
7 # Test truncate orphan inodes when mounting ext4
8 # ext4 used to hit WARNING, this commit fixed the issue
9 #
10 # 721e3eb ext4: lock i_mutex when truncating orphan inodes
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs ext3 ext4
33 _require_scratch
34
35 rm -f $seqres.full
36 echo "Silence is golden"
37
38 _scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1
39 _scratch_mount
40
41 # create a file and get its inode number, usually it's 12, but to be accurate
42 testfile=$SCRATCH_MNT/testfile
43 touch $testfile
44 inode=`ls -i $testfile | awk '{print $1}'`
45
46 # add the inode in orphan inode list
47 _scratch_unmount
48 debugfs -w -R "set_super_value last_orphan $inode" $SCRATCH_DEV \
49         >>$seqres.full 2>&1
50
51 # mount again to truncate orphan inode, _check_dmesg will catch the WARNING
52 _scratch_mount
53
54 status=0
55 exit