]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Btrfs: Check kthread_should_stop() before schedule() in worker_loop
authoryanhai zhu <zhu.yanhai@gmail.com>
Wed, 12 Nov 2008 19:36:58 +0000 (14:36 -0500)
committerChris Mason <chris.mason@oracle.com>
Wed, 12 Nov 2008 19:36:58 +0000 (14:36 -0500)
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>
fs/btrfs/async-thread.c

index e1e49715459ee9d45617bf67879afe5317257050..4229450b75963c8e6311a76f4b29dd52669836de 100644 (file)
@@ -171,7 +171,8 @@ static int worker_loop(void *arg)
                } else {
                        set_current_state(TASK_INTERRUPTIBLE);
                        spin_unlock_irq(&worker->lock);
-                       schedule();
+                       if (!kthread_should_stop())
+                               schedule();
                        __set_current_state(TASK_RUNNING);
                }
        } while (!kthread_should_stop());