@@ -6183,6 +6183,8 @@ int smb2_read(struct ksmbd_work *work)
6183
6183
size_t length , mincount ;
6184
6184
ssize_t nbytes = 0 , remain_bytes = 0 ;
6185
6185
int err = 0 ;
6186
+ bool is_rdma_channel = false;
6187
+ unsigned int max_read_size = conn -> vals -> max_read_size ;
6186
6188
6187
6189
WORK_BUFFERS (work , req , rsp );
6188
6190
@@ -6194,6 +6196,11 @@ int smb2_read(struct ksmbd_work *work)
6194
6196
6195
6197
if (req -> Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
6196
6198
req -> Channel == SMB2_CHANNEL_RDMA_V1 ) {
6199
+ is_rdma_channel = true;
6200
+ max_read_size = get_smbd_max_read_write_size ();
6201
+ }
6202
+
6203
+ if (is_rdma_channel == true) {
6197
6204
unsigned int ch_offset = le16_to_cpu (req -> ReadChannelInfoOffset );
6198
6205
6199
6206
if (ch_offset < offsetof(struct smb2_read_req , Buffer )) {
@@ -6225,9 +6232,9 @@ int smb2_read(struct ksmbd_work *work)
6225
6232
length = le32_to_cpu (req -> Length );
6226
6233
mincount = le32_to_cpu (req -> MinimumCount );
6227
6234
6228
- if (length > conn -> vals -> max_read_size ) {
6235
+ if (length > max_read_size ) {
6229
6236
ksmbd_debug (SMB , "limiting read size to max size(%u)\n" ,
6230
- conn -> vals -> max_read_size );
6237
+ max_read_size );
6231
6238
err = - EINVAL ;
6232
6239
goto out ;
6233
6240
}
@@ -6259,8 +6266,7 @@ int smb2_read(struct ksmbd_work *work)
6259
6266
ksmbd_debug (SMB , "nbytes %zu, offset %lld mincount %zu\n" ,
6260
6267
nbytes , offset , mincount );
6261
6268
6262
- if (req -> Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
6263
- req -> Channel == SMB2_CHANNEL_RDMA_V1 ) {
6269
+ if (is_rdma_channel == true) {
6264
6270
/* write data to the client using rdma channel */
6265
6271
remain_bytes = smb2_read_rdma_channel (work , req ,
6266
6272
work -> aux_payload_buf ,
@@ -6421,8 +6427,9 @@ int smb2_write(struct ksmbd_work *work)
6421
6427
size_t length ;
6422
6428
ssize_t nbytes ;
6423
6429
char * data_buf ;
6424
- bool writethrough = false;
6430
+ bool writethrough = false, is_rdma_channel = false ;
6425
6431
int err = 0 ;
6432
+ unsigned int max_write_size = work -> conn -> vals -> max_write_size ;
6426
6433
6427
6434
WORK_BUFFERS (work , req , rsp );
6428
6435
@@ -6431,8 +6438,17 @@ int smb2_write(struct ksmbd_work *work)
6431
6438
return smb2_write_pipe (work );
6432
6439
}
6433
6440
6441
+ offset = le64_to_cpu (req -> Offset );
6442
+ length = le32_to_cpu (req -> Length );
6443
+
6434
6444
if (req -> Channel == SMB2_CHANNEL_RDMA_V1 ||
6435
6445
req -> Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ) {
6446
+ is_rdma_channel = true;
6447
+ max_write_size = get_smbd_max_read_write_size ();
6448
+ length = le32_to_cpu (req -> RemainingBytes );
6449
+ }
6450
+
6451
+ if (is_rdma_channel == true) {
6436
6452
unsigned int ch_offset = le16_to_cpu (req -> WriteChannelInfoOffset );
6437
6453
6438
6454
if (req -> Length != 0 || req -> DataOffset != 0 ||
@@ -6467,21 +6483,17 @@ int smb2_write(struct ksmbd_work *work)
6467
6483
goto out ;
6468
6484
}
6469
6485
6470
- offset = le64_to_cpu (req -> Offset );
6471
- length = le32_to_cpu (req -> Length );
6472
-
6473
- if (length > work -> conn -> vals -> max_write_size ) {
6486
+ if (length > max_write_size ) {
6474
6487
ksmbd_debug (SMB , "limiting write size to max size(%u)\n" ,
6475
- work -> conn -> vals -> max_write_size );
6488
+ max_write_size );
6476
6489
err = - EINVAL ;
6477
6490
goto out ;
6478
6491
}
6479
6492
6480
6493
if (le32_to_cpu (req -> Flags ) & SMB2_WRITEFLAG_WRITE_THROUGH )
6481
6494
writethrough = true;
6482
6495
6483
- if (req -> Channel != SMB2_CHANNEL_RDMA_V1 &&
6484
- req -> Channel != SMB2_CHANNEL_RDMA_V1_INVALIDATE ) {
6496
+ if (is_rdma_channel == false) {
6485
6497
if ((u64 )le16_to_cpu (req -> DataOffset ) + length >
6486
6498
get_rfc1002_len (work -> request_buf )) {
6487
6499
pr_err ("invalid write data offset %u, smb_len %u\n" ,
@@ -6507,8 +6519,7 @@ int smb2_write(struct ksmbd_work *work)
6507
6519
/* read data from the client using rdma channel, and
6508
6520
* write the data.
6509
6521
*/
6510
- nbytes = smb2_write_rdma_channel (work , req , fp , offset ,
6511
- le32_to_cpu (req -> RemainingBytes ),
6522
+ nbytes = smb2_write_rdma_channel (work , req , fp , offset , length ,
6512
6523
writethrough );
6513
6524
if (nbytes < 0 ) {
6514
6525
err = (int )nbytes ;
0 commit comments