From patchwork Thu Aug 17 13:39:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 9906337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23D4860386 for ; Thu, 17 Aug 2017 13:39:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14EF328A9B for ; Thu, 17 Aug 2017 13:39:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0974D28AAD; Thu, 17 Aug 2017 13:39:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3746528A9B for ; Thu, 17 Aug 2017 13:39:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751684AbdHQNjs (ORCPT ); Thu, 17 Aug 2017 09:39:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58640 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbdHQNjs (ORCPT ); Thu, 17 Aug 2017 09:39:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D90DCA375 for ; Thu, 17 Aug 2017 13:39:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D90DCA375 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=cmaiolino@redhat.com Received: from hades.localdomain.com (ovpn-204-167.brq.redhat.com [10.40.204.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8220F7F6DD for ; Thu, 17 Aug 2017 13:39:47 +0000 (UTC) From: Carlos Maiolino To: fstests@vger.kernel.org Subject: [PATCH V2] xfs: Test infinite loop while searching for a free inode slot Date: Thu, 17 Aug 2017 15:39:43 +0200 Message-Id: <20170817133943.10774-1-cmaiolino@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 17 Aug 2017 13:39:48 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changelog: V2: - Small clean up - use _disable_dmesg_check (the test will generate error messages which will appear in dmesg) - Get the amount of free inodes from the AGI instead of assuming 61 free inodes - Send a few outputs to $seqres.full - Use xfs_db `write` without -d option once this will create incompatibility with previous xfsprogs, and is not strictly required for the test to work. - Check for finobt, and explicitly disable it if it is supported by the kernel being tested. tests/xfs/057 | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/057.out | 2 ++ tests/xfs/group | 1 + 3 files changed, 89 insertions(+) create mode 100755 tests/xfs/057 create mode 100644 tests/xfs/057.out diff --git a/tests/xfs/057 b/tests/xfs/057 new file mode 100755 index 00000000..9833ba25 --- /dev/null +++ b/tests/xfs/057 @@ -0,0 +1,86 @@ +#! /bin/bash +# FS QA Test 057 +# +# 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 +_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 >/dev/null 2>&1 + +# agi->freecount is 0 here, corrupt it to show extra free inodes +$XFS_DB_PROG -x -c "agi 0" -c "write freecount 10" $SCRATCH_DEV >> $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/057.out b/tests/xfs/057.out new file mode 100644 index 00000000..185023c7 --- /dev/null +++ b/tests/xfs/057.out @@ -0,0 +1,2 @@ +QA output created by 057 +Silence is golden diff --git a/tests/xfs/group b/tests/xfs/group index cf876a29..37e4e641 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -54,6 +54,7 @@ 054 auto quick 055 dump ioctl remote tape 056 dump ioctl auto quick +057 auto quick fuzzers dangerous 059 dump ioctl auto quick 060 dump ioctl auto quick 061 dump ioctl auto quick