[PATCH 1/1] nvmet-fcloop: Check remoteport port_state before calling done callback

Aristeu Rozanski aris at redhat.com
Fri Dec 5 06:02:50 PST 2025


On Thu, Dec 04, 2025 at 12:26:13PM -0800, Justin Tee wrote:
> In nvme_fc_handle_ls_rqst_work, the lsrsp->done callback is only set when
> remoteport->port_state is FC_OBJSTATE_ONLINE.  Otherwise, the
> nvme_fc_xmt_ls_rsp's LLDD call to lport->ops->xmt_ls_rsp is expected to
> fail and the nvme-fc transport layer itself will directly call
> nvme_fc_xmt_ls_rsp_free instead of relying on LLDD's done callback to free
> the lsrsp resources.
> 
> Update the fcloop_t2h_xmt_ls_rsp routine to check remoteport->port_state.
> If online, then lsrsp->done callback will free the lsrsp.  Else, return
> -ENODEV to signal the nvme-fc transport to handle freeing lsrsp.
> 
> Cc: Aristeu Rozanski <aris at redhat.com>
> Cc: Daniel Wagner <wagi at kernel.org>
> Cc: Ewan D. Milne <emilne at redhat.com>
> Closes: https://lore.kernel.org/linux-nvme/21255200-a271-4fa0-b099-97755c8acd4c@work/
> Fixes: 10c165af35d2 ("nvmet-fcloop: call done callback even when remote port is gone")
> Signed-off-by: Justin Tee <justintee8345 at gmail.com>
> ---
>  drivers/nvme/target/fcloop.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
> index c30e9a3e014f..38bd2db3d6bb 100644
> --- a/drivers/nvme/target/fcloop.c
> +++ b/drivers/nvme/target/fcloop.c
> @@ -491,6 +491,7 @@ fcloop_t2h_xmt_ls_rsp(struct nvme_fc_local_port *localport,
>  	struct fcloop_rport *rport = remoteport->private;
>  	struct nvmet_fc_target_port *targetport = rport->targetport;
>  	struct fcloop_tport *tport;
> +	int ret = 0;
>  
>  	if (!targetport) {
>  		/*
> @@ -500,12 +501,18 @@ fcloop_t2h_xmt_ls_rsp(struct nvme_fc_local_port *localport,
>  		 * We end up here from delete association exchange:
>  		 * nvmet_fc_xmt_disconnect_assoc sends an async request.
>  		 *
> -		 * Return success because this is what LLDDs do; silently
> -		 * drop the response.
> +		 * Return success when remoteport is still online because this
> +		 * is what LLDDs do and silently drop the response.  Otherwise,
> +		 * return with error to signal upper layer to perform the lsrsp
> +		 * resource cleanup.
>  		 */
> -		lsrsp->done(lsrsp);
> +		if (remoteport->port_state == FC_OBJSTATE_ONLINE)
> +			lsrsp->done(lsrsp);
> +		else
> +			ret = -ENODEV;
> +
>  		kmem_cache_free(lsreq_cache, tls_req);
> -		return 0;
> +		return ret;
>  	}
>  
>  	memcpy(lsreq->rspaddr, lsrsp->rspbuf,

survived overnight here and makes sense to me. Thanks!

Tested-by: Aristeu Rozanski <aris at redhat.com>
Acked-by: Aristeu Rozanski <aris at redhat.com>

-- 
Aristeu




More information about the Linux-nvme mailing list