Skip to content

Commit 1b2c46c

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: send empty packets via send_immediate_work
This is what the server already does and it makes refactoring for common structures and functions much easier. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent ea5a4e3 commit 1b2c46c

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

fs/smb/client/smbdirect.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static void smbd_disconnect_rdma_work(struct work_struct *work)
173173
disable_work(&sc->disconnect_work);
174174
disable_work(&sc->recv_io.posted.refill_work);
175175
disable_work(&info->mr_recovery_work);
176+
disable_work(&info->send_immediate_work);
176177
disable_delayed_work(&info->idle_timer_work);
177178

178179
switch (sc->status) {
@@ -569,8 +570,8 @@ static void smbd_post_send_credits(struct work_struct *work)
569570
/* Promptly send an immediate packet as defined in [MS-SMBD] 3.1.1.1 */
570571
if (atomic_read(&sc->recv_io.credits.count) <
571572
sc->recv_io.credits.target - 1) {
572-
log_keep_alive(INFO, "send an empty message\n");
573-
smbd_post_send_empty(info);
573+
log_keep_alive(INFO, "schedule send of an empty message\n");
574+
queue_work(info->workqueue, &info->send_immediate_work);
574575
}
575576
}
576577

@@ -1455,6 +1456,19 @@ static void destroy_receive_buffers(struct smbd_connection *info)
14551456
mempool_free(response, sc->recv_io.mem.pool);
14561457
}
14571458

1459+
static void send_immediate_empty_message(struct work_struct *work)
1460+
{
1461+
struct smbd_connection *info =
1462+
container_of(work, struct smbd_connection, send_immediate_work);
1463+
struct smbdirect_socket *sc = &info->socket;
1464+
1465+
if (sc->status != SMBDIRECT_SOCKET_CONNECTED)
1466+
return;
1467+
1468+
log_keep_alive(INFO, "send an empty message\n");
1469+
smbd_post_send_empty(info);
1470+
}
1471+
14581472
/* Implement idle connection timer [MS-SMBD] 3.1.6.2 */
14591473
static void idle_connection_timer(struct work_struct *work)
14601474
{
@@ -1472,8 +1486,8 @@ static void idle_connection_timer(struct work_struct *work)
14721486
return;
14731487
}
14741488

1475-
log_keep_alive(INFO, "about to send an empty idle message\n");
1476-
smbd_post_send_empty(info);
1489+
log_keep_alive(INFO, "schedule send of empty idle message\n");
1490+
queue_work(info->workqueue, &info->send_immediate_work);
14771491

14781492
/* Setup the next idle timeout work */
14791493
queue_delayed_work(info->workqueue, &info->idle_timer_work,
@@ -1520,6 +1534,8 @@ void smbd_destroy(struct TCP_Server_Info *server)
15201534

15211535
log_rdma_event(INFO, "cancelling idle timer\n");
15221536
disable_delayed_work_sync(&info->idle_timer_work);
1537+
log_rdma_event(INFO, "cancelling send immediate work\n");
1538+
disable_work_sync(&info->send_immediate_work);
15231539

15241540
/* It's not possible for upper layer to get to reassembly */
15251541
log_rdma_event(INFO, "drain the reassembly queue\n");
@@ -1863,6 +1879,7 @@ static struct smbd_connection *_smbd_get_connection(
18631879
goto allocate_cache_failed;
18641880
}
18651881

1882+
INIT_WORK(&info->send_immediate_work, send_immediate_empty_message);
18661883
INIT_DELAYED_WORK(&info->idle_timer_work, idle_connection_timer);
18671884
queue_delayed_work(info->workqueue, &info->idle_timer_work,
18681885
msecs_to_jiffies(sp->keepalive_interval_msec));

fs/smb/client/smbdirect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct smbd_connection {
7171
wait_queue_head_t wait_for_mr_cleanup;
7272

7373
struct workqueue_struct *workqueue;
74+
struct work_struct send_immediate_work;
7475
struct delayed_work idle_timer_work;
7576

7677
/* for debug purposes */

0 commit comments

Comments
 (0)