Skip to content

Commit 90cee52

Browse files
Dust Lidavem330
authored andcommitted
net/smc: don't send CDC/LLC message if link not ready
We found smc_llc_send_link_delete_all() sometimes wait for 2s timeout when testing with RDMA link up/down. It is possible when a smc_link is in ACTIVATING state, the underlaying QP is still in RESET or RTR state, which cannot send any messages out. smc_llc_send_link_delete_all() use smc_link_usable() to checks whether the link is usable, if the QP is still in RESET or RTR state, but the smc_link is in ACTIVATING, this LLC message will always fail without any CQE entering the CQ, and we will always wait 2s before timeout. Since we cannot send any messages through the QP before the QP enter RTS. I add a wrapper smc_link_sendable() which checks the state of QP along with the link state. And replace smc_link_usable() with smc_link_sendable() in all LLC & CDC message sending routine. Fixes: 5f08318 ("smc: connection data control (CDC)") Signed-off-by: Dust Li <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1b9dadb commit 90cee52

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

net/smc/smc_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static void smcr_lgr_link_deactivate_all(struct smc_link_group *lgr)
647647
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
648648
struct smc_link *lnk = &lgr->lnk[i];
649649

650-
if (smc_link_usable(lnk))
650+
if (smc_link_sendable(lnk))
651651
lnk->state = SMC_LNK_INACTIVE;
652652
}
653653
wake_up_all(&lgr->llc_msg_waiter);

net/smc/smc_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ static inline bool smc_link_usable(struct smc_link *lnk)
415415
return true;
416416
}
417417

418+
static inline bool smc_link_sendable(struct smc_link *lnk)
419+
{
420+
return smc_link_usable(lnk) &&
421+
lnk->qp_attr.cur_qp_state == IB_QPS_RTS;
422+
}
423+
418424
static inline bool smc_link_active(struct smc_link *lnk)
419425
{
420426
return lnk->state == SMC_LNK_ACTIVE;

net/smc/smc_llc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ void smc_llc_send_link_delete_all(struct smc_link_group *lgr, bool ord, u32 rsn)
16301630
delllc.reason = htonl(rsn);
16311631

16321632
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
1633-
if (!smc_link_usable(&lgr->lnk[i]))
1633+
if (!smc_link_sendable(&lgr->lnk[i]))
16341634
continue;
16351635
if (!smc_llc_send_message_wait(&lgr->lnk[i], &delllc))
16361636
break;

net/smc/smc_wr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void smc_wr_tx_cq_handler(struct ib_cq *ib_cq, void *cq_context)
188188
static inline int smc_wr_tx_get_free_slot_index(struct smc_link *link, u32 *idx)
189189
{
190190
*idx = link->wr_tx_cnt;
191-
if (!smc_link_usable(link))
191+
if (!smc_link_sendable(link))
192192
return -ENOLINK;
193193
for_each_clear_bit(*idx, link->wr_tx_mask, link->wr_tx_cnt) {
194194
if (!test_and_set_bit(*idx, link->wr_tx_mask))
@@ -231,7 +231,7 @@ int smc_wr_tx_get_free_slot(struct smc_link *link,
231231
} else {
232232
rc = wait_event_interruptible_timeout(
233233
link->wr_tx_wait,
234-
!smc_link_usable(link) ||
234+
!smc_link_sendable(link) ||
235235
lgr->terminating ||
236236
(smc_wr_tx_get_free_slot_index(link, &idx) != -EBUSY),
237237
SMC_WR_TX_WAIT_FREE_SLOT_TIME);

net/smc/smc_wr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static inline void smc_wr_tx_set_wr_id(atomic_long_t *wr_tx_id, long val)
6262

6363
static inline bool smc_wr_tx_link_hold(struct smc_link *link)
6464
{
65-
if (!smc_link_usable(link))
65+
if (!smc_link_sendable(link))
6666
return false;
6767
atomic_inc(&link->wr_tx_refcnt);
6868
return true;

0 commit comments

Comments
 (0)