提交 b5555f77 编写于 作者: A Amit Gud 提交者: Chris Mason

Btrfs: fix race in worker_loop

Need to check kthread_should_stop after schedule_timeout() before calling
schedule(). This causes threads to sleep with potentially no one to wake them
up causing mount(2) to hang in btrfs_stop_workers waiting for threads to stop.
Signed-off-by: NAmit Gud <gud@ksu.edu>
Signed-off-by: NChris Mason <chris.mason@oracle.com>
上级 dccae999
...@@ -195,6 +195,9 @@ static int worker_loop(void *arg) ...@@ -195,6 +195,9 @@ static int worker_loop(void *arg)
if (!list_empty(&worker->pending)) if (!list_empty(&worker->pending))
continue; continue;
if (kthread_should_stop())
break;
/* still no more work?, sleep for real */ /* still no more work?, sleep for real */
spin_lock_irq(&worker->lock); spin_lock_irq(&worker->lock);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -208,6 +211,7 @@ static int worker_loop(void *arg) ...@@ -208,6 +211,7 @@ static int worker_loop(void *arg)
worker->working = 0; worker->working = 0;
spin_unlock_irq(&worker->lock); spin_unlock_irq(&worker->lock);
if (!kthread_should_stop())
schedule(); schedule();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册