[v3,09/12] sunrpc: Allow xprt->ops->timer method to sleep
diff mbox

Message ID 20170208220051.7152.67740.stgit@manet.1015granger.net
State New
Headers show

Commit Message

Chuck Lever Feb. 8, 2017, 10 p.m. UTC
The transport lock is needed to protect the xprt_adjust_cwnd() call
in xs_udp_timer, but it is not necessary for accessing the
rq_reply_bytes_recvd or tk_status fields. It is correct to sublimate
the lock into UDP's xs_udp_timer method, where it is required.

The ->timer method has to take the transport lock if needed, but it
can now sleep safely, or even call back into the RPC scheduler.

This is more a clean-up than a fix, but the "issue" was introduced
by my transport switch patches back in 2005.

Fixes: 46c0ee8bc4ad ("RPC: separate xprt_timer implementations")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 net/sunrpc/xprt.c     |    2 --
 net/sunrpc/xprtsock.c |    2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)


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

Comments

Trond Myklebust Feb. 8, 2017, 11:48 p.m. UTC | #1
T24gV2VkLCAyMDE3LTAyLTA4IGF0IDE3OjAwIC0wNTAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g
VGhlIHRyYW5zcG9ydCBsb2NrIGlzIG5lZWRlZCB0byBwcm90ZWN0IHRoZSB4cHJ0X2FkanVzdF9j
d25kKCkgY2FsbA0KPiBpbiB4c191ZHBfdGltZXIsIGJ1dCBpdCBpcyBub3QgbmVjZXNzYXJ5IGZv
ciBhY2Nlc3NpbmcgdGhlDQo+IHJxX3JlcGx5X2J5dGVzX3JlY3ZkIG9yIHRrX3N0YXR1cyBmaWVs
ZHMuIEl0IGlzIGNvcnJlY3QgdG8gc3VibGltYXRlDQo+IHRoZSBsb2NrIGludG8gVURQJ3MgeHNf
dWRwX3RpbWVyIG1ldGhvZCwgd2hlcmUgaXQgaXMgcmVxdWlyZWQuDQo+IA0KPiBUaGUgLT50aW1l
ciBtZXRob2QgaGF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PiDCoHN0YXRpYyB1bnNpZ25l
ZCBzaG9ydCB4c19nZXRfcmFuZG9tX3BvcnQodm9pZCkNCj4gDQoNClRoYW5rcyEgR29vZCBjbGVh
bnVwLi4uDQoNClRyb25kDQoNCi0tIA0KDQoNCg0KCQ0KCQ0KDQoNClRyb25kIE15a2xlYnVzdA0K
UHJpbmNpcGFsIFN5c3RlbSBBcmNoaXRlY3QNCjQzMDAgRWwgQ2FtaW5vIFJlYWwgfCBTdWl0ZSAx
MDANCkxvcyBBbHRvcywgQ0HCoMKgOTQwMjINClc6IDY1MC00MjItMzgwMA0KQzogODAxLTkyMS00
NTgzwqANCnd3dy5wcmltYXJ5ZGF0YS5jb20NCg0KDQoNCg0K

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

Patch
diff mbox

diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 9a6be03..b530a28 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -897,13 +897,11 @@  static void xprt_timer(struct rpc_task *task)
 		return;
 	dprintk("RPC: %5u xprt_timer\n", task->tk_pid);
 
-	spin_lock_bh(&xprt->transport_lock);
 	if (!req->rq_reply_bytes_recvd) {
 		if (xprt->ops->timer)
 			xprt->ops->timer(xprt, task);
 	} else
 		task->tk_status = 0;
-	spin_unlock_bh(&xprt->transport_lock);
 }
 
 /**
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index af392d9..d9bb644 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1734,7 +1734,9 @@  static void xs_udp_set_buffer_size(struct rpc_xprt *xprt, size_t sndsize, size_t
  */
 static void xs_udp_timer(struct rpc_xprt *xprt, struct rpc_task *task)
 {
+	spin_lock_bh(&xprt->transport_lock);
 	xprt_adjust_cwnd(xprt, task, -ETIMEDOUT);
+	spin_unlock_bh(&xprt->transport_lock);
 }
 
 static unsigned short xs_get_random_port(void)