Skip to content

Commit 072a14e

Browse files
longlimsftsmfrench
authored andcommitted
cifs: smbd: Merge code to track pending packets
As an optimization, SMBD tries to track two types of packets: packets with payload and without payload. There is no obvious benefit or performance gain to separately track two types of packets. Just treat them as pending packets and merge the tracking code. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent e79b033 commit 072a14e

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

fs/cifs/cifs_debug.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
323323
atomic_read(&server->smbd_conn->send_credits),
324324
atomic_read(&server->smbd_conn->receive_credits),
325325
server->smbd_conn->receive_credit_target);
326-
seq_printf(m, "\nPending send_pending: %x "
327-
"send_payload_pending: %x",
328-
atomic_read(&server->smbd_conn->send_pending),
329-
atomic_read(&server->smbd_conn->send_payload_pending));
326+
seq_printf(m, "\nPending send_pending: %x ",
327+
atomic_read(&server->smbd_conn->send_pending));
330328
seq_printf(m, "\nReceive buffers count_receive_queue: %x "
331329
"count_empty_packet_queue: %x",
332330
server->smbd_conn->count_receive_queue,

fs/cifs/smbdirect.c

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,9 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
284284
request->sge[i].length,
285285
DMA_TO_DEVICE);
286286

287-
if (request->has_payload) {
288-
if (atomic_dec_and_test(&request->info->send_payload_pending))
289-
wake_up(&request->info->wait_send_payload_pending);
290-
} else {
291-
if (atomic_dec_and_test(&request->info->send_pending))
292-
wake_up(&request->info->wait_send_pending);
293-
}
287+
if (atomic_dec_and_test(&request->info->send_pending))
288+
wake_up(&request->info->wait_send_pending);
289+
294290

295291
mempool_free(request, request->info->request_mempool);
296292
}
@@ -749,7 +745,6 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
749745
request->sge[0].addr,
750746
request->sge[0].length, request->sge[0].lkey);
751747

752-
request->has_payload = false;
753748
atomic_inc(&info->send_pending);
754749
rc = ib_post_send(info->id->qp, &send_wr, NULL);
755750
if (!rc)
@@ -919,7 +914,7 @@ static void smbd_destroy_header(struct smbd_connection *info,
919914

920915
/* Post the send request */
921916
static int smbd_post_send(struct smbd_connection *info,
922-
struct smbd_request *request, bool has_payload)
917+
struct smbd_request *request)
923918
{
924919
struct ib_send_wr send_wr;
925920
int rc, i;
@@ -944,24 +939,13 @@ static int smbd_post_send(struct smbd_connection *info,
944939
send_wr.opcode = IB_WR_SEND;
945940
send_wr.send_flags = IB_SEND_SIGNALED;
946941

947-
if (has_payload) {
948-
request->has_payload = true;
949-
atomic_inc(&info->send_payload_pending);
950-
} else {
951-
request->has_payload = false;
952-
atomic_inc(&info->send_pending);
953-
}
942+
atomic_inc(&info->send_pending);
954943

955944
rc = ib_post_send(info->id->qp, &send_wr, NULL);
956945
if (rc) {
957946
log_rdma_send(ERR, "ib_post_send failed rc=%d\n", rc);
958-
if (has_payload) {
959-
if (atomic_dec_and_test(&info->send_payload_pending))
960-
wake_up(&info->wait_send_payload_pending);
961-
} else {
962-
if (atomic_dec_and_test(&info->send_pending))
963-
wake_up(&info->wait_send_pending);
964-
}
947+
if (atomic_dec_and_test(&info->send_pending))
948+
wake_up(&info->wait_send_pending);
965949
smbd_disconnect_rdma_connection(info);
966950
rc = -EAGAIN;
967951
} else
@@ -1001,7 +985,7 @@ static int smbd_post_send_sgl(struct smbd_connection *info,
1001985
request->num_sge++;
1002986
}
1003987

1004-
rc = smbd_post_send(info, request, data_length);
988+
rc = smbd_post_send(info, request);
1005989
if (!rc)
1006990
return 0;
1007991

@@ -1413,8 +1397,6 @@ void smbd_destroy(struct TCP_Server_Info *server)
14131397
log_rdma_event(INFO, "wait for all send posted to IB to finish\n");
14141398
wait_event(info->wait_send_pending,
14151399
atomic_read(&info->send_pending) == 0);
1416-
wait_event(info->wait_send_payload_pending,
1417-
atomic_read(&info->send_payload_pending) == 0);
14181400

14191401
/* It's not posssible for upper layer to get to reassembly */
14201402
log_rdma_event(INFO, "drain the reassembly queue\n");
@@ -1751,8 +1733,6 @@ static struct smbd_connection *_smbd_get_connection(
17511733
init_waitqueue_head(&info->wait_send_pending);
17521734
atomic_set(&info->send_pending, 0);
17531735

1754-
init_waitqueue_head(&info->wait_send_payload_pending);
1755-
atomic_set(&info->send_payload_pending, 0);
17561736

17571737
INIT_WORK(&info->disconnect_work, smbd_disconnect_rdma_work);
17581738
INIT_WORK(&info->post_send_credits_work, smbd_post_send_credits);
@@ -2226,8 +2206,8 @@ int smbd_send(struct TCP_Server_Info *server,
22262206
* that means all the I/Os have been out and we are good to return
22272207
*/
22282208

2229-
wait_event(info->wait_send_payload_pending,
2230-
atomic_read(&info->send_payload_pending) == 0);
2209+
wait_event(info->wait_send_pending,
2210+
atomic_read(&info->send_pending) == 0);
22312211

22322212
return rc;
22332213
}

fs/cifs/smbdirect.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ struct smbd_connection {
114114
/* Activity accoutning */
115115
atomic_t send_pending;
116116
wait_queue_head_t wait_send_pending;
117-
atomic_t send_payload_pending;
118-
wait_queue_head_t wait_send_payload_pending;
119117

120118
/* Receive queue */
121119
struct list_head receive_queue;
@@ -234,9 +232,6 @@ struct smbd_request {
234232
struct smbd_connection *info;
235233
struct ib_cqe cqe;
236234

237-
/* true if this request carries upper layer payload */
238-
bool has_payload;
239-
240235
/* the SGE entries for this packet */
241236
struct ib_sge sge[SMBDIRECT_MAX_SGE];
242237
int num_sge;

0 commit comments

Comments
 (0)