aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/background.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/background.c')
-rw-r--r--fs/jffs2/background.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index 638836b277d4..0f224384f176 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: background.c,v 1.50 2004/11/16 20:36:10 dwmw2 Exp $ 10 * $Id: background.c,v 1.54 2005/05/20 21:37:12 gleixner Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -37,7 +37,7 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
37 if (c->gc_task) 37 if (c->gc_task)
38 BUG(); 38 BUG();
39 39
40 init_MUTEX_LOCKED(&c->gc_thread_start); 40 init_completion(&c->gc_thread_start);
41 init_completion(&c->gc_thread_exit); 41 init_completion(&c->gc_thread_exit);
42 42
43 pid = kernel_thread(jffs2_garbage_collect_thread, c, CLONE_FS|CLONE_FILES); 43 pid = kernel_thread(jffs2_garbage_collect_thread, c, CLONE_FS|CLONE_FILES);
@@ -48,7 +48,7 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
48 } else { 48 } else {
49 /* Wait for it... */ 49 /* Wait for it... */
50 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", pid));
51 down(&c->gc_thread_start); 51 wait_for_completion(&c->gc_thread_start);
52 } 52 }
53 53
54 return ret; 54 return ret;
@@ -56,13 +56,16 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
56 56
57void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) 57void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
58{ 58{
59 int wait = 0;
59 spin_lock(&c->erase_completion_lock); 60 spin_lock(&c->erase_completion_lock);
60 if (c->gc_task) { 61 if (c->gc_task) {
61 D1(printk(KERN_DEBUG "jffs2: Killing GC task %d\n", c->gc_task->pid)); 62 D1(printk(KERN_DEBUG "jffs2: Killing GC task %d\n", c->gc_task->pid));
62 send_sig(SIGKILL, c->gc_task, 1); 63 send_sig(SIGKILL, c->gc_task, 1);
64 wait = 1;
63 } 65 }
64 spin_unlock(&c->erase_completion_lock); 66 spin_unlock(&c->erase_completion_lock);
65 wait_for_completion(&c->gc_thread_exit); 67 if (wait)
68 wait_for_completion(&c->gc_thread_exit);
66} 69}
67 70
68static int jffs2_garbage_collect_thread(void *_c) 71static int jffs2_garbage_collect_thread(void *_c)
@@ -75,7 +78,7 @@ static int jffs2_garbage_collect_thread(void *_c)
75 allow_signal(SIGCONT); 78 allow_signal(SIGCONT);
76 79
77 c->gc_task = current; 80 c->gc_task = current;
78 up(&c->gc_thread_start); 81 complete(&c->gc_thread_start);
79 82
80 set_user_nice(current, 10); 83 set_user_nice(current, 10);
81 84