Thread (62 messages) flat view 62 messages, 7 authors, 2015-06-17
STALE4081d

[RFC PATCH 18/18] jffs2: Use the new API for a sleep with a timeout

From: Petr Mladek <hidden>
Date: 2015-06-05 15:02:26
Also in: linux-nfs, lkml
Subsystem: filesystems (vfs and infrastructure), journalling flash file system v2 (jffs2), the rest · Maintainers: Alexander Viro, Christian Brauner, David Woodhouse, Richard Weinberger, Linus Torvalds

It allows to maintain the checks for freezing, parking, and signal
handling on a single place.

Note that the sleep with the timeout is used here to slow down
the progress a bit. It does not matter if we do it before or after
calling jffs2_garbage_collect_pass().

Signed-off-by: Petr Mladek <redacted>
---
 fs/jffs2/background.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index 50c16048ba2d..2d38d40e0ad1 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -62,6 +62,16 @@ static void jffs2_garbage_collect_thread_func(void *_c)
 	}
 	spin_unlock(&c->erase_completion_lock);
 
+	/* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */
+	sigprocmask(SIG_BLOCK, &hupmask, NULL);
+
+	jffs2_dbg(1, "%s(): pass\n", __func__);
+	if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
+		pr_notice("No space for garbage collection. Aborting GC thread\n");
+		kthread_stop_current();
+	}
+	sigprocmask(SIG_UNBLOCK, &hupmask, NULL);
+
 	/* Problem - immediately after bootup, the GCD spends a lot
 	 * of time in places like jffs2_kill_fragtree(); so much so
 	 * that userspace processes (like gdm and X) are starved
@@ -73,24 +83,7 @@ static void jffs2_garbage_collect_thread_func(void *_c)
 	 * inode in with read_inode() is much preferable to having
 	 * the GC thread get there first.
 	 */
-	schedule_timeout_interruptible(msecs_to_jiffies(50));
-
-	if (kthread_should_stop()) {
-		jffs2_dbg(1, "%s(): kthread_stop() called\n", __func__);
-		return;
-	}
-
-	try_to_freeze();
-
-	/* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */
-	sigprocmask(SIG_BLOCK, &hupmask, NULL);
-
-	jffs2_dbg(1, "%s(): pass\n", __func__);
-	if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
-		pr_notice("No space for garbage collection. Aborting GC thread\n");
-		kthread_stop_current();
-	}
-	sigprocmask(SIG_UNBLOCK, &hupmask, NULL);
+	set_kthread_iterant_int_sleep_timeout(msecs_to_jiffies(50));
 }
 
 static void jffs2_garbage_collect_thread_destroy(void *_c)
-- 
1.8.5.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help