Skip to content

Commit db44bac

Browse files
author
J. Bruce Fields
committed
nfsd4: minor NFSv2/v3 write decoding cleanup
Use a couple shortcuts that will simplify a following bugfix. Cc: [email protected] Signed-off-by: J. Bruce Fields <[email protected]>
1 parent e6838a2 commit db44bac

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

fs/nfsd/nfs3xdr.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
358358
{
359359
unsigned int len, v, hdr, dlen;
360360
u32 max_blocksize = svc_max_payload(rqstp);
361+
struct kvec *head = rqstp->rq_arg.head;
362+
struct kvec *tail = rqstp->rq_arg.tail;
361363

362364
p = decode_fh(p, &args->fh);
363365
if (!p)
@@ -377,9 +379,8 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
377379
* Check to make sure that we got the right number of
378380
* bytes.
379381
*/
380-
hdr = (void*)p - rqstp->rq_arg.head[0].iov_base;
381-
dlen = rqstp->rq_arg.head[0].iov_len + rqstp->rq_arg.page_len
382-
+ rqstp->rq_arg.tail[0].iov_len - hdr;
382+
hdr = (void*)p - head->iov_base;
383+
dlen = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len - hdr;
383384
/*
384385
* Round the length of the data which was specified up to
385386
* the next multiple of XDR units and then compare that
@@ -396,7 +397,7 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
396397
len = args->len = max_blocksize;
397398
}
398399
rqstp->rq_vec[0].iov_base = (void*)p;
399-
rqstp->rq_vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - hdr;
400+
rqstp->rq_vec[0].iov_len = head->iov_len - hdr;
400401
v = 0;
401402
while (len > rqstp->rq_vec[v].iov_len) {
402403
len -= rqstp->rq_vec[v].iov_len;

fs/nfsd/nfsxdr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
280280
struct nfsd_writeargs *args)
281281
{
282282
unsigned int len, hdr, dlen;
283+
struct kvec *head = rqstp->rq_arg.head;
283284
int v;
284285

285286
p = decode_fh(p, &args->fh);
@@ -300,9 +301,8 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
300301
* Check to make sure that we got the right number of
301302
* bytes.
302303
*/
303-
hdr = (void*)p - rqstp->rq_arg.head[0].iov_base;
304-
dlen = rqstp->rq_arg.head[0].iov_len + rqstp->rq_arg.page_len
305-
- hdr;
304+
hdr = (void*)p - head->iov_base;
305+
dlen = head->iov_len + rqstp->rq_arg.page_len - hdr;
306306

307307
/*
308308
* Round the length of the data which was specified up to
@@ -316,7 +316,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
316316
return 0;
317317

318318
rqstp->rq_vec[0].iov_base = (void*)p;
319-
rqstp->rq_vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - hdr;
319+
rqstp->rq_vec[0].iov_len = head->iov_len - hdr;
320320
v = 0;
321321
while (len > rqstp->rq_vec[v].iov_len) {
322322
len -= rqstp->rq_vec[v].iov_len;

0 commit comments

Comments
 (0)