17
17
#include <linux/highmem.h>
18
18
#include "smbdirect.h"
19
19
#include "cifs_debug.h"
20
+ #include "cifsproto.h"
20
21
21
22
static struct smbd_response * get_empty_queue_buffer (
22
23
struct smbd_connection * info );
@@ -2082,7 +2083,7 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2082
2083
struct kvec vec ;
2083
2084
int nvecs ;
2084
2085
int size ;
2085
- int buflen = 0 , remaining_data_length ;
2086
+ unsigned int buflen = 0 , remaining_data_length ;
2086
2087
int start , i , j ;
2087
2088
int max_iov_size =
2088
2089
info -> max_send_size - sizeof (struct smbd_data_transfer );
@@ -2113,10 +2114,17 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2113
2114
buflen += iov [i ].iov_len ;
2114
2115
}
2115
2116
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
+ */
2117
2122
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 ;
2120
2128
}
2121
2129
2122
2130
if (buflen + sizeof (struct smbd_data_transfer ) >
@@ -2213,8 +2221,9 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2213
2221
2214
2222
/* now sending pages if there are any */
2215
2223
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 );
2218
2227
nvecs = (buflen + max_iov_size - 1 ) / max_iov_size ;
2219
2228
log_write (INFO , "sending pages buflen=%d nvecs=%d\n" ,
2220
2229
buflen , nvecs );
@@ -2225,9 +2234,11 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2225
2234
remaining_data_length -= size ;
2226
2235
log_write (INFO , "sending pages i=%d offset=%d size=%d"
2227
2236
" 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 );
2229
2239
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 ,
2231
2242
size , remaining_data_length );
2232
2243
if (rc )
2233
2244
goto done ;
0 commit comments