diff options
author | NeilBrown <neilb@suse.de> | 2006-10-06 03:44:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-06 11:53:41 -0400 |
commit | c6b0a9f87b82f25fa35206ec04b5160372eabab4 (patch) | |
tree | 849ed55115c95a86a3d164d674c178f9504750a5 /net/sunrpc/svc.c | |
parent | 5842730de179405d80649231faa0b3f254477434 (diff) |
[PATCH] knfsd: tidy up up meaning of 'buffer size' in nfsd/sunrpc
There is some confusion about the meaning of 'bufsz' for a sunrpc server.
In some cases it is the largest message that can be sent or received. In
other cases it is the largest 'payload' that can be included in a NFS
message.
In either case, it is not possible for both the request and the reply to be
this large. One of the request or reply may only be one page long, which
fits nicely with NFS.
So we remove 'bufsz' and replace it with two numbers: 'max_payload' and
'max_mesg'. Max_payload is the size that the server requests. It is used
by the server to check the max size allowed on a particular connection:
depending on the protocol a lower limit might be used.
max_mesg is the largest single message that can be sent or received. It is
calculated as the max_payload, rounded up to a multiple of PAGE_SIZE, and
with PAGE_SIZE added to overhead. Only one of the request and reply may be
this size. The other must be at most one page.
Cc: Greg Banks <gnb@sgi.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
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 'net/sunrpc/svc.c')
-rw-r--r-- | net/sunrpc/svc.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index c2c8bb20d07f..2807fa0eab40 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -282,7 +282,10 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, | |||
282 | serv->sv_program = prog; | 282 | serv->sv_program = prog; |
283 | serv->sv_nrthreads = 1; | 283 | serv->sv_nrthreads = 1; |
284 | serv->sv_stats = prog->pg_stats; | 284 | serv->sv_stats = prog->pg_stats; |
285 | serv->sv_bufsz = bufsize? bufsize : 4096; | 285 | if (bufsize > RPCSVC_MAXPAYLOAD) |
286 | bufsize = RPCSVC_MAXPAYLOAD; | ||
287 | serv->sv_max_payload = bufsize? bufsize : 4096; | ||
288 | serv->sv_max_mesg = roundup(serv->sv_max_payload + PAGE_SIZE, PAGE_SIZE); | ||
286 | serv->sv_shutdown = shutdown; | 289 | serv->sv_shutdown = shutdown; |
287 | xdrsize = 0; | 290 | xdrsize = 0; |
288 | while (prog) { | 291 | while (prog) { |
@@ -414,9 +417,9 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size) | |||
414 | int pages; | 417 | int pages; |
415 | int arghi; | 418 | int arghi; |
416 | 419 | ||
417 | if (size > RPCSVC_MAXPAYLOAD) | 420 | pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply. |
418 | size = RPCSVC_MAXPAYLOAD; | 421 | * We assume one is at most one page |
419 | pages = 2 + (size+ PAGE_SIZE -1) / PAGE_SIZE; | 422 | */ |
420 | arghi = 0; | 423 | arghi = 0; |
421 | BUG_ON(pages > RPCSVC_MAXPAGES); | 424 | BUG_ON(pages > RPCSVC_MAXPAGES); |
422 | while (pages) { | 425 | while (pages) { |
@@ -463,7 +466,7 @@ __svc_create_thread(svc_thread_fn func, struct svc_serv *serv, | |||
463 | 466 | ||
464 | if (!(rqstp->rq_argp = kmalloc(serv->sv_xdrsize, GFP_KERNEL)) | 467 | if (!(rqstp->rq_argp = kmalloc(serv->sv_xdrsize, GFP_KERNEL)) |
465 | || !(rqstp->rq_resp = kmalloc(serv->sv_xdrsize, GFP_KERNEL)) | 468 | || !(rqstp->rq_resp = kmalloc(serv->sv_xdrsize, GFP_KERNEL)) |
466 | || !svc_init_buffer(rqstp, serv->sv_bufsz)) | 469 | || !svc_init_buffer(rqstp, serv->sv_max_mesg)) |
467 | goto out_thread; | 470 | goto out_thread; |
468 | 471 | ||
469 | serv->sv_nrthreads++; | 472 | serv->sv_nrthreads++; |
@@ -938,8 +941,8 @@ u32 svc_max_payload(const struct svc_rqst *rqstp) | |||
938 | 941 | ||
939 | if (rqstp->rq_sock->sk_sock->type == SOCK_DGRAM) | 942 | if (rqstp->rq_sock->sk_sock->type == SOCK_DGRAM) |
940 | max = RPCSVC_MAXPAYLOAD_UDP; | 943 | max = RPCSVC_MAXPAYLOAD_UDP; |
941 | if (rqstp->rq_server->sv_bufsz < max) | 944 | if (rqstp->rq_server->sv_max_payload < max) |
942 | max = rqstp->rq_server->sv_bufsz; | 945 | max = rqstp->rq_server->sv_max_payload; |
943 | return max; | 946 | return max; |
944 | } | 947 | } |
945 | EXPORT_SYMBOL_GPL(svc_max_payload); | 948 | EXPORT_SYMBOL_GPL(svc_max_payload); |