aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2012-11-16 10:01:30 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-11-26 09:08:14 -0500
commit5a80a54d21c96590d013378d8c5f65f879451ab4 (patch)
treeb8cc3e1b86fe33f065aacde9e0f74aa3b861d419 /fs/nfsd/nfs4xdr.c
parent8a61b18c9b13987310d0f3ba13aa04af51f02a1c (diff)
nfsd4: reorganize write decoding
In preparation for moving some of it elsewhere. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c62
1 files changed, 41 insertions, 21 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index cfebc9c4f4c9..579dc707bad9 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1139,12 +1139,30 @@ nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify
1139 DECODE_TAIL; 1139 DECODE_TAIL;
1140} 1140}
1141 1141
1142static int fill_in_write_vector(struct kvec *vec, struct kvec *head, struct page **pagelist, int buflen)
1143{
1144 int i = 1;
1145
1146 vec[0].iov_base = head->iov_base;
1147 vec[0].iov_len = min_t(int, buflen, head->iov_len);
1148 buflen -= vec[0].iov_len;
1149
1150 while (buflen) {
1151 vec[i].iov_base = page_address(pagelist[i - 1]);
1152 vec[i].iov_len = min_t(int, PAGE_SIZE, buflen);
1153 buflen -= vec[i].iov_len;
1154 i++;
1155 }
1156 return i;
1157}
1158
1142static __be32 1159static __be32
1143nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) 1160nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
1144{ 1161{
1145 int avail; 1162 int avail;
1146 int v;
1147 int len; 1163 int len;
1164 struct page **pagelist;
1165 struct kvec head;
1148 DECODE_HEAD; 1166 DECODE_HEAD;
1149 1167
1150 status = nfsd4_decode_stateid(argp, &write->wr_stateid); 1168 status = nfsd4_decode_stateid(argp, &write->wr_stateid);
@@ -1167,27 +1185,29 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
1167 __FILE__, __LINE__); 1185 __FILE__, __LINE__);
1168 goto xdr_error; 1186 goto xdr_error;
1169 } 1187 }
1170 argp->rqstp->rq_vec[0].iov_base = p; 1188 head.iov_base = p;
1171 argp->rqstp->rq_vec[0].iov_len = avail; 1189 head.iov_len = avail;
1172 v = 0; 1190 WARN_ON(avail != (XDR_QUADLEN(avail) << 2));
1173 len = write->wr_buflen; 1191 pagelist = argp->pagelist;
1174 while (len > argp->rqstp->rq_vec[v].iov_len) { 1192
1175 len -= argp->rqstp->rq_vec[v].iov_len; 1193 len = XDR_QUADLEN(write->wr_buflen) << 2;
1176 v++; 1194 if (len >= avail) {
1177 argp->rqstp->rq_vec[v].iov_base = page_address(argp->pagelist[0]); 1195 int pages;
1178 argp->pagelist++; 1196
1179 if (argp->pagelen >= PAGE_SIZE) { 1197 len -= avail;
1180 argp->rqstp->rq_vec[v].iov_len = PAGE_SIZE; 1198
1181 argp->pagelen -= PAGE_SIZE; 1199 pages = len >> PAGE_SHIFT;
1182 } else { 1200 argp->pagelist += pages;
1183 argp->rqstp->rq_vec[v].iov_len = argp->pagelen; 1201 argp->pagelen -= pages * PAGE_SIZE;
1184 argp->pagelen -= len; 1202 len -= pages * PAGE_SIZE;
1185 } 1203
1204 argp->p = (__be32 *)page_address(argp->pagelist[0]);
1205 argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
1186 } 1206 }
1187 argp->end = (__be32*) (argp->rqstp->rq_vec[v].iov_base + argp->rqstp->rq_vec[v].iov_len); 1207 argp->p += XDR_QUADLEN(len);
1188 argp->p = (__be32*) (argp->rqstp->rq_vec[v].iov_base + (XDR_QUADLEN(len) << 2)); 1208 write->wr_vlen = fill_in_write_vector(argp->rqstp->rq_vec,
1189 argp->rqstp->rq_vec[v].iov_len = len; 1209 &head, pagelist, write->wr_buflen);
1190 write->wr_vlen = v+1; 1210 WARN_ON_ONCE(write->wr_vlen > ARRAY_SIZE(argp->rqstp->rq_vec));
1191 1211
1192 DECODE_TAIL; 1212 DECODE_TAIL;
1193} 1213}