Re: sendmsg blocking with sendtimeout vs. non-blocking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 23, 2008 at 09:30:32PM -0400, Jim Rees wrote:
> Steve French wrote:
> 
>   If that is the case (ie that cifs and nfs never need to set these over
>   tcp - I am still having trouble reconciling that with the NFS guys'
>   comments that they must set rcvbuf (and Jim's comment below)
> 
> If you have an application that wants to read a big chunk of data from a
> socket, and won't remove any of that data from the socket until the entire
> chunk has arrived, then the application must set the receive socket buffer
> size big enough to hold the entire chunk.  Otherwise the application will
> stall.
> 
Thats not true.  Assuming there is sufficient memory available, and the tcp
segments receive window isn't closed, then you will continue to receive data, as
not setting SO_RCVBUF will allow the receive buffers to autotune in size.

I know this is getting off the subject a bit, but if cifs is waiting for an
entire message to arrive on a tcp segment before it reads it, thats a cifs
design flaw.  While you can send messages accross stream oriented sockets, you
can't enforce message boundaries for data still in the receive buffer.  Since
the application (cifs in this case) can't (and shouldn't) have visibility into
the tcp sockets congestion window or recieve window, you'll never really know if
you'll be waiting forever for data that is waiting for you to read it out of the
socket.  The correct solution is to read data out of the socket into a temporary
buffer that you allocate in the cifs code, and loop repetatively calling
recv[msg|from] until such time as the entire message has been read.


> As far as I can tell, the corresponding situation does not hold for send
> buffers, because the tcp layer will grow the send buffer to be big enough to
> hold whatever the application wants to send.  But I don't know if that's
> always true, or if there is some limit, so to be safe our NFS patch
> continues to set both the receive and send buffer sizes.

receive buffers do the same thing as send buffers in regards to autotuning.  You
may have had to set SO_RCVBUF previously, but that should no longer be the case

Neil

-- 
/***************************************************
 *Neil Horman
 *Senior Software Engineer
 *Red Hat, Inc.
 *nhorman@xxxxxxxxxx
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***************************************************/
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux