All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH blktests V2 0/1] nvme: Add passthru error logging tests to nvme/039
@ 2024-02-20 23:30 Alan Adamson
  2024-02-20 23:30 ` [PATCH blktests V2 1/1] " Alan Adamson
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Adamson @ 2024-02-20 23:30 UTC (permalink / raw
  To: linux-block; +Cc: alan.adamson, chaitanyak, linux-nvme, shinichiro.kawasaki

v2: - Pass namespace (/dev/nvme0n1) to nvme io-passthru rather than controller (/dev/nvme0).
      This resolves a issue when testing with multi-namespace devices.
    - Only run the passthru tests on kernels 6.8.0 and greater.

Alan Adamson (1):
  nvme: Add passthru error logging tests to nvme/039

 tests/nvme/039     | 63 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/039.out |  2 ++
 tests/nvme/rc      | 37 +++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)

-- 
2.39.3


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

* [PATCH blktests V2 1/1] nvme: Add passthru error logging tests to nvme/039
  2024-02-20 23:30 [PATCH blktests V2 0/1] nvme: Add passthru error logging tests to nvme/039 Alan Adamson
@ 2024-02-20 23:30 ` Alan Adamson
  2024-02-21  7:12   ` Chaitanya Kulkarni
  2024-02-21 10:41   ` Shinichiro Kawasaki
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Adamson @ 2024-02-20 23:30 UTC (permalink / raw
  To: linux-block; +Cc: alan.adamson, chaitanyak, linux-nvme, shinichiro.kawasaki

Tests the ability to enable and disable error logging for passthru admin commands issued to
the controller and passthru IO commands issued to a namespace.

These tests will only run on 6.8.0 and greater kernels.

Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
---
 tests/nvme/039     | 62 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/039.out |  2 ++
 tests/nvme/rc      | 37 +++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)

diff --git a/tests/nvme/039 b/tests/nvme/039
index 73b53d0b949c..38a866417db9 100755
--- a/tests/nvme/039
+++ b/tests/nvme/039
@@ -130,6 +130,46 @@ inject_invalid_admin_cmd()
 	fi
 }
 
+inject_invalid_io_cmd_passthru()
+{
+	local ns
+
+	ns=$(echo "$1" |  cut -d "n" -f3)
+
+	# Inject a 'Invalid Command Opcode' (0x1) on a read (0x02)
+	_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
+
+	_nvme_disable_err_inject "$1"
+	if ${nvme_verbose_errors}; then
+		last_dmesg 2 | grep "Invalid Command Opcode (" | \
+		    sed 's/nvme.*://g'
+	else
+		last_dmesg 2 | grep "Cmd(0x2" | sed 's/I\/O Cmd/Read/g' | \
+		    sed 's/I\/O Error/Invalid Command Opcode/g' | \
+		    sed 's/nvme.*://g'
+	fi
+}
+
+RUN_PASSTHRU_TESTS=0;
+
+# Kernel must be at least 6.8.0 to run passthru logging tests
+check_kver680_for_passthru_tests() {
+        local d=6 e=8 f=0
+
+        IFS='.' read -r a b c < <(uname -r | sed 's/-.*//;s/[^.0-9]//')
+
+        if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ];
+        then
+		RUN_PASSTHRU_TESTS=0
+		return
+        fi
+
+	RUN_PASSTHRU_TESTS=1
+}
+
 test_device() {
 	echo "Running ${TEST_NAME}"
 
@@ -143,6 +183,8 @@ test_device() {
 		nvme_verbose_errors=false
 	fi
 
+	check_kver680_for_passthru_tests
+
 	ns_dev=${TEST_DEV##*/}
 	ctrl_dev=${ns_dev%n*}
 
@@ -155,6 +197,26 @@ test_device() {
 	inject_invalid_status_on_read "${ns_dev}"
 	inject_write_fault_on_write "${ns_dev}"
 
+	if [ $RUN_PASSTHRU_TESTS -ne 0 ]; then
+		_nvme_passthru_logging_setup "${ns_dev}" "${ctrl_dev}"
+
+		# Test Pass Thru Admin Logging
+		_nvme_disable_passthru_admin_error_logging "${ctrl_dev}"
+		inject_invalid_admin_cmd "${ctrl_dev}"
+		_nvme_enable_passthru_admin_error_logging "${ctrl_dev}"
+		inject_access_denied_on_identify "${ctrl_dev}"
+
+		# Test Pass Thru IO Logging
+		_nvme_disable_passthru_io_error_logging "${ns_dev}" "${ctrl_dev}"
+		inject_invalid_io_cmd_passthru "${ns_dev}" 0
+		_nvme_enable_passthru_io_error_logging "${ns_dev}" "${ctrl_dev}"
+		inject_invalid_io_cmd_passthru "${ns_dev}" 1
+
+		_nvme_passthru_logging_cleanup "${ns_dev}" "${ctrl_dev}"
+	else
+		echo " Identify(0x6), Access Denied (sct 0x2 / sc 0x86) DNR cdw10=0x1 cdw11=0x0 cdw12=0x0 cdw13=0x0 cdw14=0x0 cdw15=0x0"
+		echo " Read(0x2), Invalid Command Opcode (sct 0x0 / sc 0x1) DNR cdw10=0x0 cdw11=0x0 cdw12=0x1 cdw13=0x0 cdw14=0x0 cdw15=0x0"
+	fi
 	_nvme_err_inject_cleanup "${ns_dev}" "${ctrl_dev}"
 
 	echo "Test complete"
diff --git a/tests/nvme/039.out b/tests/nvme/039.out
index 139070d22240..fea76cfd1245 100644
--- a/tests/nvme/039.out
+++ b/tests/nvme/039.out
@@ -2,4 +2,6 @@ Running nvme/039
  Read(0x2) @ LBA 0, 1 blocks, Unrecovered Read Error (sct 0x2 / sc 0x81) DNR 
  Read(0x2) @ LBA 0, 1 blocks, Unknown (sct 0x3 / sc 0x75) DNR 
  Write(0x1) @ LBA 0, 1 blocks, Write Fault (sct 0x2 / sc 0x80) DNR 
+ Identify(0x6), Access Denied (sct 0x2 / sc 0x86) DNR cdw10=0x1 cdw11=0x0 cdw12=0x0 cdw13=0x0 cdw14=0x0 cdw15=0x0
+ Read(0x2), Invalid Command Opcode (sct 0x0 / sc 0x1) DNR cdw10=0x0 cdw11=0x0 cdw12=0x1 cdw13=0x0 cdw14=0x0 cdw15=0x0
 Test complete
diff --git a/tests/nvme/rc b/tests/nvme/rc
index dfc4c1ef1975..2d6ebeab2f6f 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -943,6 +943,23 @@ _check_uuid() {
 
 declare -A NS_DEV_FAULT_INJECT_SAVE
 declare -A CTRL_DEV_FAULT_INJECT_SAVE
+ns_dev_passthru_logging=off
+ctrl_dev_passthru_logging=off
+
+_nvme_passthru_logging_setup()
+{
+	ctrl_dev_passthru_logging=$(cat /sys/class/nvme/"$2"/passthru_err_log_enabled)
+	ns_dev_passthru_logging=$(cat /sys/class/nvme/"$2"/"$1"/passthru_err_log_enabled)
+
+	_nvme_disable_passthru_admin_error_logging "$2"
+	_nvme_disable_passthru_io_error_logging "$1" "$2"
+}
+
+_nvme_passthru_logging_cleanup()
+{
+	echo $ctrl_dev_passthru_logging > /sys/class/nvme/"$2"/passthru_err_log_enabled
+	echo $ns_dev_passthru_logging > /sys/class/nvme/"$2"/"$1"/passthru_err_log_enabled
+}
 
 _nvme_err_inject_setup()
 {
@@ -985,6 +1002,26 @@ _nvme_disable_err_inject()
         echo 0 > /sys/kernel/debug/"$1"/fault_inject/times
 }
 
+_nvme_enable_passthru_admin_error_logging()
+{
+	echo on > /sys/class/nvme/"$1"/passthru_err_log_enabled
+}
+
+_nvme_enable_passthru_io_error_logging()
+{
+	echo on > /sys/class/nvme/"$2"/"$1"/passthru_err_log_enabled
+}
+
+_nvme_disable_passthru_admin_error_logging()
+{
+	echo off > /sys/class/nvme/"$1"/passthru_err_log_enabled
+}
+
+_nvme_disable_passthru_io_error_logging()
+{
+	echo off > /sys/class/nvme/"$2"/"$1"/passthru_err_log_enabled
+}
+
 _nvme_reset_ctrl() {
 	echo 1 > /sys/class/nvme/"$1"/reset_controller
 }
-- 
2.39.3


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

* Re: [PATCH blktests V2 1/1] nvme: Add passthru error logging tests to nvme/039
  2024-02-20 23:30 ` [PATCH blktests V2 1/1] " Alan Adamson
@ 2024-02-21  7:12   ` Chaitanya Kulkarni
  2024-02-21 10:41   ` Shinichiro Kawasaki
  1 sibling, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2024-02-21  7:12 UTC (permalink / raw
  To: Alan Adamson, linux-block@vger.kernel.org
  Cc: linux-nvme@lists.infradead.org, shinichiro.kawasaki@wdc.com

On 2/20/24 15:30, Alan Adamson wrote:
> Tests the ability to enable and disable error logging for passthru admin commands issued to
> the controller and passthru IO commands issued to a namespace.
>
> These tests will only run on 6.8.0 and greater kernels.
>
> Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
> ---
>

Looks good.

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

-ck



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

* Re: [PATCH blktests V2 1/1] nvme: Add passthru error logging tests to nvme/039
  2024-02-20 23:30 ` [PATCH blktests V2 1/1] " Alan Adamson
  2024-02-21  7:12   ` Chaitanya Kulkarni
@ 2024-02-21 10:41   ` Shinichiro Kawasaki
  2024-02-21 16:42     ` alan.adamson
  1 sibling, 1 reply; 5+ messages in thread
From: Shinichiro Kawasaki @ 2024-02-21 10:41 UTC (permalink / raw
  To: Alan Adamson
  Cc: linux-block@vger.kernel.org, chaitanyak@nvidia.com,
	linux-nvme@lists.infradead.org

Thanks for this v2. I confirmed nvme/039 passes with this patch on my test
system. Good.

On Feb 20, 2024 / 15:30, Alan Adamson wrote:
> Tests the ability to enable and disable error logging for passthru admin commands issued to
> the controller and passthru IO commands issued to a namespace.
> 
> These tests will only run on 6.8.0 and greater kernels.

This v2 uses the kernel version as the condition to run passthru tests. But I
think sysfs file check is much simpler and more accurate. Please see my comment
below.

[...]

> diff --git a/tests/nvme/039 b/tests/nvme/039
> index 73b53d0b949c..38a866417db9 100755
> --- a/tests/nvme/039
> +++ b/tests/nvme/039

[...]

> @@ -155,6 +197,26 @@ test_device() {
>  	inject_invalid_status_on_read "${ns_dev}"
>  	inject_write_fault_on_write "${ns_dev}"
>  
> +	if [ $RUN_PASSTHRU_TESTS -ne 0 ]; then

The line above can be:

       if [ -e "$TEST_DEV_SYSFS/passthru_err_log_enabled" ]; then

Then RUN_PASSTHRU_TESTS and check_kver680_for_passthru_tests() are not required.

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

* Re: [PATCH blktests V2 1/1] nvme: Add passthru error logging tests to nvme/039
  2024-02-21 10:41   ` Shinichiro Kawasaki
@ 2024-02-21 16:42     ` alan.adamson
  0 siblings, 0 replies; 5+ messages in thread
From: alan.adamson @ 2024-02-21 16:42 UTC (permalink / raw
  To: Shinichiro Kawasaki
  Cc: linux-block@vger.kernel.org, chaitanyak@nvidia.com,
	linux-nvme@lists.infradead.org


On 2/21/24 2:41 AM, Shinichiro Kawasaki wrote:
> Thanks for this v2. I confirmed nvme/039 passes with this patch on my test
> system. Good.
>
> On Feb 20, 2024 / 15:30, Alan Adamson wrote:
>> Tests the ability to enable and disable error logging for passthru admin commands issued to
>> the controller and passthru IO commands issued to a namespace.
>>
>> These tests will only run on 6.8.0 and greater kernels.
> This v2 uses the kernel version as the condition to run passthru tests. But I
> think sysfs file check is much simpler and more accurate. Please see my comment
> below.
>
> [...]
>
>> diff --git a/tests/nvme/039 b/tests/nvme/039
>> index 73b53d0b949c..38a866417db9 100755
>> --- a/tests/nvme/039
>> +++ b/tests/nvme/039
> [...]
>
>> @@ -155,6 +197,26 @@ test_device() {
>>   	inject_invalid_status_on_read "${ns_dev}"
>>   	inject_write_fault_on_write "${ns_dev}"
>>   
>> +	if [ $RUN_PASSTHRU_TESTS -ne 0 ]; then
> The line above can be:
>
>         if [ -e "$TEST_DEV_SYSFS/passthru_err_log_enabled" ]; then
>
> Then RUN_PASSTHRU_TESTS and check_kver680_for_passthru_tests() are not required.

That makes sense.  I'll make this change.


Thanks,

Alan


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

end of thread, other threads:[~2024-02-21 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20 23:30 [PATCH blktests V2 0/1] nvme: Add passthru error logging tests to nvme/039 Alan Adamson
2024-02-20 23:30 ` [PATCH blktests V2 1/1] " Alan Adamson
2024-02-21  7:12   ` Chaitanya Kulkarni
2024-02-21 10:41   ` Shinichiro Kawasaki
2024-02-21 16:42     ` alan.adamson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.