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 2/9] various: fix finding metadata inode numbers when metadir is enabled
Date: Fri, 30 Dec 2022 14:20:32 -0800 [thread overview]
Message-ID: <167243883271.736753.35967461928530874.stgit@magnolia> (raw)
In-Reply-To: <167243883244.736753.17143383151073497149.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
There are a number of tests that use xfs_db to examine the contents of
metadata inodes to check correct functioning. The logic is scattered
everywhere and won't work with metadata directory trees, so make a
shared helper to find these inodes.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
common/xfs | 32 ++++++++++++++++++++++++++++++--
tests/xfs/007 | 16 +++++++++-------
tests/xfs/1562 | 9 ++-------
tests/xfs/1563 | 9 ++-------
tests/xfs/1564 | 9 ++-------
tests/xfs/1565 | 9 ++-------
tests/xfs/1566 | 9 ++-------
tests/xfs/1567 | 9 ++-------
tests/xfs/1568 | 9 ++-------
tests/xfs/1569 | 9 ++-------
tests/xfs/529 | 5 ++---
tests/xfs/530 | 6 ++----
12 files changed, 59 insertions(+), 72 deletions(-)
diff --git a/common/xfs b/common/xfs
index 8b365ad18b..dafbd1b874 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1396,7 +1396,7 @@ _scratch_get_bmx_prefix() {
_scratch_get_iext_count()
{
- local ino=$1
+ local selector=$1
local whichfork=$2
local field=""
@@ -1411,7 +1411,7 @@ _scratch_get_iext_count()
return 1
esac
- _scratch_xfs_get_metadata_field $field "inode $ino"
+ _scratch_xfs_get_metadata_field $field "$selector"
}
#
@@ -1742,3 +1742,31 @@ _require_xfs_scratch_atomicswap()
_notrun "atomicswap dependencies not supported by scratch filesystem type: $FSTYP"
_scratch_unmount
}
+
+# Find a metadata file within an xfs filesystem. The sole argument is the
+# name of the field within the superblock.
+_scratch_xfs_find_metafile()
+{
+ local metafile="$1"
+ local selector=
+
+ if ! _check_scratch_xfs_features METADIR > /dev/null; then
+ sb_field="$(_scratch_xfs_get_sb_field "$metafile")"
+ if echo "$sb_field" | grep -q -w 'not found'; then
+ return 1
+ fi
+ selector="inode $sb_field"
+ else
+ case "${metafile}" in
+ "rootino") selector="path /";;
+ "uquotino") selector="path -m /quota/user";;
+ "gquotino") selector="path -m /quota/group";;
+ "pquotino") selector="path -m /quota/project";;
+ "rbmino") selector="path -m /realtime/bitmap";;
+ "rsumino") selector="path -m /realtime/summary";;
+ esac
+ fi
+
+ echo "${selector}"
+ return 0
+}
diff --git a/tests/xfs/007 b/tests/xfs/007
index 4f864100fd..6d6d828b13 100755
--- a/tests/xfs/007
+++ b/tests/xfs/007
@@ -22,6 +22,11 @@ _require_xfs_quota
_scratch_mkfs_xfs | _filter_mkfs > /dev/null 2> $tmp.mkfs
. $tmp.mkfs
+get_qfile_nblocks() {
+ local selector="$(_scratch_xfs_find_metafile "$1")"
+ _scratch_xfs_db -c "$selector" -c "p core.nblocks"
+}
+
do_test()
{
qino_1=$1
@@ -31,12 +36,9 @@ do_test()
echo "*** umount"
_scratch_unmount
- QINO_1=`_scratch_xfs_get_sb_field $qino_1`
- QINO_2=`_scratch_xfs_get_sb_field $qino_2`
-
echo "*** Usage before quotarm ***"
- _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks"
- _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks"
+ get_qfile_nblocks $qino_1
+ get_qfile_nblocks $qino_2
_qmount
echo "*** turn off $off_opts quotas"
@@ -66,8 +68,8 @@ do_test()
_scratch_unmount
echo "*** Usage after quotarm ***"
- _scratch_xfs_db -c "inode $QINO_1" -c "p core.nblocks"
- _scratch_xfs_db -c "inode $QINO_2" -c "p core.nblocks"
+ get_qfile_nblocks $qino_1
+ get_qfile_nblocks $qino_2
}
# Test user and group first
diff --git a/tests/xfs/1562 b/tests/xfs/1562
index 015209eeb2..1e5b6881ee 100755
--- a/tests/xfs/1562
+++ b/tests/xfs/1562
@@ -27,13 +27,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtbitmap"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.bitmap')
-else
- path=('sb' 'addr rbmino')
-fi
-_scratch_xfs_fuzz_metadata '' 'online' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rbmino)"
+_scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtbitmap"
# success, all done
diff --git a/tests/xfs/1563 b/tests/xfs/1563
index 2be0870a3d..a9da78106d 100755
--- a/tests/xfs/1563
+++ b/tests/xfs/1563
@@ -27,13 +27,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtsummary"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.summary')
-else
- path=('sb' 'addr rsumino')
-fi
-_scratch_xfs_fuzz_metadata '' 'online' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rsumino)"
+_scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtsummary"
# success, all done
diff --git a/tests/xfs/1564 b/tests/xfs/1564
index c0d10ff0e9..4482861d50 100755
--- a/tests/xfs/1564
+++ b/tests/xfs/1564
@@ -27,13 +27,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtbitmap"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.bitmap')
-else
- path=('sb' 'addr rbmino')
-fi
-_scratch_xfs_fuzz_metadata '' 'offline' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rbmino)"
+_scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtbitmap"
# success, all done
diff --git a/tests/xfs/1565 b/tests/xfs/1565
index 6b4186fb3c..c43ccd848e 100755
--- a/tests/xfs/1565
+++ b/tests/xfs/1565
@@ -27,13 +27,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtsummary"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.summary')
-else
- path=('sb' 'addr rsumino')
-fi
-_scratch_xfs_fuzz_metadata '' 'offline' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rsumino)"
+_scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtsummary"
# success, all done
diff --git a/tests/xfs/1566 b/tests/xfs/1566
index 8d0f61ae10..aad4fafb15 100755
--- a/tests/xfs/1566
+++ b/tests/xfs/1566
@@ -28,13 +28,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtbitmap"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.bitmap')
-else
- path=('sb' 'addr rbmino')
-fi
-_scratch_xfs_fuzz_metadata '' 'both' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rbmino)"
+_scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtbitmap"
# success, all done
diff --git a/tests/xfs/1567 b/tests/xfs/1567
index 7dc2012b67..ff782fc239 100755
--- a/tests/xfs/1567
+++ b/tests/xfs/1567
@@ -28,13 +28,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtsummary"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.summary')
-else
- path=('sb' 'addr rsumino')
-fi
-_scratch_xfs_fuzz_metadata '' 'both' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rsumino)"
+_scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtsummary"
# success, all done
diff --git a/tests/xfs/1568 b/tests/xfs/1568
index c80640ef97..e2a28df58a 100755
--- a/tests/xfs/1568
+++ b/tests/xfs/1568
@@ -27,13 +27,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtbitmap"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.bitmap')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.bitmap')
-else
- path=('sb' 'addr rbmino')
-fi
-_scratch_xfs_fuzz_metadata '' 'none' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rbmino)"
+_scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtbitmap"
# success, all done
diff --git a/tests/xfs/1569 b/tests/xfs/1569
index e303f08ff5..dcb07440e8 100755
--- a/tests/xfs/1569
+++ b/tests/xfs/1569
@@ -27,13 +27,8 @@ echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rtsummary"
-is_metadir=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /realtime/0.summary')
-if [ -n "$is_metadir" ]; then
- path=('path -m /realtime/0.summary')
-else
- path=('sb' 'addr rsumino')
-fi
-_scratch_xfs_fuzz_metadata '' 'none' "${path[@]}" 'dblock 0' >> $seqres.full
+path="$(_scratch_xfs_find_metafile rsumino)"
+_scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full
echo "Done fuzzing rtsummary"
# success, all done
diff --git a/tests/xfs/529 b/tests/xfs/529
index 83d24da0ac..e10af6753b 100755
--- a/tests/xfs/529
+++ b/tests/xfs/529
@@ -159,9 +159,8 @@ done
_scratch_unmount >> $seqres.full
echo "Verify uquota inode's extent count"
-uquotino=$(_scratch_xfs_get_metadata_field 'uquotino' 'sb 0')
-
-nextents=$(_scratch_get_iext_count $uquotino data || \
+selector="$(_scratch_xfs_find_metafile uquotino)"
+nextents=$(_scratch_get_iext_count "$selector" data || \
_fail "Unable to obtain inode fork's extent count")
if (( $nextents > 10 )); then
echo "Extent count overflow check failed: nextents = $nextents"
diff --git a/tests/xfs/530 b/tests/xfs/530
index 56f5e7ebdb..cb8c2e3978 100755
--- a/tests/xfs/530
+++ b/tests/xfs/530
@@ -104,10 +104,8 @@ _scratch_unmount >> $seqres.full
echo "Verify rbmino's and rsumino's extent count"
for rtino in rbmino rsumino; do
- ino=$(_scratch_xfs_get_metadata_field $rtino "sb 0")
- echo "$rtino = $ino" >> $seqres.full
-
- nextents=$(_scratch_get_iext_count $ino data || \
+ selector="$(_scratch_xfs_find_metafile "$rtino")"
+ nextents=$(_scratch_get_iext_count "$selector" data || \
_fail "Unable to obtain inode fork's extent count")
if (( $nextents > 10 )); then
echo "Extent count overflow check failed: nextents = $nextents"
next prev parent reply other threads:[~2022-12-31 3:07 UTC|newest]
Thread overview: 68+ 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 ` Darrick J. Wong [this message]
2023-03-06 16:41 ` [PATCH 2/9] various: fix finding metadata inode numbers when metadir is enabled 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 ` [PATCH 01/13] xfs: fix tests that try to access the realtime rmap inode Darrick J. Wong
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
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=167243883271.736753.35967461928530874.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).