13
13
#include "cifsproto.h"
14
14
#include "smb2proto.h"
15
15
16
- static struct smbd_response * get_receive_buffer (
16
+ static struct smbdirect_recv_io * get_receive_buffer (
17
17
struct smbd_connection * info );
18
18
static void put_receive_buffer (
19
19
struct smbd_connection * info ,
20
- struct smbd_response * response );
20
+ struct smbdirect_recv_io * response );
21
21
static int allocate_receive_buffers (struct smbd_connection * info , int num_buf );
22
22
static void destroy_receive_buffers (struct smbd_connection * info );
23
23
24
24
static void enqueue_reassembly (
25
25
struct smbd_connection * info ,
26
- struct smbd_response * response , int data_length );
27
- static struct smbd_response * _get_first_reassembly (
26
+ struct smbdirect_recv_io * response , int data_length );
27
+ static struct smbdirect_recv_io * _get_first_reassembly (
28
28
struct smbd_connection * info );
29
29
30
30
static int smbd_post_recv (
31
31
struct smbd_connection * info ,
32
- struct smbd_response * response );
32
+ struct smbdirect_recv_io * response );
33
33
34
34
static int smbd_post_send_empty (struct smbd_connection * info );
35
35
@@ -260,7 +260,7 @@ static inline void *smbd_request_payload(struct smbd_request *request)
260
260
return (void * )request -> packet ;
261
261
}
262
262
263
- static inline void * smbd_response_payload (struct smbd_response * response )
263
+ static inline void * smbdirect_recv_io_payload (struct smbdirect_recv_io * response )
264
264
{
265
265
return (void * )response -> packet ;
266
266
}
@@ -315,12 +315,13 @@ static void dump_smbdirect_negotiate_resp(struct smbdirect_negotiate_resp *resp)
315
315
* return value: true if negotiation is a success, false if failed
316
316
*/
317
317
static bool process_negotiation_response (
318
- struct smbd_response * response , int packet_length )
318
+ struct smbdirect_recv_io * response , int packet_length )
319
319
{
320
- struct smbd_connection * info = response -> info ;
321
- struct smbdirect_socket * sc = & info -> socket ;
320
+ struct smbdirect_socket * sc = response -> socket ;
321
+ struct smbd_connection * info =
322
+ container_of (sc , struct smbd_connection , socket );
322
323
struct smbdirect_socket_parameters * sp = & sc -> parameters ;
323
- struct smbdirect_negotiate_resp * packet = smbd_response_payload (response );
324
+ struct smbdirect_negotiate_resp * packet = smbdirect_recv_io_payload (response );
324
325
325
326
if (packet_length < sizeof (struct smbdirect_negotiate_resp )) {
326
327
log_rdma_event (ERR ,
@@ -391,7 +392,7 @@ static void smbd_post_send_credits(struct work_struct *work)
391
392
{
392
393
int ret = 0 ;
393
394
int rc ;
394
- struct smbd_response * response ;
395
+ struct smbdirect_recv_io * response ;
395
396
struct smbd_connection * info =
396
397
container_of (work , struct smbd_connection ,
397
398
post_send_credits_work );
@@ -442,10 +443,11 @@ static void smbd_post_send_credits(struct work_struct *work)
442
443
static void recv_done (struct ib_cq * cq , struct ib_wc * wc )
443
444
{
444
445
struct smbdirect_data_transfer * data_transfer ;
445
- struct smbd_response * response =
446
- container_of (wc -> wr_cqe , struct smbd_response , cqe );
447
- struct smbd_connection * info = response -> info ;
448
- struct smbdirect_socket * sc = & info -> socket ;
446
+ struct smbdirect_recv_io * response =
447
+ container_of (wc -> wr_cqe , struct smbdirect_recv_io , cqe );
448
+ struct smbdirect_socket * sc = response -> socket ;
449
+ struct smbd_connection * info =
450
+ container_of (sc , struct smbd_connection , socket );
449
451
int data_length = 0 ;
450
452
451
453
log_rdma_recv (INFO , "response=0x%p type=%d wc status=%d wc opcode %d byte_len=%d pkey_index=%u\n" ,
@@ -467,7 +469,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
467
469
switch (sc -> recv_io .expected ) {
468
470
/* SMBD negotiation response */
469
471
case SMBDIRECT_EXPECT_NEGOTIATE_REP :
470
- dump_smbdirect_negotiate_resp (smbd_response_payload (response ));
472
+ dump_smbdirect_negotiate_resp (smbdirect_recv_io_payload (response ));
471
473
info -> full_packet_received = true;
472
474
info -> negotiate_done =
473
475
process_negotiation_response (response , wc -> byte_len );
@@ -477,7 +479,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
477
479
478
480
/* SMBD data transfer packet */
479
481
case SMBDIRECT_EXPECT_DATA_TRANSFER :
480
- data_transfer = smbd_response_payload (response );
482
+ data_transfer = smbdirect_recv_io_payload (response );
481
483
data_length = le32_to_cpu (data_transfer -> data_length );
482
484
483
485
if (data_length ) {
@@ -1034,7 +1036,7 @@ static int smbd_post_send_full_iter(struct smbd_connection *info,
1034
1036
* The interaction is controlled by send/receive credit system
1035
1037
*/
1036
1038
static int smbd_post_recv (
1037
- struct smbd_connection * info , struct smbd_response * response )
1039
+ struct smbd_connection * info , struct smbdirect_recv_io * response )
1038
1040
{
1039
1041
struct smbdirect_socket * sc = & info -> socket ;
1040
1042
struct smbdirect_socket_parameters * sp = & sc -> parameters ;
@@ -1074,7 +1076,7 @@ static int smbd_negotiate(struct smbd_connection *info)
1074
1076
{
1075
1077
struct smbdirect_socket * sc = & info -> socket ;
1076
1078
int rc ;
1077
- struct smbd_response * response = get_receive_buffer (info );
1079
+ struct smbdirect_recv_io * response = get_receive_buffer (info );
1078
1080
1079
1081
sc -> recv_io .expected = SMBDIRECT_EXPECT_NEGOTIATE_REP ;
1080
1082
rc = smbd_post_recv (info , response );
@@ -1119,7 +1121,7 @@ static int smbd_negotiate(struct smbd_connection *info)
1119
1121
*/
1120
1122
static void enqueue_reassembly (
1121
1123
struct smbd_connection * info ,
1122
- struct smbd_response * response ,
1124
+ struct smbdirect_recv_io * response ,
1123
1125
int data_length )
1124
1126
{
1125
1127
spin_lock (& info -> reassembly_queue_lock );
@@ -1143,14 +1145,14 @@ static void enqueue_reassembly(
1143
1145
* Caller is responsible for locking
1144
1146
* return value: the first entry if any, NULL if queue is empty
1145
1147
*/
1146
- static struct smbd_response * _get_first_reassembly (struct smbd_connection * info )
1148
+ static struct smbdirect_recv_io * _get_first_reassembly (struct smbd_connection * info )
1147
1149
{
1148
- struct smbd_response * ret = NULL ;
1150
+ struct smbdirect_recv_io * ret = NULL ;
1149
1151
1150
1152
if (!list_empty (& info -> reassembly_queue )) {
1151
1153
ret = list_first_entry (
1152
1154
& info -> reassembly_queue ,
1153
- struct smbd_response , list );
1155
+ struct smbdirect_recv_io , list );
1154
1156
}
1155
1157
return ret ;
1156
1158
}
@@ -1161,16 +1163,16 @@ static struct smbd_response *_get_first_reassembly(struct smbd_connection *info)
1161
1163
* pre-allocated in advance.
1162
1164
* return value: the receive buffer, NULL if none is available
1163
1165
*/
1164
- static struct smbd_response * get_receive_buffer (struct smbd_connection * info )
1166
+ static struct smbdirect_recv_io * get_receive_buffer (struct smbd_connection * info )
1165
1167
{
1166
- struct smbd_response * ret = NULL ;
1168
+ struct smbdirect_recv_io * ret = NULL ;
1167
1169
unsigned long flags ;
1168
1170
1169
1171
spin_lock_irqsave (& info -> receive_queue_lock , flags );
1170
1172
if (!list_empty (& info -> receive_queue )) {
1171
1173
ret = list_first_entry (
1172
1174
& info -> receive_queue ,
1173
- struct smbd_response , list );
1175
+ struct smbdirect_recv_io , list );
1174
1176
list_del (& ret -> list );
1175
1177
info -> count_receive_queue -- ;
1176
1178
info -> count_get_receive_buffer ++ ;
@@ -1187,7 +1189,7 @@ static struct smbd_response *get_receive_buffer(struct smbd_connection *info)
1187
1189
* receive buffer is returned.
1188
1190
*/
1189
1191
static void put_receive_buffer (
1190
- struct smbd_connection * info , struct smbd_response * response )
1192
+ struct smbd_connection * info , struct smbdirect_recv_io * response )
1191
1193
{
1192
1194
struct smbdirect_socket * sc = & info -> socket ;
1193
1195
unsigned long flags ;
@@ -1212,8 +1214,9 @@ static void put_receive_buffer(
1212
1214
/* Preallocate all receive buffer on transport establishment */
1213
1215
static int allocate_receive_buffers (struct smbd_connection * info , int num_buf )
1214
1216
{
1217
+ struct smbdirect_socket * sc = & info -> socket ;
1218
+ struct smbdirect_recv_io * response ;
1215
1219
int i ;
1216
- struct smbd_response * response ;
1217
1220
1218
1221
INIT_LIST_HEAD (& info -> reassembly_queue );
1219
1222
spin_lock_init (& info -> reassembly_queue_lock );
@@ -1231,7 +1234,7 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
1231
1234
if (!response )
1232
1235
goto allocate_failed ;
1233
1236
1234
- response -> info = info ;
1237
+ response -> socket = sc ;
1235
1238
response -> sge .length = 0 ;
1236
1239
list_add_tail (& response -> list , & info -> receive_queue );
1237
1240
info -> count_receive_queue ++ ;
@@ -1243,7 +1246,7 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
1243
1246
while (!list_empty (& info -> receive_queue )) {
1244
1247
response = list_first_entry (
1245
1248
& info -> receive_queue ,
1246
- struct smbd_response , list );
1249
+ struct smbdirect_recv_io , list );
1247
1250
list_del (& response -> list );
1248
1251
info -> count_receive_queue -- ;
1249
1252
@@ -1254,7 +1257,7 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
1254
1257
1255
1258
static void destroy_receive_buffers (struct smbd_connection * info )
1256
1259
{
1257
- struct smbd_response * response ;
1260
+ struct smbdirect_recv_io * response ;
1258
1261
1259
1262
while ((response = get_receive_buffer (info )))
1260
1263
mempool_free (response , info -> response_mempool );
@@ -1295,7 +1298,7 @@ void smbd_destroy(struct TCP_Server_Info *server)
1295
1298
struct smbd_connection * info = server -> smbd_conn ;
1296
1299
struct smbdirect_socket * sc ;
1297
1300
struct smbdirect_socket_parameters * sp ;
1298
- struct smbd_response * response ;
1301
+ struct smbdirect_recv_io * response ;
1299
1302
unsigned long flags ;
1300
1303
1301
1304
if (!info ) {
@@ -1456,17 +1459,17 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
1456
1459
if (!info -> request_mempool )
1457
1460
goto out1 ;
1458
1461
1459
- scnprintf (name , MAX_NAME_LEN , "smbd_response_ %p" , info );
1462
+ scnprintf (name , MAX_NAME_LEN , "smbdirect_recv_io_ %p" , info );
1460
1463
1461
1464
struct kmem_cache_args response_args = {
1462
- .align = __alignof__(struct smbd_response ),
1463
- .useroffset = (offsetof(struct smbd_response , packet ) +
1465
+ .align = __alignof__(struct smbdirect_recv_io ),
1466
+ .useroffset = (offsetof(struct smbdirect_recv_io , packet ) +
1464
1467
sizeof (struct smbdirect_data_transfer )),
1465
1468
.usersize = sp -> max_recv_size - sizeof (struct smbdirect_data_transfer ),
1466
1469
};
1467
1470
info -> response_cache =
1468
1471
kmem_cache_create (name ,
1469
- sizeof (struct smbd_response ) + sp -> max_recv_size ,
1472
+ sizeof (struct smbdirect_recv_io ) + sp -> max_recv_size ,
1470
1473
& response_args , SLAB_HWCACHE_ALIGN );
1471
1474
if (!info -> response_cache )
1472
1475
goto out2 ;
@@ -1756,7 +1759,7 @@ struct smbd_connection *smbd_get_connection(
1756
1759
int smbd_recv (struct smbd_connection * info , struct msghdr * msg )
1757
1760
{
1758
1761
struct smbdirect_socket * sc = & info -> socket ;
1759
- struct smbd_response * response ;
1762
+ struct smbdirect_recv_io * response ;
1760
1763
struct smbdirect_data_transfer * data_transfer ;
1761
1764
size_t size = iov_iter_count (& msg -> msg_iter );
1762
1765
int to_copy , to_read , data_read , offset ;
@@ -1792,7 +1795,7 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
1792
1795
offset = info -> first_entry_offset ;
1793
1796
while (data_read < size ) {
1794
1797
response = _get_first_reassembly (info );
1795
- data_transfer = smbd_response_payload (response );
1798
+ data_transfer = smbdirect_recv_io_payload (response );
1796
1799
data_length = le32_to_cpu (data_transfer -> data_length );
1797
1800
remaining_data_length =
1798
1801
le32_to_cpu (
0 commit comments