Commit b27cf88e authored by David Woodhouse's avatar David Woodhouse

[JFFS2] Fix lack of locking in thread_should_wake()

The thread_should_wake() function trawls through the list of 'very
dirty' eraseblocks, determining whether the background GC thread should
wake. Doing this without holding the appropriate locks is a bad idea.

OLPC Trac #8615
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
Cc: stable@kernel.org
parent f04de505
...@@ -85,15 +85,15 @@ static int jffs2_garbage_collect_thread(void *_c) ...@@ -85,15 +85,15 @@ static int jffs2_garbage_collect_thread(void *_c)
for (;;) { for (;;) {
allow_signal(SIGHUP); allow_signal(SIGHUP);
again: again:
spin_lock(&c->erase_completion_lock);
if (!jffs2_thread_should_wake(c)) { if (!jffs2_thread_should_wake(c)) {
set_current_state (TASK_INTERRUPTIBLE); set_current_state (TASK_INTERRUPTIBLE);
spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n"));
/* Yes, there's a race here; we checked jffs2_thread_should_wake()
before setting current->state to TASK_INTERRUPTIBLE. But it doesn't
matter - We don't care if we miss a wakeup, because the GC thread
is only an optimisation anyway. */
schedule(); schedule();
} } else
spin_unlock(&c->erase_completion_lock);
/* This thread is purely an optimisation. But if it runs when /* This thread is purely an optimisation. But if it runs when
other things could be running, it actually makes things a other things could be running, it actually makes things a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment