]> git.hungrycats.org Git - linux/commitdiff
[PATCH] increase socket buffer for RPC over UDP
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Fri, 26 Jul 2002 07:00:14 +0000 (00:00 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Fri, 26 Jul 2002 07:00:14 +0000 (00:00 -0700)
Make RPC over UDP use a socket buffer size that is large enough to fit
all the messages. Congestion control is in any case handled by the Van
Jacobson algoritm, and we need to work around a bug in
ip_build_xmit_slow() w.r.t. fragmentation when there is insufficient
buffer memory to fit the entire message.

fs/nfs/inode.c
include/linux/sunrpc/clnt.h
include/linux/sunrpc/xprt.h
net/sunrpc/clnt.c
net/sunrpc/sunrpc_syms.c
net/sunrpc/xprt.c

index 40ad8333e475a25a46f1f0413acfe9ad052b125e..ce7ad8ae64a33af44cc19ee80c4a3f2724ada529 100644 (file)
@@ -425,7 +425,8 @@ int nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int sile
                goto failure_kill_reqlist;
        }
 
-       /* We're airborne */
+       /* We're airborne Set socket buffersize */
+       rpc_setbufsize(clnt, server->wsize + 100, server->rsize + 100);
 
        /* Check whether to start the lockd process */
        if (!(server->flags & NFS_MOUNT_NONLM))
index d278df00ecb9760fd9077cbe5094df7e1f94f1df..92fa9755592e92feec331c263a1c76a636904bd0 100644 (file)
@@ -127,6 +127,7 @@ int         rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
 void           rpc_restart_call(struct rpc_task *);
 void           rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
 void           rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
+void           rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
 
 static __inline__
 int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
index e3c7a6b9c5ba47efcb604a39b480102fc2ceb422..c9b93c6a7a27da9159c5f7b486581b292102cab4 100644 (file)
@@ -122,6 +122,9 @@ struct rpc_xprt {
        unsigned long           cong;           /* current congestion */
        unsigned long           cwnd;           /* congestion window */
 
+       unsigned int            rcvsize,        /* socket receive buffer size */
+                               sndsize;        /* socket send buffer size */
+
        struct rpc_wait_queue   sending;        /* requests waiting to send */
        struct rpc_wait_queue   resend;         /* requests waiting to resend */
        struct rpc_wait_queue   pending;        /* requests in flight */
@@ -177,6 +180,7 @@ int                 xprt_adjust_timeout(struct rpc_timeout *);
 void                   xprt_release(struct rpc_task *);
 void                   xprt_reconnect(struct rpc_task *);
 int                    xprt_clear_backlog(struct rpc_xprt *);
+void                   xprt_sock_setbufsize(struct rpc_xprt *);
 
 #define XPRT_CONNECT   0
 
index 4d98ac870e8564049ab1418a896832d21c688a48..001c2253ec8fa3122022648ffe197978e86172af 100644 (file)
@@ -335,6 +335,20 @@ rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags)
                rpcproc_count(task->tk_client, task->tk_msg.rpc_proc)++;
 }
 
+void
+rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize)
+{
+       struct rpc_xprt *xprt = clnt->cl_xprt;
+
+       xprt->sndsize = 0;
+       if (sndsize)
+               xprt->sndsize = sndsize + RPC_SLACK_SPACE;
+       xprt->rcvsize = 0;
+       if (rcvsize)
+               xprt->rcvsize = rcvsize + RPC_SLACK_SPACE;
+       xprt_sock_setbufsize(xprt);
+}
+
 /*
  * Restart an (async) RPC call. Usually called from within the
  * exit handler.
index d6bdb4630d2d37c8e9f1ac23cdced5cb4061f942..2b41eb87de5d7b36dc151685693eb3e757e3f5f6 100644 (file)
@@ -50,6 +50,7 @@ EXPORT_SYMBOL(rpc_clnt_sigmask);
 EXPORT_SYMBOL(rpc_clnt_sigunmask);
 EXPORT_SYMBOL(rpc_delay);
 EXPORT_SYMBOL(rpc_restart_call);
+EXPORT_SYMBOL(rpc_setbufsize);
 
 /* Client transport */
 EXPORT_SYMBOL(xprt_create_proto);
index d805ed6c08d1d91d2c471a36bd27e145b53d80a1..3d4ba37b48e11561f423364361d7b05d3cfc2926 100644 (file)
@@ -1420,6 +1420,27 @@ xprt_bind_socket(struct rpc_xprt *xprt, struct socket *sock)
        return 0;
 }
 
+/*
+ * Set socket buffer length
+ */
+void
+xprt_sock_setbufsize(struct rpc_xprt *xprt)
+{
+       struct sock *sk = xprt->inet;
+
+       if (xprt->stream)
+               return;
+       if (xprt->rcvsize) {
+               sk->userlocks |= SOCK_RCVBUF_LOCK;
+               sk->rcvbuf = xprt->rcvsize * RPC_MAXCONG * 2;
+       }
+       if (xprt->sndsize) {
+               sk->userlocks |= SOCK_SNDBUF_LOCK;
+               sk->sndbuf = xprt->sndsize * RPC_MAXCONG * 2;
+               sk->write_space(sk);
+       }
+}
+
 /*
  * Create a client socket given the protocol and peer address.
  */