From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: "shinichiro.kawasaki@wdc.com" <shinichiro.kawasaki@wdc.com>,
Nilay Shroff <nilay@linux.ibm.com>,
"dwagner@suse.de" <dwagner@suse.de>
Cc: "hch@lst.de" <hch@lst.de>,
"kbusch@kernel.org" <kbusch@kernel.org>,
"sagi@grimberg.me" <sagi@grimberg.me>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
"gjoyce@linux.ibm.com" <gjoyce@linux.ibm.com>
Subject: Re: [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Date: Thu, 5 Dec 2024 07:32:55 +0000 [thread overview]
Message-ID: <5178056a-4297-43ca-b15b-dfb8d9b21857@nvidia.com> (raw)
In-Reply-To: <20241204114755.190660-3-nilay@linux.ibm.com>
> +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
why can't we just use the standard block device backed ns ?
> +
> + 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
> +
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)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 1f4e9989663b..eede3a7c5594 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -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.
> + # 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
next prev parent reply other threads:[~2024-12-05 7:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 11:47 [PATCHv2 blktests 0/2] add nvme test for creating sleep while atomic kernel BUG Nilay Shroff
2024-12-04 11:47 ` [PATCHv2 blktests 1/2] nvme/052: move nvmf_wait_for_ns() to common/nvme Nilay Shroff
2024-12-04 11:47 ` [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it Nilay Shroff
2024-12-05 7:32 ` Chaitanya Kulkarni [this message]
2024-12-05 9:40 ` Nilay Shroff
2024-12-05 10:47 ` Daniel Wagner
2024-12-05 11:06 ` Nilay Shroff
2024-12-05 11:20 ` Daniel Wagner
2024-12-06 1:49 ` Shinichiro Kawasaki
2024-12-06 1:53 ` Shinichiro Kawasaki
2024-12-06 10:54 ` Nilay Shroff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5178056a-4297-43ca-b15b-dfb8d9b21857@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=gjoyce@linux.ibm.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox