Skip to content

Commit b6903bc

Browse files
longlimsftSteve French
authored andcommitted
CIFS: SMBD: Support page offset in RDMA send
The RDMA send function needs to look at offset in the request pages, and send data starting from there. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent e8157b2 commit b6903bc

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

fs/cifs/smbdirect.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/highmem.h>
1818
#include "smbdirect.h"
1919
#include "cifs_debug.h"
20+
#include "cifsproto.h"
2021

2122
static struct smbd_response *get_empty_queue_buffer(
2223
struct smbd_connection *info);
@@ -2082,7 +2083,7 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
20822083
struct kvec vec;
20832084
int nvecs;
20842085
int size;
2085-
int buflen = 0, remaining_data_length;
2086+
unsigned int buflen = 0, remaining_data_length;
20862087
int start, i, j;
20872088
int max_iov_size =
20882089
info->max_send_size - sizeof(struct smbd_data_transfer);
@@ -2113,10 +2114,17 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
21132114
buflen += iov[i].iov_len;
21142115
}
21152116

2116-
/* add in the page array if there is one */
2117+
/*
2118+
* Add in the page array if there is one. The caller needs to set
2119+
* rq_tailsz to PAGE_SIZE when the buffer has multiple pages and
2120+
* ends at page boundary
2121+
*/
21172122
if (rqst->rq_npages) {
2118-
buflen += rqst->rq_pagesz * (rqst->rq_npages - 1);
2119-
buflen += rqst->rq_tailsz;
2123+
if (rqst->rq_npages == 1)
2124+
buflen += rqst->rq_tailsz;
2125+
else
2126+
buflen += rqst->rq_pagesz * (rqst->rq_npages - 1) -
2127+
rqst->rq_offset + rqst->rq_tailsz;
21202128
}
21212129

21222130
if (buflen + sizeof(struct smbd_data_transfer) >
@@ -2213,8 +2221,9 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
22132221

22142222
/* now sending pages if there are any */
22152223
for (i = 0; i < rqst->rq_npages; i++) {
2216-
buflen = (i == rqst->rq_npages-1) ?
2217-
rqst->rq_tailsz : rqst->rq_pagesz;
2224+
unsigned int offset;
2225+
2226+
rqst_page_get_length(rqst, i, &buflen, &offset);
22182227
nvecs = (buflen + max_iov_size - 1) / max_iov_size;
22192228
log_write(INFO, "sending pages buflen=%d nvecs=%d\n",
22202229
buflen, nvecs);
@@ -2225,9 +2234,11 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
22252234
remaining_data_length -= size;
22262235
log_write(INFO, "sending pages i=%d offset=%d size=%d"
22272236
" remaining_data_length=%d\n",
2228-
i, j*max_iov_size, size, remaining_data_length);
2237+
i, j*max_iov_size+offset, size,
2238+
remaining_data_length);
22292239
rc = smbd_post_send_page(
2230-
info, rqst->rq_pages[i], j*max_iov_size,
2240+
info, rqst->rq_pages[i],
2241+
j*max_iov_size + offset,
22312242
size, remaining_data_length);
22322243
if (rc)
22332244
goto done;

0 commit comments

Comments
 (0)