[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: David Woodhouse <David.Woodhouse@intel.com>
Cc: stable@kernel.org

+5 -5
+5 -5
fs/jffs2/background.c
··· 85 for (;;) { 86 allow_signal(SIGHUP); 87 again: 88 if (!jffs2_thread_should_wake(c)) { 89 set_current_state (TASK_INTERRUPTIBLE); 90 D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); 91 - /* Yes, there's a race here; we checked jffs2_thread_should_wake() 92 - before setting current->state to TASK_INTERRUPTIBLE. But it doesn't 93 - matter - We don't care if we miss a wakeup, because the GC thread 94 - is only an optimisation anyway. */ 95 schedule(); 96 - } 97 98 /* This thread is purely an optimisation. But if it runs when 99 other things could be running, it actually makes things a
··· 85 for (;;) { 86 allow_signal(SIGHUP); 87 again: 88 + spin_lock(&c->erase_completion_lock); 89 if (!jffs2_thread_should_wake(c)) { 90 set_current_state (TASK_INTERRUPTIBLE); 91 + spin_unlock(&c->erase_completion_lock); 92 D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); 93 schedule(); 94 + } else 95 + spin_unlock(&c->erase_completion_lock); 96 + 97 98 /* This thread is purely an optimisation. But if it runs when 99 other things could be running, it actually makes things a