aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
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 /include/linux
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 'include/linux')
-rw-r--r--include/linux/sunrpc/svc.h69
1 files changed, 10 insertions, 59 deletions
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 4ebcdf91f3b3..3669e91c43b8 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -170,7 +170,6 @@ static inline void svc_putu32(struct kvec *iov, __be32 val)
170/* 170/*
171 * The context of a single thread, including the request currently being 171 * The context of a single thread, including the request currently being
172 * processed. 172 * processed.
173 * NOTE: First two items must be prev/next.
174 */ 173 */
175struct svc_rqst { 174struct svc_rqst {
176 struct list_head rq_list; /* idle list */ 175 struct list_head rq_list; /* idle list */
@@ -189,12 +188,9 @@ struct svc_rqst {
189 188
190 struct xdr_buf rq_arg; 189 struct xdr_buf rq_arg;
191 struct xdr_buf rq_res; 190 struct xdr_buf rq_res;
192 struct page * rq_argpages[RPCSVC_MAXPAGES]; 191 struct page * rq_pages[RPCSVC_MAXPAGES];
193 struct page * rq_respages[RPCSVC_MAXPAGES]; 192 struct page * *rq_respages; /* points into rq_pages */
194 int rq_restailpage; 193 int rq_resused; /* number of pages used for result */
195 short rq_argused; /* pages used for argument */
196 short rq_arghi; /* pages available in argument page list */
197 short rq_resused; /* pages used for result */
198 194
199 __be32 rq_xid; /* transmission id */ 195 __be32 rq_xid; /* transmission id */
200 u32 rq_prog; /* program number */ 196 u32 rq_prog; /* program number */
@@ -255,63 +251,18 @@ xdr_ressize_check(struct svc_rqst *rqstp, __be32 *p)
255 return vec->iov_len <= PAGE_SIZE; 251 return vec->iov_len <= PAGE_SIZE;
256} 252}
257 253
258static inline struct page * 254static inline void svc_free_res_pages(struct svc_rqst *rqstp)
259svc_take_res_page(struct svc_rqst *rqstp)
260{ 255{
261 if (rqstp->rq_arghi <= rqstp->rq_argused) 256 while (rqstp->rq_resused) {
262 return NULL; 257 struct page **pp = (rqstp->rq_respages +
263 rqstp->rq_arghi--; 258 --rqstp->rq_resused);
264 rqstp->rq_respages[rqstp->rq_resused] = 259 if (*pp) {
265 rqstp->rq_argpages[rqstp->rq_arghi]; 260 put_page(*pp);
266 return rqstp->rq_respages[rqstp->rq_resused++]; 261 *pp = NULL;
267}
268
269static inline void svc_take_page(struct svc_rqst *rqstp)
270{
271 if (rqstp->rq_arghi <= rqstp->rq_argused) {
272 WARN_ON(1);
273 return;
274 }
275 rqstp->rq_arghi--;
276 rqstp->rq_respages[rqstp->rq_resused] =
277 rqstp->rq_argpages[rqstp->rq_arghi];
278 rqstp->rq_resused++;
279}
280
281static inline void svc_pushback_allpages(struct svc_rqst *rqstp)
282{
283 while (rqstp->rq_resused) {
284 if (rqstp->rq_respages[--rqstp->rq_resused] == NULL)
285 continue;
286 rqstp->rq_argpages[rqstp->rq_arghi++] =
287 rqstp->rq_respages[rqstp->rq_resused];
288 rqstp->rq_respages[rqstp->rq_resused] = NULL;
289 }
290}
291
292static inline void svc_pushback_unused_pages(struct svc_rqst *rqstp)
293{
294 while (rqstp->rq_resused &&
295 rqstp->rq_res.pages != &rqstp->rq_respages[rqstp->rq_resused]) {
296
297 if (rqstp->rq_respages[--rqstp->rq_resused] != NULL) {
298 rqstp->rq_argpages[rqstp->rq_arghi++] =
299 rqstp->rq_respages[rqstp->rq_resused];
300 rqstp->rq_respages[rqstp->rq_resused] = NULL;
301 } 262 }
302 } 263 }
303} 264}
304 265
305static inline void svc_free_allpages(struct svc_rqst *rqstp)
306{
307 while (rqstp->rq_resused) {
308 if (rqstp->rq_respages[--rqstp->rq_resused] == NULL)
309 continue;
310 put_page(rqstp->rq_respages[rqstp->rq_resused]);
311 rqstp->rq_respages[rqstp->rq_resused] = NULL;
312 }
313}
314
315struct svc_deferred_req { 266struct svc_deferred_req {
316 u32 prot; /* protocol (UDP or TCP) */ 267 u32 prot; /* protocol (UDP or TCP) */
317 struct sockaddr_in addr; 268 struct sockaddr_in addr;