From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Nigel Cunningham <ncunningham@linuxmail.org>
Cc: Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH] Freeze bdevs when freezing processes.
Date: Tue, 24 Oct 2006 22:16:05 +0200 [thread overview]
Message-ID: <200610242216.05949.rjw@sisk.pl> (raw)
In-Reply-To: <1161576735.3466.7.camel@nigel.suspend2.net>
On Monday, 23 October 2006 06:12, Nigel Cunningham wrote:
> XFS can continue to submit I/O from a timer routine, even after
> freezeable kernel and userspace threads are frozen. This doesn't seem to
> be an issue for current swsusp code, but is definitely an issue for
> Suspend2, where the pages being written could be overwritten by
> Suspend2's atomic copy.
>
> We can address this issue by freezing bdevs after stopping userspace
> threads, and thawing them prior to thawing userspace.
Okay, it turns out we'll probably need this, so a couple of comments follow.
> Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
>
> diff --git a/kernel/power/process.c b/kernel/power/process.c
> index 4a001fe..ddeeb50 100644
> --- a/kernel/power/process.c
> +++ b/kernel/power/process.c
> @@ -13,6 +13,7 @@ #include <linux/interrupt.h>
> #include <linux/suspend.h>
> #include <linux/module.h>
> #include <linux/syscalls.h>
> +#include <linux/buffer_head.h>
> #include <linux/freezer.h>
>
> /*
> @@ -20,6 +21,58 @@ #include <linux/freezer.h>
> */
> #define TIMEOUT (20 * HZ)
>
> +struct frozen_fs
> +{
> + struct list_head fsb_list;
> + struct super_block *sb;
> +};
> +
> +LIST_HEAD(frozen_fs_list);
> +
> +void freezer_make_fses_rw(void)
I'd call it thaw_filesystems()
> +{
> + struct frozen_fs *fs, *next_fs;
> +
> + list_for_each_entry_safe(fs, next_fs, &frozen_fs_list, fsb_list) {
> + thaw_bdev(fs->sb->s_bdev, fs->sb);
> +
> + list_del(&fs->fsb_list);
> + kfree(fs);
> + }
> +}
> +
> +/*
> + * Done after userspace is frozen, so there should be no danger of
> + * fses being unmounted while we're in here.
> + */
> +int freezer_make_fses_ro(void)
I'd call it freeze_filesystems()
> +{
> + struct frozen_fs *fs;
> + struct super_block *sb;
> +
> + /* Generate the list */
> + list_for_each_entry(sb, &super_blocks, s_list) {
> + if (!sb->s_root || !sb->s_bdev ||
> + (sb->s_frozen == SB_FREEZE_TRANS) ||
> + (sb->s_flags & MS_RDONLY))
> + continue;
> +
> + fs = kmalloc(sizeof(struct frozen_fs), GFP_ATOMIC);
> + if (!fs)
> + return 1;
return -ENOMEM
> + fs->sb = sb;
> + list_add_tail(&fs->fsb_list, &frozen_fs_list);
> + };
> +
> + /* Do the freezing in reverse order so filesystems dependant
> + * upon others are frozen in the right order. (Eg loopback
> + * on ext3). */
> + list_for_each_entry_reverse(fs, &frozen_fs_list, fsb_list)
> + freeze_bdev(fs->sb->s_bdev);
> +
> + return 0;
> +}
> +
>
> static inline int freezeable(struct task_struct * p)
> {
> @@ -119,7 +172,7 @@ int freeze_processes(void)
> read_unlock(&tasklist_lock);
> todo += nr_user;
> if (!user_frozen && !nr_user) {
> - sys_sync();
> + freezer_make_fses_ro();
> start_time = jiffies;
> }
> user_frozen = !nr_user;
> @@ -174,6 +227,12 @@ void thaw_some_processes(int all)
> "Strange, %s not stopped\n", p->comm );
> } while_each_thread(g, p);
>
> + if (!pass) {
> + read_unlock(&tasklist_lock);
> + freezer_make_fses_rw();
> + read_lock(&tasklist_lock);
> + }
> +
> pass++;
> } while (pass < 2 && all);
>
>
>
>
>
Greetings,
Rafael
--
You never change things by fighting the existing reality.
R. Buckminster Fuller
next prev parent reply other threads:[~2006-10-24 20:16 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-23 4:12 [PATCH] Freeze bdevs when freezing processes Nigel Cunningham
2006-10-23 10:36 ` Rafael J. Wysocki
2006-10-23 12:09 ` Nigel Cunningham
2006-10-23 14:07 ` Rafael J. Wysocki
2006-10-23 14:15 ` Nick Piggin
2006-10-23 14:20 ` Rafael J. Wysocki
2006-10-23 23:05 ` Nigel Cunningham
2006-10-23 16:55 ` Andrew Morton
2006-10-23 17:14 ` Pavel Machek
2006-10-23 17:50 ` Andrew Morton
2006-10-23 18:06 ` Pavel Machek
2006-10-23 19:19 ` Rafael J. Wysocki
2006-10-23 22:52 ` Nigel Cunningham
2006-10-24 7:57 ` Rafael J. Wysocki
2006-10-24 8:21 ` Nigel Cunningham
2006-10-23 21:39 ` Matthew Garrett
2006-10-23 22:12 ` Rafael J. Wysocki
2006-10-24 7:58 ` Pavel Machek
2006-10-23 22:58 ` Nigel Cunningham
2006-10-24 8:01 ` Pavel Machek
2006-10-23 23:22 ` Nigel Cunningham
2006-10-24 8:37 ` Rafael J. Wysocki
2006-10-24 14:44 ` David Chinner
2006-10-24 15:29 ` Rafael J. Wysocki
2006-10-24 16:20 ` Oleg Verych
2006-10-24 16:27 ` Oleg Verych
2006-10-24 17:08 ` Christoph Hellwig
2006-10-25 8:05 ` Pavel Machek
2006-10-24 16:33 ` David Chinner
2006-10-24 21:37 ` Pavel Machek
2006-10-25 0:13 ` David Chinner
2006-10-25 8:10 ` Pavel Machek
2006-10-25 8:38 ` David Chinner
2006-10-25 8:47 ` Pavel Machek
2006-10-25 12:32 ` Rafael J. Wysocki
2006-10-25 13:23 ` Nigel Cunningham
2006-10-25 19:05 ` Rafael J. Wysocki
2006-10-26 7:30 ` David Chinner
2006-10-26 8:18 ` Nigel Cunningham
2006-10-26 8:48 ` Rafael J. Wysocki
2006-10-26 8:57 ` David Chinner
2006-10-26 9:11 ` Rafael J. Wysocki
2006-10-27 1:38 ` David Chinner
2006-10-27 14:37 ` Rafael J. Wysocki
2006-10-29 17:35 ` Pavel Machek
2006-10-29 23:29 ` Rafael J. Wysocki
2006-10-29 23:46 ` Nigel Cunningham
2006-10-26 9:18 ` Nigel Cunningham
2006-10-26 9:08 ` Rafael J. Wysocki
2006-10-25 8:12 ` Rafael J. Wysocki
2006-10-24 17:06 ` Christoph Hellwig
2006-10-24 19:09 ` Rafael J. Wysocki
2006-10-24 21:26 ` Pavel Machek
2006-10-24 21:33 ` Christoph Hellwig
2006-10-24 21:43 ` Pavel Machek
2006-10-24 22:19 ` Nigel Cunningham
2006-10-24 20:16 ` Rafael J. Wysocki [this message]
2006-10-24 22:17 ` Nigel Cunningham
2006-10-24 20:38 ` Christoph Hellwig
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=200610242216.05949.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ncunningham@linuxmail.org \
--cc=pavel@ucw.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.