From: Darrick J. Wong Date: Tue, 29 Jul 2025 20:10:35 +0000 (-0700) Subject: xfs/432: fix metadump loop device blocksize problems X-Git-Tag: v2025.08.04~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dca21d3724df983fd8dccdf2b5bfcd99c073f786;p=xfstests-dev.git xfs/432: fix metadump loop device blocksize problems 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 Reviewed-by: Christoph Hellwig Signed-off-by: Zorro Lang --- diff --git a/common/metadump b/common/metadump index 61ba3cbb..d411bc0d 100644 --- a/common/metadump +++ b/common/metadump @@ -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 diff --git a/common/rc b/common/rc index 66c8e079..ff5df203 100644 --- 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 diff --git a/tests/generic/563 b/tests/generic/563 index 89a71aa4..a43ffcbd 100755 --- a/tests/generic/563 +++ b/tests/generic/563 @@ -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`))