From patchwork Tue Mar 23 04:20:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12156883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEE96C433EB for ; Tue, 23 Mar 2021 04:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A66A619B9 for ; Tue, 23 Mar 2021 04:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbhCWEVG (ORCPT ); Tue, 23 Mar 2021 00:21:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbhCWEUu (ORCPT ); Tue, 23 Mar 2021 00:20:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6FF8B6198E; Tue, 23 Mar 2021 04:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616473250; bh=GDWjU4DCIze5DwS4eYYYPuxPlGnlspEYDBe52dhwOH8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=UqBkY2vVm08AEoCJW29uqVwHyXC43heW3b0CtBn7PMZ6fZD1CyRPaUoa4PQ9L1ws1 2UHEdbHl+azbMGjhPTu8d7C1bmW9PPR6c+5mra4igZcZkrW+JoLfrvX45qx50sKJIO l0wox21CfvxikDAAJ56FcgBdN+DKfr+pUlL1epcxYHUHz/GQg1GJOdH3Rcp68k4tyt DnTIPzk5n0fCp/JylkLyB5M96SEiZPu2Y5SGJDPuPgGHx/FTR49Y3CHBEm8/1in58t NZmI/wC3yGcJH6PuO9TsiDc00etm51RE9NbTfkqJ5zonnmLq/fWORwEFACXIamCMWl j5AKaqXhYuq1g== Subject: [PATCH 1/3] xfs/{010,030}: update repair output to deal with inobtcount feature From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: Brian Foster , linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Mon, 22 Mar 2021 21:20:50 -0700 Message-ID: <161647325010.3431131.10019758464943956019.stgit@magnolia> In-Reply-To: <161647324459.3431131.16341235245632737552.stgit@magnolia> References: <161647324459.3431131.16341235245632737552.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Update both of these tests to filter out the new error messages from repair when the inode btree counter feature is enabled. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- tests/xfs/010 | 3 ++- tests/xfs/030 | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/xfs/010 b/tests/xfs/010 index 1f9bcdff..95cc2555 100755 --- a/tests/xfs/010 +++ b/tests/xfs/010 @@ -113,7 +113,8 @@ _check_scratch_fs _corrupt_finobt_root $SCRATCH_DEV filter_finobt_repair() { - sed -e '/^agi has bad CRC/d' | \ + sed -e '/^agi has bad CRC/d' \ + -e '/^bad finobt block/d' | \ _filter_repair_lostblocks } diff --git a/tests/xfs/030 b/tests/xfs/030 index 04440f9c..906d9019 100755 --- a/tests/xfs/030 +++ b/tests/xfs/030 @@ -44,6 +44,8 @@ _check_ag() -e '/^bad agbno AGBNO for refcntbt/d' \ -e '/^agf has bad CRC/d' \ -e '/^agi has bad CRC/d' \ + -e '/^bad inobt block count/d' \ + -e '/^bad finobt block count/d' \ -e '/^Missing reverse-mapping record.*/d' \ -e '/^bad levels LEVELS for [a-z]* root.*/d' \ -e '/^unknown block state, ag AGNO, block.*/d' From patchwork Tue Mar 23 04:20:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12156885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA3B5C433EC for ; Tue, 23 Mar 2021 04:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEED2619B8 for ; Tue, 23 Mar 2021 04:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbhCWEVG (ORCPT ); Tue, 23 Mar 2021 00:21:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbhCWEU4 (ORCPT ); Tue, 23 Mar 2021 00:20:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 013BE6198E; Tue, 23 Mar 2021 04:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616473256; bh=yUB8d38HfpbDCRPHNKnnorSrkrAJTVvygBH4h4lHOZY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=cngs+7G5TBY6AZ/UnqUDjzKGCj376lsUVBYJuiqZzMVhsUBMIJtxHoE5UjAQeNSeX eAxoA4X/LQbPCoN3+D1AUKA03ujoCFDcSBltLMgsYAswYnq0g12VrXEWeZ+zeBgnDC wfpRslDW4hR3xGmkxAjiyThkK5b7niCIgYqxOD4NzKOdVUlxdUB4UOPeTg5OHvhK0u WnJlYNjk4BtG8lFBR5UtWcxxzrb0BdKaKSQdys3DNUiDLtELFYNErg8Gd73ItiRZfI PVxdqrAdTE2/yw+lSs5h/ocoVE+LRIbhpg2LvQaOtCl2NU6TDCx9Su72XxDf+ZbCFX Hdafjkv/TA6YA== Subject: [PATCH 2/3] xfs/122: embiggen struct xfs_agi size for inobtcount feature From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: Brian Foster , linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Mon, 22 Mar 2021 21:20:55 -0700 Message-ID: <161647325568.3431131.12651460689158775079.stgit@magnolia> In-Reply-To: <161647324459.3431131.16341235245632737552.stgit@magnolia> References: <161647324459.3431131.16341235245632737552.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make the expected AGI size larger for the inobtcount feature. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- tests/xfs/122.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/xfs/122.out b/tests/xfs/122.out index cfe09c6d..b0773756 100644 --- a/tests/xfs/122.out +++ b/tests/xfs/122.out @@ -113,7 +113,7 @@ sizeof(struct xfs_scrub_metadata) = 64 sizeof(struct xfs_unmount_log_format) = 8 sizeof(xfs_agf_t) = 224 sizeof(xfs_agfl_t) = 36 -sizeof(xfs_agi_t) = 336 +sizeof(xfs_agi_t) = 344 sizeof(xfs_alloc_key_t) = 8 sizeof(xfs_alloc_rec_incore_t) = 8 sizeof(xfs_alloc_rec_t) = 8 From patchwork Tue Mar 23 04:21:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12156887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1EDC433DB for ; Tue, 23 Mar 2021 04:22:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99A2461990 for ; Tue, 23 Mar 2021 04:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbhCWEVd (ORCPT ); Tue, 23 Mar 2021 00:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:47202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbhCWEVC (ORCPT ); Tue, 23 Mar 2021 00:21:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8059A61990; Tue, 23 Mar 2021 04:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616473261; bh=Ia3DSPrSyoh26guVcuPPnNI26IG0Xz9inLURjJmlyMM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=U9E2SOAL/7M4kU7AYyXBj8l2y4a4giqezvnF6AZyjBfooL3e37beQ7lT67EDGSZ+d Daf7yfnvNIIr99oaXofgLvciDyQ50nGpqW1OVkmmMbtVgPhjifRGQhbu7Bi7Nm/mRH PHdzpEE/u4rRMpFPDDtEdWRoIZ35Ms0vor6ftcD5qD42/Agh7iLM00YxHkoUSJXy2O l954JifALocigqzaISxwcLWbpL4zwtRRFhzOKgG85kQHPrKJRChXbeoYBAs8xQ8cpy y+Bwo+v6h4NMW/8X9HnvG50Nc6b5bOyK3CuvM463aHooAmB/qObIArkXd3tGZPSRZ4 lzR75HdbSuGmg== Subject: [PATCH 3/3] xfs: test inobtcount upgrade From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Mon, 22 Mar 2021 21:21:01 -0700 Message-ID: <161647326120.3431131.9588272913557202987.stgit@magnolia> In-Reply-To: <161647324459.3431131.16341235245632737552.stgit@magnolia> References: <161647324459.3431131.16341235245632737552.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make sure we can actually upgrade filesystems to support inode btree counters. Signed-off-by: Darrick J. Wong --- common/xfs | 20 ++++++ tests/xfs/764 | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/764.out | 27 ++++++++ tests/xfs/910 | 84 +++++++++++++++++++++++ tests/xfs/910.out | 12 +++ tests/xfs/group | 2 + 6 files changed, 335 insertions(+) create mode 100755 tests/xfs/764 create mode 100644 tests/xfs/764.out create mode 100755 tests/xfs/910 create mode 100644 tests/xfs/910.out diff --git a/common/xfs b/common/xfs index 9cb373ba..a316f384 100644 --- a/common/xfs +++ b/common/xfs @@ -1085,3 +1085,23 @@ _require_xfs_copy() [ "$USE_EXTERNAL" = yes ] && \ _notrun "Cannot xfs_copy with external devices" } + +_require_xfs_repair_upgrade() +{ + local type="$1" + + $XFS_REPAIR_PROG -c "$type=narf" 2>&1 | \ + grep -q 'unknown option' && \ + _notrun "xfs_repair does not support upgrading fs with $type" +} + +_require_xfs_scratch_inobtcount() +{ + _require_scratch + + _scratch_mkfs -m inobtcount=1 &> /dev/null || \ + _notrun "mkfs.xfs doesn't have inobtcount feature" + _try_scratch_mount || \ + _notrun "inobtcount not supported by scratch filesystem type: $FSTYP" + _scratch_unmount +} diff --git a/tests/xfs/764 b/tests/xfs/764 new file mode 100755 index 00000000..cf6784d2 --- /dev/null +++ b/tests/xfs/764 @@ -0,0 +1,190 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2021 Oracle. All Rights Reserved. +# +# FS QA Test No. 764 +# +# Functional testing for xfs_admin -O, which is a new switch that enables us to +# add features to an existing filesystem. In these test scenarios, we try to +# add the inode btree counter 'feature' to the filesystem, and make sure that +# NEEDSREPAIR (aka the thing that prevents us from mounting after an upgrade +# fails) is clear if the upgraded succeeds and set if it fails. +# +# The first scenario tests that we can't add inobtcount to the V4 format, +# which is now deprecated. +# +# The middle five scenarios ensure that xfs_admin -O works even when external +# log devices and realtime volumes are specified. This part is purely an +# exerciser for the userspace tools; kernel support for those features is not +# required. +# +# The last scenario uses a xfs_repair debug knob to simulate failure during an +# inobtcount upgrade, then checks that mounts fail when the flag is enabled, +# that repair clears the flag, and mount works after repair. + +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.* $fake_logfile $fake_rtfile +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs xfs +_require_test +_require_xfs_scratch_inobtcount +_require_command "$XFS_ADMIN_PROG" "xfs_admin" +_require_xfs_repair_upgrade inobtcount + +rm -f $seqres.full + +note() { + echo "$@" | tee -a $seqres.full +} + +note "S1: Cannot add inobtcount to a V4 fs" +_scratch_mkfs -m crc=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full + +# Middle five scenarios: Make sure upgrades work with various external device +# configurations. +note "S2: Check that setting with xfs_admin + logdev works" +fake_logfile=$TEST_DIR/scratch.log +rm -f $fake_logfile +truncate -s 500m $fake_logfile + +old_external=$USE_EXTERNAL +old_logdev=$SCRATCH_LOGDEV +USE_EXTERNAL=yes +SCRATCH_LOGDEV=$fake_logfile + +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR && \ + echo "xfs_admin should have cleared needsrepair?" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "xfs_admin should have set inobtcount?" + +note "Check clean" +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +USE_EXTERNAL=$old_external +SCRATCH_LOGDEV=$old_logdev + +note "S3: Check that setting with xfs_admin + realtime works" +fake_rtfile=$TEST_DIR/scratch.rt +rm -f $fake_rtfile +truncate -s 500m $fake_rtfile + +old_external=$USE_EXTERNAL +old_rtdev=$SCRATCH_RTDEV +USE_EXTERNAL=yes +SCRATCH_RTDEV=$fake_rtfile + +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR && \ + echo "xfs_admin should have cleared needsrepair?" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "xfs_admin should have set inobtcount?" + +note "Check clean" +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +USE_EXTERNAL=$old_external +SCRATCH_RTDEV=$old_rtdev + +note "S4: Check that setting with xfs_admin + realtime + logdev works" +old_external=$USE_EXTERNAL +old_logdev=$SCRATCH_LOGDEV +old_rtdev=$SCRATCH_RTDEV +USE_EXTERNAL=yes +SCRATCH_LOGDEV=$fake_logfile +SCRATCH_RTDEV=$fake_rtfile + +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR && \ + echo "xfs_admin should have cleared needsrepair?" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "xfs_admin should have set inobtcount?" + +note "Check clean" +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +USE_EXTERNAL=$old_external +SCRATCH_LOGDEV=$old_logdev +SCRATCH_RTDEV=$old_rtdev + +note "S5: Check that setting with xfs_admin + nortdev + nologdev works" +old_external=$USE_EXTERNAL +old_logdev=$SCRATCH_LOGDEV +old_rtdev=$SCRATCH_RTDEV +USE_EXTERNAL= +SCRATCH_LOGDEV= +SCRATCH_RTDEV= + +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR && \ + echo "xfs_admin should have cleared needsrepair?" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "xfs_admin should have set inobtcount?" + +note "Check clean" +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +USE_EXTERNAL=$old_external +SCRATCH_LOGDEV=$old_logdev +SCRATCH_RTDEV=$old_rtdev + +# Run our test with the test runner's config last so that the post-test check +# won't trip over our artificial log/rt devices +note "S6: Check that setting with xfs_admin testrunner config works" +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR && \ + echo "xfs_admin should have cleared needsrepair?" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "xfs_admin should have set inobtcount?" + +note "Check clean" +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S7: Simulate failure during upgrade process" +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full +test $? -eq 137 || echo "repair should have been killed??" +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR || \ + echo "needsrepair should have been set on fs" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "inobtcount should have been set on fs" +_try_scratch_mount &> $tmp.mount +res=$? +_filter_scratch < $tmp.mount +if [ $res -eq 0 ]; then + echo "needsrepair should have prevented mount" + _scratch_unmount +fi +_scratch_xfs_repair 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q NEEDSREPAIR && \ + echo "xfs_repair should have cleared needsrepair?" +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "xfs_admin should have set inobtcount?" +_scratch_mount + +# success, all done +status=0 +exit diff --git a/tests/xfs/764.out b/tests/xfs/764.out new file mode 100644 index 00000000..067639c9 --- /dev/null +++ b/tests/xfs/764.out @@ -0,0 +1,27 @@ +QA output created by 764 +S1: Cannot add inobtcount to a V4 fs +Running xfs_repair to upgrade filesystem. +Inode btree count feature only supported on V5 filesystems. +S2: Check that setting with xfs_admin + logdev works +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +Check clean +S3: Check that setting with xfs_admin + realtime works +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +Check clean +S4: Check that setting with xfs_admin + realtime + logdev works +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +Check clean +S5: Check that setting with xfs_admin + nortdev + nologdev works +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +Check clean +S6: Check that setting with xfs_admin testrunner config works +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +Check clean +S7: Simulate failure during upgrade process +Adding inode btree counts to filesystem. +mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning. diff --git a/tests/xfs/910 b/tests/xfs/910 new file mode 100755 index 00000000..4bf79db2 --- /dev/null +++ b/tests/xfs/910 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2021 Oracle. All Rights Reserved. +# +# FS QA Test No. 910 +# +# Check that we can upgrade a filesystem to support inobtcount and that +# everything works properly after the upgrade. + +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 + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_inobtcount +_require_command "$XFS_ADMIN_PROG" "xfs_admin" +_require_xfs_repair_upgrade inobtcount + +rm -f $seqres.full + +# Make sure we can't format a filesystem with inobtcount and not finobt. +_scratch_mkfs -m crc=1,inobtcount=1,finobt=0 &> $seqres.full && \ + echo "Should not be able to format with inobtcount but not finobt." + +# Make sure we can't upgrade a V4 filesystem +_scratch_mkfs -m crc=0,inobtcount=0,finobt=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q INOBTCNT && \ + echo "Should not be able to upgrade to inobtcount without V5." + +# Make sure we can't upgrade a filesystem to inobtcount without finobt. +_scratch_mkfs -m crc=1,inobtcount=0,finobt=0 >> $seqres.full +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q INOBTCNT && \ + echo "Should not be able to upgrade to inobtcount without finobt." + +# Format V5 filesystem without inode btree counter support and populate it +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full +_scratch_mount >> $seqres.full + +echo moo > $SCRATCH_MNT/urk + +_scratch_unmount +_check_scratch_fs + +# Now upgrade to inobtcount support +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_xfs_db -c 'version' | grep -q INOBTCNT || \ + echo "Cannot detect new feature?" +_check_scratch_fs +_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' -c 'agi 0' -c 'p' >> $seqres.full + +# Make sure we have nonzero counters +_scratch_xfs_db -c 'agi 0' -c 'print ino_blocks fino_blocks' | \ + sed -e 's/= [1-9]*/= NONZERO/g' + +# Mount again, look at our files +_scratch_mount >> $seqres.full +cat $SCRATCH_MNT/urk + +# Make sure we can't re-add inobtcount +_scratch_unmount +_scratch_xfs_admin -O inobtcount=1 2>> $seqres.full +_scratch_mount >> $seqres.full + +status=0 +exit diff --git a/tests/xfs/910.out b/tests/xfs/910.out new file mode 100644 index 00000000..c3cfbb80 --- /dev/null +++ b/tests/xfs/910.out @@ -0,0 +1,12 @@ +QA output created by 910 +Running xfs_repair to upgrade filesystem. +Inode btree count feature only supported on V5 filesystems. +Running xfs_repair to upgrade filesystem. +Inode btree count feature requires free inode btree. +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +ino_blocks = NONZERO +fino_blocks = NONZERO +moo +Running xfs_repair to upgrade filesystem. +Filesystem already has inode btree counts. diff --git a/tests/xfs/group b/tests/xfs/group index 6aa7883e..28176409 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -517,7 +517,9 @@ 538 auto stress 759 auto quick rw realtime 760 auto quick rw realtime collapse insert unshare zero prealloc +764 auto quick repair 768 auto quick repair 770 auto repair +910 auto quick inobtcount 917 auto quick db 918 auto quick db