linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsfreeze: tell hung_task about processes put to sleep
@ 2012-10-12  9:47 Fernando Luis Vázquez Cao
  2012-10-13  1:06 ` Dave Chinner
  0 siblings, 1 reply; 8+ messages in thread
From: Fernando Luis Vázquez Cao @ 2012-10-12  9:47 UTC (permalink / raw)
  To: Al Viro, Ingo Molnar; +Cc: Jan Kara, linux-fsdevel

Any process attempting to write to a frozen filesystem uninterruptibly and
unkillably waits for the filesystem to be thawed. This wait is of unbounded
length. Ignore such waits in the hung_task detector.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jan Kara <jack@suse.cz>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
---

diff -urNp linux-3.6.1-orig/fs/super.c linux-3.6.1/fs/super.c
--- linux-3.6.1-orig/fs/super.c	2012-10-01 08:47:46.000000000 +0900
+++ linux-3.6.1/fs/super.c	2012-10-12 18:01:56.881255168 +0900
@@ -46,6 +46,13 @@ static char *sb_writers_name[SB_FREEZE_L
 	"sb_internal",
 };
 
+static inline void wait_thaw(struct super_block *sb, int level)
+{
+	current->flags |= PF_FSFROZEN;
+	wait_event(sb->s_writers.wait_unfrozen, sb->s_writers.frozen < level);
+	current->flags &= ~ PF_FSFROZEN;
+}
+
 /*
  * One thing we have to be careful of with a per-sb shrinker is that we don't
  * drop the last active reference to the superblock from within the shrinker.
@@ -663,8 +670,7 @@ struct super_block *get_super_thawed(str
 		if (!s || s->s_writers.frozen == SB_UNFROZEN)
 			return s;
 		up_read(&s->s_umount);
-		wait_event(s->s_writers.wait_unfrozen,
-			   s->s_writers.frozen == SB_UNFROZEN);
+		wait_thaw(s, SB_FREEZE_WRITE);
 		put_super(s);
 	}
 }
@@ -1227,8 +1233,7 @@ retry:
 	if (unlikely(sb->s_writers.frozen >= level)) {
 		if (!wait)
 			return 0;
-		wait_event(sb->s_writers.wait_unfrozen,
-			   sb->s_writers.frozen < level);
+		wait_thaw(sb, level);
 	}
 
 #ifdef CONFIG_LOCKDEP
diff -urNp linux-3.6.1-orig/include/linux/sched.h linux-3.6.1/include/linux/sched.h
--- linux-3.6.1-orig/include/linux/sched.h	2012-10-01 08:47:46.000000000 +0900
+++ linux-3.6.1/include/linux/sched.h	2012-10-12 17:46:48.909249791 +0900
@@ -1803,6 +1803,7 @@ extern void thread_group_times(struct ta
 #define PF_MEMPOLICY	0x10000000	/* Non-default NUMA mempolicy */
 #define PF_MUTEX_TESTER	0x20000000	/* Thread belongs to the rt mutex tester */
 #define PF_FREEZER_SKIP	0x40000000	/* Freezer should not count it as freezable */
+#define PF_FSFROZEN	0x80000000	/* Waiting filesystem thaw */
 
 /*
  * Only the _current_ task can read/write to tsk->flags, but other
diff -urNp linux-3.6.1-orig/kernel/hung_task.c linux-3.6.1/kernel/hung_task.c
--- linux-3.6.1-orig/kernel/hung_task.c	2012-10-01 08:47:46.000000000 +0900
+++ linux-3.6.1/kernel/hung_task.c	2012-10-12 18:04:02.465256245 +0900
@@ -73,10 +73,11 @@ static void check_hung_task(struct task_
 	unsigned long switch_count = t->nvcsw + t->nivcsw;
 
 	/*
-	 * Ensure the task is not frozen.
-	 * Also, skip vfork and any other user process that freezer should skip.
+	 * Ensure the task is not frozen or waiting for a filesystem to be
+	 * thawed to proceed with a write. Also, skip vfork and any other user
+	 * process that freezer should skip.
 	 */
-	if (unlikely(t->flags & (PF_FROZEN | PF_FREEZER_SKIP)))
+	if (unlikely(t->flags & (PF_FROZEN | PF_FSFROZEN | PF_FREEZER_SKIP)))
 	    return;
 
 	/*



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-10-16  4:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12  9:47 [PATCH] fsfreeze: tell hung_task about processes put to sleep Fernando Luis Vázquez Cao
2012-10-13  1:06 ` Dave Chinner
2012-10-15  3:24   ` Fernando Luis Vazquez Cao
2012-10-15  6:36     ` Dave Chinner
2012-10-15  6:51       ` Fernando Luis Vazquez Cao
2012-10-15 21:02         ` Dave Chinner
2012-10-16  2:30           ` Fernando Luis Vazquez Cao
2012-10-16  4:52             ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).