[NFS] [PATCH 4/7] SUNRPC: Use shutdown() instead of close() when disconnecting a TCP socket
Trond Myklebust
Trond.Myklebust at netapp.com
Fri Nov 9 08:51:34 EST 2007
On Fri, 2007-11-09 at 08:38 -0500, Talpey, Thomas wrote:
> At 07:39 PM 11/6/2007, Trond Myklebust wrote:
> >From: Trond Myklebust <Trond.Myklebust at netapp.com>
> >
> >By using shutdown() rather than close() we allow the RPC client to wait
> >for the TCP close handshake to complete before we start trying to reconnect
> >using the same port.
> >We use shutdown(SHUT_WR) only instead of shutting down both directions,
> >however we wait until the server has closed the connection on its side.
> >
> >Signed-off-by: Trond Myklebust <Trond.Myklebust at netapp.com>
> >---
> >
> > net/sunrpc/xprtsock.c | 53 +++++++++++++++++++++++++++++++++++++++++++------
> > 1 files changed, 46 insertions(+), 7 deletions(-)
> >
> >diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> >index 99c0166..d610d28 100644
> >--- a/net/sunrpc/xprtsock.c
> >+++ b/net/sunrpc/xprtsock.c
> >@@ -614,6 +614,34 @@ static int xs_udp_send_request(struct rpc_task *task)
> > return status;
> > }
> >
> >+static int xs_shutdown(struct socket *sock, int how)
> >+{
> >+ /*
> >+ * Note: 'how - 1' trick converts
> >+ * RCV_SHUTDOWN -> SHUT_RD = 0
> >+ * SEND_SHUTDOWN -> SHUT_WR = 1
> >+ * RCV_SHUTDOWN|SEND_SHUTDOWN -> SHUT_RDWR = 2
> >+ */
> >+ return sock->ops->shutdown(sock, how - 1);
>
> These #defines might be better if they had XPRT_ or RPCXPRT_ in front
> of them to make it clear they're flags for an RPC API. All by themselves
> they kind of look like a standard networking component.
They're not #defines, but just a comment...
However yesterday I did submit a patch to clean this up by providing the
proper functionality in the networking layer. See
http://article.gmane.org/gmane.linux.network/77163
Cheers
Trond
More information about the NFSv4
mailing list