generic/108: use sysfs values for logical,physical block size in scsi_debug
A message that is not in the archive (sent off-list or not yet received): CGME20220301213455epcas5p30ff48390a70523f4bc3d99de0027d3bd@epcas5p3.samsung.com
PATCH 1/1 generic/108: use sysfs values for logical,physical block size in scsi_debug
scsi_debug device used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, when SCRATCH_DEV device lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.
--- tests/generic/108 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tests/generic/108 +4 -1
@@ -42,8 +42,11 @@ _require_non_zoned_device $SCRATCH_DEV lvname=lv_$seq vgname=vg_$seq +physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) +logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size) + # _get_scsi_debug_dev returns a scsi debug device with 128M in size by default -SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 300` +SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300` test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device" echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
base-commit: 2ea74ba4e70b546279896e2a733c8c7f4b206193
Signature · 1 line
2.25.1
Quoted 7 lines · Nitesh Shetty
scsi_debugdevice used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, whenSCRATCH_DEVdevice lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.Signed-off-by Nitesh Shetty <[email protected]>
Luis
Quoted 16 lines · Nitesh Shetty
scsi_debugdevice used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, whenSCRATCH_DEVdevice lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.Signed-off-by Nitesh Shetty <[email protected]>--- tests/generic/108 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tests/generic/108 +0
-0
tests/generic/108 _require_non_zoned_device $SCRATCH_DEV · line 46
Quoted 5 lines
tests/generic/108 +2
-0@@ -42,8 +42,11 @@ _require_non_zoned_device $SCRATCH_DEV lvname=lv_$seq vgname=vg_$seq +physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) +logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size)
This causes a regression if $SCRATCH_DEV is not a raw block device:
# SCRATCH_DEV=/dev/sda4 ./check generic/108
...
108.out.bad renamed from 108.out +2 -0
@@ -1,2 +1,4 @@ QA output created by 108 +cat: /sys/block/sda4/queue/physical_block_size: No such file or directory +cat: /sys/block/sda4/queue/logical_block_size: No such file or directory fsync: Input/output error
--D
Quoted 12 lines
tests/generic/108 +2
-1+ # _get_scsi_debug_dev returns a scsi debug device with 128M in size by default -SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 300` +SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300` test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device" echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.fullbase-commit:
2ea74ba4e70b546279896e2a733c8c7f4b206193Signature · 1 line
2.25.1
Quoted 20 lines · Darrick J. Wong
Quoted 19 lines · Nitesh Shetty
scsi_debugdevice used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, whenSCRATCH_DEVdevice lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.Signed-off-by Nitesh Shetty <[email protected]>--- tests/generic/108 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tests/generic/108 +0
-0@@ -42,8 +42,11 @@ _require_non_zoned_device $SCRATCH_DEV lvname=lv_$seq vgname=vg_$seq
Quoted 5 lines
tests/generic/108 _require_non_zoned_device $SCRATCH_DEV · line 46
Quoted 2 lines
tests/generic/108 +2
-0+physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) +logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size)This causes a regression if $SCRATCH_DEV is not a raw block device:
Acked, I was testing for NVMe device, missed out sda sysfs. Let me see, if I can use other sysfs/utility to get block size of device.
Also I see many 4k LBA tests failing mainly because of setup failure in format command. This is not actually test failure, rather setup failure. So what do you suggest for those type of tests?
Should I put them in not run status or just report to community so that person with relevant expertise can add a fix?
--Nitesh Shetty
Quoted 25 lines
# SCRATCH_DEV=/dev/sda4 ./check generic/108
...108.out.bad renamed from 108.out +2
-1@@ -1,2 +1,4 @@ QA output created by 108 +cat: /sys/block/sda4/queue/physical_block_size: No such file or directory +cat: /sys/block/sda4/queue/logical_block_size: No such file or directory fsync: Input/output error --DQuoted 13 lines
tests/generic/108 +2
-1+ # _get_scsi_debug_dev returns a scsi debug device with 128M in size by default -SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 300` +SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300` test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device" echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.fullbase-commit:
2ea74ba4e70b546279896e2a733c8c7f4b206193Signature · 1 line
2.25.1
Quoted 26 lines · Nitesh Shetty
Quoted 20 lines · Darrick J. Wong
Quoted 19 lines · Nitesh Shetty
scsi_debugdevice used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, whenSCRATCH_DEVdevice lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.Signed-off-by Nitesh Shetty <[email protected]>--- tests/generic/108 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tests/generic/108 +0
-0@@ -42,8 +42,11 @@ _require_non_zoned_device $SCRATCH_DEV lvname=lv_$seq vgname=vg_$seqQuoted 5 lines
tests/generic/108 _require_non_zoned_device $SCRATCH_DEV · line 46
Quoted 2 lines
tests/generic/108 +2
-0+physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) +logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size)This causes a regression if $SCRATCH_DEV is not a raw block device:
Quoted 6 lines
Acked, I was testing for NVMe device, missed out sda sysfs. Let me see, if I can use other sysfs/utility to get block size of device.
Also I see many 4k LBA tests failing mainly because of setup failure in format command. This is not actually test failure, rather setup failure. So what do you suggest for those type of tests?
Ideally, fix the ones that can be fixed, and _notrun the rest.
Quoted 2 lines
Should I put them in not run status or just report to community so that person with relevant expertise can add a fix?
For this specific problem I suggest creating a function that finds the /sys/block/XXX path for any given block device or partition, and then update all the open coded logic to use it. Something like:
# Map a block device to its counterpart in sysfs
_sysfs_block() {
local dev="$1"
local shortdev="$(_short_dev "$dev")"
# Full block devices are simple
local ret="/sys/block/$shortdev"
if [ -e "$ret" ]; then
readlink -m "$ret"
return 0
fi
# Partitions are a little trickier
ret="/sys/class/block/$shortdev"
if [ -e "$ret/partition" ]; then
readlink -m "$ret/.."
return 0
fi
# ???
return 1
}sysfsb=$(_sysfs_block $SCRATCH_DEV)
physical=$(cat $sysfsb/queue/physical_block_size)
--D
Quoted 29 lines
--Nitesh Shetty
Quoted 25 lines
# SCRATCH_DEV=/dev/sda4 ./check generic/108
...108.out.bad renamed from 108.out +2
-1@@ -1,2 +1,4 @@ QA output created by 108 +cat: /sys/block/sda4/queue/physical_block_size: No such file or directory +cat: /sys/block/sda4/queue/logical_block_size: No such file or directory fsync: Input/output error --DQuoted 13 lines
tests/generic/108 +2
-1+ # _get_scsi_debug_dev returns a scsi debug device with 128M in size by default -SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 300` +SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300` test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device" echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.fullbase-commit:
2ea74ba4e70b546279896e2a733c8c7f4b206193Signature · 1 line
2.25.1
Quoted 27 lines · Darrick J. Wong
Quoted 26 lines · Nitesh Shetty
Quoted 25 lines · Darrick J. Wong
Quoted 16 lines · Nitesh Shetty
scsi_debugdevice used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, whenSCRATCH_DEVdevice lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.Signed-off-by Nitesh Shetty <[email protected]>--- tests/generic/108 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tests/generic/108 +0
-0tests/generic/108 _require_non_zoned_device $SCRATCH_DEV · line 46
Quoted 5 lines
tests/generic/108 +2
-0@@ -42,8 +42,11 @@ _require_non_zoned_device $SCRATCH_DEV lvname=lv_$seq vgname=vg_$seq +physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) +logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size)This causes a regression if $SCRATCH_DEV is not a raw block device:
Quoted 9 lines
Quoted 6 lines
Acked, I was testing for NVMe device, missed out sda sysfs. Let me see, if I can use other sysfs/utility to get block size of device.
Also I see many 4k LBA tests failing mainly because of setup failure in format command. This is not actually test failure, rather setup failure. So what do you suggest for those type of tests?
Ideally, fix the ones that can be fixed, and
_notrunthe rest.
Sure, will send a different patchset.
Quoted 30 lines
Quoted 2 lines
Should I put them in not run status or just report to community so that person with relevant expertise can add a fix?
For this specific problem I suggest creating a function that finds the
/sys/block/XXXpath for any given block device or partition, and then update all the open coded logic to use it. Something like:# Map a block device to its counterpart in sysfs
_sysfs_block() { local dev="$1" local shortdev="$(_short_dev "$dev")" # Full block devices are simple local ret="/sys/block/$shortdev" if [ -e "$ret" ]; then readlink -m "$ret" return 0 fi # Partitions are a little trickier ret="/sys/class/block/$shortdev" if [ -e "$ret/partition" ]; then readlink -m "$ret/.." return 0 fi # ??? return 1 }
Quoted 5 lines
sysfsb=$(_sysfs_block $SCRATCH_DEV)
physical=$(cat $sysfsb/queue/physical_block_size)--D
As a alternate, using blockdev utility might reduce and simplify the changes required. how about below changes ?
-physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) -logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size) +physical=blockdev --getpbsz $SCRATCH_DEV
+logical=blockdev --getss $SCRATCH_DEV
--Nitesh Shetty
Quoted 79 lines · Nitesh Shetty
Quoted 27 lines · Darrick J. Wong
Quoted 26 lines · Nitesh Shetty
Quoted 25 lines · Darrick J. Wong
Quoted 16 lines · Nitesh Shetty
scsi_debugdevice used for test, is created with assumption of 512 bytes logical and physical block size.
This causes error in lvcreate step, whenSCRATCH_DEVdevice lba is not 512 bytes. This can be solved by reading block size from sysfs of device. If sysfs is missing fallback to 512 bytes as default.Signed-off-by Nitesh Shetty <[email protected]>--- tests/generic/108 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tests/generic/108 +0
-0tests/generic/108 _require_non_zoned_device $SCRATCH_DEV · line 46
Quoted 5 lines
tests/generic/108 +2
-0@@ -42,8 +42,11 @@ _require_non_zoned_device $SCRATCH_DEV lvname=lv_$seq vgname=vg_$seq +physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) +logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size)This causes a regression if $SCRATCH_DEV is not a raw block device:
Quoted 9 lines
Quoted 6 lines
Acked, I was testing for NVMe device, missed out sda sysfs. Let me see, if I can use other sysfs/utility to get block size of device.
Also I see many 4k LBA tests failing mainly because of setup failure in format command. This is not actually test failure, rather setup failure. So what do you suggest for those type of tests?
Ideally, fix the ones that can be fixed, and
_notrunthe rest.Sure, will send a different patchset.
Quoted 30 lines
Quoted 2 lines
Should I put them in not run status or just report to community so that person with relevant expertise can add a fix?
For this specific problem I suggest creating a function that finds the
/sys/block/XXXpath for any given block device or partition, and then update all the open coded logic to use it. Something like:# Map a block device to its counterpart in sysfs
_sysfs_block() { local dev="$1" local shortdev="$(_short_dev "$dev")" # Full block devices are simple local ret="/sys/block/$shortdev" if [ -e "$ret" ]; then readlink -m "$ret" return 0 fi # Partitions are a little trickier ret="/sys/class/block/$shortdev" if [ -e "$ret/partition" ]; then readlink -m "$ret/.." return 0 fi # ??? return 1 }Quoted 5 lines
sysfsb=$(_sysfs_block $SCRATCH_DEV)
physical=$(cat $sysfsb/queue/physical_block_size)--D
As a alternate, using blockdev utility might reduce and simplify the changes required. how about below changes ?
Review
Quoted 4 lines
(quoted diff) +2
-2-physical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/physical_block_size) -logical=$(cat /sys/block/$(_short_dev $SCRATCH_DEV)/queue/logical_block_size) +physical=`blockdev --getpbsz $SCRATCH_DEV` +logical=`blockdev --getss $SCRATCH_DEV`
Good idea! :)
--D
Quoted 1 line
--Nitesh Shetty