Skip to content

Commit 4ebb879

Browse files
longlimsftsmfrench
authored andcommitted
cifs: smbd: Check and extend sender credits in interrupt context
When a RDMA packet is received and server is extending send credits, we should check and unblock senders immediately in IRQ context. Doing it in a worker queue causes unnecessary delay and doesn't save much CPU on the receive path. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent f7950cb commit 4ebb879

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

fs/cifs/smbdirect.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -459,25 +459,6 @@ static void smbd_post_send_credits(struct work_struct *work)
459459
check_and_send_immediate(info);
460460
}
461461

462-
static void smbd_recv_done_work(struct work_struct *work)
463-
{
464-
struct smbd_connection *info =
465-
container_of(work, struct smbd_connection, recv_done_work);
466-
467-
/*
468-
* We may have new send credits granted from remote peer
469-
* If any sender is blcoked on lack of credets, unblock it
470-
*/
471-
if (atomic_read(&info->send_credits))
472-
wake_up_interruptible(&info->wait_send_queue);
473-
474-
/*
475-
* Check if we need to send something to remote peer to
476-
* grant more credits or respond to KEEP_ALIVE packet
477-
*/
478-
check_and_send_immediate(info);
479-
}
480-
481462
/* Called from softirq, when recv is done */
482463
static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
483464
{
@@ -546,8 +527,15 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
546527
atomic_dec(&info->receive_credits);
547528
info->receive_credit_target =
548529
le16_to_cpu(data_transfer->credits_requested);
549-
atomic_add(le16_to_cpu(data_transfer->credits_granted),
550-
&info->send_credits);
530+
if (le16_to_cpu(data_transfer->credits_granted)) {
531+
atomic_add(le16_to_cpu(data_transfer->credits_granted),
532+
&info->send_credits);
533+
/*
534+
* We have new send credits granted from remote peer
535+
* If any sender is waiting for credits, unblock it
536+
*/
537+
wake_up_interruptible(&info->wait_send_queue);
538+
}
551539

552540
log_incoming(INFO, "data flags %d data_offset %d "
553541
"data_length %d remaining_data_length %d\n",
@@ -563,7 +551,12 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
563551
info->keep_alive_requested = KEEP_ALIVE_PENDING;
564552
}
565553

566-
queue_work(info->workqueue, &info->recv_done_work);
554+
/*
555+
* Check if we need to send something to remote peer to
556+
* grant more credits or respond to KEEP_ALIVE packet
557+
*/
558+
check_and_send_immediate(info);
559+
567560
return;
568561

569562
default:
@@ -1762,7 +1755,6 @@ static struct smbd_connection *_smbd_get_connection(
17621755
atomic_set(&info->send_payload_pending, 0);
17631756

17641757
INIT_WORK(&info->disconnect_work, smbd_disconnect_rdma_work);
1765-
INIT_WORK(&info->recv_done_work, smbd_recv_done_work);
17661758
INIT_WORK(&info->post_send_credits_work, smbd_post_send_credits);
17671759
info->new_credits_offered = 0;
17681760
spin_lock_init(&info->lock_new_credits_offered);

fs/cifs/smbdirect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ struct smbd_connection {
6767
bool negotiate_done;
6868

6969
struct work_struct disconnect_work;
70-
struct work_struct recv_done_work;
7170
struct work_struct post_send_credits_work;
7271

7372
spinlock_t lock_new_credits_offered;

0 commit comments

Comments
 (0)