From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (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 108E63161A6 for ; Tue, 3 Feb 2026 18:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770144043; cv=none; b=bX2Pz1LcEXg4WEueVolIZmyCum+5p/kzWoP2JPtXxVt7VRXKnPLzDzISuWCPNC7XoEiIczMy28wlPNX7uzRGWyJk+y2wyeKIRztHWUjA8ABnKYYme/0RwXSImDD8PFNK/4WOISfUSbCoqRdjOMhKtn7xzWqJus0E4edUxhOGM4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770144043; c=relaxed/simple; bh=yvD+F24Xn61IqI1ApFSQQW/b1rTe/GX9yzsfE4pZM+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BFfCs2VKZvb5pfEDaExinfvAMtvAf5+c/vaBaSWGb5Bjv2f4A9TEkYZD2roannj2XOhJYRjpLxoBYN7XjwlquQzWowzT/+y3f1K0VeGWnohysAw25KOLCTcFyGaWQNgVGZuKnS3nP058dEhvD/h8wYDTygOeFEMY2Of+qMhHzuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=J3w8Im9K; arc=none smtp.client-ip=74.125.82.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="J3w8Im9K" Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-2b7381d2d95so77796eec.0 for ; Tue, 03 Feb 2026 10:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1770144041; x=1770748841; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mkOMXZ+mhfKPghY6ZSWYtvEZTLv6CxviqMg+Pg3zze0=; b=J3w8Im9Kj32u4t2zvg32Awo16vr8dDfRKM8HOd+4Pnsj6cbQ3RNmOjO3JeShtVxxmp 9VwQ2nuBjKBB+wbDH7zLUFQOHNlfbj0Wk1TmGSz0LGEYGqpkBbeDx2VSqMuVmuVezsTF XWRYlD/FfL/nifpWxFqQVlvBx0d9s48bhQebx03RGk8XL2vf8SftsQAxxdNl8ULpVGnA MMCMMULgtXMMukxpdXN5sT2bZ/kxXZRMpY52zTR7hvTmH495I5l10B+9+kzDHwNX/0ci OpAHXl8XjD4gCDeH1pdVN0NmYivb/y7wg1USAvfeTFco1Pr5KC9zH2eoM9zoO4Wuvad/ j2zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770144041; x=1770748841; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mkOMXZ+mhfKPghY6ZSWYtvEZTLv6CxviqMg+Pg3zze0=; b=Q9F8c6iVCVwZI1/WM7Hqq3+7k6BASQwutnGvaIorL9xTsxY6jRwRWvKV7ngSqB23Up r1+emwYlvbbSOJLNGFvqHGe0LtyACwvmkFYVq/qG9gogQRWB9jHXaNHDOih5/sMU4+C7 Zo8vARussouNMTnNgYTi5g6s5NIJO4meOmxqy1l6x+reJdoS+v/We8/jTNzuQL/tCNYT zX+fbwvCxuFYTJfFpHsf0/hFtsKElKhyYD7B7vmqaruSYPoa3gQm1r4Rg1uNKcJ9z5oH wKYp70AD06mUM9rqui6lKJvnc3qj6CQMDjj6aSf616Y41pKRWjLHVpw45x9+EpQaJLF/ x0ew== X-Forwarded-Encrypted: i=1; AJvYcCXd3/l8Dy+Sil7E20Gq5baazWfxNGf5hc4D42wJ0q1Px5mgEgz1vGTmdBC1eKxmlWl57GlH0SOuzxnWJMk=@vger.kernel.org X-Gm-Message-State: AOJu0YyhtUnP3bjJGr0rALPwCkorHLzogk+HHPQQENp1IqMBpIrdqxgb ERZOdUVVIMtjuUmJAQOR33MmQtozjjnQoTHGRlfM+31vlyIlykj/2jP9sVWeWejjAMU= X-Gm-Gg: AZuq6aLlF3lVrjpOAWeNXOluCjtwVVPfqD3F+T0O5i/OY784imPCbKcFniCpQ2CDJlM z1DQ2N9gkiZCVT8ciwnQsmZXwHe7uFWJWSoTfuH+AHrIdpssxP+AAMb6Ys3+EYCt+QVkbNQtYnw 3Un/ntrfmvdmFwY+5M+joPMz/cyp9dkcmLVlWnuoM+ZXLvW6AATZ1Ru1Tt7SGGAkR6HQXNrveYx aL5+SzdOgu7l2x9hw2QyROE7QCm3vFCwwHwAMXTogXVdsHaZTR/z1yH/P0SRNONLagb359HwKGb jfs/lNjgJpJJVuZBXZ6BjKyH5BwaiQ37Tt1DfYeKe8itD7azJjXpW8zvYKFOYbWRKuRajENaTLu q+q0liYTPKO7+V3X1TswfOpA7gvuQ69KWSeNu7ldwhvHicISJ4QJDYZIafm0V+SMDusosyJYc50 yRpi+66CZnoUVy0dtc/4UXCogL3fPqFwM= X-Received: by 2002:a05:7300:3707:b0:2b6:f13c:8d58 with SMTP id 5a478bee46e88-2b820f69facmr2054379eec.20.1770144040807; Tue, 03 Feb 2026 10:40:40 -0800 (PST) Received: from medusa.lab.kspace.sh ([208.88.152.253]) by smtp.googlemail.com with UTF8SMTPSA id a92af1059eb24-126f4e107b4sm109588c88.7.2026.02.03.10.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 10:40:40 -0800 (PST) Date: Tue, 3 Feb 2026 10:40:39 -0800 From: Mohamed Khalfella To: Hannes Reinecke Cc: Justin Tee , Naresh Gottumukkala , Paul Ely , Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , Aaron Dailey , Randy Jennings , Dhaval Giani , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 03/14] nvmet: Implement CCR nvme command Message-ID: <20260203184039.GB3729-mkhalfella@purestorage.com> References: <20260130223531.2478849-1-mkhalfella@purestorage.com> <20260130223531.2478849-4-mkhalfella@purestorage.com> <77a00fa1-5707-4859-8a7a-e823ca18c9fe@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <77a00fa1-5707-4859-8a7a-e823ca18c9fe@suse.de> On Tue 2026-02-03 04:19:50 +0100, Hannes Reinecke wrote: > On 1/30/26 23:34, Mohamed Khalfella wrote: > > @@ -1501,6 +1516,38 @@ struct nvmet_ctrl *nvmet_ctrl_find_get(const char *subsysnqn, > > return ctrl; > > } > > > > +struct nvmet_ctrl *nvmet_ctrl_find_get_ccr(struct nvmet_subsys *subsys, > > + const char *hostnqn, u8 ciu, > > + u16 cntlid, u64 cirn) > > +{ > > + struct nvmet_ctrl *ctrl; > > + bool found = false; > > + > > + mutex_lock(&subsys->lock); > > + list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) { > > + if (ctrl->cntlid != cntlid) > > + continue; > > + if (strncmp(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE)) > > + continue; > > + > Why do we compare the hostnqn here, too? To my understanding the host > NQN is tied to the controller, so the controller ID should be sufficient > here. We got cntlid from CCR nvme command and we do not trust the value sent by the host. We check hostnqn to confirm that host is actually connected to the impacted controller. A host should not be allowed to reset a controller connected to another host. > > @@ -1740,12 +1788,35 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args) > > } > > EXPORT_SYMBOL_GPL(nvmet_alloc_ctrl); > > > > +static void nvmet_ctrl_complete_pending_ccr(struct nvmet_ctrl *ctrl) > > +{ > > + struct nvmet_subsys *subsys = ctrl->subsys; > > + struct nvmet_ctrl *sctrl; > > + struct nvmet_ccr *ccr; > > + > > + mutex_lock(&ctrl->lock); > > + nvmet_ctrl_cleanup_ccrs(ctrl, true); > > + mutex_unlock(&ctrl->lock); > > + > > + list_for_each_entry(sctrl, &subsys->ctrls, subsys_entry) { > > + mutex_lock(&sctrl->lock); > > + list_for_each_entry(ccr, &sctrl->ccr_list, entry) { > > + if (ccr->ctrl == ctrl) { > > + ccr->ctrl = NULL; > > + break; > > + } > > + } > > + mutex_unlock(&sctrl->lock); > > + } > > +} > > + > > Maybe add documentation here that the first CCR cleanup is for clearing > CCRs issued from this controller, and the second is for CCRs issued _to_ > this controller. > Good point. Will do that.