aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-10-04 05:15:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-04 10:55:15 -0400
commit4452435948424e5322c2a2fefbdc2cf3732cc45d (patch)
treed2082c68d33298e85298852cafde7999ccca3364 /fs/nfsd/nfs4xdr.c
parent5680c44632053a6c9464bca43083f01776d318da (diff)
[PATCH] knfsd: Replace two page lists in struct svc_rqst with one
We are planning to increase RPCSVC_MAXPAGES from about 8 to about 256. This means we need to be a bit careful about arrays of size RPCSVC_MAXPAGES. struct svc_rqst contains two such arrays. However the there are never more that RPCSVC_MAXPAGES pages in the two arrays together, so only one array is needed. The two arrays are for the pages holding the request, and the pages holding the reply. Instead of two arrays, we can simply keep an index into where the first reply page is. This patch also removes a number of small inline functions that probably server to obscure what is going on rather than clarify it, and opencode the needed functionality. Also remove the 'rq_restailpage' variable as it is *always* 0. i.e. if the response 'xdr' structure has a non-empty tail it is always in the same pages as the head. check counters are initilised and incr properly check for consistant usage of ++ etc maybe extra some inlines for common approach general review Signed-off-by: Neil Brown <neilb@suse.de> Cc: Magnus Maatta <novell@kiruna.se> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5be00436b5b8..9f30c53ac0ed 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2039,7 +2039,8 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, int nfserr, struct n
2039} 2039}
2040 2040
2041static int 2041static int
2042nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_read *read) 2042nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr,
2043 struct nfsd4_read *read)
2043{ 2044{
2044 u32 eof; 2045 u32 eof;
2045 int v, pn; 2046 int v, pn;
@@ -2061,10 +2062,11 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_read
2061 len = maxcount; 2062 len = maxcount;
2062 v = 0; 2063 v = 0;
2063 while (len > 0) { 2064 while (len > 0) {
2064 pn = resp->rqstp->rq_resused; 2065 pn = resp->rqstp->rq_resused++;
2065 svc_take_page(resp->rqstp); 2066 read->rd_iov[v].iov_base =
2066 read->rd_iov[v].iov_base = page_address(resp->rqstp->rq_respages[pn]); 2067 page_address(resp->rqstp->rq_respages[pn]);
2067 read->rd_iov[v].iov_len = len < PAGE_SIZE ? len : PAGE_SIZE; 2068 read->rd_iov[v].iov_len =
2069 len < PAGE_SIZE ? len : PAGE_SIZE;
2068 v++; 2070 v++;
2069 len -= PAGE_SIZE; 2071 len -= PAGE_SIZE;
2070 } 2072 }
@@ -2078,7 +2080,8 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_read
2078 nfserr = nfserr_inval; 2080 nfserr = nfserr_inval;
2079 if (nfserr) 2081 if (nfserr)
2080 return nfserr; 2082 return nfserr;
2081 eof = (read->rd_offset + maxcount >= read->rd_fhp->fh_dentry->d_inode->i_size); 2083 eof = (read->rd_offset + maxcount >=
2084 read->rd_fhp->fh_dentry->d_inode->i_size);
2082 2085
2083 WRITE32(eof); 2086 WRITE32(eof);
2084 WRITE32(maxcount); 2087 WRITE32(maxcount);
@@ -2088,7 +2091,6 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_read
2088 resp->xbuf->page_len = maxcount; 2091 resp->xbuf->page_len = maxcount;
2089 2092
2090 /* Use rest of head for padding and remaining ops: */ 2093 /* Use rest of head for padding and remaining ops: */
2091 resp->rqstp->rq_restailpage = 0;
2092 resp->xbuf->tail[0].iov_base = p; 2094 resp->xbuf->tail[0].iov_base = p;
2093 resp->xbuf->tail[0].iov_len = 0; 2095 resp->xbuf->tail[0].iov_len = 0;
2094 if (maxcount&3) { 2096 if (maxcount&3) {
@@ -2113,8 +2115,7 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_r
2113 if (resp->xbuf->page_len) 2115 if (resp->xbuf->page_len)
2114 return nfserr_resource; 2116 return nfserr_resource;
2115 2117
2116 svc_take_page(resp->rqstp); 2118 page = page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused++]);
2117 page = page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
2118 2119
2119 maxcount = PAGE_SIZE; 2120 maxcount = PAGE_SIZE;
2120 RESERVE_SPACE(4); 2121 RESERVE_SPACE(4);
@@ -2138,7 +2139,6 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_r
2138 resp->xbuf->page_len = maxcount; 2139 resp->xbuf->page_len = maxcount;
2139 2140
2140 /* Use rest of head for padding and remaining ops: */ 2141 /* Use rest of head for padding and remaining ops: */
2141 resp->rqstp->rq_restailpage = 0;
2142 resp->xbuf->tail[0].iov_base = p; 2142 resp->xbuf->tail[0].iov_base = p;
2143 resp->xbuf->tail[0].iov_len = 0; 2143 resp->xbuf->tail[0].iov_len = 0;
2144 if (maxcount&3) { 2144 if (maxcount&3) {
@@ -2189,8 +2189,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_re
2189 goto err_no_verf; 2189 goto err_no_verf;
2190 } 2190 }
2191 2191
2192 svc_take_page(resp->rqstp); 2192 page = page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused++]);
2193 page = page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
2194 readdir->common.err = 0; 2193 readdir->common.err = 0;
2195 readdir->buflen = maxcount; 2194 readdir->buflen = maxcount;
2196 readdir->buffer = page; 2195 readdir->buffer = page;
@@ -2215,10 +2214,10 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_re
2215 p = readdir->buffer; 2214 p = readdir->buffer;
2216 *p++ = 0; /* no more entries */ 2215 *p++ = 0; /* no more entries */
2217 *p++ = htonl(readdir->common.err == nfserr_eof); 2216 *p++ = htonl(readdir->common.err == nfserr_eof);
2218 resp->xbuf->page_len = ((char*)p) - (char*)page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]); 2217 resp->xbuf->page_len = ((char*)p) - (char*)page_address(
2218 resp->rqstp->rq_respages[resp->rqstp->rq_resused-1]);
2219 2219
2220 /* Use rest of head for padding and remaining ops: */ 2220 /* Use rest of head for padding and remaining ops: */
2221 resp->rqstp->rq_restailpage = 0;
2222 resp->xbuf->tail[0].iov_base = tailbase; 2221 resp->xbuf->tail[0].iov_base = tailbase;
2223 resp->xbuf->tail[0].iov_len = 0; 2222 resp->xbuf->tail[0].iov_len = 0;
2224 resp->p = resp->xbuf->tail[0].iov_base; 2223 resp->p = resp->xbuf->tail[0].iov_base;