提交 106f359c 编写于 作者: T Trond Myklebust 提交者: J. Bruce Fields

SUNRPC: Do not grab pool->sp_lock unnecessarily in svc_get_next_xprt

Signed-off-by: NTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 88799977
...@@ -651,8 +651,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -651,8 +651,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
} else { } else {
if (pool->sp_task_pending) { if (pool->sp_task_pending) {
pool->sp_task_pending = 0; pool->sp_task_pending = 0;
spin_unlock_bh(&pool->sp_lock); xprt = ERR_PTR(-EAGAIN);
return ERR_PTR(-EAGAIN); goto out;
} }
/* No data pending. Go to sleep */ /* No data pending. Go to sleep */
svc_thread_enqueue(pool, rqstp); svc_thread_enqueue(pool, rqstp);
...@@ -672,8 +672,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -672,8 +672,8 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
*/ */
if (kthread_should_stop()) { if (kthread_should_stop()) {
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
spin_unlock_bh(&pool->sp_lock); xprt = ERR_PTR(-EINTR);
return ERR_PTR(-EINTR); goto out;
} }
add_wait_queue(&rqstp->rq_wait, &wait); add_wait_queue(&rqstp->rq_wait, &wait);
...@@ -683,8 +683,12 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -683,8 +683,12 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
try_to_freeze(); try_to_freeze();
spin_lock_bh(&pool->sp_lock);
remove_wait_queue(&rqstp->rq_wait, &wait); remove_wait_queue(&rqstp->rq_wait, &wait);
xprt = rqstp->rq_xprt;
if (xprt != NULL)
return xprt;
spin_lock_bh(&pool->sp_lock);
if (!time_left) if (!time_left)
pool->sp_stats.threads_timedout++; pool->sp_stats.threads_timedout++;
...@@ -699,6 +703,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -699,6 +703,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
return ERR_PTR(-EAGAIN); return ERR_PTR(-EAGAIN);
} }
} }
out:
spin_unlock_bh(&pool->sp_lock); spin_unlock_bh(&pool->sp_lock);
return xprt; return xprt;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册