Skip to content

Commit 1fab7dc

Browse files
author
Trond Myklebust
committed
SUNRPC: Don't start a timer on an already queued rpc task
Move the test for whether a task is already queued to prevent corruption of the timer list in __rpc_sleep_on_priority_timeout(). Signed-off-by: Trond Myklebust <[email protected]>
1 parent 44ea8df commit 1fab7dc

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

net/sunrpc/sched.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,6 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue,
204204
struct rpc_task *task,
205205
unsigned char queue_priority)
206206
{
207-
WARN_ON_ONCE(RPC_IS_QUEUED(task));
208-
if (RPC_IS_QUEUED(task))
209-
return;
210-
211207
INIT_LIST_HEAD(&task->u.tk_wait.timer_list);
212208
if (RPC_IS_PRIORITY(queue))
213209
__rpc_add_wait_queue_priority(queue, task, queue_priority);
@@ -382,7 +378,7 @@ static void rpc_make_runnable(struct workqueue_struct *wq,
382378
* NB: An RPC task will only receive interrupt-driven events as long
383379
* as it's on a wait queue.
384380
*/
385-
static void __rpc_sleep_on_priority(struct rpc_wait_queue *q,
381+
static void __rpc_do_sleep_on_priority(struct rpc_wait_queue *q,
386382
struct rpc_task *task,
387383
unsigned char queue_priority)
388384
{
@@ -395,12 +391,23 @@ static void __rpc_sleep_on_priority(struct rpc_wait_queue *q,
395391

396392
}
397393

394+
static void __rpc_sleep_on_priority(struct rpc_wait_queue *q,
395+
struct rpc_task *task,
396+
unsigned char queue_priority)
397+
{
398+
if (WARN_ON_ONCE(RPC_IS_QUEUED(task)))
399+
return;
400+
__rpc_do_sleep_on_priority(q, task, queue_priority);
401+
}
402+
398403
static void __rpc_sleep_on_priority_timeout(struct rpc_wait_queue *q,
399404
struct rpc_task *task, unsigned long timeout,
400405
unsigned char queue_priority)
401406
{
407+
if (WARN_ON_ONCE(RPC_IS_QUEUED(task)))
408+
return;
402409
if (time_is_after_jiffies(timeout)) {
403-
__rpc_sleep_on_priority(q, task, queue_priority);
410+
__rpc_do_sleep_on_priority(q, task, queue_priority);
404411
__rpc_add_timer(q, task, timeout);
405412
} else
406413
task->tk_status = -ETIMEDOUT;

0 commit comments

Comments
 (0)