aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryanhai zhu <zhu.yanhai@gmail.com>2008-11-12 14:36:58 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-12 14:36:58 -0500
commit0df49b911db2b22ea808b596070b1cc65c23d148 (patch)
tree0750dd5ad6cfccff98f3c44c7ef120378cf42eb6
parentc36047d729a3fa080dd194b20b684cc9fe73e90c (diff)
Btrfs: Check kthread_should_stop() before schedule() in worker_loop
In worker_loop(), the func should check whether it has been requested to stop before it decides to schedule out. Otherwise if the stop request(also the last wake_up()) sent by btrfs_stop_workers() happens when worker_loop() running after the "while" judgement and before schedule(), woker_loop() will schedule away and never be woken up, which will also cause btrfs_stop_workers() wait forever. Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/async-thread.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index e1e49715459e..4229450b7596 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -171,7 +171,8 @@ static int worker_loop(void *arg)
171 } else { 171 } else {
172 set_current_state(TASK_INTERRUPTIBLE); 172 set_current_state(TASK_INTERRUPTIBLE);
173 spin_unlock_irq(&worker->lock); 173 spin_unlock_irq(&worker->lock);
174 schedule(); 174 if (!kthread_should_stop())
175 schedule();
175 __set_current_state(TASK_RUNNING); 176 __set_current_state(TASK_RUNNING);
176 } 177 }
177 } while (!kthread_should_stop()); 178 } while (!kthread_should_stop());