From nobody Tue Dec 16 07:06:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E279A26E15B for ; Wed, 7 May 2025 12:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746620603; cv=none; b=SC8FQBgZGqOeSL0tzO/egUeJBofs/sllyQROVtR30QN0ZgfZLm61R3YH/77loypoqdG2IgKpi8DLD5tje1Bi+Vo8zJ4V+a9qpIReq0B96ogD7tEaashxFGchebqM8+JxV2afuYMbIkU/5ZJo1yJ6eRNw0/ZKDdcaYOsGLUfiMyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746620603; c=relaxed/simple; bh=bWfF/z6J6VjDnFu295fwOKQGsLQiUbigzuCMF8Epxkw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C+TevYkwPB9urWJz/I84mUaK+Dqy6Qt8AHctvrofy05X8xjqVRXB80b2J/TeCNLFHwg17sa2YTzra39FKPd4L86UUBD18nlHjCBr0RWnUf0Ho4jtWYdYReUSIUc5h2lmZxcH8IokQEe0ggOsDyYuPudkzjjnLCq5/ASHxZq1dY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aKocHqCl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aKocHqCl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 545C0C4CEE7; Wed, 7 May 2025 12:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746620602; bh=bWfF/z6J6VjDnFu295fwOKQGsLQiUbigzuCMF8Epxkw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aKocHqCloH3XUjV8KfPLiFtcfK4rgFUtH8psUn+MTLIHKbWMurnP9cM6wzMEkD8z/ 7JFPItaOTQukdfrtMSbHhpMPG9cCTqba+ofjxjETHUAfacHqdp32pDR62UJ8SOwonE tPim3gqH57e7PeGctL/O9hlpyvigibfpVUViStM+RrI9MX8UL9putJwa+k9zjeK1zy XZKdpi0OEL1vnb6A9U+Vd22mR+1vTvFUQmd4Sq7i6D39h4uMOklAnb8dMDp9QuOSYf 9aN9+nwuE8Eg9qyFlR2ejUYLVqThZxUfAP1Nv/3/9ZSk1SqwS3Zp6kabdwiQELqHLW UYAZK7z6+ANow== From: Daniel Wagner Date: Wed, 07 May 2025 14:23:03 +0200 Subject: [PATCH v6 07/14] nvmet-fcloop: access fcpreq only when holding reqlock 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-nvmet-fcloop-v6-7-ca02e16fb018@kernel.org> References: <20250507-nvmet-fcloop-v6-0-ca02e16fb018@kernel.org> In-Reply-To: <20250507-nvmet-fcloop-v6-0-ca02e16fb018@kernel.org> To: James Smart , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: Hannes Reinecke , Keith Busch , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.2 The abort handling logic expects that the state and the fcpreq are only accessed when holding the reqlock lock. While at it, only handle the aborts in the abort handler. Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fcloop.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index 0c0117e03adc81c643e90a7e7832ff087a4c2fd7..9adaee3c7129f7e270842c5d09f= 78de2e108479a 100644 --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -619,12 +619,13 @@ fcloop_fcp_recv_work(struct work_struct *work) { struct fcloop_fcpreq *tfcp_req =3D container_of(work, struct fcloop_fcpreq, fcp_rcv_work); - struct nvmefc_fcp_req *fcpreq =3D tfcp_req->fcpreq; + struct nvmefc_fcp_req *fcpreq; unsigned long flags; int ret =3D 0; bool aborted =3D false; =20 spin_lock_irqsave(&tfcp_req->reqlock, flags); + fcpreq =3D tfcp_req->fcpreq; switch (tfcp_req->inistate) { case INI_IO_START: tfcp_req->inistate =3D INI_IO_ACTIVE; @@ -639,16 +640,19 @@ fcloop_fcp_recv_work(struct work_struct *work) } spin_unlock_irqrestore(&tfcp_req->reqlock, flags); =20 - if (unlikely(aborted)) - ret =3D -ECANCELED; - else { - if (likely(!check_for_drop(tfcp_req))) - ret =3D nvmet_fc_rcv_fcp_req(tfcp_req->tport->targetport, - &tfcp_req->tgt_fcp_req, - fcpreq->cmdaddr, fcpreq->cmdlen); - else - pr_info("%s: dropped command ********\n", __func__); + if (unlikely(aborted)) { + /* the abort handler will call fcloop_call_host_done */ + return; + } + + if (unlikely(check_for_drop(tfcp_req))) { + pr_info("%s: dropped command ********\n", __func__); + return; } + + ret =3D nvmet_fc_rcv_fcp_req(tfcp_req->tport->targetport, + &tfcp_req->tgt_fcp_req, + fcpreq->cmdaddr, fcpreq->cmdlen); if (ret) fcloop_call_host_done(fcpreq, tfcp_req, ret); } @@ -663,9 +667,10 @@ fcloop_fcp_abort_recv_work(struct work_struct *work) unsigned long flags; =20 spin_lock_irqsave(&tfcp_req->reqlock, flags); - fcpreq =3D tfcp_req->fcpreq; switch (tfcp_req->inistate) { case INI_IO_ABORTED: + fcpreq =3D tfcp_req->fcpreq; + tfcp_req->fcpreq =3D NULL; break; case INI_IO_COMPLETED: completed =3D true; @@ -688,10 +693,6 @@ fcloop_fcp_abort_recv_work(struct work_struct *work) nvmet_fc_rcv_fcp_abort(tfcp_req->tport->targetport, &tfcp_req->tgt_fcp_req); =20 - spin_lock_irqsave(&tfcp_req->reqlock, flags); - tfcp_req->fcpreq =3D NULL; - spin_unlock_irqrestore(&tfcp_req->reqlock, flags); - fcloop_call_host_done(fcpreq, tfcp_req, -ECANCELED); /* call_host_done releases reference for abort downcall */ } --=20 2.49.0