diff options
author | NeilBrown <neilb@suse.de> | 2006-10-04 05:15:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-04 10:55:15 -0400 |
commit | 3cc03b164cf01c6f36e64720b58610d292fb26f7 (patch) | |
tree | b558e11a087945ad5b9a1a25483aa2acc8d93fbb /fs/nfsd | |
parent | 4452435948424e5322c2a2fefbdc2cf3732cc45d (diff) |
[PATCH] knfsd: Avoid excess stack usage in svc_tcp_recvfrom
.. by allocating the array of 'kvec' in 'struct svc_rqst'.
As we plan to increase RPCSVC_MAXPAGES from 8 upto 256, we can no longer
allocate an array of this size on the stack. So we allocate it in 'struct
svc_rqst'.
However svc_rqst contains (indirectly) an array of the same type and size
(actually several, but they are in a union). So rather than waste space, we
move those arrays out of the separately allocated union and into svc_rqst to
share with the kvec moved out of svc_tcp_recvfrom (various arrays are used at
different times, so there is no conflict).
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs3proc.c | 4 | ||||
-rw-r--r-- | fs/nfsd/nfs3xdr.c | 22 | ||||
-rw-r--r-- | fs/nfsd/nfs4proc.c | 2 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 26 | ||||
-rw-r--r-- | fs/nfsd/nfsproc.c | 4 | ||||
-rw-r--r-- | fs/nfsd/nfsxdr.c | 22 |
6 files changed, 40 insertions, 40 deletions
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index f61142afea44..0c4fab018791 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c | |||
@@ -180,7 +180,7 @@ nfsd3_proc_read(struct svc_rqst *rqstp, struct nfsd3_readargs *argp, | |||
180 | fh_copy(&resp->fh, &argp->fh); | 180 | fh_copy(&resp->fh, &argp->fh); |
181 | nfserr = nfsd_read(rqstp, &resp->fh, NULL, | 181 | nfserr = nfsd_read(rqstp, &resp->fh, NULL, |
182 | argp->offset, | 182 | argp->offset, |
183 | argp->vec, argp->vlen, | 183 | rqstp->rq_vec, argp->vlen, |
184 | &resp->count); | 184 | &resp->count); |
185 | if (nfserr == 0) { | 185 | if (nfserr == 0) { |
186 | struct inode *inode = resp->fh.fh_dentry->d_inode; | 186 | struct inode *inode = resp->fh.fh_dentry->d_inode; |
@@ -210,7 +210,7 @@ nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp, | |||
210 | resp->committed = argp->stable; | 210 | resp->committed = argp->stable; |
211 | nfserr = nfsd_write(rqstp, &resp->fh, NULL, | 211 | nfserr = nfsd_write(rqstp, &resp->fh, NULL, |
212 | argp->offset, | 212 | argp->offset, |
213 | argp->vec, argp->vlen, | 213 | rqstp->rq_vec, argp->vlen, |
214 | argp->len, | 214 | argp->len, |
215 | &resp->committed); | 215 | &resp->committed); |
216 | resp->count = argp->count; | 216 | resp->count = argp->count; |
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 20ba728a4642..4b9aefbcc93c 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
@@ -344,9 +344,9 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, u32 *p, | |||
344 | v=0; | 344 | v=0; |
345 | while (len > 0) { | 345 | while (len > 0) { |
346 | pn = rqstp->rq_resused++; | 346 | pn = rqstp->rq_resused++; |
347 | args->vec[v].iov_base = page_address(rqstp->rq_respages[pn]); | 347 | rqstp->rq_vec[v].iov_base = page_address(rqstp->rq_respages[pn]); |
348 | args->vec[v].iov_len = len < PAGE_SIZE? len : PAGE_SIZE; | 348 | rqstp->rq_vec[v].iov_len = len < PAGE_SIZE? len : PAGE_SIZE; |
349 | len -= args->vec[v].iov_len; | 349 | len -= rqstp->rq_vec[v].iov_len; |
350 | v++; | 350 | v++; |
351 | } | 351 | } |
352 | args->vlen = v; | 352 | args->vlen = v; |
@@ -372,22 +372,22 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, u32 *p, | |||
372 | rqstp->rq_arg.len - hdr < len) | 372 | rqstp->rq_arg.len - hdr < len) |
373 | return 0; | 373 | return 0; |
374 | 374 | ||
375 | args->vec[0].iov_base = (void*)p; | 375 | rqstp->rq_vec[0].iov_base = (void*)p; |
376 | args->vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - hdr; | 376 | rqstp->rq_vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - hdr; |
377 | 377 | ||
378 | if (len > NFSSVC_MAXBLKSIZE) | 378 | if (len > NFSSVC_MAXBLKSIZE) |
379 | len = NFSSVC_MAXBLKSIZE; | 379 | len = NFSSVC_MAXBLKSIZE; |
380 | v= 0; | 380 | v= 0; |
381 | while (len > args->vec[v].iov_len) { | 381 | while (len > rqstp->rq_vec[v].iov_len) { |
382 | len -= args->vec[v].iov_len; | 382 | len -= rqstp->rq_vec[v].iov_len; |
383 | v++; | 383 | v++; |
384 | args->vec[v].iov_base = page_address(rqstp->rq_pages[v]); | 384 | rqstp->rq_vec[v].iov_base = page_address(rqstp->rq_pages[v]); |
385 | args->vec[v].iov_len = PAGE_SIZE; | 385 | rqstp->rq_vec[v].iov_len = PAGE_SIZE; |
386 | } | 386 | } |
387 | args->vec[v].iov_len = len; | 387 | rqstp->rq_vec[v].iov_len = len; |
388 | args->vlen = v+1; | 388 | args->vlen = v+1; |
389 | 389 | ||
390 | return args->count == args->len && args->vec[0].iov_len > 0; | 390 | return args->count == args->len && rqstp->rq_vec[0].iov_len > 0; |
391 | } | 391 | } |
392 | 392 | ||
393 | int | 393 | int |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 15ded7a30a72..38b0f91175d0 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -646,7 +646,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_writ | |||
646 | *p++ = nfssvc_boot.tv_usec; | 646 | *p++ = nfssvc_boot.tv_usec; |
647 | 647 | ||
648 | status = nfsd_write(rqstp, current_fh, filp, write->wr_offset, | 648 | status = nfsd_write(rqstp, current_fh, filp, write->wr_offset, |
649 | write->wr_vec, write->wr_vlen, write->wr_buflen, | 649 | rqstp->rq_vec, write->wr_vlen, write->wr_buflen, |
650 | &write->wr_how_written); | 650 | &write->wr_how_written); |
651 | if (filp) | 651 | if (filp) |
652 | fput(filp); | 652 | fput(filp); |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 9f30c53ac0ed..df341956254e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -926,26 +926,26 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) | |||
926 | printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); | 926 | printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); |
927 | goto xdr_error; | 927 | goto xdr_error; |
928 | } | 928 | } |
929 | write->wr_vec[0].iov_base = p; | 929 | argp->rqstp->rq_vec[0].iov_base = p; |
930 | write->wr_vec[0].iov_len = avail; | 930 | argp->rqstp->rq_vec[0].iov_len = avail; |
931 | v = 0; | 931 | v = 0; |
932 | len = write->wr_buflen; | 932 | len = write->wr_buflen; |
933 | while (len > write->wr_vec[v].iov_len) { | 933 | while (len > argp->rqstp->rq_vec[v].iov_len) { |
934 | len -= write->wr_vec[v].iov_len; | 934 | len -= argp->rqstp->rq_vec[v].iov_len; |
935 | v++; | 935 | v++; |
936 | write->wr_vec[v].iov_base = page_address(argp->pagelist[0]); | 936 | argp->rqstp->rq_vec[v].iov_base = page_address(argp->pagelist[0]); |
937 | argp->pagelist++; | 937 | argp->pagelist++; |
938 | if (argp->pagelen >= PAGE_SIZE) { | 938 | if (argp->pagelen >= PAGE_SIZE) { |
939 | write->wr_vec[v].iov_len = PAGE_SIZE; | 939 | argp->rqstp->rq_vec[v].iov_len = PAGE_SIZE; |
940 | argp->pagelen -= PAGE_SIZE; | 940 | argp->pagelen -= PAGE_SIZE; |
941 | } else { | 941 | } else { |
942 | write->wr_vec[v].iov_len = argp->pagelen; | 942 | argp->rqstp->rq_vec[v].iov_len = argp->pagelen; |
943 | argp->pagelen -= len; | 943 | argp->pagelen -= len; |
944 | } | 944 | } |
945 | } | 945 | } |
946 | argp->end = (u32*) (write->wr_vec[v].iov_base + write->wr_vec[v].iov_len); | 946 | argp->end = (u32*) (argp->rqstp->rq_vec[v].iov_base + argp->rqstp->rq_vec[v].iov_len); |
947 | argp->p = (u32*) (write->wr_vec[v].iov_base + (XDR_QUADLEN(len) << 2)); | 947 | argp->p = (u32*) (argp->rqstp->rq_vec[v].iov_base + (XDR_QUADLEN(len) << 2)); |
948 | write->wr_vec[v].iov_len = len; | 948 | argp->rqstp->rq_vec[v].iov_len = len; |
949 | write->wr_vlen = v+1; | 949 | write->wr_vlen = v+1; |
950 | 950 | ||
951 | DECODE_TAIL; | 951 | DECODE_TAIL; |
@@ -2063,9 +2063,9 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, | |||
2063 | v = 0; | 2063 | v = 0; |
2064 | while (len > 0) { | 2064 | while (len > 0) { |
2065 | pn = resp->rqstp->rq_resused++; | 2065 | pn = resp->rqstp->rq_resused++; |
2066 | read->rd_iov[v].iov_base = | 2066 | resp->rqstp->rq_vec[v].iov_base = |
2067 | page_address(resp->rqstp->rq_respages[pn]); | 2067 | page_address(resp->rqstp->rq_respages[pn]); |
2068 | read->rd_iov[v].iov_len = | 2068 | resp->rqstp->rq_vec[v].iov_len = |
2069 | len < PAGE_SIZE ? len : PAGE_SIZE; | 2069 | len < PAGE_SIZE ? len : PAGE_SIZE; |
2070 | v++; | 2070 | v++; |
2071 | len -= PAGE_SIZE; | 2071 | len -= PAGE_SIZE; |
@@ -2073,7 +2073,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, int nfserr, | |||
2073 | read->rd_vlen = v; | 2073 | read->rd_vlen = v; |
2074 | 2074 | ||
2075 | nfserr = nfsd_read(read->rd_rqstp, read->rd_fhp, read->rd_filp, | 2075 | nfserr = nfsd_read(read->rd_rqstp, read->rd_fhp, read->rd_filp, |
2076 | read->rd_offset, read->rd_iov, read->rd_vlen, | 2076 | read->rd_offset, resp->rqstp->rq_vec, read->rd_vlen, |
2077 | &maxcount); | 2077 | &maxcount); |
2078 | 2078 | ||
2079 | if (nfserr == nfserr_symlink) | 2079 | if (nfserr == nfserr_symlink) |
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 4e06810b6104..ca4973150218 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c | |||
@@ -159,7 +159,7 @@ nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp, | |||
159 | resp->count = argp->count; | 159 | resp->count = argp->count; |
160 | nfserr = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, | 160 | nfserr = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, |
161 | argp->offset, | 161 | argp->offset, |
162 | argp->vec, argp->vlen, | 162 | rqstp->rq_vec, argp->vlen, |
163 | &resp->count); | 163 | &resp->count); |
164 | 164 | ||
165 | if (nfserr) return nfserr; | 165 | if (nfserr) return nfserr; |
@@ -185,7 +185,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp, | |||
185 | 185 | ||
186 | nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, | 186 | nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, |
187 | argp->offset, | 187 | argp->offset, |
188 | argp->vec, argp->vlen, | 188 | rqstp->rq_vec, argp->vlen, |
189 | argp->len, | 189 | argp->len, |
190 | &stable); | 190 | &stable); |
191 | return nfsd_return_attrs(nfserr, resp); | 191 | return nfsd_return_attrs(nfserr, resp); |
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index ad2fba3c54f8..ab6745e78d16 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c | |||
@@ -263,9 +263,9 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, u32 *p, | |||
263 | v=0; | 263 | v=0; |
264 | while (len > 0) { | 264 | while (len > 0) { |
265 | pn = rqstp->rq_resused++; | 265 | pn = rqstp->rq_resused++; |
266 | args->vec[v].iov_base = page_address(rqstp->rq_respages[pn]); | 266 | rqstp->rq_vec[v].iov_base = page_address(rqstp->rq_respages[pn]); |
267 | args->vec[v].iov_len = len < PAGE_SIZE?len:PAGE_SIZE; | 267 | rqstp->rq_vec[v].iov_len = len < PAGE_SIZE?len:PAGE_SIZE; |
268 | len -= args->vec[v].iov_len; | 268 | len -= rqstp->rq_vec[v].iov_len; |
269 | v++; | 269 | v++; |
270 | } | 270 | } |
271 | args->vlen = v; | 271 | args->vlen = v; |
@@ -285,21 +285,21 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, u32 *p, | |||
285 | args->offset = ntohl(*p++); /* offset */ | 285 | args->offset = ntohl(*p++); /* offset */ |
286 | p++; /* totalcount */ | 286 | p++; /* totalcount */ |
287 | len = args->len = ntohl(*p++); | 287 | len = args->len = ntohl(*p++); |
288 | args->vec[0].iov_base = (void*)p; | 288 | rqstp->rq_vec[0].iov_base = (void*)p; |
289 | args->vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - | 289 | rqstp->rq_vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - |
290 | (((void*)p) - rqstp->rq_arg.head[0].iov_base); | 290 | (((void*)p) - rqstp->rq_arg.head[0].iov_base); |
291 | if (len > NFSSVC_MAXBLKSIZE) | 291 | if (len > NFSSVC_MAXBLKSIZE) |
292 | len = NFSSVC_MAXBLKSIZE; | 292 | len = NFSSVC_MAXBLKSIZE; |
293 | v = 0; | 293 | v = 0; |
294 | while (len > args->vec[v].iov_len) { | 294 | while (len > rqstp->rq_vec[v].iov_len) { |
295 | len -= args->vec[v].iov_len; | 295 | len -= rqstp->rq_vec[v].iov_len; |
296 | v++; | 296 | v++; |
297 | args->vec[v].iov_base = page_address(rqstp->rq_pages[v]); | 297 | rqstp->rq_vec[v].iov_base = page_address(rqstp->rq_pages[v]); |
298 | args->vec[v].iov_len = PAGE_SIZE; | 298 | rqstp->rq_vec[v].iov_len = PAGE_SIZE; |
299 | } | 299 | } |
300 | args->vec[v].iov_len = len; | 300 | rqstp->rq_vec[v].iov_len = len; |
301 | args->vlen = v+1; | 301 | args->vlen = v+1; |
302 | return args->vec[0].iov_len > 0; | 302 | return rqstp->rq_vec[0].iov_len > 0; |
303 | } | 303 | } |
304 | 304 | ||
305 | int | 305 | int |