Skip to contentSkip to conversation

NFS: Detect unreachable NFS/RDMA servers more reliably

PATCH In review Chuck Lever 2 participants 8 messages Dec 16, 2016 – Jan 13, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFS: Detect unreachable NFS/RDMA servers more reliably

Current NFS clients rely on connection loss to determine when to retransmit. In particular, for protocols like NFSv4, clients no longer rely on RPC timeouts to drive retransmission: NFSv4 servers are required to terminate a connection when they need a client to retransmit pending RPCs.

When a server is no longer reachable, either because it has crashed or because the network path has broken, the server cannot actively terminate a connection. Thus NFS clients depend on transport-level keepalive to determine when a connection must be replaced and pending RPCs retransmitted.

However, RDMA RC connections do not have a native keepalive mechanism. If an NFS/RDMA server crashes after a client has sent RPCs successfully (an RC ACK has been received for all OTW RDMA requests), there is no way for the client to know the connection is moribund.

In addition, new RDMA requests are subject to the RPC-over-RDMA credit limit. If the client has consumed all granted credits with NFS traffic, it is not allowed to send another RDMA request until the server replies. Thus it has no way to send a true keepalive when the workload has already consumed all credits with pending RPCs.

To address this, we reserve one RPC-over-RDMA credit that may be used only for an NFS NULL. A periodic RPC ping is done on transports whenever there are outstanding RPCs.

The purpose of this ping is to drive traffic regularly on each connection to force the transport layer to disconnect it if it is no longer viable. Some RDMA operations are fully offloaded to the HCA, and can be successful even if the remote host has crashed. Thus an operation that requires that the server is responsive is used for the ping.

This implementation re-uses existing generic RPC infrastructure to form each NULL Call. An rpc_clnt context must be available to start an RPC. Thus a generic keepalive mechanism is introduced so that both an rpc_clnt and an rpc_xprt is available to perform the ping.

---

Before sending this for internal testing, I'd like to hear comments on this approach. It's a little more churn than I had hoped for.

 fs/nfs/nfs4client.c             |    1 
 include/linux/sunrpc/clnt.h     |    2 +
 include/linux/sunrpc/sched.h    |    3 +
 include/linux/sunrpc/xprt.h     |    1 
 net/sunrpc/clnt.c               |  101 +++++++++++++++++++++++++++++++++++++++
 net/sunrpc/sched.c              |   19 +++++++
 net/sunrpc/xprt.c               |    5 ++
 net/sunrpc/xprtrdma/rpc_rdma.c  |    4 +-
 net/sunrpc/xprtrdma/transport.c |   13 +++++
 9 files changed, 148 insertions(+), 1 deletion(-)
fs/nfs/nfs4client.c +1 -0
index 074ac71..c5f5ce8 100644
@@ -378,6 +378,7 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
 		error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
 	if (error < 0)
 		goto error;
+	rpc_schedule_keepalive(clp->cl_rpcclient);
 
 	/* If no clientaddr= option was specified, find a usable cb address */
 	if (ip_addr == NULL) {
include/linux/sunrpc/clnt.h +2 -0
index 85cc819..443a955 100644
@@ -69,6 +69,7 @@ struct rpc_clnt {
 	struct dentry		*cl_debugfs;	/* debugfs directory */
 #endif
 	struct rpc_xprt_iter	cl_xpi;
+	struct delayed_work	cl_ka_worker;
 };
 
 /*
@@ -187,6 +188,7 @@ struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
 size_t		rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
 const char	*rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
 int		rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t);
+void		rpc_schedule_keepalive(struct rpc_clnt *clnt);
 
 int 		rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt,
 			int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *),
include/linux/sunrpc/sched.h +3 -0
index 7ba040c..fd5d7ca 100644
@@ -127,6 +127,7 @@ struct rpc_task_setup {
 #define RPC_TASK_TIMEOUT	0x1000		/* fail with ETIMEDOUT on timeout */
 #define RPC_TASK_NOCONNECT	0x2000		/* return ENOTCONN if not connected */
 #define RPC_TASK_NO_RETRANS_TIMEOUT	0x4000		/* wait forever for a reply */
+#define RPC_TASK_PRIORITY	0x8000		/* skip congestion control */
 
 #define RPC_IS_ASYNC(t)		((t)->tk_flags & RPC_TASK_ASYNC)
 #define RPC_IS_SWAPPER(t)	((t)->tk_flags & RPC_TASK_SWAPPER)
@@ -135,6 +136,7 @@ struct rpc_task_setup {
 #define RPC_IS_SOFT(t)		((t)->tk_flags & (RPC_TASK_SOFT|RPC_TASK_TIMEOUT))
 #define RPC_IS_SOFTCONN(t)	((t)->tk_flags & RPC_TASK_SOFTCONN)
 #define RPC_WAS_SENT(t)		((t)->tk_flags & RPC_TASK_SENT)
+#define RPC_HAS_PRIORITY(t)	((t)->tk_flags & RPC_TASK_PRIORITY)
 
 #define RPC_TASK_RUNNING	0
 #define RPC_TASK_QUEUED		1
@@ -238,6 +240,7 @@ struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *,
 					bool (*)(struct rpc_task *, void *),
 					void *);
 void		rpc_wake_up_status(struct rpc_wait_queue *, int);
+bool		rpc_wait_queue_is_active(struct rpc_wait_queue *queue);
 void		rpc_delay(struct rpc_task *, unsigned long);
 int		rpc_malloc(struct rpc_task *);
 void		rpc_free(struct rpc_task *);
include/linux/sunrpc/xprt.h +1 -0
index a5da60b..603cd67 100644
@@ -222,6 +222,7 @@ struct rpc_xprt {
 	unsigned long		last_used,
 				idle_timeout,
 				max_reconnect_timeout;
+	bool			keepalive;
 
 	/*
 	 * Send stuff
net/sunrpc/clnt.c +101 -0

125 lines not on this page · raw message

net/sunrpc/sched.c +19 -0
index 5db68b3..bb98a9f 100644
@@ -635,6 +635,25 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status)
 }
 EXPORT_SYMBOL_GPL(rpc_wake_up_status);
 
+/**
+ * rpc_wait_queue_is_active - check if there are queue waiters
+ * @queue: rpc_wait_queue on which the tasks are sleeping
+ *
+ * Grabs queue->lock
+ */
+bool rpc_wait_queue_is_active(struct rpc_wait_queue *queue)
+{
+	struct list_head *head;
+	bool result;
+
+	spin_lock_bh(&queue->lock);
+	head = &queue->tasks[queue->maxpriority];
+	result = !list_empty(head);
+	spin_unlock_bh(&queue->lock);
+
+	return result;
+}
+
 static void __rpc_queue_timer_fn(unsigned long ptr)
 {
 	struct rpc_wait_queue *queue = (struct rpc_wait_queue *)ptr;
net/sunrpc/xprt.c +5 -0
index 685e6d2..941949c 100644
@@ -392,6 +392,10 @@ static inline void xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *ta
 {
 	struct rpc_rqst *req = task->tk_rqstp;
 
+	if (RPC_HAS_PRIORITY(task)) {
+		req->rq_cong = 0;
+		return 1;
+	}
 	if (req->rq_cong)
 		return 1;
 	dprintk("RPC: %5u xprt_cwnd_limited cong = %lu cwnd = %lu\n",
@@ -1328,6 +1332,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net)
 	xprt->last_used = jiffies;
 	xprt->cwnd = RPC_INITCWND;
 	xprt->bind_index = 0;
+	xprt->keepalive = false;
 
 	rpc_init_wait_queue(&xprt->binding, "xprt_binding");
 	rpc_init_wait_queue(&xprt->pending, "xprt_pending");
net/sunrpc/xprtrdma/rpc_rdma.c +3 -1
index c52e0f2..9631fcf 100644
@@ -1083,7 +1083,9 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt,
 
 	spin_lock_bh(&xprt->transport_lock);
 	cwnd = xprt->cwnd;
-	xprt->cwnd = atomic_read(&r_xprt->rx_buf.rb_credits) << RPC_CWNDSHIFT;
+	/* Reserve one credit for keepalive ping */
+	xprt->cwnd = atomic_read(&r_xprt->rx_buf.rb_credits) - 1;
+	xprt->cwnd <<= RPC_CWNDSHIFT;
 	if (xprt->cwnd > cwnd)
 		xprt_release_rqst_cong(rqst->rq_task);
 
net/sunrpc/xprtrdma/transport.c +13 -0
index 534c178..cb6e67b 100644
@@ -312,6 +312,18 @@
 	module_put(THIS_MODULE);
 }
 
+static bool
+rpcrdma_need_keepalive(struct rpcrdma_xprt *r_xprt)
+{
+	struct rdma_cm_id *id = r_xprt->rx_ia.ri_id;
+
+	/* RDMA RC on InfiniBand has no native keepalive
+	 * mechanism. iWARP runs on a lower layer that
+	 * already provides keepalive.
+	 */
+	return !rdma_protocol_iwarp(id->device, id->port_num);
+}
+
 static const struct rpc_timeout xprt_rdma_default_timeout = {
 	.to_initval = 60 * HZ,
 	.to_maxval = 60 * HZ,
@@ -433,6 +445,7 @@
 	xprt->max_payload = new_xprt->rx_ia.ri_ops->ro_maxpages(new_xprt);
 	if (xprt->max_payload == 0)
 		goto out4;
+	xprt->keepalive = rpcrdma_need_keepalive(new_xprt);
 	xprt->max_payload <<= PAGE_SHIFT;
 	dprintk("RPC:       %s: transport data payload maximum: %zu bytes\n",
 		__func__, xprt->max_payload);
#1 lore raw

T24gRnJpLCAyMDE2LTEyLTE2IGF0IDExOjQ4IC0wNTAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g Q3VycmVudCBORlMgY2xpZW50cyByZWx5IG9uIGNvbm5lY3Rpb24gbG9zcyB0byBkZXRlcm1pbmUg d2hlbiB0bw0KPiByZXRyYW5zbWl0LiBJbiBwYXJ0aWN1bGFyLCBmb3IgcHJvdG9jb2xzIGxpa2Ug TkZTdjQsIGNsaWVudHMgbm8NCj4gbG9uZ2VyIHJlbHkgb24gUlBDIHRpbWVvdXRzIHRvIGRyaXZl IHJldHJhbnNtaXNzaW9uOiBORlN2NCBzZXJ2ZXJzDQo+IGFyZSByZXF1aXJlZCB0byB0ZXJtaW5h dGUgYSBjb25uZWN0aW9uIHdoZW4gdGhleSBuZWVkwqDCoGEgY2xpZW50IHRvDQo+IHJldHJhbnNt aXQgcGVuZGluZyBSUENzLg0KPiANCj4gV2hlbiBhIHNlcnZlciBpcyBubyBsb25nZXIgcmVhY2hh YmxlLCBlaXRoZXIgYmVjYXVzZSBpdCBoYXMgY3Jhc2hlZA0KPiBvciBiZWNhdXNlIHRoZSBuZXR3 b3JrIHBhdGggaGFzIGJyb2tlbiwgdGhlIHNlcnZlciBjYW5ub3QgYWN0aXZlbHkNCj4gdGVybWlu YXRlIGEgY29ubmVjdGlvbi4gVGh1cyBORlMgY2xpZW50cyBkZXBlbmQgb24gdHJhbnNwb3J0LWxl dmVsDQo+IGtlZXBhbGl2ZSB0byBkZX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cyBjaGFuZ2VkLCAxNDggaW5zZXJ0aW9ucygr KSwgMSBkZWxldGlvbigtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL2ZzL25mcy9uZnM0Y2xpZW50LmMg Yi9mcy9uZnMvbmZzNGNsaWVudC5jDQo+IGluZGV4IDA3NGFjNzEuLmM1ZjVjZTggMTAwNjQ0DQo+ IC0tLSBhL2ZzL25mcy9uZnM0Y2xpZW50LmMNCj4gKysrIGIvZnMvbmZzL25mczRjbGllbnQuYw0K PiBAQCAtMzc4LDYgKzM3OCw3IEBAIHN0cnVjdCBuZnNfY2xpZW50ICpuZnM0X2luaXRfY2xpZW50 KHN0cnVjdA0KPiBuZnNfY2xpZW50ICpjbHAsDQo+IMKgCQllcnJvciA9IG5mc19jcmVhdGVfcnBj X2NsaWVudChjbHAsIGNsX2luaXQsDQo+IFJQQ19BVVRIX1VOSVgpOw0KPiDCoAlpZiAoZXJyb3Ig PCAwKQ0KPiDCoAkJZ290byBlcnJvcjsNCj4gKwlycGNfc2NoZWR1bGVfa2VlcGFsaXZlKGNscC0+ Y2xfcnBjY2xpZW50KTsNCg0KV2h5IGRvIHdlIHdhbnQgdG8gZW5hYmxlIHRoaXMgZm9yIG5vbi1S RE1BIHRyYW5zcG9ydHM/IFNob3VsZG4ndCB0aGlzDQpmdW5jdGlvbmFsaXR5IGJlIGhpZGRlbiBp biB0aGUgUkRNQSBjbGllbnQgY29kZSwgaW4gdGhlIHNhbWUgd2F5IHRoYXQNCnRoZSBUQ1Aga2Vl cGFsaXZlIGlzIGhpZGRlbiBpbiB0aGUgc29ja2V0IGNvZGUuDQoNCi0tIA0KVHJvbmQgTXlrbGVi dXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXIsIFByaW1hcnlEYXRhDQp0cm9uZC5teWts ZWJ1c3RAcHJpbWFyeWRhdGEuY29tDQo=

#2 lore raw
Quoted 63 lines · Trond Myklebust
Quoted 59 lines · Chuck Lever

Current NFS clients rely on connection loss to determine when to retransmit. In particular, for protocols like NFSv4, clients no longer rely on RPC timeouts to drive retransmission: NFSv4 servers are required to terminate a connection when they need a client to retransmit pending RPCs.

When a server is no longer reachable, either because it has crashed or because the network path has broken, the server cannot actively terminate a connection. Thus NFS clients depend on transport-level keepalive to determine when a connection must be replaced and pending RPCs retransmitted.

However, RDMA RC connections do not have a native keepalive mechanism. If an NFS/RDMA server crashes after a client has sent RPCs successfully (an RC ACK has been received for all OTW RDMA requests), there is no way for the client to know the connection is moribund.

In addition, new RDMA requests are subject to the RPC-over-RDMA credit limit. If the client has consumed all granted credits with NFS traffic, it is not allowed to send another RDMA request until the server replies. Thus it has no way to send a true keepalive when the workload has already consumed all credits with pending RPCs.

To address this, we reserve one RPC-over-RDMA credit that may be used only for an NFS NULL. A periodic RPC ping is done on transports whenever there are outstanding RPCs.

The purpose of this ping is to drive traffic regularly on each connection to force the transport layer to disconnect it if it is no longer viable. Some RDMA operations are fully offloaded to the HCA, and can be successful even if the remote host has crashed. Thus an operation that requires that the server is responsive is used for the ping.

This implementation re-uses existing generic RPC infrastructure to form each NULL Call. An rpc_clnt context must be available to start an RPC. Thus a generic keepalive mechanism is introduced so that both an rpc_clnt and an rpc_xprt is available to perform the ping.

---

Before sending this for internal testing, I'd like to hear comments on this approach. It's a little more churn than I had hoped for.

 fs/nfs/nfs4client.c             |    1 
 include/linux/sunrpc/clnt.h     |    2 +
 include/linux/sunrpc/sched.h    |    3 +
 include/linux/sunrpc/xprt.h     |    1 
 net/sunrpc/clnt.c               |  101
+++++++++++++++++++++++++++++++++++++++
 net/sunrpc/sched.c              |   19 +++++++
 net/sunrpc/xprt.c               |    5 ++
 net/sunrpc/xprtrdma/rpc_rdma.c  |    4 +-
 net/sunrpc/xprtrdma/transport.c |   13 +++++
 9 files changed, 148 insertions(+), 1 deletion(-)
Quoted 15 lines

fs/nfs/nfs4client.c struct nfs_client *nfs4_init_client(struct · line 383

Quoted 11 lines
fs/nfs/nfs4client.c +1 -0
index 074ac71..c5f5ce8 100644
@@ -378,6 +378,7 @@ struct nfs_client *nfs4_init_client(struct
 nfs_client *clp,
 		error = nfs_create_rpc_client(clp, cl_init,
 RPC_AUTH_UNIX);
 	if (error < 0)
 		goto error;
+	rpc_schedule_keepalive(clp->cl_rpcclient);

Why do we want to enable this for non-RDMA transports? Shouldn't this functionality be hidden in the RDMA client code, in the same way that the TCP keepalive is hidden in the socket code.

Sending a NULL request by re-using the normal RPC infrastructure requires a struct rpc_clnt. Thus it has to be driven by an upper layer context.

I'm open to suggestions.

--
Chuck Lever

#3 lore raw
Quoted 5 lines · Chuck Lever

=20
=20

Quoted 1 line

On Jan 12, 2017, at 12:38 PM, Trond Myklebust <[email protected]> =

Quoted 76 lines · wrote:
Quoted 68 lines

=20

Quoted 66 lines · Chuck Lever

Current NFS clients rely on connection loss to determine when to retransmit. In particular, for protocols like NFSv4, clients no longer rely on RPC timeouts to drive retransmission: NFSv4 servers are required to terminate a connection when they need a client to retransmit pending RPCs.
=20
When a server is no longer reachable, either because it has crashed or because the network path has broken, the server cannot actively terminate a connection. Thus NFS clients depend on transport-level keepalive to determine when a connection must be replaced and pending RPCs retransmitted.
=20
However, RDMA RC connections do not have a native keepalive mechanism. If an NFS/RDMA server crashes after a client has sent RPCs successfully (an RC ACK has been received for all OTW RDMA requests), there is no way for the client to know the connection is moribund.
=20
In addition, new RDMA requests are subject to the RPC-over-RDMA credit limit. If the client has consumed all granted credits with NFS traffic, it is not allowed to send another RDMA request until the server replies. Thus it has no way to send a true keepalive when the workload has already consumed all credits with pending RPCs. =20
To address this, we reserve one RPC-over-RDMA credit that may be used only for an NFS NULL. A periodic RPC ping is done on transports whenever there are outstanding RPCs.
=20
The purpose of this ping is to drive traffic regularly on each connection to force the transport layer to disconnect it if it is no longer viable. Some RDMA operations are fully offloaded to the HCA, and can be successful even if the remote host has crashed. Thus an operation that requires that the server is responsive is used for the ping.
=20
This implementation re-uses existing generic RPC infrastructure to form each NULL Call. An rpc_clnt context must be available to start an RPC. Thus a generic keepalive mechanism is introduced so that both an rpc_clnt and an rpc_xprt is available to perform the ping. =20

---
=20
Before sending this for internal testing, I'd like to hear comments on this approach. It's a little more churn than I had hoped for. =20
=20

fs/nfs/nfs4client.c             |    1=20
include/linux/sunrpc/clnt.h     |    2 +
include/linux/sunrpc/sched.h    |    3 +
include/linux/sunrpc/xprt.h     |    1=20
net/sunrpc/clnt.c               |  101
+++++++++++++++++++++++++++++++++++++++
net/sunrpc/sched.c              |   19 +++++++
net/sunrpc/xprt.c               |    5 ++
net/sunrpc/xprtrdma/rpc_rdma.c  |    4 +-
net/sunrpc/xprtrdma/transport.c |   13 +++++
9 files changed, 148 insertions(+), 1 deletion(-)

=20

fs/nfs/nfs4client.c +0 -0
index 074ac71..c5f5ce8 100644
@@ -378,6 +378,7 @@ struct nfs_client *nfs4_init_client(struct
 nfs_client *clp,
 =09=09error =3D nfs_create_rpc_client(clp, cl_init,
Quoted 8 lines

fs/nfs/nfs4client.c struct nfs_client *nfs4_init_client(struct · line 383

Quoted 4 lines
fs/nfs/nfs4client.c +1 -0
 RPC_AUTH_UNIX);
 =09if (error < 0)
 =09=09goto error;
+=09rpc_schedule_keepalive(clp->cl_rpcclient);

=20
Why do we want to enable this for non-RDMA transports? Shouldn't this functionality be hidden in the RDMA client code, in the same way that the TCP keepalive is hidden in the socket code.

Quoted 7 lines

=20
Sending a NULL request by re-using the normal RPC infrastructure requires a struct rpc_clnt. Thus it has to be driven by an upper layer context.
=20
I'm open to suggestions.
=20

Ideally we just want this to operate when there are outstanding RPC calls w= aiting for a reply, am I correct?

If so, perhaps we might have it triggersd by a timer that is armed in xprt-=

Quoted 1 line

ops->send_request() and disarmed in xprt->ops->release_xprt()? It might th=

en configure itself by looking in the xprt->recv list to find a hanging rpc= _task and steal its rpc_client info.

Cheers
Trond

#4 lore raw
Quoted 89 lines · Trond Myklebust
Quoted 87 lines · Chuck Lever
Quoted 64 lines · Trond Myklebust
Quoted 59 lines · Chuck Lever

Current NFS clients rely on connection loss to determine when to retransmit. In particular, for protocols like NFSv4, clients no longer rely on RPC timeouts to drive retransmission: NFSv4 servers are required to terminate a connection when they need a client to retransmit pending RPCs.

When a server is no longer reachable, either because it has crashed or because the network path has broken, the server cannot actively terminate a connection. Thus NFS clients depend on transport-level keepalive to determine when a connection must be replaced and pending RPCs retransmitted.

However, RDMA RC connections do not have a native keepalive mechanism. If an NFS/RDMA server crashes after a client has sent RPCs successfully (an RC ACK has been received for all OTW RDMA requests), there is no way for the client to know the connection is moribund.

In addition, new RDMA requests are subject to the RPC-over-RDMA credit limit. If the client has consumed all granted credits with NFS traffic, it is not allowed to send another RDMA request until the server replies. Thus it has no way to send a true keepalive when the workload has already consumed all credits with pending RPCs.

To address this, we reserve one RPC-over-RDMA credit that may be used only for an NFS NULL. A periodic RPC ping is done on transports whenever there are outstanding RPCs.

The purpose of this ping is to drive traffic regularly on each connection to force the transport layer to disconnect it if it is no longer viable. Some RDMA operations are fully offloaded to the HCA, and can be successful even if the remote host has crashed. Thus an operation that requires that the server is responsive is used for the ping.

This implementation re-uses existing generic RPC infrastructure to form each NULL Call. An rpc_clnt context must be available to start an RPC. Thus a generic keepalive mechanism is introduced so that both an rpc_clnt and an rpc_xprt is available to perform the ping.

---

Before sending this for internal testing, I'd like to hear comments on this approach. It's a little more churn than I had hoped for.

fs/nfs/nfs4client.c             |    1 
include/linux/sunrpc/clnt.h     |    2 +
include/linux/sunrpc/sched.h    |    3 +
include/linux/sunrpc/xprt.h     |    1 
net/sunrpc/clnt.c               |  101
+++++++++++++++++++++++++++++++++++++++
net/sunrpc/sched.c              |   19 +++++++
net/sunrpc/xprt.c               |    5 ++
net/sunrpc/xprtrdma/rpc_rdma.c  |    4 +-
net/sunrpc/xprtrdma/transport.c |   13 +++++
9 files changed, 148 insertions(+), 1 deletion(-)
Quoted 15 lines

fs/nfs/nfs4client.c struct nfs_client *nfs4_init_client(struct · line 383

Quoted 11 lines
fs/nfs/nfs4client.c +1 -0
index 074ac71..c5f5ce8 100644
@@ -378,6 +378,7 @@ struct nfs_client *nfs4_init_client(struct
 nfs_client *clp,
 		error = nfs_create_rpc_client(clp, cl_init,
 RPC_AUTH_UNIX);
 	if (error < 0)
 		goto error;
+	rpc_schedule_keepalive(clp->cl_rpcclient);

Why do we want to enable this for non-RDMA transports? Shouldn't this functionality be hidden in the RDMA client code, in the same way that the TCP keepalive is hidden in the socket code.

Sending a NULL request by re-using the normal RPC infrastructure requires a struct rpc_clnt. Thus it has to be driven by an upper layer context.

Quoted 6 lines
Quoted 2 lines

I'm open to suggestions.

Ideally we just want this to operate when there are outstanding RPC calls waiting for a reply, am I correct?

If so, perhaps we might have it triggered by a timer that is armed in xprt->ops->send_request() and disarmed in xprt->ops->release_xprt()? It might then configure itself by looking in the xprt->recv list to find a hanging rpc_task and steal its rpc_client info.

Perhaps, but I was hoping to find a solution that did not add more overhead (arming and disarming another timer) to the send_request path.

__mod_timer can do an irqsave spinlock in some cases, for example.

This impacts all I/O on all transports to handle a case that will be very rare.

We could mitigate the timer flapping by arming when xprt_transmit finds the recv list empty before adding, and when xprt_lookup_rqst empties the recv list.

Quoted 7 lines

Cheers
Trond

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Chuck Lever

#5 lore raw

T24gRnJpLCAyMDE3LTAxLTEzIGF0IDEwOjEzIC0wNTAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g PiBPbiBKYW4gMTIsIDIwMTcsIGF0IDU6MTUgUE0sIFRyb25kIE15a2xlYnVzdCA8dHJvbmRteUBw cmltYXJ5ZGF0YS5jDQo+ID4gb20+IHdyb3RlOg0KPiA+IA0KPiA+ID4gDQo+ID4gPiBPbiBKYW4g MTIsIDIwMTcsIGF0IDEyOjQyLCBDaHVjayBMZXZlciA8Y2h1Y2subGV2ZXJAb3JhY2xlLmNvbT4N Cj4gPiA+IHdyb3RlOg0KPiA+ID4gDQo+ID4gPiANCj4gPiA+ID4gT24gSmFuID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u c3BvcnRzIHRvIGhhbmRsZSBhIGNhc2UgdGhhdCB3aWxsDQo+IGJlIHZlcnkgcmFyZS4NCj4gDQo+ IFdlIGNvdWxkIG1pdGlnYXRlIHRoZSB0aW1lciBmbGFwcGluZyBieSBhcm1pbmcgd2hlbiB4cHJ0 X3RyYW5zbWl0DQo+IGZpbmRzIHRoZSByZWN2IGxpc3QgZW1wdHkgYmVmb3JlIGFkZGluZywgYW5k IHdoZW4geHBydF9sb29rdXBfcnFzdA0KPiBlbXB0aWVzIHRoZSByZWN2IGxpc3QuDQo+IA0KDQpB bHRlcm5hdGl2ZWx5LCBob3cgYWJvdXQganVzdCBwdXR0aW5nIHRoZSB0cmlnZ2VyIGluIHhwcnRf dGltZXIgKGkuZS4NCmluIHRoZSB4cHJ0LT5vcHMtPnRpbWVyKCkgY2FsbGJhY2spPyBUaGF0IHJl cXVpcmVzIG5vIG5ldyB0aW1lcnMsIGFuZA0KaXQgc29sdmVzIHRoZSBwcm9ibGVtIG9mIHdoaWNo IHJwY19jbG50IHRvIHVzZS4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGll bnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5j b20NCg==

#6 lore raw
Quoted 147 lines · Trond Myklebust
Quoted 143 lines · Chuck Lever
Quoted 125 lines
Quoted 115 lines · Trond Myklebust
Quoted 101 lines · Chuck Lever

On Jan 12, 2017, at 12:38 PM, Trond Myklebust <trondmy@primaryd ata.com> wrote:

Quoted 97 lines · Chuck Lever

Current NFS clients rely on connection loss to determine when to
retransmit. In particular, for protocols like NFSv4, clients no
longer rely on RPC timeouts to drive retransmission: NFSv4 servers
are required to terminate a connection when they need聽聽a client to
retransmit pending RPCs.

When a server is no longer reachable, either because it has crashed
or because the network path has broken, the server cannot actively
terminate a connection. Thus NFS clients depend on transport- level
keepalive to determine when a connection must be replaced and pending RPCs retransmitted.

However, RDMA RC connections do not have a native keepalive mechanism. If an NFS/RDMA server crashes after a client has sent
RPCs successfully (an RC ACK has been received for all OTW RDMA
requests), there is no way for the client to know the connection is
moribund.

In addition, new RDMA requests are subject to the RPC-over- RDMA
credit limit. If the client has consumed all granted credits with
NFS traffic, it is not allowed to send another RDMA request until
the server replies. Thus it has no way to send a true keepalive when
the workload has already consumed all credits with pending RPCs.

To address this, we reserve one RPC-over-RDMA credit that may be
used only for an NFS NULL. A periodic RPC ping is done on transports
whenever there are outstanding RPCs.

The purpose of this ping is to drive traffic regularly on each
connection to force the transport layer to disconnect it if it is no
longer viable. Some RDMA operations are fully offloaded to the HCA,
and can be successful even if the remote host has crashed. Thus an
operation that requires that the server is responsive is used for
the ping.

This implementation re-uses existing generic RPC infrastructure to
form each NULL Call. An rpc_clnt context must be available to start
an RPC. Thus a generic keepalive mechanism is introduced so that
both an rpc_clnt and an rpc_xprt is available to perform the ping.

---

Before sending this for internal testing, I'd like to hear comments
on this approach. It's a little more churn than I had hoped for.

fs/nfs/nfs4client.c聽聽聽聽聽聽聽聽聽聽聽聽聽|聽聽聽聽1聽
include/linux/sunrpc/clnt.h聽聽聽聽聽|聽聽聽聽2 +
include/linux/sunrpc/sched.h聽聽聽聽|聽聽聽聽3 +
include/linux/sunrpc/xprt.h聽聽聽聽聽|聽聽聽聽1聽
net/sunrpc/clnt.c聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽|聽聽101
+++++++++++++++++++++++++++++++++++++++
net/sunrpc/sched.c聽聽聽聽聽聽聽聽聽聽聽聽聽聽|聽聽聽19 +++++++
net/sunrpc/xprt.c聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽|聽聽聽聽5 ++
net/sunrpc/xprtrdma/rpc_rdma.c聽聽|聽聽聽聽4 +-
net/sunrpc/xprtrdma/transport.c |聽聽聽13 +++++

9 files changed, 148 insertions(+), 1 deletion(-)
fs/nfs/nfs4client.c +0 -0
index 074ac71..c5f5ce8 100644
@@ -378,6 +378,7 @@ struct nfs_client
 *nfs4_init_client(struct
 nfs_client *clp,
 		error = nfs_create_rpc_client(clp, cl_init,
 RPC_AUTH_UNIX);
 	if (error < 0)
Quoted 8 lines

fs/nfs/nfs4client.c struct nfs_client *nfs4_init_client(struct nfs_client *clp, · line 381

Quoted 2 lines
fs/nfs/nfs4client.c +1 -0
 		goto error;
+	rpc_schedule_keepalive(clp->cl_rpcclient);

Why do we want to enable this for non-RDMA transports? Shouldn't this
functionality be hidden in the RDMA client code, in the same way that
the TCP keepalive is hidden in the socket code.

Quoted 6 lines

Sending a NULL request by re-using the normal RPC infrastructure requires a struct rpc_clnt. Thus it has to be driven by an upper layer context.

I'm open to suggestions.

Quoted 8 lines

Ideally we just want this to operate when there are outstanding RPC calls waiting for a reply, am I correct?

If so, perhaps we might have it triggered by a timer that is armed in xprt->ops->send_request() and disarmed in xprt->ops-

Quoted 1 line

release_xprt()? It might then configure itself by looking in the

xprt->recv list to find a hanging rpc_task and steal its rpc_client info.

Perhaps, but I was hoping to find a solution that did not add more overhead (arming and disarming another timer) to the send_request path.

__mod_timer can do an irqsave spinlock in some cases, for example.

This impacts all I/O on all transports to handle a case that will be very rare.

Quoted 8 lines
Quoted 4 lines

We could mitigate the timer flapping by arming when xprt_transmit finds the recv list empty before adding, and when xprt_lookup_rqst empties the recv list.

Alternatively, how about just putting the trigger in xprt_timer (i.e. in the xprt->ops->timer() callback)? That requires no new timers, and it solves the problem of which rpc_clnt to use.

I was thinking of wiring something into call_timeout, but xprt_timer looks like it would perform the same job, and there is already a per-xprt hook. I'll have a look.

Is it safe to call rpc_run_task while transport_lock is held? If not I can simply schedule a generic worker thread to construct and send the NULL.

Quoted 5 lines
Signature · 4 lines
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
��N嫥叉靣笡y氊b瞂千v豝�)藓{.n�+壏{睗�"炟^n噐■��侂h櫒璀�&Ⅷ�瓽珴閔��(殠娸"濟���m��飦赇z罐枈帼f"穐殘坢

--
Chuck Lever

#7 lore raw

T24gRnJpLCAyMDE3LTAxLTEzIGF0IDE0OjA4IC0wNTAwLCBDaHVjayBMZXZlciB3cm90ZToNCg0K PiBJIHdhcyB0aGlua2luZyBvZiB3aXJpbmcgc29tZXRoaW5nIGludG8gY2FsbF90aW1lb3V0LCBi dXQgeHBydF90aW1lcg0KPiBsb29rcyBsaWtlIGl0IHdvdWxkIHBlcmZvcm0gdGhlIHNhbWUgam9i LCBhbmQgdGhlcmUgaXMgYWxyZWFkeSBhDQo+IHBlci14cHJ0IGhvb2suIEknbGwgaGF2ZSBhIGxv b2suDQo+IA0KPiBJcyBpdCBzYWZlIHRvIGNhbGwgcnBjX3J1bl90YXNrIHdoaWxlIHRyYW5zcG9y dF9sb2NrIGlzIGhlbGQ/IElmIG5vdA0KPiBJIGNhbiBzaW1wbHkgc2NoZWR1bGUgYSBnZW5lcmlj IHdvcmtlciB0aHJlYWQgdG8gY29uc3RydWN0IGFuZCBzZW5kDQo+IHRoZSBOVUxMLg0KDQpZb3Ug c2hvdWxkbid0IGNhbGwgcnBjX3J1bl90YXNrKCkgZnJvbSBhIHNwaW5sb2NrIGNvbnRleHQsIGJ1 dCBsZXQncw0KY29uc2lkZXIgbW92aW5nIHRoYXQgc3BpbmxvY2sgaW50byB0aGUgeHBydC0+b3Bz LT50aW1lcigpIGNhbGxiYWNrLiBJDQpkb24ndCByZWFsbHkgc2VlIGhvdyBpdCBpcyAgbmVlZGVk IGZvciB0aGUgY2FzZXMgd2hlcmUgeW91IGRvbid0IGhhdmUgYQ0KY2FsbGJhY2suDQoNCi0tIA0K VHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXIsIFByaW1hcnlEYXRh DQp0cm9uZC5teWtsZWJ1c3RAcHJpbWFyeWRhdGEuY29tDQo=