[PATCH v7 03/17] nvmet: Implement CCR nvme command

Dmitry Bogdanov d.bogdanov at yadro.com
Mon Nov 16 00:45:40 PST 2026


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 at purestorage.com>
> Reviewed-by: Hannes Reinecke <hare at suse.de>
> Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
> ---
>  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.

> +
> +       /* Find and get impacted controller */
> +       ictrl = nvmet_ctrl_find_get_ccr(sctrl->subsys, sctrl->hostnqn,
> +                                       cmd->ccr.ciu, cntlid,
> +                                       le64_to_cpu(cmd->ccr.cirn));
> +       if (!ictrl) {
> +               /* Immediate Reset Successful */
> +               nvmet_set_result(req, 1);
> +               status = NVME_SC_SUCCESS;
> +               goto out;
> +       }
> +



More information about the Linux-nvme mailing list