Skip to content

Commit b2b0f16

Browse files
javed-hmartinkpetersen
authored andcommitted
scsi: libfc: Avoid invoking response handler twice if ep is already completed
A race condition exists between the response handler getting called because of exchange_mgr_reset() (which clears out all the active XIDs) and the response we get via an interrupt. Sequence of events: rport ba0200: Port timeout, state PLOGI rport ba0200: Port entered PLOGI state from PLOGI state xid 1052: Exchange timer armed : 20000 msecs  xid timer armed here rport ba0200: Received LOGO request while in state PLOGI rport ba0200: Delete port rport ba0200: work event 3 rport ba0200: lld callback ev 3 bnx2fc: rport_event_hdlr: event = 3, port_id = 0xba0200 bnx2fc: ba0200 - rport not created Yet!! /* Here we reset any outstanding exchanges before freeing rport using the exch_mgr_reset() */ xid 1052: Exchange timer canceled /* Here we got two responses for one xid */ xid 1052: invoking resp(), esb 20000000 state 3 xid 1052: invoking resp(), esb 20000000 state 3 xid 1052: fc_rport_plogi_resp() : ep->resp_active 2 xid 1052: fc_rport_plogi_resp() : ep->resp_active 2 Skip the response if the exchange is already completed. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Javed Hasan <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 72eeb7c commit b2b0f16

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/scsi/libfc/fc_exch.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,8 +1623,13 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
16231623
rc = fc_exch_done_locked(ep);
16241624
WARN_ON(fc_seq_exch(sp) != ep);
16251625
spin_unlock_bh(&ep->ex_lock);
1626-
if (!rc)
1626+
if (!rc) {
16271627
fc_exch_delete(ep);
1628+
} else {
1629+
FC_EXCH_DBG(ep, "ep is completed already,"
1630+
"hence skip calling the resp\n");
1631+
goto skip_resp;
1632+
}
16281633
}
16291634

16301635
/*
@@ -1643,6 +1648,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
16431648
if (!fc_invoke_resp(ep, sp, fp))
16441649
fc_frame_free(fp);
16451650

1651+
skip_resp:
16461652
fc_exch_release(ep);
16471653
return;
16481654
rel:
@@ -1899,10 +1905,16 @@ static void fc_exch_reset(struct fc_exch *ep)
18991905

19001906
fc_exch_hold(ep);
19011907

1902-
if (!rc)
1908+
if (!rc) {
19031909
fc_exch_delete(ep);
1910+
} else {
1911+
FC_EXCH_DBG(ep, "ep is completed already,"
1912+
"hence skip calling the resp\n");
1913+
goto skip_resp;
1914+
}
19041915

19051916
fc_invoke_resp(ep, sp, ERR_PTR(-FC_EX_CLOSED));
1917+
skip_resp:
19061918
fc_seq_set_resp(sp, NULL, ep->arg);
19071919
fc_exch_release(ep);
19081920
}

0 commit comments

Comments
 (0)