]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
various: fix finding metadata inode numbers when metadir is enabled
authorDarrick J. Wong <djwong@kernel.org>
Tue, 6 Feb 2024 00:06:37 +0000 (16:06 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 1 Nov 2024 20:41:56 +0000 (13:41 -0700)
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>
12 files changed:
common/xfs
tests/xfs/007
tests/xfs/529
tests/xfs/530
tests/xfs/739
tests/xfs/740
tests/xfs/741
tests/xfs/742
tests/xfs/743
tests/xfs/744
tests/xfs/745
tests/xfs/746

index 53d55f9907fbb03bef0d0f7d36b63f51a37dd74e..b473950a4fb1701a4112424005cc9f71f4aa60a6 100644 (file)
@@ -1390,7 +1390,7 @@ _scratch_get_bmx_prefix() {
 
 _scratch_get_iext_count()
 {
-       local ino=$1
+       local selector=$1
        local whichfork=$2
        local field=""
 
@@ -1405,7 +1405,7 @@ _scratch_get_iext_count()
                        return 1
        esac
 
-       _scratch_xfs_get_metadata_field $field "inode $ino"
+       _scratch_xfs_get_metadata_field $field "$selector"
 }
 
 #
@@ -1875,3 +1875,20 @@ _wipe_xfs_properties()
                setfattr --remove="$name" "$1"
        done
 }
+
+# Return the xfs_db selector for a superblock-rooted metadata file on the
+# scratch filesystem.  The sole argument is the name of the field within the
+# superblock.  This helper cannot be used to find files under the metadata
+# directory tree.
+_scratch_xfs_find_metafile()
+{
+       local metafile="$1"
+       local sb_field
+
+       sb_field="$(_scratch_xfs_get_sb_field "$metafile")"
+       if echo "$sb_field" | grep -q -w 'not found'; then
+               return 1
+       fi
+       echo "inode $sb_field"
+       return 0
+}
index 2535f04cac36a58ef9a3d775eb3b5c0dbd30fe84..e35a069f9bd5c57f51823efe35f6aeda39a1aa46 100755 (executable)
@@ -21,6 +21,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
@@ -30,12 +35,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"
@@ -65,8 +67,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
index 14bdd2eebf70478bf7f4f8e20fa4d1b9feb7152e..aab8668c76f46c2ef53407ae7875c0c62dad8173 100755 (executable)
@@ -161,9 +161,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"
index 8a182bd6a3928ab788724ea06166f9ae2eb27062..f6c88cd12e187ca0c967af36cd2de0652958f34c 100755 (executable)
@@ -102,10 +102,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"
index a4f553d818c2beddaf45f2fdfb0044378826df4a..a143325e3facb67a8b004eb8fe87cdb10ee48be3 100755 (executable)
@@ -25,13 +25,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
index 971bf31e3239b1201a3419bdf5554798006e3cbd..e867d591fd99cb561cb749ee036324cfd364f18f 100755 (executable)
@@ -25,13 +25,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
index 4e24fb4e2fef31c7dbf38b7113a95989d8a631f0..ea4aa75b24741be25caf376b4f36a07061360c61 100755 (executable)
@@ -25,13 +25,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
index eabe766d725c07390f75ab18ad744b327e9389e7..967e384f659f7246262756a031a1727073b69a17 100755 (executable)
@@ -25,13 +25,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
index b5cec7d71a400237edb9ef88dc70a6aeb1d2014b..82b87b33792cdd4effbda109e894c97f5efdb343 100755 (executable)
@@ -26,13 +26,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
index e2d097c2f0d59f132a6cc59b0065f2890b45bd5d..4840e78c4427ab8794c7a24bfb620ce36fc9332a 100755 (executable)
@@ -26,13 +26,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
index d139aeefdd8a3746a8cbc4eca1ff96b73d926799..6cc3805d4c9df831182d673b77a6b4e01e14c1b7 100755 (executable)
@@ -25,13 +25,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
index 696d024532982a0bc457fa2e129131a2ca3d332b..b6ec74524b0eaa84eca502ef74e06c4a8d891655 100755 (executable)
@@ -25,13 +25,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