On Wed, Mar 30, 2011 at 08:34:24PM +0200, Mark Kettenis wrote:
> > Date: Tue, 29 Mar 2011 22:42:47 +0200
> > From: Claudio Jeker <cje...@diehard.n-r-g.com>
> > 
> > Here is a possible fix. The problem was that because of the way NFS uses
> > the socket API it did not turn of the sendbuffer scaling which reset the
> > size of the socket back to 17376 bytes which is a no go when a buffer of
> > more then 17k is generated by NFS. It is better to initialize the sb_wat
> > in soreserve() which is called by NFS and all attach functions.
> 
> This no longer does the sbcheckreserve() dance though.  Is that alright?
> 

The code that was there previously was a bit strange. Since when
sb_hiwat == 0 is true then sb_wat is 0 as well. Additionally
sbcheckreserve() would only cause the watermark to be set to the default
which is tcp_sendspace/tcp_recvspace. So since sb_hiwat == 0 is never run.

-- 
:wq Claudio

> > Index: netinet/tcp_usrreq.c
> > ===================================================================
> > RCS file: /cvs/src/sys/netinet/tcp_usrreq.c,v
> > retrieving revision 1.105
> > diff -u -p -r1.105 tcp_usrreq.c
> > --- netinet/tcp_usrreq.c    10 Oct 2010 22:02:50 -0000      1.105
> > +++ netinet/tcp_usrreq.c    29 Mar 2011 20:26:55 -0000
> > @@ -653,15 +653,7 @@ tcp_attach(so)
> >     int error;
> >  
> >     if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
> > -           /* if low on memory only allow smaller then default buffers */
> > -           if (so->so_snd.sb_wat == 0 ||
> > -               sbcheckreserve(so->so_snd.sb_wat, tcp_sendspace))
> > -                   so->so_snd.sb_wat = tcp_sendspace;
> > -           if (so->so_rcv.sb_wat == 0 ||
> > -               sbcheckreserve(so->so_rcv.sb_wat, tcp_recvspace))
> > -                   so->so_rcv.sb_wat = tcp_recvspace;
> > -
> > -           error = soreserve(so, so->so_snd.sb_wat, so->so_rcv.sb_wat);
> > +           error = soreserve(so, tcp_sendspace, tcp_recvspace);
> >             if (error)
> >                     return (error);
> >     }
> > Index: kern/uipc_socket2.c
> > ===================================================================
> > RCS file: /cvs/src/sys/kern/uipc_socket2.c,v
> > retrieving revision 1.51
> > diff -u -p -r1.51 uipc_socket2.c
> > --- kern/uipc_socket2.c     24 Sep 2010 02:59:45 -0000      1.51
> > +++ kern/uipc_socket2.c     29 Mar 2011 20:18:46 -0000
> > @@ -353,6 +353,8 @@ soreserve(struct socket *so, u_long sndc
> >             goto bad;
> >     if (sbreserve(&so->so_rcv, rcvcc))
> >             goto bad2;
> > +   so->so_snd.sb_wat = sndcc;
> > +   so->so_rcv.sb_wat = rcvcc;
> >     if (so->so_rcv.sb_lowat == 0)
> >             so->so_rcv.sb_lowat = 1;
> >     if (so->so_snd.sb_lowat == 0)

Reply via email to