On Wed, 2012-06-27 at 15:28 -0400, Jeff Layton wrote: > On Wed, 27 Jun 2012 18:43:56 +0000 > "Myklebust, Trond" <Trond.Myklebust@xxxxxxxxxx> wrote: > > The reason why we close these sockets is that if the attempt at aborting > > the connection fails, then they typically end up in a TIME_WAIT state. > > > > I'm still trying to wade through the xprtsock.c socket handling code, > but it looks like we currently tear down the connection in 3 different > ways: > > xs_close: which basically calls sock_release and gets rid of our > reference to an existing socket. Most of the places where we disconnect > the socket use this. After this, we end up with srcport == 0 which > makes it pick a new port. > > xs_tcp_shutdown: which calls ->shutdown on it, but doesn't free > anything. This also preserves the existing srcport. > > xs_abort_connection: calls kernel_connect to reconnect the socket to > AF_UNSPEC address (effectively disconnecting it?). This also preserves > the srcport. I guess we use this just before reconnecting when the > remote end drops the connection, since we don't need to be graceful > about tearing anything down at that point. > > The last one actually does reuse the same socket, so my thinking was > that we could extend that scheme to the other cases. If we called > ->shutdown on it and then reconnected it to AF_UNSPEC, would that > "reset" it back to a usable state? Not that I'm aware of. The problem is that most of this stuff is undocumented. For instance, the AF_UNSPEC reconnect is documented only for UDP connections. While Linux implements it for TCP too, there is no spec (that I'm aware of) that explains how that should work. > If there really is no alternative to freeing the socket, then the only > real fix I can see is to set PF_MEMALLOC when we go to create it and > then reset it afterward. That's a pretty ugly fix though... Agreed... -- Trond Myklebust Linux NFS client maintainer NetApp Trond.Myklebust@xxxxxxxxxx www.netapp.com ��.n��������+%������w��{.n�����{��w���jg��������ݢj����G�������j:+v���w�m������w�������h�����٥