]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.4.39/sunrpc-add-barriers-to-ensure-read-ordering-in-rpc_wake_up_task_queue_locked.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.39 / sunrpc-add-barriers-to-ensure-read-ordering-in-rpc_wake_up_task_queue_locked.patch
CommitLineData
1839400a
GKH
1From 1166fde6a923c30f4351515b6a9a1efc513e7d00 Mon Sep 17 00:00:00 2001
2From: Trond Myklebust <Trond.Myklebust@netapp.com>
3Date: Mon, 25 Mar 2013 11:23:40 -0400
4Subject: SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked
5
6From: Trond Myklebust <Trond.Myklebust@netapp.com>
7
8commit 1166fde6a923c30f4351515b6a9a1efc513e7d00 upstream.
9
10We need to be careful when testing task->tk_waitqueue in
11rpc_wake_up_task_queue_locked, because it can be changed while we
12are holding the queue->lock.
13By adding appropriate memory barriers, we can ensure that it is safe to
14test task->tk_waitqueue for equality if the RPC_TASK_QUEUED bit is set.
15
16Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
17Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18
19---
20 net/sunrpc/sched.c | 9 +++++++--
21 1 file changed, 7 insertions(+), 2 deletions(-)
22
23--- a/net/sunrpc/sched.c
24+++ b/net/sunrpc/sched.c
25@@ -143,6 +143,8 @@ static void __rpc_add_wait_queue(struct
26 list_add_tail(&task->u.tk_wait.list, &queue->tasks[0]);
27 task->tk_waitqueue = queue;
28 queue->qlen++;
29+ /* barrier matches the read in rpc_wake_up_task_queue_locked() */
30+ smp_wmb();
31 rpc_set_queued(task);
32
33 dprintk("RPC: %5u added to queue %p \"%s\"\n",
34@@ -399,8 +401,11 @@ static void __rpc_do_wake_up_task(struct
35 */
36 static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct rpc_task *task)
37 {
38- if (RPC_IS_QUEUED(task) && task->tk_waitqueue == queue)
39- __rpc_do_wake_up_task(queue, task);
40+ if (RPC_IS_QUEUED(task)) {
41+ smp_rmb();
42+ if (task->tk_waitqueue == queue)
43+ __rpc_do_wake_up_task(queue, task);
44+ }
45 }
46
47 /*