From: Carlos Maiolino Date: Fri, 18 Aug 2017 08:51:56 +0000 (+0200) Subject: xfs: Test infinite loop while searching for a free inode slot X-Git-Tag: v2022.05.01~1870 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=642eb97b9f99dcc1a72dc7c3e83c0862b38682c9;p=users%2Fhch%2Fxfstests-dev.git xfs: Test infinite loop while searching for a free inode slot Tests the search algorithm for a free inode slot in a specific AG, done in xfs_dialloc_ag_inobt(). When finobt is not used, and agi->freecount is not 0, XFS will scan the AG inode tree looking for a free inode slot, but if agi->freecount is corrupted, and there is no free slot at all, it will end up in an infinite loop. This test checks for the infinite loop fix. Signed-off-by: Carlos Maiolino Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/tests/xfs/115 b/tests/xfs/115 new file mode 100755 index 000000000..0e62628d7 --- /dev/null +++ b/tests/xfs/115 @@ -0,0 +1,89 @@ +#! /bin/bash +# FS QA Test 115 +# +# Check if the filesystem will lockup when trying to allocate a new inode in +# an AG with no free inodes but with a corrupted agi->freecount showing free inodes. +# +# At the end of the test, the scratch device will purposely be in a corrupted +# state, so there is no need for checking that. +#----------------------------------------------------------------------- +# Copyright (c) 2017 Red Hat, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_scratch_nocheck +# we corrupt XFS on purpose, and debug built XFS would crash due to assert +# failure, so skip if we're testing on a debug built XFS +_require_no_xfs_debug +_disable_dmesg_check + +# Make sure we disable finobt if the filesystem supports it, otherwise, just +# initialize it with default options. +_scratch_mkfs | grep -q "finobt=1" && _scratch_mkfs -m "finobt=0" >/dev/null 2>&1 + +# Get the amount of free inodes from the AGI 0, so we can fill up the freecount +# structure. +freecount=`_scratch_xfs_db -c "agi 0" -c "p freecount" | cut -d' ' -f 3` + +_scratch_mount + +# At the end of filesystem's initialization, AG 0 will have $freecount free +# inodes in the agi->freecount, create $freecount extra dummy files to fill it. +for i in `seq 1 $freecount`; do + touch $SCRATCH_MNT/dummy_file$i +done + +_scratch_unmount + +# agi->freecount is 0 here, corrupt it to show extra free inodes +_scratch_xfs_db -x -c "agi 0" -c "write freecount 10" >> $seqres.full 2>&1 + +_scratch_mount + +# Lock up a buggy kernel +touch $SCRATCH_MNT/lockupfile >> $seqres.full 2>&1 + +# If we reach this point, the filesystem is fixed +echo "Silence is golden" +status=0 +exit diff --git a/tests/xfs/115.out b/tests/xfs/115.out new file mode 100644 index 000000000..d9dd136f3 --- /dev/null +++ b/tests/xfs/115.out @@ -0,0 +1,2 @@ +QA output created by 115 +Silence is golden