From: Randy Jennings <randyj@purestorage.com>
To: lsf-pc@lists.linux-foundation.org, linux-nvme@lists.infradead.org
Cc: cleech@redhat.com, mkhalfella@purestorage.com
Subject: [PATCH 4/7] nvmet: delay requests
Date: Thu, 30 Apr 2026 17:29:10 -0600 [thread overview]
Message-ID: <20260430232913.129271-5-randyj@purestorage.com> (raw)
In-Reply-To: <20260430232913.129271-1-randyj@purestorage.com>
From: Chris Leech <cleech@redhat.com>
Allow requests to be delayed for testing.
Signed-off-by: Chris Leech <cleech@redhat.com>
---
drivers/nvme/target/core.c | 30 ++++++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 8 ++++++++
2 files changed, 38 insertions(+)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index e534ad312275..c5028f1fc458 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -6,7 +6,9 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/random.h>
+#include <linux/jiffies.h>
#include <linux/rculist.h>
+#include <linux/workqueue.h>
#include <linux/pci-p2pdma.h>
#include <linux/scatterlist.h>
@@ -1891,6 +1893,34 @@ ssize_t nvmet_ctrl_host_traddr(struct nvmet_ctrl *ctrl,
return ctrl->ops->host_traddr(ctrl, traddr, traddr_len);
}
+#if IS_ENABLED(CONFIG_NVME_TARGET_DELAY_REQUESTS)
+static void nvmet_delayed_execute_req(struct work_struct *work) {
+ struct nvmet_req *req =
+ container_of(to_delayed_work(work), struct nvmet_req, req_work);
+ req->execute(req);
+}
+
+void nvmet_execute_request(struct nvmet_req *req) {
+ struct nvmet_ctrl *ctrl = req->sq->ctrl;
+ int delay_count;
+ u32 delay_msec;
+
+ if (unlikely(req->sq->qid == 0))
+ return req->execute(req);
+
+ if (ctrl) {
+ delay_count = atomic_dec_if_positive(&ctrl->delay_count) + 1;
+ delay_msec = ctrl->delay_msec;
+ }
+ if (!(ctrl && delay_count && delay_msec))
+ return req->execute(req);
+
+ INIT_DELAYED_WORK(&req->req_work, nvmet_delayed_execute_req);
+ queue_delayed_work(nvmet_wq, &req->req_work, msecs_to_jiffies(delay_msec));
+}
+EXPORT_SYMBOL_GPL(nvmet_execute_request);
+#endif
+
static struct nvmet_subsys *nvmet_find_get_subsys(struct nvmet_port *port,
const char *subsysnqn)
{
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index beade281164a..845072cf4fae 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -511,6 +511,9 @@ struct nvmet_req {
u16 error_loc;
u64 error_slba;
struct nvmet_pr_per_ctrl_ref *pc_ref;
+#if IS_ENABLED(CONFIG_NVME_TARGET_DELAY_REQUESTS)
+ struct delayed_work req_work;
+#endif
};
#define NVMET_MAX_MPOOL_BVEC 16
@@ -998,5 +1001,10 @@ struct nvmet_feat_arbitration {
u8 ab;
};
+#if IS_ENABLED(CONFIG_NVME_TARGET_DELAY_REQUESTS)
+void nvmet_execute_request(struct nvmet_req *req);
+#else
static inline void nvmet_execute_request(struct nvmet_req *req) { req->execute(req); }
+#endif
+
#endif /* _NVMET_H */
--
2.54.0
next prev parent reply other threads:[~2026-04-30 23:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
2026-04-30 23:29 ` [PATCH 1/7] fixup: nvme fix CCR command Randy Jennings
2026-04-30 23:29 ` [PATCH 2/7] nvmet: put all nvmet_req.execute calls behind a function name Randy Jennings
2026-04-30 23:29 ` [PATCH 3/7] nvmet: add delay debugfs file to nvmet_ctrl Randy Jennings
2026-04-30 23:29 ` Randy Jennings [this message]
2026-04-30 23:29 ` [PATCH 5/7] nvmet: Added debugfs fatal opcode Randy Jennings
2026-04-30 23:29 ` [PATCH 6/7] nvmet: kill nvme controller when fatal opcode is received Randy Jennings
2026-04-30 23:29 ` [PATCH 7/7] Force CCR operation to fail Randy Jennings
2026-05-10 22:39 ` [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Sagi Grimberg
2026-05-11 19:14 ` Randy Jennings
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=20260430232913.129271-5-randyj@purestorage.com \
--to=randyj@purestorage.com \
--cc=cleech@redhat.com \
--cc=linux-nvme@lists.infradead.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=mkhalfella@purestorage.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