From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8743821B905 for ; Thu, 25 Dec 2025 13:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766668477; cv=none; b=DtaMUP8hHDKWfkQm9GdhWhs8qrF2ARXnbZHSTaTAPK0v/iN/UNiFLjHuNWrVVtoLVm4geiAAYa1gzU7VoAHY+FRTvXFFAHDcLT1cKJ0Cbg/aBCx6/Jv+FmvcKrskoxa610/z7yW+0br0ISbDLZw67A1yB9G6TUcav4NCVIvcT9A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766668477; c=relaxed/simple; bh=fSfYhWS6FOJTMC/cvtiZZo9GHl7KiSjJE0RgcbLL2aA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aWaqxEH/2ci8y3loJnYJL7fAs16obS8NYxObOuHiPFkgR/eAZeiRrzNu76CK0MbiLkOqcyrcqQ/TqQkYJEKghKSetOYcj9nWy7KPXzOXBVacOFLMRghRx6uivzaW2NmkQmcPxLBKOMV9s4J4896cjhmpGgerz16SgshhVOff+YM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-42fb0fc5aa9so2807241f8f.1 for ; Thu, 25 Dec 2025 05:14:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766668474; x=1767273274; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FBgdEXalUb5he9o3+VbaIAmoleCwvYIFnU8MOfTz47A=; b=kHPH5dIctM/N+D9GPyNaRxVjnnOQxvUSjJ5WElj/LgneIeqG9Gd/alHztcqWlMVf8T MpLvfVezrea0vNcm20i5lg47JG8rfFMrj9/rRv9+VXLC0lxG9SyoG66iDqw4TAyMhu6D deHeHfuUTrGcygBlVM+S20466gMuttEM95Wn+8cDi2LDsN06/fJbSaQzzXofKG9BLRGq gyra06kP49KpOqgqF9B1TypVE6iIyGjdk9VP9UhPQow18nH4DVafYPyPGGI5Tl0pKXiS u6j89eidjpju22Ldp3CpccxKjjyfyv8ALtow4oxq3AUwSDX9dw0c5DqSQz2JnQuZdrX4 icmQ== X-Forwarded-Encrypted: i=1; AJvYcCUXwhKVE3C3FAfQXgKR3T5G3dP1snJevgPNq8hTSrVAg8yujKT3gQQ2lsM+ONz+ru9P9JlFKdrw0klHpD4=@vger.kernel.org X-Gm-Message-State: AOJu0YzDKGpxFBQqkldi3ZyV+y7PblvQx9C0uFoxg7B+FYoldKZCkWrO jFHx0m/b71nPxbfpgOVFjN+E2pjTF/w1vBZ/O69DwSyzwzf9jzM2BurQ X-Gm-Gg: AY/fxX7vOT0SXig9f6VcIY/DdB+9s1PFsmue0lRrtvrZdNMtd6/JkGhbWeOTA4z+0pG NFCn8sZqMGrdcUzgJrMy+RysebBv+ep8dRlTKVQ9NZlBnGjtkb14f2C7Lco+olJPl9Aby/+OKc6 XOTt6o/9mDOKf+QoO4J/PjftIq0JnKEUQXjnFErX5IAPetirSUJvQFpUPZTcR4BqkLA9WNq4lq1 eARtRYWYkfhij5gKWhQS89duKHBT4qpD7JYaf8o51NirdtVksk9TG+xyE2836xHbqren3ryPxp1 eN6L2d0SEf/6eHNEzUn7+5Ea02ZhufrKlORdtfeAsJQ5ClDcfs1eZ8EaKewhhkujTA77HtYhRua HFOPIaobSvQSVNhVLiDkTeKifnKkY/k7PSKDsJUKynWdNsD4JS2N8Mji0HybWPjrV79QBneR85g DoJuG0fNcsUMYNaUDwz5VLbVk2Nu7myrgzKaf27Ptp/70Wpw== X-Google-Smtp-Source: AGHT+IG6PCGAIMcz62HJU1GeU/Kc0QPrcysQZWICO22rA4h6DFOn/bv2y/DCv97PA34yS05KXYGOqA== X-Received: by 2002:a05:6000:22c8:b0:430:f6c0:6c47 with SMTP id ffacd0b85a97d-4324e4cbea8mr23733293f8f.21.1766668473706; Thu, 25 Dec 2025 05:14:33 -0800 (PST) Received: from [10.100.102.74] (89-138-78-197.bb.netvision.net.il. [89.138.78.197]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4325b6bfe88sm31933520f8f.19.2025.12.25.05.14.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Dec 2025 05:14:32 -0800 (PST) Message-ID: <3f2c8a9e-2e1c-4cb8-b296-8f61ab16b03a@grimberg.me> Date: Thu, 25 Dec 2025 15:14:31 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 03/14] nvmet: Implement CCR nvme command To: Mohamed Khalfella , Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch Cc: Aaron Dailey , Randy Jennings , John Meneghini , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <20251126021250.2583630-1-mkhalfella@purestorage.com> <20251126021250.2583630-4-mkhalfella@purestorage.com> Content-Language: en-US From: Sagi Grimberg In-Reply-To: <20251126021250.2583630-4-mkhalfella@purestorage.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 26/11/2025 4:11, Mohamed Khalfella wrote: > Defined by TP8028 Rapid Path Failure Recovery, CCR (Cross-Controller > Reset) command is an nvme command the is issued to source controller by > initiator to reset impacted controller. Implement CCR command for linux > nvme target. > > Signed-off-by: Mohamed Khalfella > --- > drivers/nvme/target/admin-cmd.c | 79 +++++++++++++++++++++++++++++++++ > drivers/nvme/target/core.c | 69 ++++++++++++++++++++++++++++ > drivers/nvme/target/nvmet.h | 13 ++++++ > include/linux/nvme.h | 23 ++++++++++ > 4 files changed, 184 insertions(+) > > diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c > index aaceb697e4d2..a55ca010d34f 100644 > --- a/drivers/nvme/target/admin-cmd.c > +++ b/drivers/nvme/target/admin-cmd.c > @@ -376,7 +376,9 @@ 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); > + > } > > static void nvmet_get_cmd_effects_nvm(struct nvme_effects_log *log) > @@ -1615,6 +1617,80 @@ 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, *ctrl = req->sq->ctrl; > + struct nvme_command *cmd = req->cmd; > + struct nvmet_ccr *ccr, *new_ccr; > + int ccr_active, ccr_total; > + u16 cntlid, status = 0; > + > + cntlid = le16_to_cpu(cmd->ccr.icid); > + if (ctrl->cntlid == cntlid) { > + req->error_loc = > + offsetof(struct nvme_cross_ctrl_reset_cmd, icid); > + status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; > + goto out; > + } > + > + ictrl = nvmet_ctrl_find_get_ccr(ctrl->subsys, ctrl->hostnqn, What does the 'i' stand for? > + 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; > + } > + > + new_ccr = kmalloc(sizeof(*ccr), GFP_KERNEL); > + if (!new_ccr) { > + status = NVME_SC_INTERNAL; > + goto out_put_ctrl; > + } Allocating this later when you actually use it would probably simplify error path. > + > + ccr_total = ccr_active = 0; > + mutex_lock(&ctrl->lock); > + list_for_each_entry(ccr, &ctrl->ccrs, entry) { > + if (ccr->ctrl == ictrl) { > + status = NVME_SC_CCR_IN_PROGRESS | NVME_STATUS_DNR; > + goto out_unlock; > + } > + > + ccr_total++; > + if (ccr->ctrl) > + ccr_active++; > + } > + > + if (ccr_active >= NVMF_CCR_LIMIT) { > + status = NVME_SC_CCR_LIMIT_EXCEEDED; > + goto out_unlock; > + } > + if (ccr_total >= NVMF_CCR_PER_PAGE) { > + status = NVME_SC_CCR_LOGPAGE_FULL; > + goto out_unlock; > + } > + > + new_ccr->ciu = cmd->ccr.ciu; > + new_ccr->icid = cntlid; > + new_ccr->ctrl = ictrl; > + list_add_tail(&new_ccr->entry, &ctrl->ccrs); > + mutex_unlock(&ctrl->lock); > + > + nvmet_ctrl_fatal_error(ictrl); Don't you need to wait for it to complete? e.g. flush_work(&ictrl->fatal_err_work); Or is that done async? will need to look downstream...