Skip to content

Commit 044b541

Browse files
longlimsftsmfrench
authored andcommitted
cifs: smbd: Do not schedule work to send immediate packet on every receive
Immediate packets should only be sent to peer when there are new receive credits made available. New credits show up on freeing receive buffer, not on receiving data. Fix this by avoid unnenecessary work schedules. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent f1b7b86 commit 044b541

File tree

2 files changed

+10
-52
lines changed

2 files changed

+10
-52
lines changed

fs/cifs/smbdirect.c

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -380,27 +380,6 @@ static bool process_negotiation_response(
380380
return true;
381381
}
382382

383-
/*
384-
* Check and schedule to send an immediate packet
385-
* This is used to extend credtis to remote peer to keep the transport busy
386-
*/
387-
static void check_and_send_immediate(struct smbd_connection *info)
388-
{
389-
if (info->transport_status != SMBD_CONNECTED)
390-
return;
391-
392-
info->send_immediate = true;
393-
394-
/*
395-
* Promptly send a packet if our peer is running low on receive
396-
* credits
397-
*/
398-
if (atomic_read(&info->receive_credits) <
399-
info->receive_credit_target - 1)
400-
queue_delayed_work(
401-
info->workqueue, &info->send_immediate_work, 0);
402-
}
403-
404383
static void smbd_post_send_credits(struct work_struct *work)
405384
{
406385
int ret = 0;
@@ -450,8 +429,16 @@ static void smbd_post_send_credits(struct work_struct *work)
450429
info->new_credits_offered += ret;
451430
spin_unlock(&info->lock_new_credits_offered);
452431

453-
/* Check if we can post new receive and grant credits to peer */
454-
check_and_send_immediate(info);
432+
/* Promptly send an immediate packet as defined in [MS-SMBD] 3.1.1.1 */
433+
info->send_immediate = true;
434+
if (atomic_read(&info->receive_credits) <
435+
info->receive_credit_target - 1) {
436+
if (info->keep_alive_requested == KEEP_ALIVE_PENDING ||
437+
info->send_immediate) {
438+
log_keep_alive(INFO, "send an empty message\n");
439+
smbd_post_send_empty(info);
440+
}
441+
}
455442
}
456443

457444
/* Called from softirq, when recv is done */
@@ -546,12 +533,6 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
546533
info->keep_alive_requested = KEEP_ALIVE_PENDING;
547534
}
548535

549-
/*
550-
* Check if we need to send something to remote peer to
551-
* grant more credits or respond to KEEP_ALIVE packet
552-
*/
553-
check_and_send_immediate(info);
554-
555536
return;
556537

557538
default:
@@ -1311,25 +1292,6 @@ static void destroy_receive_buffers(struct smbd_connection *info)
13111292
mempool_free(response, info->response_mempool);
13121293
}
13131294

1314-
/*
1315-
* Check and send an immediate or keep alive packet
1316-
* The condition to send those packets are defined in [MS-SMBD] 3.1.1.1
1317-
* Connection.KeepaliveRequested and Connection.SendImmediate
1318-
* The idea is to extend credits to server as soon as it becomes available
1319-
*/
1320-
static void send_immediate_work(struct work_struct *work)
1321-
{
1322-
struct smbd_connection *info = container_of(
1323-
work, struct smbd_connection,
1324-
send_immediate_work.work);
1325-
1326-
if (info->keep_alive_requested == KEEP_ALIVE_PENDING ||
1327-
info->send_immediate) {
1328-
log_keep_alive(INFO, "send an empty message\n");
1329-
smbd_post_send_empty(info);
1330-
}
1331-
}
1332-
13331295
/* Implement idle connection timer [MS-SMBD] 3.1.6.2 */
13341296
static void idle_connection_timer(struct work_struct *work)
13351297
{
@@ -1384,8 +1346,6 @@ void smbd_destroy(struct TCP_Server_Info *server)
13841346

13851347
log_rdma_event(INFO, "cancelling idle timer\n");
13861348
cancel_delayed_work_sync(&info->idle_timer_work);
1387-
log_rdma_event(INFO, "cancelling send immediate work\n");
1388-
cancel_delayed_work_sync(&info->send_immediate_work);
13891349

13901350
log_rdma_event(INFO, "wait for all send posted to IB to finish\n");
13911351
wait_event(info->wait_send_pending,
@@ -1719,7 +1679,6 @@ static struct smbd_connection *_smbd_get_connection(
17191679

17201680
init_waitqueue_head(&info->wait_send_queue);
17211681
INIT_DELAYED_WORK(&info->idle_timer_work, idle_connection_timer);
1722-
INIT_DELAYED_WORK(&info->send_immediate_work, send_immediate_work);
17231682
queue_delayed_work(info->workqueue, &info->idle_timer_work,
17241683
info->keep_alive_interval*HZ);
17251684

fs/cifs/smbdirect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ struct smbd_connection {
153153

154154
struct workqueue_struct *workqueue;
155155
struct delayed_work idle_timer_work;
156-
struct delayed_work send_immediate_work;
157156

158157
/* Memory pool for preallocating buffers */
159158
/* request pool for RDMA send */

0 commit comments

Comments
 (0)