fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: zlang@redhat.com, djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me
Subject: [PATCH 01/13] xfs: fix tests that try to access the realtime rmap inode
Date: Fri, 30 Dec 2022 14:20:44 -0800	[thread overview]
Message-ID: <167243884407.739669.14948742406779742441.stgit@magnolia> (raw)
In-Reply-To: <167243884390.739669.13524725872131241203.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

The realtime rmap tests were added to fstests a long time ago.  Since
they were added, we decided to create a metadata file directory
structure instead of adding more fields to the superblock.  Therefore,
fix all the tests that try to access these paths.

While we're at it, fix xfs/409 to run the *online* scrub program like
it's supposed to.  xfs/408 is the fuzzer for xfs_repair testing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/xfs        |   18 ++++++++++++++++++
 tests/xfs/122.out |    1 -
 tests/xfs/333     |   45 ---------------------------------------------
 tests/xfs/333.out |    6 ------
 tests/xfs/337     |    2 +-
 tests/xfs/338     |   21 ++++++++++++++++-----
 tests/xfs/339     |    5 +++--
 tests/xfs/340     |   15 ++++++++++-----
 tests/xfs/341     |    2 +-
 tests/xfs/342     |    4 ++--
 10 files changed, 51 insertions(+), 68 deletions(-)
 delete mode 100755 tests/xfs/333
 delete mode 100644 tests/xfs/333.out


diff --git a/common/xfs b/common/xfs
index f451dfb8ae..aea2b678c8 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1922,3 +1922,21 @@ _require_xfs_scratch_metadir()
 		_scratch_unmount
 	fi
 }
+
+# Resolve a metadata directory tree path and return the inode number.
+_scratch_metadir_lookup() {
+	local res="$(_scratch_xfs_db -c "ls -i -m $1")"
+	test "${PIPESTATUS[0]}" -eq 0 && echo "$res"
+}
+
+# Figure out which directory entry we have to change to update the rtrmap
+# inode pointer.  Assumes the /realtime directory is a short format dir.
+_scratch_find_rt_metadir_entry() {
+	local sfkey="$(_scratch_xfs_db -c 'path -m /realtime' -c print | \
+		grep "\"$1\"" | \
+		sed -e 's/.name.*$//g' -e 's/\[/\\[/g' -e 's/\]/\\]/g' )"
+	test -n "$sfkey" || return 1
+	_scratch_xfs_db -c 'path -m /realtime' -c print | \
+		grep "${sfkey}.inumber" | awk '{print $1}'
+	return 0
+}
diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 1379c7b3b5..53eff0027e 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -48,7 +48,6 @@ offsetof(xfs_sb_t, sb_rgblklog) = 280
 offsetof(xfs_sb_t, sb_rgblocks) = 272
 offsetof(xfs_sb_t, sb_rgcount) = 276
 offsetof(xfs_sb_t, sb_rootino) = 56
-offsetof(xfs_sb_t, sb_rrmapino) = 264
 offsetof(xfs_sb_t, sb_rsumino) = 72
 offsetof(xfs_sb_t, sb_sectlog) = 121
 offsetof(xfs_sb_t, sb_sectsize) = 102
diff --git a/tests/xfs/333 b/tests/xfs/333
deleted file mode 100755
index 728c518402..0000000000
--- a/tests/xfs/333
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/bash
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
-#
-# FS QA Test No. 333
-#
-# Set rrmapino to another inode on an non-rt rmap fs and see if repair fixes it.
-#
-. ./common/preamble
-_begin_fstest auto quick rmap realtime
-
-# Import common functions.
-. ./common/filter
-
-# real QA test starts here
-_supported_fs xfs
-_require_xfs_scratch_rmapbt
-_disable_dmesg_check
-
-rm -f "$seqres.full"
-
-unset SCRATCH_RTDEV
-
-echo "Format and mount"
-_scratch_mkfs > "$seqres.full" 2>&1
-rrmapino="$(_scratch_xfs_db -c 'sb 0' -c 'p rrmapino' 2>&1)"
-test "${rrmapino}" = "field rrmapino not found" && _notrun "realtime rmapbt not supported"
-_scratch_mount
-
-echo "Create some files"
-$XFS_IO_PROG -f -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f1 >> $seqres.full
-$XFS_IO_PROG -f -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full
-echo garbage > $SCRATCH_MNT/f3
-ino=$(stat -c '%i' $SCRATCH_MNT/f3)
-_scratch_unmount
-
-echo "Corrupt fs"
-_scratch_xfs_db -x -c 'sb 0' -c "write rrmapino $ino" >> $seqres.full
-_try_scratch_mount 2>&1 | _filter_error_mount
-
-echo "Test done, mount should have failed"
-
-# success, all done
-status=0
-exit
diff --git a/tests/xfs/333.out b/tests/xfs/333.out
deleted file mode 100644
index b3c698750f..0000000000
--- a/tests/xfs/333.out
+++ /dev/null
@@ -1,6 +0,0 @@
-QA output created by 333
-Format and mount
-Create some files
-Corrupt fs
-mount: Structure needs cleaning
-Test done, mount should have failed
diff --git a/tests/xfs/337 b/tests/xfs/337
index f74baae9b0..9ea8587b27 100755
--- a/tests/xfs/337
+++ b/tests/xfs/337
@@ -53,7 +53,7 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "xfs_repair should not fail"
 
 echo "+ corrupt image"
-_scratch_xfs_db -x -c "sb" -c "addr rrmapino" -c "addr u3.rtrmapbt.ptrs[1]" \
+_scratch_xfs_db -x -c "path -m /realtime/0.rmap" -c "addr u3.rtrmapbt.ptrs[1]" \
 	-c "stack" -c "blocktrash -x 4096 -y 4096 -n 8 -3 -z" \
 	>> $seqres.full 2>&1
 
diff --git a/tests/xfs/338 b/tests/xfs/338
index 9f36150c7e..9d41a83ec2 100755
--- a/tests/xfs/338
+++ b/tests/xfs/338
@@ -29,13 +29,24 @@ $XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full
 _scratch_unmount
 
 echo "Corrupt fs"
-_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \
-	-c 'write core.nlinkv2 0' -c 'write core.mode 0' -c 'sb 0' \
-	-c 'write rrmapino 0' >> $seqres.full
-_try_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed"
+rtrmap_sfentry="$(_scratch_find_rt_metadir_entry 0.rmap)"
+test -n "$rtrmap_sfentry" || _fail "Could not find rtrmap metadir entry?"
+_scratch_xfs_db -x -c 'path -m /realtime/0.rmap' \
+	-c 'write core.nlinkv2 0' -c 'write core.mode 0' \
+	-c 'path -m /realtime' \
+	-c "write $rtrmap_sfentry 0" >> $seqres.full
+if _try_scratch_mount >> $seqres.full 2>&1; then
+       echo "mount should have failed"
+       _scratch_unmount
+else
+	# If the verifiers are working properly, the mount will fail because
+	# we fuzzed the metadata root directory.  This causes loud complaints
+	# to dmesg, so we want to ignore those.
+	_disable_dmesg_check
+fi
 
 echo "Repair fs"
-_scratch_unmount 2>&1 | _filter_scratch
+_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 _repair_scratch_fs >> $seqres.full 2>&1
 
 echo "Try to create more files (again)"
diff --git a/tests/xfs/339 b/tests/xfs/339
index 3e0b4d97ab..24a90d0ba3 100755
--- a/tests/xfs/339
+++ b/tests/xfs/339
@@ -31,7 +31,8 @@ ln $SCRATCH_MNT/f3 $SCRATCH_MNT/f4
 _scratch_unmount
 
 echo "Corrupt fs"
-rrmapino=`_scratch_xfs_get_sb_field rrmapino`
+rrmapino=$(_scratch_metadir_lookup /realtime/0.rmap)
+test -n "$rrmapino" || _fail "Could not find rtrmap inode?"
 _scratch_xfs_set_metadata_field "u3.sfdir3.list[3].inumber.i4" $rrmapino \
 	'sb 0' 'addr rootino' >> $seqres.full
 _scratch_mount
@@ -43,7 +44,7 @@ echo "Try to create more files"
 $XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1
 
 echo "Repair fs"
-_scratch_unmount 2>&1 | _filter_scratch
+_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 _repair_scratch_fs >> $seqres.full 2>&1
 
 echo "Try to create more files (again)"
diff --git a/tests/xfs/340 b/tests/xfs/340
index 2c0014513e..1236f6520f 100755
--- a/tests/xfs/340
+++ b/tests/xfs/340
@@ -31,16 +31,21 @@ ino=$(stat -c '%i' $SCRATCH_MNT/f3)
 _scratch_unmount
 
 echo "Corrupt fs"
-rrmapino=$(_scratch_xfs_get_sb_field rrmapino)
-_scratch_xfs_db -x -c "inode $rrmapino" \
+rtrmap_sfentry="$(_scratch_find_rt_metadir_entry 0.rmap)"
+test -n "$rtrmap_sfentry" || _fail "Could not find rtrmap metadir entry?"
+rrmapino=$(_scratch_metadir_lookup /realtime/0.rmap)
+test -n "$rrmapino" || _fail "Could not find rtrmap inode?"
+_scratch_xfs_db -x -c "path -m /realtime/0.rmap" \
 	-c 'write core.format 2' -c 'write core.size 0' \
-	-c 'write core.nblocks 0' -c 'sb 0' -c 'addr rootino' \
+	-c 'write core.nblocks 0' \
+	-c 'sb 0' -c 'addr rootino' \
 	-c "write u3.sfdir3.list[2].inumber.i4 $rrmapino" \
-	-c 'sb 0' -c "write rrmapino $ino" >> $seqres.full
+	-c 'path -m /realtime' \
+	-c "write $rtrmap_sfentry $ino" >> $seqres.full
 _try_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed"
 
 echo "Repair fs"
-_scratch_unmount 2>&1 | _filter_scratch
+_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 _repair_scratch_fs >> $seqres.full 2>&1
 
 echo "Try to create more files (again)"
diff --git a/tests/xfs/341 b/tests/xfs/341
index 7d2842b579..8861e751a9 100755
--- a/tests/xfs/341
+++ b/tests/xfs/341
@@ -53,7 +53,7 @@ echo "Corrupt fs"
 fsbno=$(_scratch_xfs_db -c "inode $ino" -c 'bmap' | grep 'flag 0' | head -n 1 | \
 	sed -e 's/^.*startblock \([0-9]*\) .*$/\1/g')
 
-_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \
+_scratch_xfs_db -x -c 'path -m /realtime/0.rmap' \
 	-c "write u3.rtrmapbt.ptrs[1] $fsbno" -c 'p' >> $seqres.full
 _scratch_mount
 
diff --git a/tests/xfs/342 b/tests/xfs/342
index 538c8987ef..f29bd874e9 100755
--- a/tests/xfs/342
+++ b/tests/xfs/342
@@ -47,9 +47,9 @@ ino=$(stat -c '%i' $SCRATCH_MNT/f3)
 _scratch_unmount
 
 echo "Corrupt fs"
-_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full
+_scratch_xfs_db -c 'path -m /realtime/0.rmap' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full
 
-fsbno=$(_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' \
+fsbno=$(_scratch_xfs_db -c 'path -m /realtime/0.rmap' \
 	-c 'p u3.rtrmapbt.ptrs[1]' | sed -e 's/^.*://g')
 _scratch_xfs_db -x -c "inode $ino" -c "write u3.bmx[0].startblock $fsbno" >> $seqres.full
 _scratch_mount


  parent reply	other threads:[~2022-12-31  3:12 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30 21:14 [NYE DELUGE 3/4] xfs: modernize the realtime volume Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET 0/1] fstests: test upgrading older features Darrick J. Wong
2022-12-30 22:20   ` [PATCH 1/1] xfs: test upgrading old features Darrick J. Wong
2023-03-06 15:56     ` Zorro Lang
2023-03-06 16:41       ` Darrick J. Wong
2023-03-06 16:54         ` Zorro Lang
2023-03-06 23:14           ` Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 0/9] fstests: test XFS metadata directories Darrick J. Wong
2022-12-30 22:20   ` [PATCH 3/9] xfs/{030,033,178}: forcibly disable metadata directory trees Darrick J. Wong
2022-12-30 22:20   ` [PATCH 1/9] xfs/122: fix metadirino Darrick J. Wong
2022-12-30 22:20   ` [PATCH 2/9] various: fix finding metadata inode numbers when metadir is enabled Darrick J. Wong
2023-03-06 16:41     ` Zorro Lang
2022-12-30 22:20   ` [PATCH 4/9] common/repair: patch up repair sb inode value complaints Darrick J. Wong
2022-12-30 22:20   ` [PATCH 6/9] xfs/{050,144,153,299,330}: update quota reports to leave out metadir files Darrick J. Wong
2022-12-30 22:20   ` [PATCH 9/9] xfs: create fuzz tests for metadata directories Darrick J. Wong
2022-12-30 22:20   ` [PATCH 7/9] xfs/769: add metadir upgrade to test matrix Darrick J. Wong
2022-12-30 22:20   ` [PATCH 5/9] xfs/206: update for metadata directory support Darrick J. Wong
2022-12-30 22:20   ` [PATCH 8/9] xfs/509: adjust inumbers accounting for metadata directories Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 0/4] fstests: support metadump to external devices Darrick J. Wong
2022-12-30 22:20   ` [PATCH 3/4] common/ext4: reformat external logs during mdrestore operations Darrick J. Wong
2022-12-30 22:20   ` [PATCH 2/4] common/xfs: wipe " Darrick J. Wong
2022-12-30 22:20   ` [PATCH 1/4] common/populate: refactor caching of metadumps to a helper Darrick J. Wong
2022-12-30 22:20   ` [PATCH 4/4] common/xfs: capture external logs during metadump/mdrestore Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 00/12] xfsprogs: shard the realtime section Darrick J. Wong
2022-12-30 22:20   ` [PATCH 03/12] xfs/206: update mkfs filtering for rt groups feature Darrick J. Wong
2022-12-30 22:20   ` [PATCH 01/12] xfs/122: update for rtgroups Darrick J. Wong
2022-12-30 22:20   ` [PATCH 02/12] punch-alternating: detect xfs realtime files with large allocation units Darrick J. Wong
2022-12-30 22:20   ` [PATCH 10/12] xfs/27[46],xfs/556: fix tests to deal with rtgroups output in bmap/fsmap commands Darrick J. Wong
2022-12-30 22:20   ` [PATCH 07/12] xfs/449: update test to know about xfs_db -R Darrick J. Wong
2022-12-30 22:20   ` [PATCH 11/12] common/xfs: capture realtime devices during metadump/mdrestore Darrick J. Wong
2022-12-30 22:20   ` [PATCH 05/12] common: filter rtgroups when we're disabling metadir Darrick J. Wong
2022-12-30 22:20   ` [PATCH 08/12] xfs/122: update for rtbitmap headers Darrick J. Wong
2022-12-30 22:20   ` [PATCH 06/12] xfs/185: update for rtgroups Darrick J. Wong
2022-12-30 22:20   ` [PATCH 04/12] common: pass the realtime device to xfs_db when possible Darrick J. Wong
2022-12-30 22:20   ` [PATCH 09/12] xfs/122: udpate test to pick up rtword/suminfo ondisk unions Darrick J. Wong
2022-12-30 22:20   ` [PATCH 12/12] common/fuzzy: adapt the scrub stress tests to support rtgroups Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 00/13] fstests: fixes for realtime rmap Darrick J. Wong
2022-12-30 22:20   ` [PATCH 03/13] xfs: race fsstress with realtime rmap btree scrub and repair Darrick J. Wong
2022-12-30 22:20   ` [PATCH 04/13] xfs/769: add rtrmapbt upgrade to test matrix Darrick J. Wong
2022-12-30 22:20   ` [PATCH 05/13] xfs/122: update for rtgroups-based realtime rmap btrees Darrick J. Wong
2022-12-30 22:20   ` [PATCH 07/13] xfs/341: update test for rtgroup-based rmap Darrick J. Wong
2022-12-30 22:20   ` [PATCH 06/13] xfs: fix various problems with fsmap detecting the data device Darrick J. Wong
2022-12-30 22:20   ` Darrick J. Wong [this message]
2022-12-30 22:20   ` [PATCH 02/13] fuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file Darrick J. Wong
2022-12-30 22:20   ` [PATCH 09/13] xfs: skip tests if formatting small filesystem fails Darrick J. Wong
2022-12-30 22:20   ` [PATCH 10/13] xfs/443: use file allocation unit, not dbsize Darrick J. Wong
2022-12-30 22:20   ` [PATCH 12/13] populate: check that we created a realtime rmap btree of the given height Darrick J. Wong
2022-12-30 22:20   ` [PATCH 13/13] fuzzy: create missing fuzz tests for rt rmap btrees Darrick J. Wong
2022-12-30 22:20   ` [PATCH 11/13] populate: adjust rtrmap calculations for rtgroups Darrick J. Wong
2022-12-30 22:20   ` [PATCH 08/13] xfs/3{43,32}: adapt tests for rt extent size greater than 1 Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 00/10] fstests: reflink on the realtime device Darrick J. Wong
2022-12-30 22:20   ` [PATCH 01/10] xfs/122: update fields for realtime reflink Darrick J. Wong
2022-12-30 22:20   ` [PATCH 02/10] common/populate: create realtime refcount btree Darrick J. Wong
2022-12-30 22:20   ` [PATCH 03/10] xfs: create fuzz tests for the " Darrick J. Wong
2022-12-30 22:20   ` [PATCH 06/10] xfs: race fsstress with realtime refcount btree scrub and repair Darrick J. Wong
2022-12-30 22:20   ` [PATCH 09/10] generic/331,xfs/240: support files that skip delayed allocation Darrick J. Wong
2022-12-30 22:20   ` [PATCH 05/10] xfs/243: don't run when realtime storage is the default Darrick J. Wong
2022-12-30 22:20   ` [PATCH 04/10] xfs/27[24]: adapt for checking files on the realtime volume Darrick J. Wong
2022-12-30 22:20   ` [PATCH 08/10] xfs/769: add rtreflink upgrade to test matrix Darrick J. Wong
2022-12-30 22:20   ` [PATCH 10/10] common/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section Darrick J. Wong
2022-12-30 22:20   ` [PATCH 07/10] xfs: remove xfs/131 now that we allow reflink on realtime volumes Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 0/4] fstests: reflink with large realtime extents Darrick J. Wong
2022-12-30 22:20   ` [PATCH 1/4] xfs: make sure that CoW will write around when rextsize > 1 Darrick J. Wong
2022-12-30 22:20   ` [PATCH 2/4] xfs: skip cowextsize hint fragmentation tests on realtime volumes Darrick J. Wong
2022-12-30 22:20   ` [PATCH 4/4] generic/303: avoid test failures on weird rt extent sizes Darrick J. Wong
2022-12-30 22:20   ` [PATCH 3/4] misc: add more congruent oplen testing Darrick J. Wong
2022-12-30 22:20 ` [PATCHSET v1.0 0/1] fstests: functional tests for rt quota Darrick J. Wong
2022-12-30 22:20   ` [PATCH 1/1] xfs: regression testing of quota on the realtime device Darrick J. Wong
2023-12-31 20:00 [PATCHSET v2.0 4/9] fstests: fixes for realtime rmap Darrick J. Wong
2023-12-27 13:57 ` [PATCH 01/13] xfs: fix tests that try to access the realtime rmap inode Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=167243884407.739669.14948742406779742441.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).