diff options
| author | Neil Brown <neilb@cse.unsw.edu.au> | 2002-02-25 22:23:49 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-02-25 22:23:49 -0800 |
| commit | a87d73921a20f3e5df824eb27edff866e8a5169c (patch) | |
| tree | 013167dcdb3fe82c1651bb18d673abf2e6dd9359 /include | |
| parent | cbf593fcd65839fb89ff55a6696896b7841d77cb (diff) | |
[PATCH] PATCH 13/16: NFSD: TCP: Reserve space on sndbuf so we never block when writing
Make sure there is alway adequate sndbuf space for replies.
We keep track of how much space might be needed for replies
and never dequeue a request unless there is adequate space
for a maximal reply. We assume each request will generate a maximal
sized reply until the request is partly decoded.
Each RPC program/procedure can specify the maximum size
of a reply to the precedure (though they don't yet).
The wspace callback is used to enqueue sockets that may be waiting
for sndbuf space to become available.
As there should always be enough buffer space to the full
reply, the only reason that sock_sendmsg could block is due
to a kmalloc delay. As this is likely to be fairly quick (and if
it isn't the server is clagged anyway) we remove the MSG_DONTWAIT
flag, but set a 30 second timeout on waiting. If the wait
ever times out, we close the connection. If it doesn't we can
be sure that we did a complete write.
When a request completes, we make sure that the space
used for the reply does not exceed the space reserved. This
is an internal consistancy check.
This patchs sets the sndbuf and rcvbuf sizes for all sockets
used for rpc service. This size if dependant on the servers bufsize (S) and
partially on the number of threads (N).
For UDP
sndbuf == 5*S
rcvbuf == (N+2)*S
for TCP
sndbuf == N*S
rcvbuf == 3*S
see code for rationale (in comments).
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/sunrpc/svc.h | 6 | ||||
| -rw-r--r-- | include/linux/sunrpc/svcsock.h | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index a7f2bcc327a1..c56c9d726bd0 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -115,6 +115,10 @@ struct svc_rqst { void * rq_argp; /* decoded arguments */ void * rq_resp; /* xdr'd results */ + int rq_reserved; /* space on socket outq + * reserved for this request + */ + /* Catering to nfsd */ struct svc_client * rq_client; /* RPC peer info */ struct svc_cacherep * rq_cacherep; /* cache info */ @@ -163,6 +167,7 @@ struct svc_procedure { unsigned int pc_ressize; /* result struct size */ unsigned int pc_count; /* call count */ unsigned int pc_cachetype; /* cache info (NFS) */ + unsigned int pc_xdrressize; /* maximum size of XDR reply */ }; /* @@ -180,5 +185,6 @@ void svc_destroy(struct svc_serv *); int svc_process(struct svc_serv *, struct svc_rqst *); int svc_register(struct svc_serv *, int, unsigned short); void svc_wake_up(struct svc_serv *); +void svc_reserve(struct svc_rqst *rqstp, int space); #endif /* SUNRPC_SVC_H */ diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h index b8ca275d5ab5..95f52982b49e 100644 --- a/include/linux/sunrpc/svcsock.h +++ b/include/linux/sunrpc/svcsock.h @@ -31,12 +31,15 @@ struct svc_sock { #define SK_QUED 5 /* on serv->sk_sockets */ #define SK_DEAD 6 /* socket closed */ + int sk_reserved; /* space on outq that is reserved */ + int (*sk_recvfrom)(struct svc_rqst *rqstp); int (*sk_sendto)(struct svc_rqst *rqstp); /* We keep the old state_change and data_ready CB's here */ void (*sk_ostate)(struct sock *); void (*sk_odata)(struct sock *, int bytes); + void (*sk_owspace)(struct sock *); /* private TCP part */ int sk_reclen; /* length of record */ @@ -52,5 +55,6 @@ void svc_delete_socket(struct svc_sock *); int svc_recv(struct svc_serv *, struct svc_rqst *, long); int svc_send(struct svc_rqst *); void svc_drop(struct svc_rqst *); +void svc_sock_update_bufs(struct svc_serv *serv); #endif /* SUNRPC_SVCSOCK_H */ |
