]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/xfs: simplify maximum metadump format detection
authorDarrick J. Wong <djwong@kernel.org>
Wed, 7 Feb 2024 02:18:45 +0000 (18:18 -0800)
committerZorro Lang <zlang@kernel.org>
Fri, 9 Feb 2024 05:27:17 +0000 (13:27 +0800)
xfs_metadump (aka the wrapper around xfs_db -c metadump) advertises the
-v switch to turn on v2 format in its help screen.  There's no need to
fire up xfs_db on the scratch device which will load the AGs and take
much longer.

While we're at it, reduce the amount of boilerplate in the test files by
changing the function to emit the max version supported.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/xfs
tests/xfs/129
tests/xfs/234
tests/xfs/253
tests/xfs/291
tests/xfs/432
tests/xfs/503
tests/xfs/605

index 11cfd79562b62305a88ca65e60cb4281402938a5..248ccefda39e134a3c611c3ef63de941e622c574 100644 (file)
@@ -713,10 +713,14 @@ _xfs_mdrestore() {
        $XFS_MDRESTORE_PROG $options "${metadump}" "${device}"
 }
 
-_scratch_metadump_v2_supported()
+# What is the maximum metadump file format supported by xfs_metadump?
+_xfs_metadump_max_version()
 {
-       $XFS_DB_PROG -c "help metadump" $SCRATCH_DEV | \
-               grep -q "Metadump version to be used"
+       if $XFS_METADUMP_PROG --help 2>&1 | grep -q -- '-v version'; then
+               echo 2
+       else
+               echo 1
+       fi
 }
 
 # Snapshot the metadata on the scratch device
index 8a817b416c7c7045a33479e1da5ef542584c3da0..cdac2349df5a5fc7fd5875606c380191981075b4 100755 (executable)
@@ -106,8 +106,7 @@ verify_metadump_v2()
 
 _scratch_mkfs >/dev/null 2>&1
 
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 _scratch_mount
 
index c9bdb674ab61e198d4d8fe9bb6af2090841c6c58..f4f8af6d3af32b5362bca4eb6928520f33166bd5 100755 (executable)
@@ -106,8 +106,7 @@ verify_metadump_v2()
 
 _scratch_mkfs >/dev/null 2>&1
 
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 _scratch_mount
 
index 8e18ddb83a674f664597ce5b62218681d5401bcf..3b567999d819391fb17de2515967d049c9d2a6db 100755 (executable)
@@ -233,8 +233,7 @@ cd $here
 
 _scratch_unmount
 
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 verify_metadump_v1 $max_md_version
 
index 33193eb78e04d7e455f8c41b991cc51f9a0848e3..143314082116b985cf560b3b9c9207d49f330fbf 100755 (executable)
@@ -92,8 +92,7 @@ _scratch_xfs_check >> $seqres.full 2>&1 || _fail "xfs_check failed"
 
 # Yes they can!  Now...
 # Can xfs_metadump cope with this monster?
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 for md_version in $(seq 1 $max_md_version); do
        version=""
index a215d3ce2e6eec4b944aed876d4b32aed80c69a9..7e402aa88fd3d6c60f183a4d608129ede1f6bd51 100755 (executable)
@@ -87,8 +87,7 @@ echo "qualifying extent: $extlen blocks" >> $seqres.full
 test -n "$extlen" || _notrun "could not create dir extent > 1000 blocks"
 
 echo "Try to metadump, restore and check restored metadump image"
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 for md_version in $(seq 1 $max_md_version); do
        version=""
index a1479eb613e0bbe5c1acfb9d877521f99017eff3..8643c3d4832635c88ca4ce19debd45a85acf16d9 100755 (executable)
@@ -54,8 +54,7 @@ check_restored_metadump_image()
        _destroy_loop_device $loop_dev
 }
 
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 echo "metadump and mdrestore"
 for md_version in $(seq 1 $max_md_version); do
index 5cbf5d25502d86b6c42857b947468b5c660a1527..f2cd7aba98d51140278c8f0899ecb46bb966ca49 100755 (executable)
@@ -44,8 +44,7 @@ testfile=${SCRATCH_MNT}/testfile
 echo "Format filesystem on scratch device"
 _scratch_mkfs >> $seqres.full 2>&1
 
-max_md_version=1
-_scratch_metadump_v2_supported && max_md_version=2
+max_md_version=$(_xfs_metadump_max_version)
 
 external_log=0
 if [[ $USE_EXTERNAL = yes && -n "$SCRATCH_LOGDEV" ]]; then