Commit 91e0955b57377578f7555b5d0f2a21040691004b

Authored by Gerard Lledo
Committed by David Woodhouse
1 parent 2c78c44362

jffs2: move jffs2_gcd_mtd threads to the new kthread API

Move the jffs2 garbage collecting thread to the new kthread API.

Signed-off-by: Gerard Lledo <gerard.lledo@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Showing 1 changed file with 13 additions and 7 deletions Side-by-side Diff

fs/jffs2/background.c
... ... @@ -15,6 +15,7 @@
15 15 #include <linux/completion.h>
16 16 #include <linux/sched.h>
17 17 #include <linux/freezer.h>
  18 +#include <linux/kthread.h>
18 19 #include "nodelist.h"
19 20  
20 21  
... ... @@ -31,7 +32,7 @@
31 32 /* This must only ever be called when no GC thread is currently running */
32 33 int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
33 34 {
34   - pid_t pid;
  35 + struct task_struct *tsk;
35 36 int ret = 0;
36 37  
37 38 BUG_ON(c->gc_task);
38 39  
39 40  
40 41  
... ... @@ -39,15 +40,16 @@
39 40 init_completion(&c->gc_thread_start);
40 41 init_completion(&c->gc_thread_exit);
41 42  
42   - pid = kernel_thread(jffs2_garbage_collect_thread, c, CLONE_FS|CLONE_FILES);
43   - if (pid < 0) {
44   - printk(KERN_WARNING "fork failed for JFFS2 garbage collect thread: %d\n", -pid);
  43 + tsk = kthread_run(jffs2_garbage_collect_thread, c, "jffs2_gcd_mtd%d", c->mtd->index);
  44 + if (IS_ERR(tsk)) {
  45 + printk(KERN_WARNING "fork failed for JFFS2 garbage collect thread: %ld\n", -PTR_ERR(tsk));
45 46 complete(&c->gc_thread_exit);
46   - ret = pid;
  47 + ret = PTR_ERR(tsk);
47 48 } else {
48 49 /* Wait for it... */
49   - D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", pid));
  50 + D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", tsk->pid));
50 51 wait_for_completion(&c->gc_thread_start);
  52 + ret = tsk->pid;
51 53 }
52 54  
53 55 return ret;
... ... @@ -71,7 +73,6 @@
71 73 {
72 74 struct jffs2_sb_info *c = _c;
73 75  
74   - daemonize("jffs2_gcd_mtd%d", c->mtd->index);
75 76 allow_signal(SIGKILL);
76 77 allow_signal(SIGSTOP);
77 78 allow_signal(SIGCONT);
... ... @@ -106,6 +107,11 @@
106 107 * inode in with read_inode() is much preferable to having
107 108 * the GC thread get there first. */
108 109 schedule_timeout_interruptible(msecs_to_jiffies(50));
  110 +
  111 + if (kthread_should_stop()) {
  112 + D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): kthread_stop() called.\n"));
  113 + goto die;
  114 + }
109 115  
110 116 /* Put_super will send a SIGKILL and then wait on the sem.
111 117 */