* [PATCH] Check kthread_should_stop() before schedule() in worker_loop
@ 2008-11-06 12:50 yanhai zhu
0 siblings, 0 replies; only message in thread
From: yanhai zhu @ 2008-11-06 12:50 UTC (permalink / raw)
To: linux-btrfs
Hello,
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.
Thanks,
Zhu Yanhai
---
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index d82efd7..423ef27 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -119,7 +119,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());
---
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-06 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-06 12:50 [PATCH] Check kthread_should_stop() before schedule() in worker_loop yanhai zhu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox