Skip to content

Commit ca48841

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of smbdirect_socket.send_io.pending.{count,{dec,zero}_wait_queue}
This will be used by the server too and will allow to create common helper functions. 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 a51c67d commit ca48841

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
497497
atomic_read(&server->smbd_conn->receive_credits),
498498
server->smbd_conn->receive_credit_target);
499499
seq_printf(m, "\nPending send_pending: %u ",
500-
atomic_read(&server->smbd_conn->send_pending));
500+
atomic_read(&sc->send_io.pending.count));
501501
seq_printf(m, "\nReceive buffers count_receive_queue: %u ",
502502
server->smbd_conn->count_receive_queue);
503503
seq_printf(m, "\nMR responder_resources: %u "

fs/smb/client/smbdirect.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,10 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
418418
return;
419419
}
420420

421-
if (atomic_dec_and_test(&info->send_pending))
422-
wake_up(&info->wait_send_pending);
421+
if (atomic_dec_and_test(&sc->send_io.pending.count))
422+
wake_up(&sc->send_io.pending.zero_wait_queue);
423423

424-
wake_up(&info->wait_post_send);
424+
wake_up(&sc->send_io.pending.dec_wait_queue);
425425

426426
mempool_free(request, sc->send_io.mem.pool);
427427
}
@@ -908,14 +908,14 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
908908
request->sge[0].addr,
909909
request->sge[0].length, request->sge[0].lkey);
910910

911-
atomic_inc(&info->send_pending);
911+
atomic_inc(&sc->send_io.pending.count);
912912
rc = ib_post_send(sc->ib.qp, &send_wr, NULL);
913913
if (!rc)
914914
return 0;
915915

916916
/* if we reach here, post send failed */
917917
log_rdma_send(ERR, "ib_post_send failed rc=%d\n", rc);
918-
atomic_dec(&info->send_pending);
918+
atomic_dec(&sc->send_io.pending.count);
919919
ib_dma_unmap_single(sc->ib.dev, request->sge[0].addr,
920920
request->sge[0].length, DMA_TO_DEVICE);
921921

@@ -1038,8 +1038,8 @@ static int smbd_post_send_iter(struct smbd_connection *info,
10381038
}
10391039

10401040
wait_send_queue:
1041-
wait_event(info->wait_post_send,
1042-
atomic_read(&info->send_pending) < sp->send_credit_target ||
1041+
wait_event(sc->send_io.pending.dec_wait_queue,
1042+
atomic_read(&sc->send_io.pending.count) < sp->send_credit_target ||
10431043
sc->status != SMBDIRECT_SOCKET_CONNECTED);
10441044

10451045
if (sc->status != SMBDIRECT_SOCKET_CONNECTED) {
@@ -1048,9 +1048,9 @@ static int smbd_post_send_iter(struct smbd_connection *info,
10481048
goto err_wait_send_queue;
10491049
}
10501050

1051-
if (unlikely(atomic_inc_return(&info->send_pending) >
1051+
if (unlikely(atomic_inc_return(&sc->send_io.pending.count) >
10521052
sp->send_credit_target)) {
1053-
atomic_dec(&info->send_pending);
1053+
atomic_dec(&sc->send_io.pending.count);
10541054
goto wait_send_queue;
10551055
}
10561056

@@ -1157,8 +1157,8 @@ static int smbd_post_send_iter(struct smbd_connection *info,
11571157
atomic_sub(new_credits, &info->receive_credits);
11581158

11591159
err_alloc:
1160-
if (atomic_dec_and_test(&info->send_pending))
1161-
wake_up(&info->wait_send_pending);
1160+
if (atomic_dec_and_test(&sc->send_io.pending.count))
1161+
wake_up(&sc->send_io.pending.zero_wait_queue);
11621162

11631163
err_wait_send_queue:
11641164
/* roll back send credits and pending */
@@ -1848,11 +1848,6 @@ static struct smbd_connection *_smbd_get_connection(
18481848
queue_delayed_work(info->workqueue, &info->idle_timer_work,
18491849
msecs_to_jiffies(sp->keepalive_interval_msec));
18501850

1851-
init_waitqueue_head(&info->wait_send_pending);
1852-
atomic_set(&info->send_pending, 0);
1853-
1854-
init_waitqueue_head(&info->wait_post_send);
1855-
18561851
INIT_WORK(&info->post_send_credits_work, smbd_post_send_credits);
18571852
info->new_credits_offered = 0;
18581853
spin_lock_init(&info->lock_new_credits_offered);
@@ -2151,8 +2146,8 @@ int smbd_send(struct TCP_Server_Info *server,
21512146
* that means all the I/Os have been out and we are good to return
21522147
*/
21532148

2154-
wait_event(info->wait_send_pending,
2155-
atomic_read(&info->send_pending) == 0 ||
2149+
wait_event(sc->send_io.pending.zero_wait_queue,
2150+
atomic_read(&sc->send_io.pending.count) == 0 ||
21562151
sc->status != SMBDIRECT_SOCKET_CONNECTED);
21572152

21582153
if (sc->status != SMBDIRECT_SOCKET_CONNECTED && rc == 0)

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ struct smbd_connection {
8282
/* Used by transport to wait until all MRs are returned */
8383
wait_queue_head_t wait_for_mr_cleanup;
8484

85-
/* Activity accounting */
86-
atomic_t send_pending;
87-
wait_queue_head_t wait_send_pending;
88-
wait_queue_head_t wait_post_send;
89-
9085
/* Receive queue */
9186
int count_receive_queue;
9287
wait_queue_head_t wait_receive_queues;

0 commit comments

Comments
 (0)