From patchwork Wed Mar 31 01:08:28 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: 12174063 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.0 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 DCA44C433DB for ; Wed, 31 Mar 2021 01:09:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5B86619CF for ; Wed, 31 Mar 2021 01:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232788AbhCaBIv (ORCPT ); Tue, 30 Mar 2021 21:08:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:42022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232874AbhCaBIb (ORCPT ); Tue, 30 Mar 2021 21:08:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E14976190A; Wed, 31 Mar 2021 01:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617152911; bh=P1Fmy1riqPQVPjzMQgX+u7SvzQFcwEeEp3MrBRwUMD4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AmgEBk/XEwunOLt4vucfojQ9YmZ9nZ44LVpaUxnW7q8nvvR/n/DQvFJW0b9bwwr5e 92W3aXOcdF4L/g2tRot0wXlgNvrr6W6AwUhssA2SePhPc9DAEL2J33L0BvZIsgfGCA XiqC+XWVva5KZtnZcHFKdPlpESck2Te0/tFAazYoLYJ2grtXpoE+1MaC1FkP3jMc70 tdEmVNNEEn+HiLzzFqUl6F5g8A8BPQv4a+UztIEDGe8yyhPJcUJnzR8djF/qXOALDM 5nnT4j8APJXCqWm9l4SXrKVAO88LOnCLEJQIkS6TMK1JM3U0h3Za5Tip7s5a9WLylz hbM8IvFjWQQHA== Subject: [PATCH 1/2] xfs: functional testing of V5-relevant options 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: Tue, 30 Mar 2021 18:08:28 -0700 Message-ID: <161715290858.2703879.2364659698245587140.stgit@magnolia> In-Reply-To: <161715290311.2703879.6182444659830603450.stgit@magnolia> References: <161715290311.2703879.6182444659830603450.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong Currently, the only functional testing for xfs_admin is xfs/287, which checks that one can add 32-bit project ids to a V4 filesystem. This obviously isn't an exhaustive test of all the CLI arguments, and historically there have been xfs configurations that don't even work. Therefore, introduce a couple of new tests -- one that will test the simple options with the default configuration, and a second test that steps a bit outside of the test run configuration to make sure that we do the right thing for external devices. The second test already caught a nasty bug in xfsprogs 5.11. Signed-off-by: Darrick J. Wong --- common/xfs | 21 ++++++++++ tests/xfs/764 | 91 ++++++++++++++++++++++++++++++++++++++++++ tests/xfs/764.out | 17 ++++++++ tests/xfs/773 | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/773.out | 19 +++++++++ tests/xfs/group | 2 + 6 files changed, 264 insertions(+) create mode 100755 tests/xfs/764 create mode 100644 tests/xfs/764.out create mode 100755 tests/xfs/773 create mode 100644 tests/xfs/773.out diff --git a/common/xfs b/common/xfs index 051e5652..a65eeb58 100644 --- a/common/xfs +++ b/common/xfs @@ -1112,3 +1112,24 @@ _check_scratch_xfs_features() echo "${output[@]}" test "${found}" -eq "$#" } + +# Decide if xfs_repair knows how to set (or clear) a filesystem feature. +_require_xfs_repair_upgrade() +{ + local type="$1" + + $XFS_REPAIR_PROG -c "$type=garbagevalue" 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..c710ad4e --- /dev/null +++ b/tests/xfs/764 @@ -0,0 +1,91 @@ +#! /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 to make sure that it handles option parsing +# correctly, at least for functionality that's relevant to V5 filesystems. + +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_scratch +_require_command "$XFS_ADMIN_PROG" "xfs_admin" + +rm -f $seqres.full + +note() { + echo "$@" | tee -a $seqres.full +} + +note "S0: Initialize filesystem" +_scratch_mkfs -L origlabel -m uuid=babababa-baba-baba-baba-babababababa >> $seqres.full +_scratch_xfs_db -c label -c uuid +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S1: Set a filesystem label" +_scratch_xfs_admin -L newlabel >> $seqres.full +_scratch_xfs_db -c label +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S2: Clear filesystem label" +_scratch_xfs_admin -L -- >> $seqres.full +_scratch_xfs_db -c label +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S3: Try to set oversized label" +_scratch_xfs_admin -L thisismuchtoolongforxfstohandle >> $seqres.full +_scratch_xfs_db -c label +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S4: Set filesystem UUID" +_scratch_xfs_admin -U deaddead-dead-dead-dead-deaddeaddead >> $seqres.full +_scratch_xfs_db -c uuid +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S5: Zero out filesystem UUID" +_scratch_xfs_admin -U nil >> $seqres.full +_scratch_xfs_db -c uuid +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S6: Randomize filesystem UUID" +old_uuid="$(_scratch_xfs_db -c uuid)" +_scratch_xfs_admin -U generate >> $seqres.full +new_uuid="$(_scratch_xfs_db -c uuid)" +if [ "$new_uuid" = "$old_uuid" ]; then + echo "UUID randomization failed? $old_uuid == $new_uuid" +fi +_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" + +note "S7: Restore original filesystem UUID" +if _check_scratch_xfs_features V5 >/dev/null; then + # Only V5 supports the metauuid feature that enables us to restore the + # original UUID after a change. + _scratch_xfs_admin -U restore >> $seqres.full + _scratch_xfs_db -c uuid +else + echo "UUID = babababa-baba-baba-baba-babababababa" +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/764.out b/tests/xfs/764.out new file mode 100644 index 00000000..8da929ec --- /dev/null +++ b/tests/xfs/764.out @@ -0,0 +1,17 @@ +QA output created by 764 +S0: Initialize filesystem +label = "origlabel" +UUID = babababa-baba-baba-baba-babababababa +S1: Set a filesystem label +label = "newlabel" +S2: Clear filesystem label +label = "" +S3: Try to set oversized label +label = "thisismuchto" +S4: Set filesystem UUID +UUID = deaddead-dead-dead-dead-deaddeaddead +S5: Zero out filesystem UUID +UUID = 00000000-0000-0000-0000-000000000000 +S6: Randomize filesystem UUID +S7: Restore original filesystem UUID +UUID = babababa-baba-baba-baba-babababababa diff --git a/tests/xfs/773 b/tests/xfs/773 new file mode 100755 index 00000000..f184962a --- /dev/null +++ b/tests/xfs/773 @@ -0,0 +1,114 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2021 Oracle. All Rights Reserved. +# +# FS QA Test No. 773 +# +# Functional testing for xfs_admin to ensure that it parses arguments correctly +# with regards to data devices that are files, external logs, and realtime +# devices. +# +# Because this test synthesizes log and rt devices (by modifying the test run +# configuration), it does /not/ require the ability to mount the scratch +# filesystem. This increases test coverage while isolating the weird bits to a +# single test. +# +# This is partially a regression test for "xfs_admin: pick up log arguments +# correctly", insofar as the issue fixed by that patch was discovered with an +# earlier revision of this test. + +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 $fake_datafile +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs xfs +_require_test +_require_scratch_nocheck +_require_command "$XFS_ADMIN_PROG" "xfs_admin" + +rm -f $seqres.full + +# Create some fake sparse files for testing external devices and whatnot +fake_datafile=$TEST_DIR/scratch.data +rm -f $fake_datafile +truncate -s 500m $fake_datafile + +fake_logfile=$TEST_DIR/scratch.log +rm -f $fake_logfile +truncate -s 500m $fake_logfile + +fake_rtfile=$TEST_DIR/scratch.rt +rm -f $fake_rtfile +truncate -s 500m $fake_rtfile + +# Save the original variables +orig_ddev=$SCRATCH_DEV +orig_external=$USE_EXTERNAL +orig_logdev=$SCRATCH_LOGDEV +orig_rtdev=$SCRATCH_RTDEV + +scenario() { + echo "$@" | tee -a $seqres.full + + SCRATCH_DEV=$orig_ddev + USE_EXTERNAL=$orig_external + SCRATCH_LOGDEV=$orig_logdev + SCRATCH_RTDEV=$orig_rtdev +} + +check_label() { + _scratch_mkfs -L oldlabel >> $seqres.full + _scratch_xfs_db -c label + _scratch_xfs_admin -L newlabel "$@" >> $seqres.full + _scratch_xfs_db -c label + _scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?" +} + +scenario "S1: Check that label setting with file image" +SCRATCH_DEV=$fake_datafile +check_label -f + +scenario "S2: Check that setting with logdev works" +USE_EXTERNAL=yes +SCRATCH_LOGDEV=$fake_logfile +check_label + +scenario "S3: Check that setting with rtdev works" +USE_EXTERNAL=yes +SCRATCH_RTDEV=$fake_rtfile +check_label + +scenario "S4: Check that setting with rtdev + logdev works" +USE_EXTERNAL=yes +SCRATCH_LOGDEV=$fake_logfile +SCRATCH_RTDEV=$fake_rtfile +check_label + +scenario "S5: Check that setting with nortdev + nologdev works" +USE_EXTERNAL= +SCRATCH_LOGDEV= +SCRATCH_RTDEV= +check_label + +scenario "S6: Check that setting with bdev incorrectly flagged as file works" +check_label -f + +# success, all done +status=0 +exit diff --git a/tests/xfs/773.out b/tests/xfs/773.out new file mode 100644 index 00000000..954bfb85 --- /dev/null +++ b/tests/xfs/773.out @@ -0,0 +1,19 @@ +QA output created by 773 +S1: Check that label setting with file image +label = "oldlabel" +label = "newlabel" +S2: Check that setting with logdev works +label = "oldlabel" +label = "newlabel" +S3: Check that setting with rtdev works +label = "oldlabel" +label = "newlabel" +S4: Check that setting with rtdev + logdev works +label = "oldlabel" +label = "newlabel" +S5: Check that setting with nortdev + nologdev works +label = "oldlabel" +label = "newlabel" +S6: Check that setting with bdev incorrectly flagged as file works +label = "oldlabel" +label = "newlabel" diff --git a/tests/xfs/group b/tests/xfs/group index 09fddb5a..5801471b 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -520,5 +520,7 @@ 537 auto quick 538 auto stress 539 auto quick mount +764 auto quick repair 768 auto quick repair 770 auto repair +773 auto quick repair From patchwork Wed Mar 31 01:08:34 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: 12174073 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.0 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 E09C9C433F1 for ; Wed, 31 Mar 2021 01:09:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C09FF619DE for ; Wed, 31 Mar 2021 01:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232979AbhCaBIv (ORCPT ); Tue, 30 Mar 2021 21:08:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:42096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232401AbhCaBIg (ORCPT ); Tue, 30 Mar 2021 21:08:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A3AC619C1; Wed, 31 Mar 2021 01:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617152916; bh=tNKYNINkwBQFb6YnVmhPWA6Rf7IrRz3Xtm4x7yTZahQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iWrwpxKyacFtq7fm9ZM357HaJrZW8bEg0W0DZ5AxuNWxD08kGWfdkyc88yIM0IdOM OyRD7tzUbhzkVvNDabAWtvqKPCbR0DHDtVE27gsQnp6/48asaE706D8ELr6Br6noi3 WDH8I4bZhUUeB6yNByasNNaxQ5qSd/FrtdVJSzzrWY+Up1KKFRniTVm/horihnlL95 bykFO+j1BmyVu5tIObKFm//bFhOkWyrwpwxwqZWAIQ5u3cAYn3DcwPyZ9TzL+HWfoQ y/owidmmgJb4X2w7z0zrEe4SAMu83FpY82Idb/owH0FNJnxnWsIBLYyyFVwBMLMiZQ X/SEOX4Kji4cQ== Subject: [PATCH 2/2] 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: Tue, 30 Mar 2021 18:08:34 -0700 Message-ID: <161715291407.2703879.12588572306371939752.stgit@magnolia> In-Reply-To: <161715290311.2703879.6182444659830603450.stgit@magnolia> References: <161715290311.2703879.6182444659830603450.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 --- tests/xfs/910 | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/910.out | 23 +++++++++++ tests/xfs/group | 1 3 files changed, 136 insertions(+) create mode 100755 tests/xfs/910 create mode 100644 tests/xfs/910.out diff --git a/tests/xfs/910 b/tests/xfs/910 new file mode 100755 index 00000000..5f095324 --- /dev/null +++ b/tests/xfs/910 @@ -0,0 +1,112 @@ +#! /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 +_check_scratch_xfs_features INOBTCNT + +# 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 +_check_scratch_xfs_features INOBTCNT + +# Format V5 filesystem without inode btree counter support and upgrade it. +# Inject failure into repair and make sure that the only path forward is +# to re-run repair on the filesystem. +_scratch_mkfs -m crc=1,inobtcount=0 >> $seqres.full +echo "Fail partway through upgrading" +XFS_REPAIR_FAIL_AFTER_PHASE=2 _scratch_xfs_repair -c inobtcount=1 2>> $seqres.full +test $? -eq 137 || echo "repair should have been killed??" +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT +_try_scratch_mount &> $tmp.mount +res=$? +_filter_scratch < $tmp.mount +if [ $res -eq 0 ]; then + echo "needsrepair should have prevented mount" + _scratch_unmount +fi + +echo "Re-run repair to finish upgrade" +_scratch_xfs_repair 2>> $seqres.full +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT + +echo "Filesystem should be usable again" +_try_scratch_mount &> $tmp.mount +res=$? +_filter_scratch < $tmp.mount +if [ $res -eq 0 ]; then + _scratch_unmount +else + echo "mount should succeed after second repair" +fi +_check_scratch_xfs_features NEEDSREPAIR INOBTCNT + +# Format V5 filesystem without inode btree counter support and upgrade 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 +_check_scratch_xfs_features INOBTCNT +_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..ed78d88f --- /dev/null +++ b/tests/xfs/910.out @@ -0,0 +1,23 @@ +QA output created by 910 +Running xfs_repair to upgrade filesystem. +Inode btree count feature only supported on V5 filesystems. +FEATURES: INOBTCNT:NO +Running xfs_repair to upgrade filesystem. +Inode btree count feature requires free inode btree. +FEATURES: INOBTCNT:NO +Fail partway through upgrading +Adding inode btree counts to filesystem. +FEATURES: NEEDSREPAIR:YES INOBTCNT:YES +mount: SCRATCH_MNT: mount(2) system call failed: Structure needs cleaning. +Re-run repair to finish upgrade +FEATURES: NEEDSREPAIR:NO INOBTCNT:YES +Filesystem should be usable again +FEATURES: NEEDSREPAIR:NO INOBTCNT:YES +Running xfs_repair to upgrade filesystem. +Adding inode btree counts to filesystem. +FEATURES: INOBTCNT:YES +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 5801471b..0dc8038a 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -524,3 +524,4 @@ 768 auto quick repair 770 auto repair 773 auto quick repair +910 auto quick inobtcount