0e62628d70ec36db95e5f07107a919f2e717f85c
[xfstests-dev.git] / tests / xfs / 115
1 #! /bin/bash
2 # FS QA Test 115
3 #
4 # Check if the filesystem will lockup when trying to allocate a new inode in
5 # an AG with no free inodes but with a corrupted agi->freecount showing free inodes.
6 #
7 # At the end of the test, the scratch device will purposely be in a corrupted
8 # state, so there is no need for checking that.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # remove previous $seqres.full before test
47 rm -f $seqres.full
48
49 # real QA test starts here
50
51 # Modify as appropriate.
52 _supported_fs generic
53 _supported_os Linux
54 _require_scratch_nocheck
55 # we corrupt XFS on purpose, and debug built XFS would crash due to assert
56 # failure, so skip if we're testing on a debug built XFS
57 _require_no_xfs_debug
58 _disable_dmesg_check
59
60 # Make sure we disable finobt if the filesystem supports it, otherwise, just
61 # initialize it with default options.
62 _scratch_mkfs | grep -q "finobt=1" && _scratch_mkfs -m "finobt=0" >/dev/null 2>&1
63
64 # Get the amount of free inodes from the AGI 0, so we can fill up the freecount
65 # structure.
66 freecount=`_scratch_xfs_db -c "agi 0" -c "p freecount" | cut -d' ' -f 3`
67
68 _scratch_mount
69
70 # At the end of filesystem's initialization, AG 0 will have $freecount free
71 # inodes in the agi->freecount, create $freecount extra dummy files to fill it.
72 for i in `seq 1 $freecount`; do
73         touch $SCRATCH_MNT/dummy_file$i
74 done
75
76 _scratch_unmount
77
78 # agi->freecount is 0 here, corrupt it to show extra free inodes
79 _scratch_xfs_db -x -c "agi 0" -c "write freecount 10" >> $seqres.full 2>&1
80
81 _scratch_mount
82
83 # Lock up a buggy kernel
84 touch $SCRATCH_MNT/lockupfile >> $seqres.full 2>&1
85
86 # If we reach this point, the filesystem is fixed
87 echo "Silence is golden"
88 status=0
89 exit