Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT
@ 2026-04-30 23:29 Randy Jennings
  2026-04-30 23:29 ` [PATCH 1/7] fixup: nvme fix CCR command Randy Jennings
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

This code is not for check-in or as an RFC.

This post is just an FYI of code used on the target for
a functional test for CCR/CQT for this presentation:
https://lore.kernel.org/linux-nvme/CAPpK+O03nHvHGESXsDDARz_kgbNkmeHmu-G3XWto7CqHtyVedQ@mail.gmail.com/

The code by Chris Leech comes from the NVMe Cancel implemetation posted here:
https://lore.kernel.org/linux-nvme/20250324102310.658007-1-mlombard@redhat.com/

Code built on:
v3 of the CCR+CQT patches as described here:
https://lore.kernel.org/linux-nvme/20260214042753.4073668-1-mkhalfella@purestorage.com/T
* 011e0880d366 - nvmet: report NPDGL and NPDAL (8 weeks ago) <Caleb Sander Mateos>
(which was nvme-next a few weeks ago):

Chris Leech (3):
  nvmet: put all nvmet_req.execute calls behind a function name
  nvmet: add delay debugfs file to nvmet_ctrl
  nvmet: delay requests

Mohamed Khalfella (4):
  fixup: nvme fix CCR command
  nvmet: Added debugfs fatal opcode
  nvmet: kill nvme controller when fatal opcode is received
  Force CCR operation to fail

 drivers/nvme/target/Kconfig     | 19 ++++++++
 drivers/nvme/target/admin-cmd.c | 11 ++---
 drivers/nvme/target/core.c      | 37 ++++++++++++++++
 drivers/nvme/target/debugfs.c   | 78 +++++++++++++++++++++++++++++++++
 drivers/nvme/target/fc.c        |  4 +-
 drivers/nvme/target/loop.c      |  2 +-
 drivers/nvme/target/nvmet.h     | 17 +++++++
 drivers/nvme/target/rdma.c      |  4 +-
 drivers/nvme/target/tcp.c       |  4 +-
 include/linux/nvme.h            |  4 +-
 10 files changed, 166 insertions(+), 14 deletions(-)

-- 
2.54.0



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

* [PATCH 1/7] fixup: nvme fix CCR command
  2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
@ 2026-04-30 23:29 ` Randy Jennings
  2026-04-30 23:29 ` [PATCH 2/7] nvmet: put all nvmet_req.execute calls behind a function name Randy Jennings
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

From: Mohamed Khalfella <mkhalfella@purestorage.com>

---
 include/linux/nvme.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index e7f70774cbd8..742159dd2b89 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1247,9 +1247,9 @@ struct nvme_cross_ctrl_reset_cmd {
 	__le32			nsid;
 	__le64			rsvd2[2];
 	union nvme_data_ptr	dptr;
-	__u8			rsvd10;
-	__u8			ciu;
 	__le16			icid;
+	__u8			ciu;
+	__u8			rsvd10;
 	__le32			cdw11;
 	__le64			cirn;
 	__le32			cdw14;
-- 
2.54.0



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

* [PATCH 2/7] nvmet: put all nvmet_req.execute calls behind a function name
  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 ` Randy Jennings
  2026-04-30 23:29 ` [PATCH 3/7] nvmet: add delay debugfs file to nvmet_ctrl Randy Jennings
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

From: Chris Leech <cleech@redhat.com>

This is setup for being able to manipluate the outstanding requests.

Signed-off-by: Chris Leech <cleech@redhat.com>
---
 drivers/nvme/target/fc.c    | 4 ++--
 drivers/nvme/target/loop.c  | 2 +-
 drivers/nvme/target/nvmet.h | 1 +
 drivers/nvme/target/rdma.c  | 4 ++--
 drivers/nvme/target/tcp.c   | 4 ++--
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 0d9784004c9b..93b904864390 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -2391,7 +2391,7 @@ nvmet_fc_fod_op_done(struct nvmet_fc_fcp_iod *fod)
 		}
 
 		/* data transfer complete, resume with nvmet layer */
-		fod->req.execute(&fod->req);
+		nvmet_execute_request(&fod->req);
 		break;
 
 	case NVMET_FCOP_READDATA:
@@ -2600,7 +2600,7 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
 	 * can invoke the nvmet_layer now. If read data, cmd completion will
 	 * push the data
 	 */
-	fod->req.execute(&fod->req);
+	nvmet_execute_request(&fod->req);
 	return;
 
 transport_error:
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index fc8e7c9ad858..678d619083a6 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -127,7 +127,7 @@ static void nvme_loop_execute_work(struct work_struct *work)
 	struct nvme_loop_iod *iod =
 		container_of(work, struct nvme_loop_iod, work);
 
-	iod->req.execute(&iod->req);
+	nvmet_execute_request(&iod->req);
 }
 
 static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 5319765eaf5c..acb2f0f3cdc8 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -994,4 +994,5 @@ struct nvmet_feat_arbitration {
 	u8		ab;
 };
 
+static inline void nvmet_execute_request(struct nvmet_req *req) { req->execute(req); }
 #endif /* _NVMET_H */
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 9c12b2361a6d..5beb33629500 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -773,7 +773,7 @@ static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc)
 	if (unlikely(status))
 		nvmet_req_complete(&rsp->req, status);
 	else
-		rsp->req.execute(&rsp->req);
+		nvmet_execute_request(&rsp->req);
 }
 
 static void nvmet_rdma_write_data_done(struct ib_cq *cq, struct ib_wc *wc)
@@ -958,7 +958,7 @@ static bool nvmet_rdma_execute_command(struct nvmet_rdma_rsp *rsp)
 				queue->cm_id->port_num, &rsp->read_cqe, NULL))
 			nvmet_req_complete(&rsp->req, NVME_SC_DATA_XFER_ERROR);
 	} else {
-		rsp->req.execute(&rsp->req);
+		nvmet_execute_request(&rsp->req);
 	}
 
 	return true;
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 15416ff0eac4..fe811b55e0f8 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -606,7 +606,7 @@ static void nvmet_tcp_execute_request(struct nvmet_tcp_cmd *cmd)
 	if (unlikely(cmd->flags & NVMET_TCP_F_INIT_FAILED))
 		nvmet_tcp_queue_response(&cmd->req);
 	else
-		cmd->req.execute(&cmd->req);
+		nvmet_execute_request(&cmd->req);
 }
 
 static int nvmet_try_send_data_pdu(struct nvmet_tcp_cmd *cmd)
@@ -1072,7 +1072,7 @@ static int nvmet_tcp_done_recv_pdu(struct nvmet_tcp_queue *queue)
 		goto out;
 	}
 
-	queue->cmd->req.execute(&queue->cmd->req);
+	nvmet_execute_request(&queue->cmd->req);
 out:
 	nvmet_prepare_receive_pdu(queue);
 	return ret;
-- 
2.54.0



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

* [PATCH 3/7] nvmet: add delay debugfs file to nvmet_ctrl
  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 ` Randy Jennings
  2026-04-30 23:29 ` [PATCH 4/7] nvmet: delay requests Randy Jennings
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

From: Chris Leech <cleech@redhat.com>

Creates an delay attribute file on the controler in debugfs
/sys/kernel/debug/nvmet/<subsystem>/ctrlN/delay

Reading this file returns two numbers, a reqeust delay count and a delay
time in ms.  Each delayed request will decrement the delay count until
it reaches 0.

Writing to this file can set both the delay and count at once, or just
the count to trigger more delays.

 # delay the next 5 request by 5 seconds each
 echo 5 5000 > delay

 # set the delay time to 3 seconds without starting a count
 echo 0 3000 > delay

 # delay to the next 5 requests by the current delay time
 echo 5 > delay

Signed-off-by: Chris Leech <cleech@redhat.com>
---
 drivers/nvme/target/Kconfig   |  9 ++++++++
 drivers/nvme/target/debugfs.c | 40 +++++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h   |  4 ++++
 3 files changed, 53 insertions(+)

diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
index 4904097dfd49..cfcc652c6f9f 100644
--- a/drivers/nvme/target/Kconfig
+++ b/drivers/nvme/target/Kconfig
@@ -127,3 +127,12 @@ config NVME_TARGET_PCI_EPF
 	  capable PCI controller.
 
 	  If unsure, say N.
+
+config NVME_TARGET_DELAY_REQUESTS
+	bool "NVMe over Fabrics target request delay"
+	depends on NVME_TARGET && NVME_TARGET_DEBUGFS
+	help
+	 This is a testing feature to allow delaying request completion in an
+	 NVMe over Fabrics target, which allows for support of the cancel command.
+
+	 If unsure, say N.
diff --git a/drivers/nvme/target/debugfs.c b/drivers/nvme/target/debugfs.c
index 1300adf6c1fb..ae45aca728ea 100644
--- a/drivers/nvme/target/debugfs.c
+++ b/drivers/nvme/target/debugfs.c
@@ -170,6 +170,42 @@ static int nvmet_ctrl_instance_cirn_show(struct seq_file *m, void *p)
 }
 NVMET_DEBUGFS_ATTR(nvmet_ctrl_instance_cirn);
 
+#if IS_ENABLED(CONFIG_NVME_TARGET_DELAY_REQUESTS)
+static int nvmet_ctrl_delay_show(struct seq_file *m, void *p)
+{
+	struct nvmet_ctrl *ctrl = m->private;
+	int delay_count = atomic_read(&ctrl->delay_count);
+
+	seq_printf(m, "%u %u\n", delay_count, ctrl->delay_msec);
+	return 0;
+}
+
+static ssize_t nvmet_ctrl_delay_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 delay_buf[22] = {};
+	int delay_count;
+	int delay_msec;
+	int n;
+
+	if (count >= sizeof(delay_buf))
+		return -EINVAL;
+	if (copy_from_user(delay_buf, buf, count))
+		return -EFAULT;
+
+	n = sscanf(delay_buf, "%u %u", &delay_count, &delay_msec);
+	if (n < 1 || n > 2)
+		return -EINVAL;
+	if (n == 2)
+		ctrl->delay_msec = delay_msec;
+	atomic_set(&ctrl->delay_count, delay_count);
+	return count;
+}
+NVMET_DEBUGFS_RW_ATTR(nvmet_ctrl_delay);
+#endif /* CONFIG_NVME_TARGET_DELAY_REQUESTS */
+
 int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl)
 {
 	char name[32];
@@ -205,6 +241,10 @@ int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl)
 			    &nvmet_ctrl_instance_ciu_fops);
 	debugfs_create_file("cirn", S_IRUSR, ctrl->debugfs_dir, ctrl,
 			    &nvmet_ctrl_instance_cirn_fops);
+#if IS_ENABLED(CONFIG_NVME_TARGET_DELAY_REQUESTS)
+	debugfs_create_file("delay", S_IWUSR, ctrl->debugfs_dir, ctrl,
+			    &nvmet_ctrl_delay_fops);
+#endif
 	return 0;
 }
 
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index acb2f0f3cdc8..beade281164a 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -313,6 +313,10 @@ struct nvmet_ctrl {
 #endif
 #ifdef CONFIG_NVME_TARGET_TCP_TLS
 	struct key		*tls_key;
+#endif
+#ifdef CONFIG_NVME_TARGET_DELAY_REQUESTS
+	atomic_t		delay_count;
+	u32			delay_msec;
 #endif
 	struct nvmet_pr_log_mgr pr_log_mgr;
 };
-- 
2.54.0



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

* [PATCH 4/7] nvmet: delay requests
  2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
                   ` (2 preceding siblings ...)
  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
  2026-04-30 23:29 ` [PATCH 5/7] nvmet: Added debugfs fatal opcode Randy Jennings
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

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



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

* [PATCH 5/7] nvmet: Added debugfs fatal opcode
  2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
                   ` (3 preceding siblings ...)
  2026-04-30 23:29 ` [PATCH 4/7] nvmet: delay requests Randy Jennings
@ 2026-04-30 23:29 ` Randy Jennings
  2026-04-30 23:29 ` [PATCH 6/7] nvmet: kill nvme controller when fatal opcode is received Randy Jennings
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

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



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

* [PATCH 6/7] nvmet: kill nvme controller when fatal opcode is received
  2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
                   ` (4 preceding siblings ...)
  2026-04-30 23:29 ` [PATCH 5/7] nvmet: Added debugfs fatal opcode Randy Jennings
@ 2026-04-30 23:29 ` 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
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

From: Mohamed Khalfella <mkhalfella@purestorage.com>

---
 drivers/nvme/target/core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index c5028f1fc458..866c8736b60c 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1909,12 +1909,19 @@ void nvmet_execute_request(struct nvmet_req *req) {
 		return req->execute(req);
 
 	if (ctrl) {
+		if (req->cmd->common.opcode == ctrl->fopcode) {
+			delay_msec = ctrl->fopcode_delay_ms;
+			nvmet_ctrl_fatal_error(ctrl);
+			goto delay;
+		}
+
 		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);
 
+delay:
 	INIT_DELAYED_WORK(&req->req_work, nvmet_delayed_execute_req);
 	queue_delayed_work(nvmet_wq, &req->req_work, msecs_to_jiffies(delay_msec));
 }
-- 
2.54.0



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

* [PATCH 7/7] Force CCR operation to fail
  2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
                   ` (5 preceding siblings ...)
  2026-04-30 23:29 ` [PATCH 6/7] nvmet: kill nvme controller when fatal opcode is received Randy Jennings
@ 2026-04-30 23:29 ` Randy Jennings
  2026-05-10 22:39 ` [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Sagi Grimberg
  7 siblings, 0 replies; 9+ messages in thread
From: Randy Jennings @ 2026-04-30 23:29 UTC (permalink / raw)
  To: lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

From: Mohamed Khalfella <mkhalfella@purestorage.com>

---
 drivers/nvme/target/admin-cmd.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 53ec682f27b0..04369ce79ad0 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -626,13 +626,11 @@ static void nvmet_execute_get_log_page_ccr(struct nvmet_req *req)
 	mutex_lock(&ctrl->lock);
 	list_for_each_entry(ccr, &ctrl->ccr_list, entry) {
 		u8 flags = NVME_CCR_FLAGS_VALIDATED | NVME_CCR_FLAGS_INITIATED;
-		u8 status = ccr->ctrl ? NVME_CCR_STATUS_IN_PROGRESS :
-					NVME_CCR_STATUS_SUCCESS;
 
 		log->entries[index].icid = cpu_to_le16(ccr->icid);
 		log->entries[index].ciu = ccr->ciu;
 		log->entries[index].acid = cpu_to_le16(0xffff);
-		log->entries[index].ccrs = status;
+		log->entries[index].ccrs = NVME_CCR_STATUS_FAILED;
 		log->entries[index].ccrf = flags;
 		index++;
 	}
@@ -1725,8 +1723,11 @@ void nvmet_execute_cross_ctrl_reset(struct nvmet_req *req)
 
 out_unlock:
 	mutex_unlock(&sctrl->lock);
-	if (status == NVME_SC_SUCCESS)
-		nvmet_ctrl_fatal_error(ictrl);
+	if (status == NVME_SC_SUCCESS) {
+		nvmet_add_async_event(sctrl, NVME_AER_NOTICE,
+				      NVME_AER_NOTICE_CCR_COMPLETED,
+				      NVME_LOG_CCR);
+	}
 	nvmet_ctrl_put(ictrl);
 out:
 	nvmet_req_complete(req, status);
-- 
2.54.0



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

* Re: [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT
  2026-04-30 23:29 [PATCH 0/7] NOT FOR MERGE nvmet code to exercise CCR/CQT Randy Jennings
                   ` (6 preceding siblings ...)
  2026-04-30 23:29 ` [PATCH 7/7] Force CCR operation to fail Randy Jennings
@ 2026-05-10 22:39 ` Sagi Grimberg
  7 siblings, 0 replies; 9+ messages in thread
From: Sagi Grimberg @ 2026-05-10 22:39 UTC (permalink / raw)
  To: Randy Jennings, lsf-pc, linux-nvme; +Cc: cleech, mkhalfella

Was another round of this patch set submitted randy?


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

end of thread, other threads:[~2026-05-10 22:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox