add nvme test for creating sleep while atomic kernel BUG
Subsystems (2)
v2 cover add nvme test for creating sleep while atomic kernel BUG
Hi,
There're two patches in this series. The first patch is a preparation patch for reusing a common function nvmf_wait_for_ns from multiple nvme test scripts. The second patch adds a new nvme regression[1] test for commit 505363957fad ("nvmet: fix nvme status code when namespace is disabled").
For fixing regression, as suggested by Christoph[2], I would send a separate patch upstream.
[1] https://lore.kernel.org/linux-nvme/tqcy3sveity7p56v7ywp7ssyviwcb3w4623cnxj3knoobfcanq@yxgt2mjkbkam/
[2] https://lore.kernel.org/linux-nvme/[email protected]/
Changes from v1:
- Update the second patch in the series so that we can trigger the regression 100% of time when we run the test (Chaitanya Kulkarni)
Nilay Shroff (2):
nvme/052: move nvmf_wait_for_ns() to common/nvme
nvme: add test for writing to file-ns just after disabling it
common/nvme | 26 ++++++++++ tests/nvme/052 | 30 +----------- tests/nvme/055 | 117 +++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/055.out | 2 + 4 files changed, 147 insertions(+), 28 deletions(-) create mode 100755 tests/nvme/055 create mode 100644 tests/nvme/055.out
Signature · 1 line
2.45.2
PATCH v2 1/2 nvme/052: move nvmf_wait_for_ns() to common/nvme
In a preparation for the use of nvmf_wait_for_ns function from other nvme test script, move nvmf_wait_for_ns from nvme/052 to common/nvme file so that we can reuse the nvmf_wait_for_ns from multiple test scripts.
--- common/nvme | 26 ++++++++++++++++++++++++++ tests/nvme/052 | 30 ++---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-)
common/nvme +26 -0
@@ -483,6 +483,32 @@ _remove_nvmet_port() { rmdir "${NVMET_CFS}/ports/${port}" } +# Wait for the namespace with specified uuid to fulfill the specified condtion, +# "created" or "removed". +_nvmf_wait_for_ns() { + local ns + local timeout="5" + local uuid="$1" + local condition="$2" + + ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL") + + start_time=$(date +%s) + while [[ -z "$ns" && "$condition" == created ]] || + [[ -n "$ns" && "$condition" == removed ]]; do + sleep .1 + end_time=$(date +%s) + if (( end_time - start_time > timeout )); then + echo "namespace with uuid \"${uuid}\" not " \ + "${condition} within ${timeout} seconds" + return 1 + fi + ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL") + done + + return 0 +} + _create_nvmet_ns() { local subsysnqn="${def_subsysnqn}" local nsid="${def_nsid}"
tests/nvme/052 +2 -28
@@ -20,32 +20,6 @@ set_conditions() { _set_nvme_trtype "$@" } -# Wait for the namespace with specified uuid to fulfill the specified condtion, -# "created" or "removed". -nvmf_wait_for_ns() { - local ns - local timeout="5" - local uuid="$1" - local condition="$2" - - ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL") - - start_time=$(date +%s) - while [[ -z "$ns" && "$condition" == created ]] || - [[ -n "$ns" && "$condition" == removed ]]; do - sleep .1 - end_time=$(date +%s) - if (( end_time - start_time > timeout )); then - echo "namespace with uuid \"${uuid}\" not " \ - "${condition} within ${timeout} seconds" - return 1 - fi - ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL") - done - - return 0 -} - test() { echo "Running ${TEST_NAME}"
@@ -65,7 +39,7 @@ test() { uuid=$(_create_nvmet_ns --blkdev "$filepath" --nsid "${nsid}") # wait until async request is processed and ns is created - if ! nvmf_wait_for_ns "${uuid}" created; then + if ! _nvmf_wait_for_ns "${uuid}" created; then echo "FAIL" rm "$filepath" break
@@ -74,7 +48,7 @@ test() { _remove_nvmet_ns "${def_subsysnqn}" "${nsid}" # wait until async request is processed and ns is removed - if ! nvmf_wait_for_ns "${uuid}" removed; then + if ! _nvmf_wait_for_ns "${uuid}" removed; then echo "FAIL" rm "$filepath" break
Signature · 1 line
2.45.2
PATCH v2 2/2 nvme: add test for writing to file-ns just after disabling it
In reply to Nilay ShroffThis is a regression test for commit 505363957fad ("nvmet: fix nvme status code when namespace is disabled")[1].
This test creates a regular file backed loop target namespace, disables the asynchronous event notification for ns-changed events and then write to the namespace just after disabling it.
[1] https://lore.kernel.org/linux-nvme/tqcy3sveity7p56v7ywp7ssyviwcb3w4623cnxj3knoobfcanq@yxgt2mjkbkam/
--- tests/nvme/055 | 117 +++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/055.out | 2 + 2 files changed, 119 insertions(+) create mode 100755 tests/nvme/055 create mode 100644 tests/nvme/055.out
tests/nvme/055 new file +117 -0
@@ -0,0 +1,117 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Nilay Shroff +# +# Regression test for commit 505363957fad ("nvmet: fix nvme +# status code when namespace is disabled"). + +. tests/nvme/rc + +DESCRIPTION="Test nvme write to a loop target ns just after ns is disabled" + +QUICK=1 + +requires() { + _nvme_requires + _have_loop + _require_nvme_trtype_is_loop + _have_kernel_option DEBUG_ATOMIC_SLEEP +} + +set_conditions() { + _set_nvme_trtype "$@" +} + +nvmf_disable_ns_change_aen() { + + local disk="$1" + local timeout="5" + + # get async event configuration value + aen_conf=$(nvme get-feature "$disk" --feature-id=0xB | cut -d':' -f3) + + # disable async ns change event notfication + disable_ns_change=$(( aen_conf & 0xFEFF )) + + # stop receiving aen event for ns change from target + nvme set-feature "$disk" --feature-id=0xB \ + --value="$disable_ns_change" 2>>"$FULL" 1>&2 + + start_time=$(date +%s) + + while true; do + aen_conf=$(nvme get-feature "$disk" \ + --feature-id=0xB | cut -d':' -f3) + + # Validate whether ns-changed notification is disabled or not; + # If it's already disabled then break and return success + if ! (( aen_conf & 0x100 )); then + break + fi + + sleep 1 + + end_time=$(date +%s) + + if (( end_time - start_time > timeout )); then + echo "can't disable ns-changed async event "\ + "notification within $timeout seconds" + return 1 + fi + done + + return 0 +} + +test() { + echo "Running ${TEST_NAME}" + + local iteration=1 i=0 + + _setup_nvmet + + _nvmet_target_setup + + _nvme_connect_subsys + + img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=none + + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" + ns_path="${subsys_path}/namespaces/${def_nsid}" + + while (( i < iteration )); do + # Wait until async request is processed and default ns + # is created + if ! _nvmf_wait_for_ns "${def_subsys_uuid}" created; then + echo "FAIL" + break + fi + + disk="/dev/$(_find_nvme_ns "${def_subsys_uuid}")" + + # Disable ns change async event notification from target. It + # would ensure that when we disable the target ns, the host + # would not receive ns removal notification from target and + # so from host we can attempt writing to a disabled ns. + if ! nvmf_disable_ns_change_aen "${disk}"; then + echo "FAIL" + break + fi + + # disable target namespace and write to it + echo 0 > ${ns_path}/enable + nvme write --start-block=1 --block-count=0 \ + --data-size=512 --data="$img" "$disk" 2>>"$FULL" + + ((i++)) + done + + rm "$img" + + _nvme_disconnect_subsys >> "$FULL" 2>&1 + + _nvmet_target_cleanup + + echo "Test complete" +}
tests/nvme/055.out new file +2 -0
@@ -0,0 +1,2 @@ +Running nvme/055 +Test complete
Signature · 1 line
2.45.2
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 4 lines
(quoted diff) +3
-0+test() { + echo "Running ${TEST_NAME}" +
Review
Quoted 10 lines
(quoted diff) +10
-0+ local iteration=1 i=0 + + _setup_nvmet + + _nvmet_target_setup + + _nvme_connect_subsys + + img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=none
why can't we just use the standard block device backed ns ?
Quoted 13 lines
(quoted diff) +13
-0+ + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" + ns_path="${subsys_path}/namespaces/${def_nsid}" + + while (( i < iteration )); do + # Wait until async request is processed and default ns + # is created + if ! _nvmf_wait_for_ns "${def_subsys_uuid}" created; then + echo "FAIL" + break + fi + + disk="/dev/$(_find_nvme_ns "${def_subsys_uuid}")"
Review
Quoted 10 lines
(quoted diff) +10
-0+ + # Disable ns change async event notification from target. It + # would ensure that when we disable the target ns, the host + # would not receive ns removal notification from target and + # so from host we can attempt writing to a disabled ns. + if ! nvmf_disable_ns_change_aen "${disk}"; then + echo "FAIL" + break + fi +
I'm really not sure disabling a functionality for testing purpose gives us full coverage, for a tests I believe it is important to have full functionality running and available so it will reflect the real setup, e.g. for this scenario we cannot dependent on disabling AEN since users are not disabling the AEN's every-time they disable the namespace and ends up writing to the ns on host side triggering the BUG.
Can this be an exception for some reason ?
Shinichiro, Daniel any thoughts ?
why not something like following ? (totally untested and rough)
drivers/nvme/target/core.c +5 -0
@@ -5,6 +5,7 @@*/ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> +#include <linux/delay.h> #include <linux/random.h> #include <linux/rculist.h> #include <linux/pci-p2pdma.h>
@@ -18,6 +19,11 @@ #include "nvmet.h" #include "debugfs.h" +unsigned int ns_disable_error_inject; +module_param (ns_disable_error_inject, int,0644 ); +MODULE_PARM_DESC(ns_disable_error_inject, + "delay xa_erase() in ns-disable path in seconds
(default 0)");
+
struct kmem_cache *nvmet_bvec_cache;
struct workqueue_struct *buffered_io_wq;
struct workqueue_struct *zbd_wq;
@@ -649,6 +655,8 @@ void nvmet_ns_disable(struct nvmet_ns *ns)
goto out_unlock;
ns->enabled = false;
+ if (ns_disable_error_inject)
+ msleep(ns_disable_error_inject * 1000);
xa_erase(&ns->subsys->namespaces, ns->nsid); if (ns->nsid == subsys->max_nsid) subsys->max_nsid = nvmet_max_nsid(subsys);
and add load the module with modprobe ns_disable_error_inject=10 ? or we can even mode this module as a part of ns configfs attr.
with above change following statement will block for 10 seconds.
Review
Quoted 4 lines
(quoted diff) +4
-0+ # disable target namespace and write to it + echo 0 > ${ns_path}/enable + nvme write --start-block=1 --block-count=0 \ + --data-size=512 --data="$img" "$disk" 2>>"$FULL"
-ck
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 16 lines · Chaitanya Kulkarni
Quoted 4 lines
(quoted diff) +3
-0+test() { + echo "Running ${TEST_NAME}" +Review
Quoted 10 lines
(quoted diff) +10
-0+ local iteration=1 i=0 + + _setup_nvmet + + _nvmet_target_setup + + _nvme_connect_subsys + + img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=nonewhy can't we just use the standard block device backed ns ?
Using standard block device would also work however using the file backed block device would be handy in case user doesn't have a spare standard block device available which could be used for writing a random junk to it.
Quoted 23 lines
Quoted 23 lines
(quoted diff) +22
-0+ + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" + ns_path="${subsys_path}/namespaces/${def_nsid}" + + while (( i < iteration )); do + # Wait until async request is processed and default ns + # is created + if ! _nvmf_wait_for_ns "${def_subsys_uuid}" created; then + echo "FAIL" + break + fi + + disk="/dev/$(_find_nvme_ns "${def_subsys_uuid}")" + + # Disable ns change async event notification from target. It + # would ensure that when we disable the target ns, the host + # would not receive ns removal notification from target and + # so from host we can attempt writing to a disabled ns. + if ! nvmf_disable_ns_change_aen "${disk}"; then + echo "FAIL" + break + fi
Quoted 9 lines
Quoted 1 line
+
I'm really not sure disabling a functionality for testing purpose gives us full coverage, for a tests I believe it is important to have full functionality running and available so it will reflect the real setup, e.g. for this scenario we cannot dependent on disabling AEN since users are not disabling the AEN's every-time they disable the namespace and ends up writing to the ns on host side triggering the BUG.
OK I think maybe there's a confusion, let me clarify one thing here: We're *not* disabling AEN functionality but only masking the ns-changed async even notification from target and I believe that's perfectly legal per spec. I shall update the comment added in the test case to avoid this confusion.
Quoted 42 lines
Can this be an exception for some reason ?
Shinichiro, Daniel any thoughts ?
why not something like following ? (totally untested and rough)
drivers/nvme/target/core.c +6
-0@@ -5,6 +5,7 @@*/ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> +#include <linux/delay.h> #include <linux/random.h> #include <linux/rculist.h> #include <linux/pci-p2pdma.h>@@ -18,6 +19,11 @@ #include "nvmet.h" #include "debugfs.h" +unsigned int ns_disable_error_inject; +module_param (ns_disable_error_inject, int,0644 ); +MODULE_PARM_DESC (ns_disable_error_inject, + "delay xa_erase() in ns-disable path in seconds (default 0)"); + struct kmem_cache *nvmet_bvec_cache; struct workqueue_struct *buffered_io_wq;struct
workqueue_struct*zbd_wq;drivers/nvme/target/core.c +2
-0@@ -649,6 +655,8 @@ void nvmet_ns_disable(struct nvmet_ns *ns) goto out_unlock; ns->enabled = false; + if (ns_disable_error_inject) + msleep(ns_disable_error_inject * 1000); xa_erase(&ns->subsys->namespaces, ns->nsid); if (ns->nsid == subsys->max_nsid) subsys->max_nsid = nvmet_max_nsid(subsys);
Quoted 2 lines
and add load the module with modprobe ns_disable_error_inject=10 ? or we can even mode this module as a part of ns configfs attr.
IMO, adding sleep won't help always because it's not guaranteed that write to ns would happen *always* at the correct time. Yes, in theory, above change would work most of the time but may not always?
Quoted 10 lines
with above change following statement will block for 10 seconds.
Review
Quoted 4 lines
(quoted diff) +4
-0+ # disable target namespace and write to it + echo 0 > ${ns_path}/enable + nvme write --start-block=1 --block-count=0 \ + --data-size=512 --data="$img" "$disk" 2>>"$FULL"-ck
So, as you suggested, I think lets wait for Daniel, Shinichiro and others to comment on this.
Thanks,
--Nilay
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 7 lines · Nilay Shroff
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=nonewhy can't we just use the standard block device backed ns ?
Using standard block device would also work however using the file backed block device would be handy in case user doesn't have a spare standard block device available which could be used for writing a random junk to it.
If I understood Chaitanya correctly, he would prefer to use the existing helpers to setup the backend, either file or block. If so, I am also on board with this idea, not to hard code backend into the test. We have moved this into the helpers so that it's a test parameter.
Quoted 8 lines
OK I think maybe there's a confusion, let me clarify one thing here: We're *not* disabling AEN functionality but only masking the ns-changed async even notification from target and I believe that's perfectly legal per spec. I shall update the comment added in the test case to avoid this confusion.
Quoted 3 lines
Can this be an exception for some reason ?
Shinichiro, Daniel any thoughts ?
I haven't really checked what the spec says on this topic. Nilay, could you give a pointer, so I don't spend too much time trying to find the right spot in the spec. Thanks!
Quoted 6 lines
Quoted 6 lines
drivers/nvme/target/core.c +4
-0+unsigned int ns_disable_error_inject; +module_param (ns_disable_error_inject, int,0644 ); +MODULE_PARM_DESC(ns_disable_error_inject, + "delay xa_erase() in ns-disable path in seconds(default 0)");
+
Please no. This type of debugging/testing interface is hard to use IMO. It should be in one of the psydo FS, sysfs, configfs or debugfs if really needed.
Daniel
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 19 lines · Daniel Wagner
Quoted 7 lines · Nilay Shroff
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=nonewhy can't we just use the standard block device backed ns ?
Using standard block device would also work however using the file backed block device would be handy in case user doesn't have a spare standard block device available which could be used for writing a random junk to it.
If I understood Chaitanya correctly, he would prefer to use the existing helpers to setup the backend, either file or block. If so, I am also on board with this idea, not to hard code backend into the test. We have moved this into the helpers so that it's a test parameter.
Quoted 5 lines
OK I think maybe there's a confusion, let me clarify one thing here: We're *not* disabling AEN functionality but only masking the ns-changed async even notification from target and I believe that's perfectly legal per spec. I shall update the comment added in the test case to avoid this confusion.
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Can this be an exception for some reason ?
Shinichiro, Daniel any thoughts ?
I haven't really checked what the spec says on this topic. Nilay, could you give a pointer, so I don't spend too much time trying to find the right spot in the spec. Thanks!
Sure, you may refer "5.27.1.8 Asynchronous Event Configuration (Feature Identifier 0Bh)" in NVMe base spec 2.0. And then refer Figure 236, Namespace Attribute Notices:
Quoted 11 lines
Quoted 6 lines
Quoted 6 lines
drivers/nvme/target/core.c +4
-0+unsigned int ns_disable_error_inject; +module_param (ns_disable_error_inject, int,0644 ); +MODULE_PARM_DESC(ns_disable_error_inject, + "delay xa_erase() in ns-disable path in seconds(default 0)");
+Please no. This type of debugging/testing interface is hard to use IMO. It should be in one of the psydo FS, sysfs, configfs or debugfs if really needed.
Quoted 2 lines
Daniel
Thanks,
--Nilay
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 3 lines · Nilay Shroff
Sure, you may refer "5.27.1.8 Asynchronous Event Configuration (Feature Identifier 0Bh)" in NVMe base spec 2.0. And then refer Figure 236, Namespace Attribute Notices:
Attached Namespace Attribute Notices (NAN): This bit determines whether an asynchronous event notification is sent to the host for an Attached Namespace Attribute Changed asynchronous event (refer to Figure 151). If this bit is set to ‘1’, then the Attached Namespace Attribute Changed asynchronous event is sent to the host when this condition occurs. If this bit is cleared to ‘0’, then the controller shall not send the Attached Namespace Attribute Changed asynchronous event to the host.
I agree, doesn't say that the controller always has to send a NAN AEN.
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 14 lines · Daniel Wagner
Quoted 3 lines · Nilay Shroff
Sure, you may refer "5.27.1.8 Asynchronous Event Configuration (Feature Identifier 0Bh)" in NVMe base spec 2.0. And then refer Figure 236, Namespace Attribute Notices:
Attached Namespace Attribute Notices (NAN): This bit determines whether an asynchronous event notification is sent to the host for an Attached Namespace Attribute Changed asynchronous event (refer to Figure 151). If this bit is set to ‘1’, then the Attached Namespace Attribute Changed asynchronous event is sent to the host when this condition occurs. If this bit is cleared to ‘0’, then the controller shall not send the Attached Namespace Attribute Changed asynchronous event to the host.
Quoted 1 line
I agree, doesn't say that the controller always has to send a NAN AEN.
Thanks for the discussion. IIUC, the users may have the NVME control which does not send a NAN AEN. In that case, the environment has same set up as this test case prepares. So this test does not look so weird for me.
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
In reply to Nilay ShroffThanks for this v2 patch. I took a quick look. Please find my comments in line. Will do another round of review when v3 comes out.
Quoted 23 lines · Nilay Shroff
This is a regression test for commit
505363957fad("nvmet: fix nvme status code when namespace is disabled")[1].This test creates a regular file backed loop target namespace, disables the asynchronous event notification for ns-changed events and then write to the namespace just after disabling it.
[1] https://lore.kernel.org/linux-nvme/tqcy3sveity7p56v7ywp7ssyviwcb3w4623cnxj3knoobfcanq@yxgt2mjkbkam/
Signed-off-by Nilay Shroff <[email protected]>--- tests/nvme/055 | 117 +++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/055.out | 2 + 2 files changed, 119 insertions(+) create mode 100755 tests/nvme/055 create mode 100644 tests/nvme/055.outtests/nvme/055 new file +0
-0
tests/nvme/055 line 6
Quoted 6 lines
tests/nvme/055 new file +6
-0@@ -0,0 +1,117 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Nilay Shroff +# +# Regression test for commit 505363957fad ("nvmet: fix nvme +# status code when namespace is disabled").
As I commented for v1 series after this v2 came out, I suggest to describe that this test intents to be independent from udev rules.
Quoted 7 lines
tests/nvme/055 new file +7
-0+ +. tests/nvme/rc + +DESCRIPTION="Test nvme write to a loop target ns just after ns is disabled" + +QUICK=1 +
[...]
Quoted 4 lines
tests/nvme/055 new file +4
-0+ +test() { + echo "Running ${TEST_NAME}" +
tests/nvme/055 line 78
Quoted 10 lines
tests/nvme/055 new file +10
-0+ local iteration=1 i=0 + + _setup_nvmet + + _nvmet_target_setup + + _nvme_connect_subsys + + img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=none
mktemp is not recommended, since blktests provides $TMPDIR as described in the "new" file.
Quoted 7 lines
tests/nvme/055 new file +7
-0+ + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" + ns_path="${subsys_path}/namespaces/${def_nsid}" + + while (( i < iteration )); do + # Wait until async request is processed and default ns + # is created
[...]
tests/nvme/055 line 105
Quoted 5 lines
tests/nvme/055 new file +5
-0+ + # disable target namespace and write to it + echo 0 > ${ns_path}/enable + nvme write --start-block=1 --block-count=0 \ + --data-size=512 --data="$img" "$disk" 2>>"$FULL"
Instead of --data="$img", can we use"--data=/dev/urandam"? If it works, we can avoid the img file.
tests/nvme/055 line 110
Quoted 5 lines
tests/nvme/055 new file +5
-0+ + ((i++)) + done + + rm "$img"
If we need img file, let's use $TMPDIR to skip this rm command.
Quoted 7 lines
tests/nvme/055 new file +7
-0+ + _nvme_disconnect_subsys >> "$FULL" 2>&1 + + _nvmet_target_cleanup + + echo "Test complete" +}
[...]
Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Quoted 21 lines · Shinichiro Kawasaki
Thanks for this v2 patch. I took a quick look. Please find my comments in line. Will do another round of review when v3 comes out.
Quoted 17 lines · Nilay Shroff
This is a regression test for commit
505363957fad("nvmet: fix nvme status code when namespace is disabled")[1].This test creates a regular file backed loop target namespace, disables the asynchronous event notification for ns-changed events and then write to the namespace just after disabling it.
[1] https://lore.kernel.org/linux-nvme/tqcy3sveity7p56v7ywp7ssyviwcb3w4623cnxj3knoobfcanq@yxgt2mjkbkam/
Signed-off-by Nilay Shroff <[email protected]>--- tests/nvme/055 | 117 +++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/055.out | 2 + 2 files changed, 119 insertions(+) create mode 100755 tests/nvme/055 create mode 100644 tests/nvme/055.out
Quoted 16 lines
tests/nvme/055 line 6
Quoted 12 lines
tests/nvme/055 new file +6
-0@@ -0,0 +1,117 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Nilay Shroff +# +# Regression test for commit 505363957fad ("nvmet: fix nvme +# status code when namespace is disabled").As I commented for v1 series after this v2 came out, I suggest to describe that this test intents to be independent from udev rules.
Sure, in the next patch I will update the comment.
Quoted 38 lines
Quoted 7 lines
tests/nvme/055 new file +7
-0+ +. tests/nvme/rc + +DESCRIPTION="Test nvme write to a loop target ns just after ns is disabled" + +QUICK=1 +[...]
Quoted 4 lines
tests/nvme/055 new file +4
-0+ +test() { + echo "Running ${TEST_NAME}" +tests/nvme/055 line 78
Quoted 10 lines
tests/nvme/055 new file +10
-0+ local iteration=1 i=0 + + _setup_nvmet + + _nvmet_target_setup + + _nvme_connect_subsys + + img="$(mktemp /tmp/blk_img_XXXXXX)" + dd if=/dev/urandom of="$img" bs=512 count=1 status=nonemktemp is not recommended, since blktests provides $TMPDIR as described in the "new" file.
Quoted 7 lines
tests/nvme/055 new file +7
-0+ + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" + ns_path="${subsys_path}/namespaces/${def_nsid}" + + while (( i < iteration )); do + # Wait until async request is processed and default ns + # is created[...]
Quoted 9 lines
tests/nvme/055 line 105
Quoted 5 lines
tests/nvme/055 new file +5
-0+ + # disable target namespace and write to it + echo 0 > ${ns_path}/enable + nvme write --start-block=1 --block-count=0 \ + --data-size=512 --data="$img" "$disk" 2>>"$FULL"Instead of --data="$img", can we use"--data=/dev/urandam"? If it works, we can avoid the img file.
Yeah I just tested with "/dev/urandom" and that seems to work. So we don't need img file. I will update this in the next patch.
Quoted 7 lines
tests/nvme/055 line 110
Quoted 5 lines
tests/nvme/055 new file +5
-0+ + ((i++)) + done + + rm "$img"If we need img file, let's use $TMPDIR to skip this rm command.
As /dev/urandom works, I would remove the use of img file.
Quoted 10 lines
Quoted 8 lines
tests/nvme/055 new file +7
-0+ + _nvme_disconnect_subsys >> "$FULL" 2>&1 + + _nvmet_target_cleanup + + echo "Test complete" +}[...]
Thanks,
--Nilay