SUNRPC: Tighten up the task locking rules in __rpc_execute()

Previous thread: ocfs2: Use xs->bucket to set xattr value outside by Linux Kernel Mailing List on Saturday, March 14, 2009 - 1:00 pm. (1 message)

Next thread: NLM: Shrink the IPv4-only version of nlm_cmp_addr() by Linux Kernel Mailing List on Saturday, March 14, 2009 - 1:00 pm. (1 message)
From: Linux Kernel Mailing List
Date: Saturday, March 14, 2009 - 1:00 pm

Gitweb:     http://git.kernel.org/linus/eb9b55ab4d73280597fd183b367d50452f4d7846
Commit:     eb9b55ab4d73280597fd183b367d50452f4d7846
Parent:     16b71fdf97599f1b1b7f38418ee9922d9f117396
Author:     Trond Myklebust <Trond.Myklebust@netapp.com>
AuthorDate: Tue Mar 10 20:33:16 2009 -0400
Committer:  Trond Myklebust <Trond.Myklebust@netapp.com>
CommitDate: Tue Mar 10 20:33:16 2009 -0400

    SUNRPC: Tighten up the task locking rules in __rpc_execute()
    
    We should probably not be testing any flags after we've cleared the
    RPC_TASK_RUNNING flag, since rpc_make_runnable() is then free to assign the
    rpc_task to another workqueue, which may then destroy it.
    
    We can fix any races with rpc_make_runnable() by ensuring that we only
    clear the RPC_TASK_RUNNING flag while holding the rpc_wait_queue->lock that
    the task is supposed to be sleeping on (and then checking whether or not
    the task really is sleeping).
    
    Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 net/sunrpc/sched.c |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 385f427..ff50a05 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -293,11 +293,6 @@ static void rpc_make_runnable(struct rpc_task *task)
 	rpc_clear_queued(task);
 	if (rpc_test_and_set_running(task))
 		return;
-	/* We might have raced */
-	if (RPC_IS_QUEUED(task)) {
-		rpc_clear_running(task);
-		return;
-	}
 	if (RPC_IS_ASYNC(task)) {
 		int status;
 
@@ -607,7 +602,9 @@ void rpc_release_calldata(const struct rpc_call_ops *ops, void *calldata)
  */
 static void __rpc_execute(struct rpc_task *task)
 {
-	int		status = 0;
+	struct rpc_wait_queue *queue;
+	int task_is_async = RPC_IS_ASYNC(task);
+	int status = 0;
 
 	dprintk("RPC: %5u __rpc_execute flags=0x%x\n",
 			task->tk_pid, task->tk_flags);
@@ -647,15 +644,25 @@ static void __rpc_execute(struct rpc_task *task)
 		 */
 		if ...
Previous thread: ocfs2: Use xs->bucket to set xattr value outside by Linux Kernel Mailing List on Saturday, March 14, 2009 - 1:00 pm. (1 message)

Next thread: NLM: Shrink the IPv4-only version of nlm_cmp_addr() by Linux Kernel Mailing List on Saturday, March 14, 2009 - 1:00 pm. (1 message)