diff mbox series

[blktests] dm/002: do not assume 512 byte block size

Message ID 20240625025143.405254-1-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series [blktests] dm/002: do not assume 512 byte block size | expand

Commit Message

Shinichiro Kawasaki June 25, 2024, 2:51 a.m. UTC
The test case assumes that TEST_DEV would have 512 byte block size
always. However, TEST_DEV may have non 512 byte, 4k block size. In that
case, the test case fails with I/O errors.

To avoid the errors, refer to the block size of TEST_DEV. Also record
dd command output to the FULL file to help debug work in the future.

Reported-by: Christoph Hellwig <hch@lst.de>
Fixes: 7308e11c595a ("tests/dm: add dm-dust general functionality test")
Link: https://lore.kernel.org/linux-block/ZmqrzUyLcUORPdOe@infradead.org/
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 tests/dm/002 | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig June 25, 2024, 5:02 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christoph Hellwig <hch@lst.de>
Chaitanya Kulkarni June 25, 2024, 6:01 a.m. UTC | #2
On 6/24/24 19:51, Shin'ichiro Kawasaki wrote:
> The test case assumes that TEST_DEV would have 512 byte block size
> always. However, TEST_DEV may have non 512 byte, 4k block size. In that
> case, the test case fails with I/O errors.
>
> To avoid the errors, refer to the block size of TEST_DEV. Also record
> dd command output to the FULL file to help debug work in the future.
>
> Reported-by: Christoph Hellwig <hch@lst.de>
> Fixes: 7308e11c595a ("tests/dm: add dm-dust general functionality test")
> Link: https://lore.kernel.org/linux-block/ZmqrzUyLcUORPdOe@infradead.org/
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>   

this patch follows the discussion onĀ  the other thread to replace the
hardcoded 512 block size with device's block size with the help of
blockdev --getsz.

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Shinichiro Kawasaki June 28, 2024, 10:10 a.m. UTC | #3
On Jun 25, 2024 / 11:51, Shin'ichiro Kawasaki wrote:
> The test case assumes that TEST_DEV would have 512 byte block size
> always. However, TEST_DEV may have non 512 byte, 4k block size. In that
> case, the test case fails with I/O errors.
> 
> To avoid the errors, refer to the block size of TEST_DEV. Also record
> dd command output to the FULL file to help debug work in the future.
> 
> Reported-by: Christoph Hellwig <hch@lst.de>
> Fixes: 7308e11c595a ("tests/dm: add dm-dust general functionality test")
> Link: https://lore.kernel.org/linux-block/ZmqrzUyLcUORPdOe@infradead.org/
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

FYI, this fix has got applied.
diff mbox series

Patch

diff --git a/tests/dm/002 b/tests/dm/002
index 6635c43..fae3986 100755
--- a/tests/dm/002
+++ b/tests/dm/002
@@ -14,10 +14,12 @@  requires() {
 
 
 test_device() {
+	local sz bsz
 	echo "Running ${TEST_NAME}"
 
-	TEST_DEV_SZ=$(blockdev --getsz "$TEST_DEV")
-	dmsetup create dust1 --table "0 $TEST_DEV_SZ dust $TEST_DEV 0 512"
+	sz=$(blockdev --getsz "$TEST_DEV")
+	bsz=$(blockdev --getbsz "$TEST_DEV")
+	dmsetup create dust1 --table "0 $sz dust $TEST_DEV 0 $bsz"
 	dmsetup message dust1 0 addbadblock 60
 	dmsetup message dust1 0 addbadblock 67
 	dmsetup message dust1 0 addbadblock 72
@@ -30,7 +32,8 @@  test_device() {
 	dmsetup message dust1 0 addbadblock 72
 	dmsetup message dust1 0 countbadblocks
 	dmsetup message dust1 0 enable
-	dd if=/dev/zero of=/dev/mapper/dust1 bs=512 count=128 oflag=direct >/dev/null 2>&1 || return $?
+	dd if=/dev/zero of=/dev/mapper/dust1 bs="$bsz" count=128 oflag=direct \
+	   >"$FULL" 2>&1 || return $?
 	sync
 	dmsetup message dust1 0 countbadblocks
 	sync