Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH blktests v2] nvme/039: check for logical block size of test device
@ 2024-11-25 19:39 Bryan Gurney
  2024-11-25 23:44 ` alan.adamson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bryan Gurney @ 2024-11-25 19:39 UTC (permalink / raw)
  To: shinichiro.kawasaki, linux-nvme; +Cc: alan.adamson, bvanassche, Bryan Gurney

This test has hard-coded 512 byte values for the dd commands, which
will fail on 4096-byte block devices.  Create an LB_SZ global
variable that is populated with the result of the command
"blockdev --getss <dev>", and use that result for the block size
of the write commands.

Also use this variable for the "--data-len" command of the "nvme
admin-passthru" and "nvme io-passthru" tests.  (On a test with a
4096-byte namespace, leaving these with the hardcoded values still
passed, but update them for the sake of consistency.)

Signed-off-by: Bryan Gurney <bgurney@redhat.com>
---
 tests/nvme/039 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/nvme/039 b/tests/nvme/039
index e8020a7..eca8ba3 100755
--- a/tests/nvme/039
+++ b/tests/nvme/039
@@ -37,7 +37,7 @@ inject_unrec_read_on_read()
 	# Inject a 'Unrecovered Read Error' (0x281) status error on a READ
 	_nvme_enable_err_inject "$1" 0 100 1 0x281 1
 
-	dd if=/dev/"$1" of=/dev/null bs=512 count=1 iflag=direct \
+	dd if=/dev/"$1" of=/dev/null bs="${LB_SZ}" count=1 iflag=direct \
 	    2> /dev/null 1>&2
 
 	_nvme_disable_err_inject "$1"
@@ -57,7 +57,7 @@ inject_invalid_status_on_read()
 	# Inject an invalid status (0x375) on a READ
 	_nvme_enable_err_inject "$1" 0 100 1 0x375 1
 
-	dd if=/dev/"$1" of=/dev/null bs=512 count=1 iflag=direct \
+	dd if=/dev/"$1" of=/dev/null bs="${LB_SZ}" count=1 iflag=direct \
 	    2> /dev/null 1>&2
 
 	_nvme_disable_err_inject "$1"
@@ -77,7 +77,7 @@ inject_write_fault_on_write()
 	# Inject a 'Write Fault' 0x280 status error on a WRITE
 	_nvme_enable_err_inject "$1" 0 100 1 0x280 1
 
-	dd if=/dev/zero of=/dev/"$1" bs=512 count=1 oflag=direct \
+	dd if=/dev/zero of=/dev/"$1" bs="${LB_SZ}" count=1 oflag=direct \
 	    2> /dev/null 1>&2
 
 	_nvme_disable_err_inject "$1"
@@ -119,7 +119,7 @@ inject_invalid_admin_cmd()
 	# Inject a 'Invalid Command Opcode' (0x1) on an invalid command (0x96)
 	 _nvme_enable_err_inject "$1" 0 100 1 0x1 1
 
-	nvme admin-passthru /dev/"$1" --opcode=0x96 --data-len=4096 \
+	nvme admin-passthru /dev/"$1" --opcode=0x96 --data-len="${LB_SZ}" \
 	    --cdw10=1 -r 2> /dev/null 1>&2
 
 	_nvme_disable_err_inject "$1"
@@ -145,7 +145,7 @@ inject_invalid_io_cmd_passthru()
 	_nvme_enable_err_inject "$ns_dev" 0 100 1 0x1 1
 
 	nvme io-passthru /dev/"$1" --opcode=0x02 --namespace-id="$ns" \
-		--data-len=512 --read --cdw10=0 --cdw11=0 --cdw12="$2" 2> /dev/null 1>&2
+		--data-len="${LB_SZ}" --read --cdw10=0 --cdw11=0 --cdw12="$2" 2> /dev/null 1>&2
 
 	_nvme_disable_err_inject "$1"
 	if ${nvme_verbose_errors}; then
@@ -174,6 +174,8 @@ test_device() {
 	ns_dev=${TEST_DEV##*/}
 	ctrl_dev=${ns_dev%n*}
 
+	LB_SZ=$(blockdev --getss "${TEST_DEV}")
+
 	_nvme_err_inject_setup "${ns_dev}" "${ctrl_dev}"
 
 	# wait DEFAULT_RATELIMIT_INTERVAL=5 seconds to ensure errors are printed
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH blktests v2] nvme/039: check for logical block size of test device
  2024-11-25 19:39 [PATCH blktests v2] nvme/039: check for logical block size of test device Bryan Gurney
@ 2024-11-25 23:44 ` alan.adamson
  2024-11-27  7:49 ` Chaitanya Kulkarni
  2024-11-28  1:03 ` Shinichiro Kawasaki
  2 siblings, 0 replies; 4+ messages in thread
From: alan.adamson @ 2024-11-25 23:44 UTC (permalink / raw)
  To: Bryan Gurney, shinichiro.kawasaki, linux-nvme; +Cc: bvanassche


On 11/25/24 11:39 AM, Bryan Gurney wrote:
> This test has hard-coded 512 byte values for the dd commands, which
> will fail on 4096-byte block devices.  Create an LB_SZ global
> variable that is populated with the result of the command
> "blockdev --getss <dev>", and use that result for the block size
> of the write commands.
>
> Also use this variable for the "--data-len" command of the "nvme
> admin-passthru" and "nvme io-passthru" tests.  (On a test with a
> 4096-byte namespace, leaving these with the hardcoded values still
> passed, but update them for the sake of consistency.)
>
> Signed-off-by: Bryan Gurney <bgurney@redhat.com>
> ---
>   tests/nvme/039 | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/tests/nvme/039 b/tests/nvme/039
> index e8020a7..eca8ba3 100755
> --- a/tests/nvme/039
> +++ b/tests/nvme/039
> @@ -37,7 +37,7 @@ inject_unrec_read_on_read()
>   	# Inject a 'Unrecovered Read Error' (0x281) status error on a READ
>   	_nvme_enable_err_inject "$1" 0 100 1 0x281 1
>   
> -	dd if=/dev/"$1" of=/dev/null bs=512 count=1 iflag=direct \
> +	dd if=/dev/"$1" of=/dev/null bs="${LB_SZ}" count=1 iflag=direct \
>   	    2> /dev/null 1>&2
>   
>   	_nvme_disable_err_inject "$1"
> @@ -57,7 +57,7 @@ inject_invalid_status_on_read()
>   	# Inject an invalid status (0x375) on a READ
>   	_nvme_enable_err_inject "$1" 0 100 1 0x375 1
>   
> -	dd if=/dev/"$1" of=/dev/null bs=512 count=1 iflag=direct \
> +	dd if=/dev/"$1" of=/dev/null bs="${LB_SZ}" count=1 iflag=direct \
>   	    2> /dev/null 1>&2
>   
>   	_nvme_disable_err_inject "$1"
> @@ -77,7 +77,7 @@ inject_write_fault_on_write()
>   	# Inject a 'Write Fault' 0x280 status error on a WRITE
>   	_nvme_enable_err_inject "$1" 0 100 1 0x280 1
>   
> -	dd if=/dev/zero of=/dev/"$1" bs=512 count=1 oflag=direct \
> +	dd if=/dev/zero of=/dev/"$1" bs="${LB_SZ}" count=1 oflag=direct \
>   	    2> /dev/null 1>&2
>   
>   	_nvme_disable_err_inject "$1"
> @@ -119,7 +119,7 @@ inject_invalid_admin_cmd()
>   	# Inject a 'Invalid Command Opcode' (0x1) on an invalid command (0x96)
>   	 _nvme_enable_err_inject "$1" 0 100 1 0x1 1
>   
> -	nvme admin-passthru /dev/"$1" --opcode=0x96 --data-len=4096 \
> +	nvme admin-passthru /dev/"$1" --opcode=0x96 --data-len="${LB_SZ}" \
>   	    --cdw10=1 -r 2> /dev/null 1>&2
>   
>   	_nvme_disable_err_inject "$1"
> @@ -145,7 +145,7 @@ inject_invalid_io_cmd_passthru()
>   	_nvme_enable_err_inject "$ns_dev" 0 100 1 0x1 1
>   
>   	nvme io-passthru /dev/"$1" --opcode=0x02 --namespace-id="$ns" \
> -		--data-len=512 --read --cdw10=0 --cdw11=0 --cdw12="$2" 2> /dev/null 1>&2
> +		--data-len="${LB_SZ}" --read --cdw10=0 --cdw11=0 --cdw12="$2" 2> /dev/null 1>&2
>   
>   	_nvme_disable_err_inject "$1"
>   	if ${nvme_verbose_errors}; then
> @@ -174,6 +174,8 @@ test_device() {
>   	ns_dev=${TEST_DEV##*/}
>   	ctrl_dev=${ns_dev%n*}
>   
> +	LB_SZ=$(blockdev --getss "${TEST_DEV}")
> +
>   	_nvme_err_inject_setup "${ns_dev}" "${ctrl_dev}"
>   
>   	# wait DEFAULT_RATELIMIT_INTERVAL=5 seconds to ensure errors are printed

Reviewed-by: Alan Adamson <alan.adamson@oracle.com>

Tested-by: Alan Adamson <alan.adamson@oracle.com>






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH blktests v2] nvme/039: check for logical block size of test device
  2024-11-25 19:39 [PATCH blktests v2] nvme/039: check for logical block size of test device Bryan Gurney
  2024-11-25 23:44 ` alan.adamson
@ 2024-11-27  7:49 ` Chaitanya Kulkarni
  2024-11-28  1:03 ` Shinichiro Kawasaki
  2 siblings, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2024-11-27  7:49 UTC (permalink / raw)
  To: Bryan Gurney, shinichiro.kawasaki@wdc.com,
	linux-nvme@lists.infradead.org
  Cc: alan.adamson@oracle.com, bvanassche@acm.org

On 11/25/24 11:39, Bryan Gurney wrote:
> This test has hard-coded 512 byte values for the dd commands, which
> will fail on 4096-byte block devices.  Create an LB_SZ global
> variable that is populated with the result of the command
> "blockdev --getss <dev>", and use that result for the block size
> of the write commands.
>
> Also use this variable for the "--data-len" command of the "nvme
> admin-passthru" and "nvme io-passthru" tests.  (On a test with a
> 4096-byte namespace, leaving these with the hardcoded values still
> passed, but update them for the sake of consistency.)
>
> Signed-off-by: Bryan Gurney<bgurney@redhat.com>


Looks good.

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

-ck



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH blktests v2] nvme/039: check for logical block size of test device
  2024-11-25 19:39 [PATCH blktests v2] nvme/039: check for logical block size of test device Bryan Gurney
  2024-11-25 23:44 ` alan.adamson
  2024-11-27  7:49 ` Chaitanya Kulkarni
@ 2024-11-28  1:03 ` Shinichiro Kawasaki
  2 siblings, 0 replies; 4+ messages in thread
From: Shinichiro Kawasaki @ 2024-11-28  1:03 UTC (permalink / raw)
  To: Bryan Gurney
  Cc: linux-nvme@lists.infradead.org, alan.adamson@oracle.com,
	bvanassche@acm.org

On Nov 25, 2024 / 14:39, Bryan Gurney wrote:
> This test has hard-coded 512 byte values for the dd commands, which
> will fail on 4096-byte block devices.  Create an LB_SZ global
> variable that is populated with the result of the command
> "blockdev --getss <dev>", and use that result for the block size
> of the write commands.
> 
> Also use this variable for the "--data-len" command of the "nvme
> admin-passthru" and "nvme io-passthru" tests.  (On a test with a
> 4096-byte namespace, leaving these with the hardcoded values still
> passed, but update them for the sake of consistency.)
> 
> Signed-off-by: Bryan Gurney <bgurney@redhat.com>

I applied it, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-28  2:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-25 19:39 [PATCH blktests v2] nvme/039: check for logical block size of test device Bryan Gurney
2024-11-25 23:44 ` alan.adamson
2024-11-27  7:49 ` Chaitanya Kulkarni
2024-11-28  1:03 ` Shinichiro Kawasaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox