Re: [PATCH v7 03/17] nvmet: Implement CCR nvme command
From: Hannes Reinecke
Date: Tue Nov 17 2026 - 02:09:36 EST
On 11/17/26 1:03 AM, Mohamed Khalfella wrote:
On Mon 2026-11-16 11:45:40 +0300, Dmitry Bogdanov wrote:The point is that in a distributed system the cntlid range is distributed across all nodes in the cluster (as indicated by
On Fri, Nov 13, 2026 at 07:04:17PM -0800, Mohamed Khalfella wrote:
Defined by TP8028 Rapid Path Failure Recovery, CCR (Cross-Controller
Reset) command is an nvme command issued to source controller by
initiator to reset impacted controller. Implement CCR command for linux
nvme target.
Signed-off-by: Mohamed Khalfella <mkhalfella@xxxxxxxxxxxxxxx>
Reviewed-by: Hannes Reinecke <hare@xxxxxxx>
Reviewed-by: Sagi Grimberg <sagi@xxxxxxxxxxx>
---
drivers/nvme/target/admin-cmd.c | 76 ++++++++++++++++++++++++++++++
drivers/nvme/target/core.c | 83 +++++++++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 13 ++++++
include/linux/nvme.h | 23 +++++++++
4 files changed, 195 insertions(+)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 5710ae53eb83..3df9db454db9 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -378,6 +378,7 @@ static void nvmet_get_cmd_effects_admin(struct nvmet_ctrl *ctrl,
log->acs[nvme_admin_get_features] =
log->acs[nvme_admin_async_event] =
log->acs[nvme_admin_keep_alive] =
+ log->acs[nvme_admin_cross_ctrl_reset] =
cpu_to_le32(NVME_CMD_EFFECTS_CSUPP);
}
@@ -1629,6 +1630,78 @@ void nvmet_execute_keep_alive(struct nvmet_req *req)
nvmet_req_complete(req, status);
}
+void nvmet_execute_cross_ctrl_reset(struct nvmet_req *req)
+{
+ struct nvmet_ctrl *ictrl, *sctrl = req->sq->ctrl;
+ struct nvme_command *cmd = req->cmd;
+ struct nvmet_ccr *ccr, *new_ccr;
+ int ccr_active, ccr_total;
+ u16 cntlid, status = NVME_SC_SUCCESS;
+
+ if (!nvmet_check_transfer_len(req, 0))
+ return;
+
+ cntlid = le16_to_cpu(cmd->ccr.icid);
+ if (sctrl->cntlid == cntlid) {
+ req->error_loc =
+ offsetof(struct nvme_cross_ctrl_reset_cmd, icid);
+ status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
+ goto out;
+ }
cntlid has to be validated against the configured range of the controller
ids (subsys->cntlid_min <= cntlid <= subsys->cntlid_max).
That will allow CCR to work correctly on a distributed target.
Thanks for the review. nvmet_ctrl_find_get_ccr() below will verify
ictrl->dntlid == cntlid before proceeding with the reset. Is this not
enough?
Adding this check here means if either cntlid_min or cntlid_max change
after ictrl has been created, CCR will fail saying the controller was not
found. Why do we want to CCR to fail in this case when ictrl might
actually be there?
min/max_cntlid).
While logically all cntlids belong to the same subsystem,
technically each node can only reach (and reset!) the cntlids
of controllers local on that node.
With CCR each node can receive a CCR for any cntlid, but it
can handle only those cntlids which are local on the node.
But as we're looking up the actual controller structures
(which are only present if the cntlid is local to the node)
I think we should be good here.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@xxxxxxx +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich