]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfs/432: fix metadump loop device blocksize problems
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Jul 2025 20:10:35 +0000 (13:10 -0700)
committerZorro Lang <zlang@kernel.org>
Fri, 1 Aug 2025 20:19:02 +0000 (04:19 +0800)
Make sure the lba size of the loop devices created for the metadump
tests actually match that of the real SCRATCH_ devices or else the tests
will fail.

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/metadump
common/rc
tests/generic/563

index 61ba3cbb91647c4ab3f52807658029b7fa1129b3..d411bc0d32d7921ccd2ecc2c8f417b3847379c1c 100644 (file)
@@ -75,7 +75,7 @@ _xfs_verify_metadump_v1()
        SCRATCH_DEV=$data_img _scratch_xfs_mdrestore $metadump_file
 
        # Create loopdev for data device so we can mount the fs
-       METADUMP_DATA_LOOP_DEV=$(_create_loop_device $data_img)
+       METADUMP_DATA_LOOP_DEV=$(_create_loop_device_like_bdev $data_img $SCRATCH_DEV)
 
        # Mount fs, run an extra test, fsck, and unmount
        SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV _scratch_mount
@@ -122,13 +122,17 @@ _xfs_verify_metadump_v2()
                _scratch_xfs_mdrestore $metadump_file
 
        # Create loopdev for data device so we can mount the fs
-       METADUMP_DATA_LOOP_DEV=$(_create_loop_device $data_img)
+       METADUMP_DATA_LOOP_DEV=$(_create_loop_device_like_bdev $data_img $SCRATCH_DEV)
 
        # Create loopdev for log device if we recovered anything
-       test -s "$log_img" && METADUMP_LOG_LOOP_DEV=$(_create_loop_device $log_img)
+       if [ -s "$log_img" ]; then
+               METADUMP_LOG_LOOP_DEV=$(_create_loop_device_like_bdev $log_img $SCRATCH_LOGDEV)
+       fi
 
        # Create loopdev for rt device if we recovered anything
-       test -s "$rt_img" && METADUMP_RT_LOOP_DEV=$(_create_loop_device $rt_img)
+       if [ -s "$rt_img" ]; then
+               METADUMP_RT_LOOP_DEV=$(_create_loop_device_like_bdev $rt_img $SCRATCH_RTDEV)
+       fi
 
        # Mount fs, run an extra test, fsck, and unmount
        SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV SCRATCH_RTDEV=$METADUMP_RT_LOOP_DEV _scratch_mount
index 66c8e0794bd56be56edb5f543bc34ebbb386fda5..ff5df203b5a3fe9376d324823f157b7f0c84a14f 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -4600,6 +4600,23 @@ _create_loop_device()
        echo $dev
 }
 
+# Create a loop device from a given file and configure it to support the same
+# sector size as the given block device.
+_create_loop_device_like_bdev()
+{
+       local file=$1
+       local bdev=$2
+       local dev
+       local blksize
+
+       test -b "$bdev" || \
+               _fail "$file: must be a block device"
+
+       blksize="$(blockdev --getss "$bdev")"
+
+       _create_loop_device "$file" "$blksize"
+}
+
 _destroy_loop_device()
 {
        local dev=$1
index 89a71aa44938ea239ef72279550a9b883f57c7bb..a43ffcbd127e17c8f27a89928792cfc1adacfb55 100755 (executable)
@@ -91,7 +91,7 @@ reset()
 
 # cgroup I/O accounting doesn't work on partitions. Use a loop device to rule
 # that out.
-loop_dev=$(_create_loop_device $SCRATCH_DEV)
+loop_dev=$(_create_loop_device_like_bdev $SCRATCH_DEV $SCRATCH_DEV)
 smajor=$((0x`stat -L -c %t $loop_dev`))
 sminor=$((0x`stat -L -c %T $loop_dev`))