[PATCH 2/2] xfs/432: fix metadump loop device blocksize problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 common/metadump   |   12 ++++++++----
 common/rc         |   17 +++++++++++++++++
 tests/generic/563 |    2 +-
 3 files changed, 26 insertions(+), 5 deletions(-)


diff --git a/common/metadump b/common/metadump
index 61ba3cbb91647c..d411bc0d32d792 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 b3f63111c6ea6c..04b721b7318a7e 100644
--- a/common/rc
+++ b/common/rc
@@ -4608,6 +4608,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 89a71aa44938ea..a43ffcbd127e17 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`))
 





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux