public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Statd port change recovery
@ 2014-09-23 16:26 Benjamin Coddington
  2014-09-23 16:26 ` [PATCH 1/2] SUNRPC: Don't wake tasks during connection abort Benjamin Coddington
  2014-09-23 16:26 ` [PATCH 2/2] lockd: Try to reconnect if statd has moved Benjamin Coddington
  0 siblings, 2 replies; 3+ messages in thread
From: Benjamin Coddington @ 2014-09-23 16:26 UTC (permalink / raw)
  To: linux-nfs

These two attempt to address the issue of the kernel not recovering from
a statd port change, which Bruce pointed out in

http://marc.info/?t=140865700700001&r=1&w=2

The second patch here re-attempts the call after doing rpc_force_rebind
which is basically copied from what NLM would do in the same case.  However,
while working on that I discovered that when the transport attempts to reuse
a socket in the first call after rpc_force_rebind, it calls kernel_connect
with AF_UNSPEC to disconnect, which wakes the task in xs_error_report.  The
change in the task's status causes the first call after rpc_force_rebind to
fail, and a soft task returns which would otherwise succeed if the
connection had already been up.

The first patch tries to remedy this by not waking the task if we end up in
xs_error_report while trying to reuse the connection.  We expect to end up
in xs_error_report with an error, but we don't want to wake the task yet
since we're already set up to immediately reconnect.

Benjamin Coddington (2):
  SUNRPC: Don't wake tasks during connection abort
  lockd: Try to reconnect if statd has moved

 fs/lockd/mon.c              |    6 ++++++
 include/linux/sunrpc/xprt.h |    1 +
 net/sunrpc/xprtsock.c       |    4 ++++
 3 files changed, 11 insertions(+), 0 deletions(-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] SUNRPC: Don't wake tasks during connection abort
  2014-09-23 16:26 [PATCH 0/2] Statd port change recovery Benjamin Coddington
@ 2014-09-23 16:26 ` Benjamin Coddington
  2014-09-23 16:26 ` [PATCH 2/2] lockd: Try to reconnect if statd has moved Benjamin Coddington
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Coddington @ 2014-09-23 16:26 UTC (permalink / raw)
  To: linux-nfs

When aborting a connection to preserve source ports, don't wake the task in
xs_error_report.  This allows tasks with RPC_TASK_SOFTCONN to succeed if the
connection needs to be re-established since it preserves the task's status
instead of setting it to the status of the aborting kernel_connect().

This may also avoid a potential conflict on the socket's lock.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 include/linux/sunrpc/xprt.h |    1 +
 net/sunrpc/xprtsock.c       |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index fcbfe87..cf391ee 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -357,6 +357,7 @@ int			xs_swapper(struct rpc_xprt *xprt, int enable);
 #define XPRT_CONNECTION_ABORT	(7)
 #define XPRT_CONNECTION_CLOSE	(8)
 #define XPRT_CONGESTED		(9)
+#define XPRT_CONNECTION_REUSE	(10)
 
 static inline void xprt_set_connected(struct rpc_xprt *xprt)
 {
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 43cd89e..700f879 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -845,6 +845,8 @@ static void xs_error_report(struct sock *sk)
 	dprintk("RPC:       xs_error_report client %p, error=%d...\n",
 			xprt, -err);
 	trace_rpc_socket_error(xprt, sk->sk_socket, err);
+	if (test_bit(XPRT_CONNECTION_REUSE, &xprt->state))
+		goto out;
 	xprt_wake_pending_tasks(xprt, err);
  out:
 	read_unlock_bh(&sk->sk_callback_lock);
@@ -2245,7 +2247,9 @@ static void xs_tcp_setup_socket(struct work_struct *work)
 		abort_and_exit = test_and_clear_bit(XPRT_CONNECTION_ABORT,
 				&xprt->state);
 		/* "close" the socket, preserving the local port */
+		set_bit(XPRT_CONNECTION_REUSE, &xprt->state);
 		xs_tcp_reuse_connection(transport);
+		clear_bit(XPRT_CONNECTION_REUSE, &xprt->state);
 
 		if (abort_and_exit)
 			goto out_eagain;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] lockd: Try to reconnect if statd has moved
  2014-09-23 16:26 [PATCH 0/2] Statd port change recovery Benjamin Coddington
  2014-09-23 16:26 ` [PATCH 1/2] SUNRPC: Don't wake tasks during connection abort Benjamin Coddington
@ 2014-09-23 16:26 ` Benjamin Coddington
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Coddington @ 2014-09-23 16:26 UTC (permalink / raw)
  To: linux-nfs

If rpc.statd is restarted, upcalls to monitor hosts can fail with
ECONNREFUSED.  In that case force a lookup of statd's new port and retry the
upcall.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/lockd/mon.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index daa8e75..9106f42 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -159,6 +159,12 @@ static int nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res,
 
 	msg.rpc_proc = &clnt->cl_procinfo[proc];
 	status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFTCONN);
+	if (status == -ECONNREFUSED) {
+		dprintk("lockd:	NSM upcall RPC failed, status=%d, forcing rebind\n",
+				status);
+		rpc_force_rebind(clnt);
+		status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFTCONN);
+	}
 	if (status < 0)
 		dprintk("lockd: NSM upcall RPC failed, status=%d\n",
 				status);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-23 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-23 16:26 [PATCH 0/2] Statd port change recovery Benjamin Coddington
2014-09-23 16:26 ` [PATCH 1/2] SUNRPC: Don't wake tasks during connection abort Benjamin Coddington
2014-09-23 16:26 ` [PATCH 2/2] lockd: Try to reconnect if statd has moved Benjamin Coddington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox