Skip to content

Commit 24b6afc

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: remove separate empty_packet_queue
There's no need to maintain two lists, we can just have a single list of receive buffers, which are free to use. It just added unneeded complexity and resulted in ib_dma_unmap_single() not being called from recv_done() for empty keepalive packets. 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 Fixes: f198186 ("CIFS: SMBD: Establish SMB Direct connection") Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 5349ae5 commit 24b6afc

3 files changed

Lines changed: 7 additions & 65 deletions

File tree

fs/smb/client/cifs_debug.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
481481
server->smbd_conn->receive_credit_target);
482482
seq_printf(m, "\nPending send_pending: %x ",
483483
atomic_read(&server->smbd_conn->send_pending));
484-
seq_printf(m, "\nReceive buffers count_receive_queue: %x "
485-
"count_empty_packet_queue: %x",
486-
server->smbd_conn->count_receive_queue,
487-
server->smbd_conn->count_empty_packet_queue);
484+
seq_printf(m, "\nReceive buffers count_receive_queue: %x ",
485+
server->smbd_conn->count_receive_queue);
488486
seq_printf(m, "\nMR responder_resources: %x "
489487
"max_frmr_depth: %x mr_type: %x",
490488
server->smbd_conn->responder_resources,

fs/smb/client/smbdirect.c

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include "cifsproto.h"
1414
#include "smb2proto.h"
1515

16-
static struct smbd_response *get_empty_queue_buffer(
17-
struct smbd_connection *info);
1816
static struct smbd_response *get_receive_buffer(
1917
struct smbd_connection *info);
2018
static void put_receive_buffer(
@@ -23,8 +21,6 @@ static void put_receive_buffer(
2321
static int allocate_receive_buffers(struct smbd_connection *info, int num_buf);
2422
static void destroy_receive_buffers(struct smbd_connection *info);
2523

26-
static void put_empty_packet(
27-
struct smbd_connection *info, struct smbd_response *response);
2824
static void enqueue_reassembly(
2925
struct smbd_connection *info,
3026
struct smbd_response *response, int data_length);
@@ -393,7 +389,6 @@ static bool process_negotiation_response(
393389
static void smbd_post_send_credits(struct work_struct *work)
394390
{
395391
int ret = 0;
396-
int use_receive_queue = 1;
397392
int rc;
398393
struct smbd_response *response;
399394
struct smbd_connection *info =
@@ -409,18 +404,9 @@ static void smbd_post_send_credits(struct work_struct *work)
409404
if (info->receive_credit_target >
410405
atomic_read(&info->receive_credits)) {
411406
while (true) {
412-
if (use_receive_queue)
413-
response = get_receive_buffer(info);
414-
else
415-
response = get_empty_queue_buffer(info);
416-
if (!response) {
417-
/* now switch to empty packet queue */
418-
if (use_receive_queue) {
419-
use_receive_queue = 0;
420-
continue;
421-
} else
422-
break;
423-
}
407+
response = get_receive_buffer(info);
408+
if (!response)
409+
break;
424410

425411
response->type = SMBD_TRANSFER_DATA;
426412
response->first_segment = false;
@@ -511,7 +497,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
511497
response,
512498
data_length);
513499
} else
514-
put_empty_packet(info, response);
500+
put_receive_buffer(info, response);
515501

516502
if (data_length)
517503
wake_up_interruptible(&info->wait_reassembly_queue);
@@ -1115,17 +1101,6 @@ static int smbd_negotiate(struct smbd_connection *info)
11151101
return rc;
11161102
}
11171103

1118-
static void put_empty_packet(
1119-
struct smbd_connection *info, struct smbd_response *response)
1120-
{
1121-
spin_lock(&info->empty_packet_queue_lock);
1122-
list_add_tail(&response->list, &info->empty_packet_queue);
1123-
info->count_empty_packet_queue++;
1124-
spin_unlock(&info->empty_packet_queue_lock);
1125-
1126-
queue_work(info->workqueue, &info->post_send_credits_work);
1127-
}
1128-
11291104
/*
11301105
* Implement Connection.FragmentReassemblyBuffer defined in [MS-SMBD] 3.1.1.1
11311106
* This is a queue for reassembling upper layer payload and present to upper
@@ -1174,25 +1149,6 @@ static struct smbd_response *_get_first_reassembly(struct smbd_connection *info)
11741149
return ret;
11751150
}
11761151

1177-
static struct smbd_response *get_empty_queue_buffer(
1178-
struct smbd_connection *info)
1179-
{
1180-
struct smbd_response *ret = NULL;
1181-
unsigned long flags;
1182-
1183-
spin_lock_irqsave(&info->empty_packet_queue_lock, flags);
1184-
if (!list_empty(&info->empty_packet_queue)) {
1185-
ret = list_first_entry(
1186-
&info->empty_packet_queue,
1187-
struct smbd_response, list);
1188-
list_del(&ret->list);
1189-
info->count_empty_packet_queue--;
1190-
}
1191-
spin_unlock_irqrestore(&info->empty_packet_queue_lock, flags);
1192-
1193-
return ret;
1194-
}
1195-
11961152
/*
11971153
* Get a receive buffer
11981154
* For each remote send, we need to post a receive. The receive buffers are
@@ -1257,10 +1213,6 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
12571213
spin_lock_init(&info->receive_queue_lock);
12581214
info->count_receive_queue = 0;
12591215

1260-
INIT_LIST_HEAD(&info->empty_packet_queue);
1261-
spin_lock_init(&info->empty_packet_queue_lock);
1262-
info->count_empty_packet_queue = 0;
1263-
12641216
init_waitqueue_head(&info->wait_receive_queues);
12651217

12661218
for (i = 0; i < num_buf; i++) {
@@ -1294,9 +1246,6 @@ static void destroy_receive_buffers(struct smbd_connection *info)
12941246

12951247
while ((response = get_receive_buffer(info)))
12961248
mempool_free(response, info->response_mempool);
1297-
1298-
while ((response = get_empty_queue_buffer(info)))
1299-
mempool_free(response, info->response_mempool);
13001249
}
13011250

13021251
/* Implement idle connection timer [MS-SMBD] 3.1.6.2 */
@@ -1383,8 +1332,7 @@ void smbd_destroy(struct TCP_Server_Info *server)
13831332

13841333
log_rdma_event(INFO, "free receive buffers\n");
13851334
wait_event(info->wait_receive_queues,
1386-
info->count_receive_queue + info->count_empty_packet_queue
1387-
== sp->recv_credit_max);
1335+
info->count_receive_queue == sp->recv_credit_max);
13881336
destroy_receive_buffers(info);
13891337

13901338
/*

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ struct smbd_connection {
110110
int count_receive_queue;
111111
spinlock_t receive_queue_lock;
112112

113-
struct list_head empty_packet_queue;
114-
int count_empty_packet_queue;
115-
spinlock_t empty_packet_queue_lock;
116-
117113
wait_queue_head_t wait_receive_queues;
118114

119115
/* Reassembly queue */

0 commit comments

Comments
 (0)