Skip to content

Commit f95b35c

Browse files
bvanasscheRobert Love
authored andcommitted
libfc: Reduce exchange lock contention in fc_exch_recv_abts()
Reduce the time during which the exchange lock is held by allocating a frame before obtaining the exchange lock. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Cc: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Robert Love <robert.w.love@intel.com>
1 parent cae7b6d commit f95b35c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

drivers/scsi/libfc/fc_exch.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,22 +1307,23 @@ static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp)
13071307

13081308
if (!ep)
13091309
goto reject;
1310+
1311+
fp = fc_frame_alloc(ep->lp, sizeof(*ap));
1312+
if (!fp)
1313+
goto free;
1314+
13101315
spin_lock_bh(&ep->ex_lock);
13111316
if (ep->esb_stat & ESB_ST_COMPLETE) {
13121317
spin_unlock_bh(&ep->ex_lock);
1318+
1319+
fc_frame_free(fp);
13131320
goto reject;
13141321
}
13151322
if (!(ep->esb_stat & ESB_ST_REC_QUAL)) {
13161323
ep->esb_stat |= ESB_ST_REC_QUAL;
13171324
fc_exch_hold(ep); /* hold for REC_QUAL */
13181325
}
13191326
fc_exch_timer_set_locked(ep, ep->r_a_tov);
1320-
1321-
fp = fc_frame_alloc(ep->lp, sizeof(*ap));
1322-
if (!fp) {
1323-
spin_unlock_bh(&ep->ex_lock);
1324-
goto free;
1325-
}
13261327
fh = fc_frame_header_get(fp);
13271328
ap = fc_frame_payload_get(fp, sizeof(*ap));
13281329
memset(ap, 0, sizeof(*ap));
@@ -1338,13 +1339,14 @@ static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp)
13381339
fc_seq_send_last(sp, fp, FC_RCTL_BA_ACC, FC_TYPE_BLS);
13391340
ep->esb_stat |= ESB_ST_ABNORMAL;
13401341
spin_unlock_bh(&ep->ex_lock);
1342+
1343+
free:
13411344
fc_frame_free(rx_fp);
13421345
return;
13431346

13441347
reject:
13451348
fc_exch_send_ba_rjt(rx_fp, FC_BA_RJT_UNABLE, FC_BA_RJT_INV_XID);
1346-
free:
1347-
fc_frame_free(rx_fp);
1349+
goto free;
13481350
}
13491351

13501352
/**

0 commit comments

Comments
 (0)