Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab...
[pandora-kernel.git] / fs / jffs2 / background.c
index 7b77a95..888f236 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/completion.h>
 #include <linux/sched.h>
+#include <linux/freezer.h>
 #include "nodelist.h"
 
 
@@ -35,8 +36,7 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
        pid_t pid;
        int ret = 0;
 
-       if (c->gc_task)
-               BUG();
+       BUG_ON(c->gc_task);
 
        init_completion(&c->gc_thread_start);
        init_completion(&c->gc_thread_exit);
@@ -99,7 +99,13 @@ static int jffs2_garbage_collect_thread(void *_c)
                if (try_to_freeze())
                        continue;
 
-               cond_resched();
+               /* This thread is purely an optimisation. But if it runs when
+                  other things could be running, it actually makes things a
+                  lot worse. Use yield() and put it at the back of the runqueue
+                  every time. Especially during boot, pulling an inode in
+                  with read_inode() is much preferable to having the GC thread
+                  get there first. */
+               yield();
 
                /* Put_super will send a SIGKILL and then wait on the sem.
                 */