Skip to content

Commit e4ce1fc

Browse files
metze-sambasmfrench
authored andcommitted
smb: smbdirect: prepare use of dedicated workqueues for different steps
This is a preparation in order to have global workqueues in the smbdirect module instead of having the caller to provide one. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 00ac2a4 commit e4ce1fc

5 files changed

Lines changed: 33 additions & 21 deletions

File tree

fs/smb/common/smbdirect/smbdirect_accept.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
139139
*/
140140
INIT_DELAYED_WORK(&sc->idle.timer_work, smbdirect_connection_idle_timer_work);
141141
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
142-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
142+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
143143
msecs_to_jiffies(sp->negotiate_timeout_msec));
144144

145145
return 0;
@@ -272,7 +272,7 @@ static void smbdirect_accept_negotiate_recv_done(struct ib_cq *cq, struct ib_wc
272272
if (!sc->first_error) {
273273
INIT_WORK(&sc->connect.work, smbdirect_accept_negotiate_recv_work);
274274
if (sc->status == SMBDIRECT_SOCKET_NEGOTIATE_NEEDED)
275-
queue_work(sc->workqueue, &sc->connect.work);
275+
queue_work(sc->workqueues.accept, &sc->connect.work);
276276
}
277277
spin_unlock_irqrestore(&sc->connect.lock, flags);
278278

@@ -317,7 +317,7 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)
317317
* order to trigger our next keepalive message.
318318
*/
319319
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_NONE;
320-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
320+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
321321
msecs_to_jiffies(sp->keepalive_interval_msec));
322322

323323
/*
@@ -751,7 +751,7 @@ static int smbdirect_accept_rdma_event_handler(struct rdma_cm_id *id,
751751
sc->status = SMBDIRECT_SOCKET_NEGOTIATE_NEEDED;
752752
spin_lock_irqsave(&sc->connect.lock, flags);
753753
if (!sc->first_error)
754-
queue_work(sc->workqueue, &sc->connect.work);
754+
queue_work(sc->workqueues.accept, &sc->connect.work);
755755
spin_unlock_irqrestore(&sc->connect.lock, flags);
756756

757757
/*

fs/smb/common/smbdirect/smbdirect_connect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static int smbdirect_connect_rdma_connect(struct smbdirect_socket *sc)
234234
*/
235235
INIT_DELAYED_WORK(&sc->idle.timer_work, smbdirect_connection_idle_timer_work);
236236
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
237-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
237+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
238238
msecs_to_jiffies(sp->rdma_connect_timeout_msec));
239239

240240
return 0;
@@ -511,7 +511,7 @@ static int smbdirect_connect_negotiate_start(struct smbdirect_socket *sc)
511511
* so that the timer will cause a disconnect.
512512
*/
513513
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
514-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
514+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
515515
msecs_to_jiffies(sp->negotiate_timeout_msec));
516516

517517
return 0;
@@ -632,7 +632,7 @@ static void smbdirect_connect_negotiate_recv_done(struct ib_cq *cq, struct ib_wc
632632
if (!sc->first_error) {
633633
INIT_WORK(&sc->connect.work, smbdirect_connect_negotiate_recv_work);
634634
if (sc->status == SMBDIRECT_SOCKET_NEGOTIATE_RUNNING)
635-
queue_work(sc->workqueue, &sc->connect.work);
635+
queue_work(sc->workqueues.connect, &sc->connect.work);
636636
}
637637
spin_unlock_irqrestore(&sc->connect.lock, flags);
638638

@@ -680,7 +680,7 @@ static void smbdirect_connect_negotiate_recv_work(struct work_struct *work)
680680
* order to trigger our next keepalive message.
681681
*/
682682
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_NONE;
683-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
683+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
684684
msecs_to_jiffies(sp->keepalive_interval_msec));
685685

686686
/*

fs/smb/common/smbdirect/smbdirect_connection.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ void smbdirect_connection_put_recv_io(struct smbdirect_recv_io *msg)
614614
sc->statistics.put_receive_buffer++;
615615
spin_unlock_irqrestore(&sc->recv_io.free.lock, flags);
616616

617-
queue_work(sc->workqueue, &sc->recv_io.posted.refill_work);
617+
queue_work(sc->workqueues.refill, &sc->recv_io.posted.refill_work);
618618
}
619619

620620
__SMBDIRECT_PRIVATE__
@@ -822,11 +822,11 @@ void smbdirect_connection_idle_timer_work(struct work_struct *work)
822822
* in order to wait for a response
823823
*/
824824
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
825-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
825+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
826826
msecs_to_jiffies(sp->keepalive_timeout_msec));
827827
smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_INFO,
828828
"schedule send of empty idle message\n");
829-
queue_work(sc->workqueue, &sc->idle.immediate_work);
829+
queue_work(sc->workqueues.immediate, &sc->idle.immediate_work);
830830
}
831831

832832
__SMBDIRECT_PRIVATE__
@@ -878,7 +878,7 @@ static bool smbdirect_connection_request_keep_alive(struct smbdirect_socket *sc)
878878
* Now use the keepalive timeout (instead of keepalive interval)
879879
* in order to wait for a response
880880
*/
881-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
881+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
882882
msecs_to_jiffies(sp->keepalive_timeout_msec));
883883
return true;
884884
}
@@ -1167,7 +1167,7 @@ int smbdirect_connection_send_single_iter(struct smbdirect_socket *sc,
11671167
* get some new recv credits we can grant to
11681168
* the peer.
11691169
*/
1170-
queue_work(sc->workqueue, &sc->recv_io.posted.refill_work);
1170+
queue_work(sc->workqueues.refill, &sc->recv_io.posted.refill_work);
11711171

11721172
/*
11731173
* wait until either the refill work or the peer
@@ -1568,7 +1568,7 @@ void smbdirect_connection_recv_io_done(struct ib_cq *cq, struct ib_wc *wc)
15681568
* order to trigger our next keepalive message.
15691569
*/
15701570
sc->idle.keepalive = SMBDIRECT_KEEPALIVE_NONE;
1571-
mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
1571+
mod_delayed_work(sc->workqueues.idle, &sc->idle.timer_work,
15721572
msecs_to_jiffies(sp->keepalive_interval_msec));
15731573

15741574
ib_dma_sync_single_for_cpu(sc->ib.dev,
@@ -1673,7 +1673,7 @@ void smbdirect_connection_recv_io_done(struct ib_cq *cq, struct ib_wc *wc)
16731673
if (flags & SMBDIRECT_FLAG_RESPONSE_REQUESTED) {
16741674
smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_INFO,
16751675
"schedule send of immediate response\n");
1676-
queue_work(sc->workqueue, &sc->idle.immediate_work);
1676+
queue_work(sc->workqueues.immediate, &sc->idle.immediate_work);
16771677
}
16781678

16791679
/*
@@ -1683,7 +1683,7 @@ void smbdirect_connection_recv_io_done(struct ib_cq *cq, struct ib_wc *wc)
16831683
if (data_length) {
16841684
if (current_recv_credits <= (sc->recv_io.credits.target / 4) ||
16851685
sc->recv_io.credits.target > old_recv_credit_target)
1686-
queue_work(sc->workqueue, &sc->recv_io.posted.refill_work);
1686+
queue_work(sc->workqueues.refill, &sc->recv_io.posted.refill_work);
16871687

16881688
smbdirect_connection_reassembly_append_recv_io(sc, recv_io, data_length);
16891689
wake_up(&sc->recv_io.reassembly.wait_queue);
@@ -1814,7 +1814,7 @@ static void smbdirect_connection_recv_io_refill_work(struct work_struct *work)
18141814
if (posted > 0) {
18151815
smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_INFO,
18161816
"schedule send of an empty message\n");
1817-
queue_work(sc->workqueue, &sc->idle.immediate_work);
1817+
queue_work(sc->workqueues.immediate, &sc->idle.immediate_work);
18181818
}
18191819
}
18201820

fs/smb/common/smbdirect/smbdirect_socket.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,12 @@ int smbdirect_socket_set_custom_workqueue(struct smbdirect_socket *sc,
242242
/*
243243
* Remember the callers workqueue
244244
*/
245-
sc->workqueue = workqueue;
245+
sc->workqueues.accept = workqueue;
246+
sc->workqueues.connect = workqueue;
247+
sc->workqueues.idle = workqueue;
248+
sc->workqueues.refill = workqueue;
249+
sc->workqueues.immediate = workqueue;
250+
sc->workqueues.cleanup = workqueue;
246251

247252
return 0;
248253
}
@@ -419,7 +424,7 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,
419424
*/
420425
smbdirect_socket_wake_up_all(sc);
421426

422-
queue_work(sc->workqueue, &sc->disconnect_work);
427+
queue_work(sc->workqueues.cleanup, &sc->disconnect_work);
423428
}
424429

425430
static void smbdirect_socket_cleanup_work(struct work_struct *work)

fs/smb/common/smbdirect/smbdirect_socket.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,19 @@ struct smbdirect_socket {
109109
int first_error;
110110

111111
/*
112-
* This points to the workqueue to
112+
* This points to the workqueues to
113113
* be used for this socket.
114114
* It can be per socket (on the client)
115115
* or point to a global workqueue (on the server)
116116
*/
117-
struct workqueue_struct *workqueue;
117+
struct {
118+
struct workqueue_struct *accept;
119+
struct workqueue_struct *connect;
120+
struct workqueue_struct *idle;
121+
struct workqueue_struct *refill;
122+
struct workqueue_struct *immediate;
123+
struct workqueue_struct *cleanup;
124+
} workqueues;
118125

119126
struct work_struct disconnect_work;
120127

0 commit comments

Comments
 (0)