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.
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.
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.
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.
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 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
46 # remove previous $seqres.full before test
49 # real QA test starts here
51 # Modify as appropriate.
54 _require_scratch_nocheck
55 # We corrupt XFS on purpose, and check if assert failures would crash system.
56 _require_no_xfs_bug_on_assert
59 # Make sure we disable finobt if the filesystem supports it, otherwise, just
60 # initialize it with default options.
61 _scratch_mkfs | grep -q "finobt=1" && _scratch_mkfs -m "finobt=0" >/dev/null 2>&1
63 # Get the amount of free inodes from the AGI 0, so we can fill up the freecount
65 freecount=`_scratch_xfs_db -c "agi 0" -c "p freecount" | cut -d' ' -f 3`
69 # At the end of filesystem's initialization, AG 0 will have $freecount free
70 # inodes in the agi->freecount, create $freecount extra dummy files to fill it.
71 for i in `seq 1 $freecount`; do
72 touch $SCRATCH_MNT/dummy_file$i
77 # agi->freecount is 0 here, corrupt it to show extra free inodes
78 _scratch_xfs_db -x -c "agi 0" -c "write freecount 10" >> $seqres.full 2>&1
82 # Lock up a buggy kernel
83 touch $SCRATCH_MNT/lockupfile >> $seqres.full 2>&1
85 # If we reach this point, the filesystem is fixed
86 echo "Silence is golden"