Commit 5a80a54d authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: reorganize write decoding

In preparation for moving some of it elsewhere.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 8a61b18c
...@@ -1139,12 +1139,30 @@ nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify ...@@ -1139,12 +1139,30 @@ nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify
DECODE_TAIL; DECODE_TAIL;
} }
static int fill_in_write_vector(struct kvec *vec, struct kvec *head, struct page **pagelist, int buflen)
{
int i = 1;
vec[0].iov_base = head->iov_base;
vec[0].iov_len = min_t(int, buflen, head->iov_len);
buflen -= vec[0].iov_len;
while (buflen) {
vec[i].iov_base = page_address(pagelist[i - 1]);
vec[i].iov_len = min_t(int, PAGE_SIZE, buflen);
buflen -= vec[i].iov_len;
i++;
}
return i;
}
static __be32 static __be32
nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
{ {
int avail; int avail;
int v;
int len; int len;
struct page **pagelist;
struct kvec head;
DECODE_HEAD; DECODE_HEAD;
status = nfsd4_decode_stateid(argp, &write->wr_stateid); status = nfsd4_decode_stateid(argp, &write->wr_stateid);
...@@ -1167,27 +1185,29 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) ...@@ -1167,27 +1185,29 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
__FILE__, __LINE__); __FILE__, __LINE__);
goto xdr_error; goto xdr_error;
} }
argp->rqstp->rq_vec[0].iov_base = p; head.iov_base = p;
argp->rqstp->rq_vec[0].iov_len = avail; head.iov_len = avail;
v = 0; WARN_ON(avail != (XDR_QUADLEN(avail) << 2));
len = write->wr_buflen; pagelist = argp->pagelist;
while (len > argp->rqstp->rq_vec[v].iov_len) {
len -= argp->rqstp->rq_vec[v].iov_len; len = XDR_QUADLEN(write->wr_buflen) << 2;
v++; if (len >= avail) {
argp->rqstp->rq_vec[v].iov_base = page_address(argp->pagelist[0]); int pages;
argp->pagelist++;
if (argp->pagelen >= PAGE_SIZE) { len -= avail;
argp->rqstp->rq_vec[v].iov_len = PAGE_SIZE;
argp->pagelen -= PAGE_SIZE; pages = len >> PAGE_SHIFT;
} else { argp->pagelist += pages;
argp->rqstp->rq_vec[v].iov_len = argp->pagelen; argp->pagelen -= pages * PAGE_SIZE;
argp->pagelen -= len; len -= pages * PAGE_SIZE;
}
argp->p = (__be32 *)page_address(argp->pagelist[0]);
argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
} }
argp->end = (__be32*) (argp->rqstp->rq_vec[v].iov_base + argp->rqstp->rq_vec[v].iov_len); argp->p += XDR_QUADLEN(len);
argp->p = (__be32*) (argp->rqstp->rq_vec[v].iov_base + (XDR_QUADLEN(len) << 2)); write->wr_vlen = fill_in_write_vector(argp->rqstp->rq_vec,
argp->rqstp->rq_vec[v].iov_len = len; &head, pagelist, write->wr_buflen);
write->wr_vlen = v+1; WARN_ON_ONCE(write->wr_vlen > ARRAY_SIZE(argp->rqstp->rq_vec));
DECODE_TAIL; DECODE_TAIL;
} }
......
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