From: "Fernando Luis Vázquez Cao" <fernando_b1@lab.ntt.co.jp>
To: Al Viro <viro@zeniv.linux.org.uk>, Ingo Molnar <mingo@redhat.com>
Cc: Jan Kara <jack@suse.cz>, linux-fsdevel@vger.kernel.org
Subject: [PATCH] fsfreeze: tell hung_task about processes put to sleep
Date: Fri, 12 Oct 2012 18:47:32 +0900 [thread overview]
Message-ID: <1350035252.6500.2.camel@nexus.lab.ntt.co.jp> (raw)
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;
/*
next reply other threads:[~2012-10-12 9:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 9:47 Fernando Luis Vázquez Cao [this message]
2012-10-13 1:06 ` [PATCH] fsfreeze: tell hung_task about processes put to sleep 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350035252.6500.2.camel@nexus.lab.ntt.co.jp \
--to=fernando_b1@lab.ntt.co.jp \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).