Skip to content

Commit f30b951

Browse files
Justin TeeSasha Levin
authored andcommitted
nvmet-fcloop: Check remoteport port_state before calling done callback
[ Upstream commit dd677d0 ] 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: Ewan D. Milne <emilne@redhat.com> Tested-by: Aristeu Rozanski <aris@redhat.com> Acked-by: Aristeu Rozanski <aris@redhat.com> Reviewed-by: Daniel Wagner <dwagner@suse.de> Closes: https://lore.kernel.org/linux-nvme/21255200-a271-4fa0-b099-97755c8acd4c@work/ Fixes: 10c165a ("nvmet-fcloop: call done callback even when remote port is gone") Signed-off-by: Justin Tee <justintee8345@gmail.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 72d08d2 commit f30b951

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

drivers/nvme/target/fcloop.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ fcloop_t2h_xmt_ls_rsp(struct nvme_fc_local_port *localport,
492492
struct fcloop_rport *rport = remoteport->private;
493493
struct nvmet_fc_target_port *targetport = rport->targetport;
494494
struct fcloop_tport *tport;
495+
int ret = 0;
495496

496497
if (!targetport) {
497498
/*
@@ -501,12 +502,18 @@ fcloop_t2h_xmt_ls_rsp(struct nvme_fc_local_port *localport,
501502
* We end up here from delete association exchange:
502503
* nvmet_fc_xmt_disconnect_assoc sends an async request.
503504
*
504-
* Return success because this is what LLDDs do; silently
505-
* drop the response.
505+
* Return success when remoteport is still online because this
506+
* is what LLDDs do and silently drop the response. Otherwise,
507+
* return with error to signal upper layer to perform the lsrsp
508+
* resource cleanup.
506509
*/
507-
lsrsp->done(lsrsp);
510+
if (remoteport->port_state == FC_OBJSTATE_ONLINE)
511+
lsrsp->done(lsrsp);
512+
else
513+
ret = -ENODEV;
514+
508515
kmem_cache_free(lsreq_cache, tls_req);
509-
return 0;
516+
return ret;
510517
}
511518

512519
memcpy(lsreq->rspaddr, lsrsp->rspbuf,

0 commit comments

Comments
 (0)