Skip to content

Commit 4dc536a

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of smbdirect_socket.idle.{keepalive,immediate_work,timer_work}
This will allow client and server to use the common structures in order to share common functions later. 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 ac31755 commit 4dc536a

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

fs/smb/client/smbdirect.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ 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);
177-
disable_delayed_work(&info->idle_timer_work);
176+
disable_work(&sc->idle.immediate_work);
177+
disable_delayed_work(&sc->idle.timer_work);
178178

179179
switch (sc->status) {
180180
case SMBDIRECT_SOCKET_NEGOTIATE_NEEDED:
@@ -571,7 +571,7 @@ static void smbd_post_send_credits(struct work_struct *work)
571571
if (atomic_read(&sc->recv_io.credits.count) <
572572
sc->recv_io.credits.target - 1) {
573573
log_keep_alive(INFO, "schedule send of an empty message\n");
574-
queue_work(info->workqueue, &info->send_immediate_work);
574+
queue_work(info->workqueue, &sc->idle.immediate_work);
575575
}
576576
}
577577

@@ -614,8 +614,8 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
614614
* Reset timer to the keepalive interval in
615615
* order to trigger our next keepalive message.
616616
*/
617-
info->keep_alive_requested = KEEP_ALIVE_NONE;
618-
mod_delayed_work(info->workqueue, &info->idle_timer_work,
617+
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_NONE;
618+
mod_delayed_work(info->workqueue, &sc->idle.timer_work,
619619
msecs_to_jiffies(sp->keepalive_interval_msec));
620620

621621
switch (sc->recv_io.expected) {
@@ -696,7 +696,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
696696
if (le16_to_cpu(data_transfer->flags) &
697697
SMBDIRECT_FLAG_RESPONSE_REQUESTED) {
698698
log_keep_alive(INFO, "schedule send of immediate response\n");
699-
queue_work(info->workqueue, &info->send_immediate_work);
699+
queue_work(info->workqueue, &sc->idle.immediate_work);
700700
}
701701

702702
/*
@@ -998,13 +998,13 @@ static int manage_keep_alive_before_sending(struct smbd_connection *info)
998998
struct smbdirect_socket *sc = &info->socket;
999999
struct smbdirect_socket_parameters *sp = &sc->parameters;
10001000

1001-
if (info->keep_alive_requested == KEEP_ALIVE_PENDING) {
1002-
info->keep_alive_requested = KEEP_ALIVE_SENT;
1001+
if (sc->idle.keepalive == SMBDIRECT_KEEPALIVE_PENDING) {
1002+
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_SENT;
10031003
/*
10041004
* Now use the keepalive timeout (instead of keepalive interval)
10051005
* in order to wait for a response
10061006
*/
1007-
mod_delayed_work(info->workqueue, &info->idle_timer_work,
1007+
mod_delayed_work(info->workqueue, &sc->idle.timer_work,
10081008
msecs_to_jiffies(sp->keepalive_timeout_msec));
10091009
return 1;
10101010
}
@@ -1471,9 +1471,10 @@ static void destroy_receive_buffers(struct smbd_connection *info)
14711471

14721472
static void send_immediate_empty_message(struct work_struct *work)
14731473
{
1474+
struct smbdirect_socket *sc =
1475+
container_of(work, struct smbdirect_socket, idle.immediate_work);
14741476
struct smbd_connection *info =
1475-
container_of(work, struct smbd_connection, send_immediate_work);
1476-
struct smbdirect_socket *sc = &info->socket;
1477+
container_of(sc, struct smbd_connection, socket);
14771478

14781479
if (sc->status != SMBDIRECT_SOCKET_CONNECTED)
14791480
return;
@@ -1485,16 +1486,16 @@ static void send_immediate_empty_message(struct work_struct *work)
14851486
/* Implement idle connection timer [MS-SMBD] 3.1.6.2 */
14861487
static void idle_connection_timer(struct work_struct *work)
14871488
{
1488-
struct smbd_connection *info = container_of(
1489-
work, struct smbd_connection,
1490-
idle_timer_work.work);
1491-
struct smbdirect_socket *sc = &info->socket;
1489+
struct smbdirect_socket *sc =
1490+
container_of(work, struct smbdirect_socket, idle.timer_work.work);
14921491
struct smbdirect_socket_parameters *sp = &sc->parameters;
1492+
struct smbd_connection *info =
1493+
container_of(sc, struct smbd_connection, socket);
14931494

1494-
if (info->keep_alive_requested != KEEP_ALIVE_NONE) {
1495+
if (sc->idle.keepalive != SMBDIRECT_KEEPALIVE_NONE) {
14951496
log_keep_alive(ERR,
1496-
"error status info->keep_alive_requested=%d\n",
1497-
info->keep_alive_requested);
1497+
"error status sc->idle.keepalive=%d\n",
1498+
sc->idle.keepalive);
14981499
smbd_disconnect_rdma_connection(info);
14991500
return;
15001501
}
@@ -1506,11 +1507,11 @@ static void idle_connection_timer(struct work_struct *work)
15061507
* Now use the keepalive timeout (instead of keepalive interval)
15071508
* in order to wait for a response
15081509
*/
1509-
info->keep_alive_requested = KEEP_ALIVE_PENDING;
1510-
mod_delayed_work(info->workqueue, &info->idle_timer_work,
1510+
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
1511+
mod_delayed_work(info->workqueue, &sc->idle.timer_work,
15111512
msecs_to_jiffies(sp->keepalive_timeout_msec));
15121513
log_keep_alive(INFO, "schedule send of empty idle message\n");
1513-
queue_work(info->workqueue, &info->send_immediate_work);
1514+
queue_work(info->workqueue, &sc->idle.immediate_work);
15141515
}
15151516

15161517
/*
@@ -1552,9 +1553,9 @@ void smbd_destroy(struct TCP_Server_Info *server)
15521553
sc->ib.qp = NULL;
15531554

15541555
log_rdma_event(INFO, "cancelling idle timer\n");
1555-
disable_delayed_work_sync(&info->idle_timer_work);
1556+
disable_delayed_work_sync(&sc->idle.timer_work);
15561557
log_rdma_event(INFO, "cancelling send immediate work\n");
1557-
disable_work_sync(&info->send_immediate_work);
1558+
disable_work_sync(&sc->idle.immediate_work);
15581559

15591560
/* It's not possible for upper layer to get to reassembly */
15601561
log_rdma_event(INFO, "drain the reassembly queue\n");
@@ -1898,14 +1899,14 @@ static struct smbd_connection *_smbd_get_connection(
18981899
goto allocate_cache_failed;
18991900
}
19001901

1901-
INIT_WORK(&info->send_immediate_work, send_immediate_empty_message);
1902-
INIT_DELAYED_WORK(&info->idle_timer_work, idle_connection_timer);
1902+
INIT_WORK(&sc->idle.immediate_work, send_immediate_empty_message);
1903+
INIT_DELAYED_WORK(&sc->idle.timer_work, idle_connection_timer);
19031904
/*
1904-
* start with the negotiate timeout and KEEP_ALIVE_PENDING
1905+
* start with the negotiate timeout and SMBDIRECT_KEEPALIVE_PENDING
19051906
* so that the timer will cause a disconnect.
19061907
*/
1907-
info->keep_alive_requested = KEEP_ALIVE_PENDING;
1908-
mod_delayed_work(info->workqueue, &info->idle_timer_work,
1908+
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
1909+
mod_delayed_work(info->workqueue, &sc->idle.timer_work,
19091910
msecs_to_jiffies(sp->negotiate_timeout_msec));
19101911

19111912
INIT_WORK(&sc->recv_io.posted.refill_work, smbd_post_send_credits);
@@ -1931,7 +1932,7 @@ static struct smbd_connection *_smbd_get_connection(
19311932
return NULL;
19321933

19331934
negotiation_failed:
1934-
disable_delayed_work_sync(&info->idle_timer_work);
1935+
disable_delayed_work_sync(&sc->idle.timer_work);
19351936
destroy_caches_and_workqueue(info);
19361937
sc->status = SMBDIRECT_SOCKET_NEGOTIATE_FAILED;
19371938
rdma_disconnect(sc->rdma.cm_id);

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ extern int smbd_max_send_size;
2727
extern int smbd_send_credit_target;
2828
extern int smbd_receive_credit_max;
2929

30-
enum keep_alive_status {
31-
KEEP_ALIVE_NONE,
32-
KEEP_ALIVE_PENDING,
33-
KEEP_ALIVE_SENT,
34-
};
35-
3630
/*
3731
* The context for the SMBDirect transport
3832
* Everything related to the transport is here. It has several logical parts
@@ -46,7 +40,6 @@ struct smbd_connection {
4640
struct smbdirect_socket socket;
4741

4842
/* dynamic connection parameters defined in [MS-SMBD] 3.1.1.1 */
49-
enum keep_alive_status keep_alive_requested;
5043
int protocol;
5144

5245
/* Memory registrations */
@@ -71,8 +64,6 @@ struct smbd_connection {
7164
wait_queue_head_t wait_for_mr_cleanup;
7265

7366
struct workqueue_struct *workqueue;
74-
struct work_struct send_immediate_work;
75-
struct delayed_work idle_timer_work;
7667

7768
/* for debug purposes */
7869
unsigned int count_get_receive_buffer;

0 commit comments

Comments
 (0)