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 5/7] nvmet: Added debugfs fatal opcode
Date: Thu, 30 Apr 2026 17:29:11 -0600 [thread overview]
Message-ID: <20260430232913.129271-6-randyj@purestorage.com> (raw)
In-Reply-To: <20260430232913.129271-1-randyj@purestorage.com>
From: Mohamed Khalfella <mkhalfella@purestorage.com>
---
drivers/nvme/target/Kconfig | 10 +++++++++
drivers/nvme/target/debugfs.c | 38 +++++++++++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 4 ++++
3 files changed, 52 insertions(+)
diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
index cfcc652c6f9f..8386ffedf645 100644
--- a/drivers/nvme/target/Kconfig
+++ b/drivers/nvme/target/Kconfig
@@ -136,3 +136,13 @@ config NVME_TARGET_DELAY_REQUESTS
NVMe over Fabrics target, which allows for support of the cancel command.
If unsure, say N.
+
+config NVME_TARGET_FATAL_OPCODE
+ bool "NVMe over Fabrics target fatal opcode"
+ depends on NVME_TARGET && NVME_TARGET_DEBUGFS
+ help
+ This is a testing feature to allow specifying an nvme opcode as fatal
+ opcode. When nvme controller receives fatal opcode it will execute
+ the request with specified delay and drop the connections to initiator.
+
+ If unsure, say N.
diff --git a/drivers/nvme/target/debugfs.c b/drivers/nvme/target/debugfs.c
index ae45aca728ea..28ab22ab3da8 100644
--- a/drivers/nvme/target/debugfs.c
+++ b/drivers/nvme/target/debugfs.c
@@ -206,6 +206,39 @@ static ssize_t nvmet_ctrl_delay_write(struct file *file, const char __user *buf,
NVMET_DEBUGFS_RW_ATTR(nvmet_ctrl_delay);
#endif /* CONFIG_NVME_TARGET_DELAY_REQUESTS */
+#if IS_ENABLED(CONFIG_NVME_TARGET_FATAL_OPCODE)
+static int nvmet_ctrl_fatal_opcode_show(struct seq_file *m, void *p)
+{
+ struct nvmet_ctrl *ctrl = m->private;
+
+ seq_printf(m, "%02x %u\n", ctrl->fopcode, ctrl->fopcode_delay_ms);
+ return 0;
+}
+
+static ssize_t nvmet_ctrl_fatal_opcode_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct seq_file *m = file->private_data;
+ struct nvmet_ctrl *ctrl = m->private;
+ char fopcode_buf[22] = {};
+ int fopcode_delay_ms, n;
+ uint8_t fopcode;
+
+ if (count >= sizeof(fopcode_buf))
+ return -EINVAL;
+ if (copy_from_user(fopcode_buf, buf, count))
+ return -EFAULT;
+
+ n = sscanf(fopcode_buf, "%hhx %u", &fopcode, &fopcode_delay_ms);
+ if (n != 2)
+ return -EINVAL;
+ ctrl->fopcode = fopcode;
+ ctrl->fopcode_delay_ms = fopcode_delay_ms;
+ return count;
+}
+NVMET_DEBUGFS_RW_ATTR(nvmet_ctrl_fatal_opcode);
+#endif /* CONFIG_NVME_TARGET_FATAL_OPCODE */
+
int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl)
{
char name[32];
@@ -245,6 +278,11 @@ int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl)
debugfs_create_file("delay", S_IWUSR, ctrl->debugfs_dir, ctrl,
&nvmet_ctrl_delay_fops);
#endif
+
+#if IS_ENABLED(CONFIG_NVME_TARGET_FATAL_OPCODE)
+ debugfs_create_file("fopcode", S_IWUSR, ctrl->debugfs_dir, ctrl,
+ &nvmet_ctrl_fatal_opcode_fops);
+#endif
return 0;
}
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 845072cf4fae..183f71bf27a4 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -317,6 +317,10 @@ struct nvmet_ctrl {
#ifdef CONFIG_NVME_TARGET_DELAY_REQUESTS
atomic_t delay_count;
u32 delay_msec;
+#endif
+#ifdef CONFIG_NVME_TARGET_FATAL_OPCODE
+ uint8_t fopcode;
+ u32 fopcode_delay_ms;
#endif
struct nvmet_pr_log_mgr pr_log_mgr;
};
--
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 ` [PATCH 4/7] nvmet: delay requests Randy Jennings
2026-04-30 23:29 ` Randy Jennings [this message]
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-6-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