Skip to content

Commit bd79bc5

Browse files
author
Trond Myklebust
committed
SUNRPC: Don't take transport->lock unnecessarily when taking XPRT_LOCK
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent adfa714 commit bd79bc5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/sunrpc/xprt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ static inline int xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
298298
{
299299
int retval;
300300

301+
if (test_bit(XPRT_LOCKED, &xprt->state) && xprt->snd_task == task)
302+
return 1;
301303
spin_lock_bh(&xprt->transport_lock);
302304
retval = xprt->ops->reserve_xprt(xprt, task);
303305
spin_unlock_bh(&xprt->transport_lock);
@@ -375,6 +377,8 @@ EXPORT_SYMBOL_GPL(xprt_release_xprt_cong);
375377

376378
static inline void xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task)
377379
{
380+
if (xprt->snd_task != task)
381+
return;
378382
spin_lock_bh(&xprt->transport_lock);
379383
xprt->ops->release_xprt(xprt, task);
380384
spin_unlock_bh(&xprt->transport_lock);
@@ -1645,8 +1649,7 @@ void xprt_release(struct rpc_task *task)
16451649
if (req == NULL) {
16461650
if (task->tk_client) {
16471651
xprt = task->tk_xprt;
1648-
if (xprt->snd_task == task)
1649-
xprt_release_write(xprt, task);
1652+
xprt_release_write(xprt, task);
16501653
}
16511654
return;
16521655
}

0 commit comments

Comments
 (0)