Commit c06a0f2d authored by Long Li's avatar Long Li Committed by Steve French

CIFS: Calculate the correct request length based on page offset and tail size

It's possible that the page offset is non-zero in the pages in a request,
change the function to calculate the correct data buffer length.
Signed-off-by: default avatarLong Li <longli@microsoft.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent ee25c6dd
...@@ -212,11 +212,25 @@ rqst_len(struct smb_rqst *rqst) ...@@ -212,11 +212,25 @@ rqst_len(struct smb_rqst *rqst)
for (i = 0; i < rqst->rq_nvec; i++) for (i = 0; i < rqst->rq_nvec; i++)
buflen += iov[i].iov_len; buflen += iov[i].iov_len;
/* add in the page array if there is one */ /*
* Add in the page array if there is one. The caller needs to make
* sure rq_offset and rq_tailsz are set correctly. If a buffer of
* multiple pages ends at page boundary, rq_tailsz needs to be set to
* PAGE_SIZE.
*/
if (rqst->rq_npages) { if (rqst->rq_npages) {
buflen += rqst->rq_pagesz * (rqst->rq_npages - 1); if (rqst->rq_npages == 1)
buflen += rqst->rq_tailsz;
else {
/*
* If there is more than one page, calculate the
* buffer length based on rq_offset and rq_tailsz
*/
buflen += rqst->rq_pagesz * (rqst->rq_npages - 1) -
rqst->rq_offset;
buflen += rqst->rq_tailsz; buflen += rqst->rq_tailsz;
} }
}
return buflen; return buflen;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment