Skip to content

Commit 61b4918

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of smbdirect_socket.recv_io.reassembly.*
This will be used by the server too and will allow us to create common helper functions. Cc: Steve French <[email protected]> Cc: Tom Talpey <[email protected]> Cc: Long Li <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Stefan Metzmacher <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b7ffb4d commit 61b4918

File tree

3 files changed

+46
-61
lines changed

3 files changed

+46
-61
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
412412
spin_lock(&cifs_tcp_ses_lock);
413413
list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
414414
#ifdef CONFIG_CIFS_SMB_DIRECT
415+
struct smbdirect_socket *sc;
415416
struct smbdirect_socket_parameters *sp;
416417
#endif
417418

@@ -436,7 +437,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
436437
seq_printf(m, "\nSMBDirect transport not available");
437438
goto skip_rdma;
438439
}
439-
sp = &server->smbd_conn->socket.parameters;
440+
sc = &server->smbd_conn->socket;
441+
sp = &sc->parameters;
440442

441443
seq_printf(m, "\nSMBDirect (in hex) protocol version: %x "
442444
"transport status: %x",
@@ -470,8 +472,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
470472
server->smbd_conn->count_reassembly_queue,
471473
server->smbd_conn->count_enqueue_reassembly_queue,
472474
server->smbd_conn->count_dequeue_reassembly_queue,
473-
server->smbd_conn->reassembly_data_length,
474-
server->smbd_conn->reassembly_queue_length);
475+
sc->recv_io.reassembly.data_length,
476+
sc->recv_io.reassembly.queue_length);
475477
seq_printf(m, "\nCurrent Credits send_credits: %x "
476478
"receive_credits: %x receive_credit_target: %x",
477479
atomic_read(&server->smbd_conn->send_credits),

fs/smb/client/smbdirect.c

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static int smbd_conn_upcall(
224224

225225
sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
226226
wake_up_interruptible(&info->disconn_wait);
227-
wake_up_interruptible(&info->wait_reassembly_queue);
227+
wake_up_interruptible(&sc->recv_io.reassembly.wait_queue);
228228
wake_up_interruptible_all(&info->wait_send_queue);
229229
break;
230230

@@ -470,7 +470,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
470470
/* SMBD negotiation response */
471471
case SMBDIRECT_EXPECT_NEGOTIATE_REP:
472472
dump_smbdirect_negotiate_resp(smbdirect_recv_io_payload(response));
473-
info->full_packet_received = true;
473+
sc->recv_io.reassembly.full_packet_received = true;
474474
info->negotiate_done =
475475
process_negotiation_response(response, wc->byte_len);
476476
put_receive_buffer(info, response);
@@ -483,13 +483,13 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
483483
data_length = le32_to_cpu(data_transfer->data_length);
484484

485485
if (data_length) {
486-
if (info->full_packet_received)
486+
if (sc->recv_io.reassembly.full_packet_received)
487487
response->first_segment = true;
488488

489489
if (le32_to_cpu(data_transfer->remaining_data_length))
490-
info->full_packet_received = false;
490+
sc->recv_io.reassembly.full_packet_received = false;
491491
else
492-
info->full_packet_received = true;
492+
sc->recv_io.reassembly.full_packet_received = true;
493493
}
494494

495495
atomic_dec(&info->receive_credits);
@@ -524,7 +524,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
524524
*/
525525
if (data_length) {
526526
enqueue_reassembly(info, response, data_length);
527-
wake_up_interruptible(&info->wait_reassembly_queue);
527+
wake_up_interruptible(&sc->recv_io.reassembly.wait_queue);
528528
} else
529529
put_receive_buffer(info, response);
530530

@@ -1124,18 +1124,20 @@ static void enqueue_reassembly(
11241124
struct smbdirect_recv_io *response,
11251125
int data_length)
11261126
{
1127-
spin_lock(&info->reassembly_queue_lock);
1128-
list_add_tail(&response->list, &info->reassembly_queue);
1129-
info->reassembly_queue_length++;
1127+
struct smbdirect_socket *sc = &info->socket;
1128+
1129+
spin_lock(&sc->recv_io.reassembly.lock);
1130+
list_add_tail(&response->list, &sc->recv_io.reassembly.list);
1131+
sc->recv_io.reassembly.queue_length++;
11301132
/*
11311133
* Make sure reassembly_data_length is updated after list and
11321134
* reassembly_queue_length are updated. On the dequeue side
11331135
* reassembly_data_length is checked without a lock to determine
11341136
* if reassembly_queue_length and list is up to date
11351137
*/
11361138
virt_wmb();
1137-
info->reassembly_data_length += data_length;
1138-
spin_unlock(&info->reassembly_queue_lock);
1139+
sc->recv_io.reassembly.data_length += data_length;
1140+
spin_unlock(&sc->recv_io.reassembly.lock);
11391141
info->count_reassembly_queue++;
11401142
info->count_enqueue_reassembly_queue++;
11411143
}
@@ -1147,11 +1149,12 @@ static void enqueue_reassembly(
11471149
*/
11481150
static struct smbdirect_recv_io *_get_first_reassembly(struct smbd_connection *info)
11491151
{
1152+
struct smbdirect_socket *sc = &info->socket;
11501153
struct smbdirect_recv_io *ret = NULL;
11511154

1152-
if (!list_empty(&info->reassembly_queue)) {
1155+
if (!list_empty(&sc->recv_io.reassembly.list)) {
11531156
ret = list_first_entry(
1154-
&info->reassembly_queue,
1157+
&sc->recv_io.reassembly.list,
11551158
struct smbdirect_recv_io, list);
11561159
}
11571160
return ret;
@@ -1219,10 +1222,10 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
12191222
struct smbdirect_recv_io *response;
12201223
int i;
12211224

1222-
INIT_LIST_HEAD(&info->reassembly_queue);
1223-
spin_lock_init(&info->reassembly_queue_lock);
1224-
info->reassembly_data_length = 0;
1225-
info->reassembly_queue_length = 0;
1225+
INIT_LIST_HEAD(&sc->recv_io.reassembly.list);
1226+
spin_lock_init(&sc->recv_io.reassembly.lock);
1227+
sc->recv_io.reassembly.data_length = 0;
1228+
sc->recv_io.reassembly.queue_length = 0;
12261229

12271230
INIT_LIST_HEAD(&sc->recv_io.free.list);
12281231
spin_lock_init(&sc->recv_io.free.lock);
@@ -1333,18 +1336,18 @@ void smbd_destroy(struct TCP_Server_Info *server)
13331336
/* It's not possible for upper layer to get to reassembly */
13341337
log_rdma_event(INFO, "drain the reassembly queue\n");
13351338
do {
1336-
spin_lock_irqsave(&info->reassembly_queue_lock, flags);
1339+
spin_lock_irqsave(&sc->recv_io.reassembly.lock, flags);
13371340
response = _get_first_reassembly(info);
13381341
if (response) {
13391342
list_del(&response->list);
13401343
spin_unlock_irqrestore(
1341-
&info->reassembly_queue_lock, flags);
1344+
&sc->recv_io.reassembly.lock, flags);
13421345
put_receive_buffer(info, response);
13431346
} else
13441347
spin_unlock_irqrestore(
1345-
&info->reassembly_queue_lock, flags);
1348+
&sc->recv_io.reassembly.lock, flags);
13461349
} while (response);
1347-
info->reassembly_data_length = 0;
1350+
sc->recv_io.reassembly.data_length = 0;
13481351

13491352
log_rdma_event(INFO, "free receive buffers\n");
13501353
wait_event(info->wait_receive_queues,
@@ -1639,7 +1642,7 @@ static struct smbd_connection *_smbd_get_connection(
16391642

16401643
init_waitqueue_head(&info->conn_wait);
16411644
init_waitqueue_head(&info->disconn_wait);
1642-
init_waitqueue_head(&info->wait_reassembly_queue);
1645+
init_waitqueue_head(&sc->recv_io.reassembly.wait_queue);
16431646
rc = rdma_connect(sc->rdma.cm_id, &conn_param);
16441647
if (rc) {
16451648
log_rdma_event(ERR, "rdma_connect() failed with %i\n", rc);
@@ -1776,9 +1779,9 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
17761779
* the only one reading from the front of the queue. The transport
17771780
* may add more entries to the back of the queue at the same time
17781781
*/
1779-
log_read(INFO, "size=%zd info->reassembly_data_length=%d\n", size,
1780-
info->reassembly_data_length);
1781-
if (info->reassembly_data_length >= size) {
1782+
log_read(INFO, "size=%zd sc->recv_io.reassembly.data_length=%d\n", size,
1783+
sc->recv_io.reassembly.data_length);
1784+
if (sc->recv_io.reassembly.data_length >= size) {
17821785
int queue_length;
17831786
int queue_removed = 0;
17841787

@@ -1790,10 +1793,10 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
17901793
* updated in SOFTIRQ as more data is received
17911794
*/
17921795
virt_rmb();
1793-
queue_length = info->reassembly_queue_length;
1796+
queue_length = sc->recv_io.reassembly.queue_length;
17941797
data_read = 0;
17951798
to_read = size;
1796-
offset = info->first_entry_offset;
1799+
offset = sc->recv_io.reassembly.first_entry_offset;
17971800
while (data_read < size) {
17981801
response = _get_first_reassembly(info);
17991802
data_transfer = smbdirect_recv_io_payload(response);
@@ -1841,10 +1844,10 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
18411844
list_del(&response->list);
18421845
else {
18431846
spin_lock_irq(
1844-
&info->reassembly_queue_lock);
1847+
&sc->recv_io.reassembly.lock);
18451848
list_del(&response->list);
18461849
spin_unlock_irq(
1847-
&info->reassembly_queue_lock);
1850+
&sc->recv_io.reassembly.lock);
18481851
}
18491852
queue_removed++;
18501853
info->count_reassembly_queue--;
@@ -1863,23 +1866,23 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
18631866
to_read, data_read, offset);
18641867
}
18651868

1866-
spin_lock_irq(&info->reassembly_queue_lock);
1867-
info->reassembly_data_length -= data_read;
1868-
info->reassembly_queue_length -= queue_removed;
1869-
spin_unlock_irq(&info->reassembly_queue_lock);
1869+
spin_lock_irq(&sc->recv_io.reassembly.lock);
1870+
sc->recv_io.reassembly.data_length -= data_read;
1871+
sc->recv_io.reassembly.queue_length -= queue_removed;
1872+
spin_unlock_irq(&sc->recv_io.reassembly.lock);
18701873

1871-
info->first_entry_offset = offset;
1874+
sc->recv_io.reassembly.first_entry_offset = offset;
18721875
log_read(INFO, "returning to thread data_read=%d reassembly_data_length=%d first_entry_offset=%d\n",
1873-
data_read, info->reassembly_data_length,
1874-
info->first_entry_offset);
1876+
data_read, sc->recv_io.reassembly.data_length,
1877+
sc->recv_io.reassembly.first_entry_offset);
18751878
read_rfc1002_done:
18761879
return data_read;
18771880
}
18781881

18791882
log_read(INFO, "wait_event on more data\n");
18801883
rc = wait_event_interruptible(
1881-
info->wait_reassembly_queue,
1882-
info->reassembly_data_length >= size ||
1884+
sc->recv_io.reassembly.wait_queue,
1885+
sc->recv_io.reassembly.data_length >= size ||
18831886
sc->status != SMBDIRECT_SOCKET_CONNECTED);
18841887
/* Don't return any data if interrupted */
18851888
if (rc)

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,30 +108,10 @@ struct smbd_connection {
108108
int count_receive_queue;
109109
wait_queue_head_t wait_receive_queues;
110110

111-
/* Reassembly queue */
112-
struct list_head reassembly_queue;
113-
spinlock_t reassembly_queue_lock;
114-
wait_queue_head_t wait_reassembly_queue;
115-
116-
/* total data length of reassembly queue */
117-
int reassembly_data_length;
118-
int reassembly_queue_length;
119-
/* the offset to first buffer in reassembly queue */
120-
int first_entry_offset;
121-
122111
bool send_immediate;
123112

124113
wait_queue_head_t wait_send_queue;
125114

126-
/*
127-
* Indicate if we have received a full packet on the connection
128-
* This is used to identify the first SMBD packet of a assembled
129-
* payload (SMB packet) in reassembly queue so we can return a
130-
* RFC1002 length to upper layer to indicate the length of the SMB
131-
* packet received
132-
*/
133-
bool full_packet_received;
134-
135115
struct workqueue_struct *workqueue;
136116
struct delayed_work idle_timer_work;
137117

0 commit comments

Comments
 (0)