- swsusp-freeze-filesystems-during-suspend-rev-2.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     swsusp: freeze filesystems during suspend
has been removed from the -mm tree.  Its filename was
     swsusp-freeze-filesystems-during-suspend-rev-2.patch

This patch was dropped because it is obsolete

------------------------------------------------------
Subject: swsusp: freeze filesystems during suspend
From: "Rafael J. Wysocki" <rjw@xxxxxxx>

Freeze all filesystems during the suspend by calling freeze_bdev() for each
of them and thaw them during the resume using thaw_bdev().

This is needed by swsusp, because some filesystems (eg.  XFS) use work
queues and worker_threads run with PF_NOFREEZE set, so if these filesystems
are not frozen, they can cause some writes to be performed after the
suspend image has been created which may corrupt lead to a filesystem
corruption.

The additional benefit of it is that if the resume fails, the filesystems
will be in a consistent state and there won't be any journal replays
needed.

The freezing of filesystems is carried out when processes are being frozen,
so on the majority of architectures it also will happen during a suspend to
RAM.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>
Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 fs/buffer.c                 |   44 +++++++++++++++++++++++++++
 include/linux/buffer_head.h |    2 +
 include/linux/freezer.h     |    7 +---
 include/linux/fs.h          |    1 
 kernel/power/process.c      |   54 ++++++++++++++++++++++------------
 5 files changed, 85 insertions(+), 23 deletions(-)

diff -puN fs/buffer.c~swsusp-freeze-filesystems-during-suspend-rev-2 fs/buffer.c
--- a/fs/buffer.c~swsusp-freeze-filesystems-during-suspend-rev-2
+++ a/fs/buffer.c
@@ -234,6 +234,50 @@ void thaw_bdev(struct block_device *bdev
 }
 EXPORT_SYMBOL(thaw_bdev);
 
+/**
+ * freeze_filesystems - lock all filesystems and force them into a consistent
+ * state
+ */
+void freeze_filesystems(void)
+{
+	struct super_block *sb;
+
+	lockdep_off();
+	/*
+	 * Freeze in reverse order so filesystems dependant upon others are
+	 * frozen in the right order (eg. loopback on ext3).
+	 */
+	list_for_each_entry_reverse(sb, &super_blocks, s_list) {
+		if (!sb->s_root || !sb->s_bdev ||
+		    (sb->s_frozen == SB_FREEZE_TRANS) ||
+		    (sb->s_flags & MS_RDONLY) ||
+		    (sb->s_flags & MS_FROZEN))
+			continue;
+
+		freeze_bdev(sb->s_bdev);
+		sb->s_flags |= MS_FROZEN;
+	}
+	lockdep_on();
+}
+
+/**
+ * thaw_filesystems - unlock all filesystems
+ */
+void thaw_filesystems(void)
+{
+	struct super_block *sb;
+
+	lockdep_off();
+
+	list_for_each_entry(sb, &super_blocks, s_list)
+		if (sb->s_flags & MS_FROZEN) {
+			sb->s_flags &= ~MS_FROZEN;
+			thaw_bdev(sb->s_bdev, sb);
+		}
+
+	lockdep_on();
+}
+
 /*
  * Various filesystems appear to want __find_get_block to be non-blocking.
  * But it's the page lock which protects the buffers.  To get around this,
diff -puN include/linux/buffer_head.h~swsusp-freeze-filesystems-during-suspend-rev-2 include/linux/buffer_head.h
--- a/include/linux/buffer_head.h~swsusp-freeze-filesystems-during-suspend-rev-2
+++ a/include/linux/buffer_head.h
@@ -170,6 +170,8 @@ wait_queue_head_t *bh_waitq_head(struct 
 int fsync_bdev(struct block_device *);
 struct super_block *freeze_bdev(struct block_device *);
 void thaw_bdev(struct block_device *, struct super_block *);
+void freeze_filesystems(void);
+void thaw_filesystems(void);
 int fsync_super(struct super_block *);
 int fsync_no_super(struct block_device *);
 struct buffer_head *__find_get_block(struct block_device *, sector_t, int);
diff -puN include/linux/freezer.h~swsusp-freeze-filesystems-during-suspend-rev-2 include/linux/freezer.h
--- a/include/linux/freezer.h~swsusp-freeze-filesystems-during-suspend-rev-2
+++ a/include/linux/freezer.h
@@ -1,8 +1,5 @@
 /* Freezer declarations */
 
-#define FREEZER_KERNEL_THREADS 0
-#define FREEZER_ALL_THREADS 1
-
 #ifdef CONFIG_PM
 /*
  * Check if a process has been frozen
@@ -60,8 +57,8 @@ static inline void frozen_process(struct
 
 extern void refrigerator(void);
 extern int freeze_processes(void);
-#define thaw_processes() do { thaw_some_processes(FREEZER_ALL_THREADS); } while(0)
-#define thaw_kernel_threads() do { thaw_some_processes(FREEZER_KERNEL_THREADS); } while(0)
+extern void thaw_processes(void);
+extern void thaw_kernel_threads(void);
 
 static inline int try_to_freeze(void)
 {
diff -puN include/linux/fs.h~swsusp-freeze-filesystems-during-suspend-rev-2 include/linux/fs.h
--- a/include/linux/fs.h~swsusp-freeze-filesystems-during-suspend-rev-2
+++ a/include/linux/fs.h
@@ -120,6 +120,7 @@ extern int dir_notify_enable;
 #define MS_PRIVATE	(1<<18)	/* change to private */
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
+#define MS_FROZEN	(1<<21)	/* Frozen by freeze_filesystems() */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
diff -puN kernel/power/process.c~swsusp-freeze-filesystems-during-suspend-rev-2 kernel/power/process.c
--- a/kernel/power/process.c~swsusp-freeze-filesystems-during-suspend-rev-2
+++ a/kernel/power/process.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/buffer_head.h>
 
 /* 
  * Timeout for stopping processes
@@ -120,6 +121,7 @@ int freeze_processes(void)
 		todo += nr_user;
 		if (!user_frozen && !nr_user) {
 			sys_sync();
+			freeze_filesystems();
 			start_time = jiffies;
 		}
 		user_frozen = !nr_user;
@@ -153,31 +155,47 @@ int freeze_processes(void)
 	return 0;
 }
 
-void thaw_some_processes(int all)
+#define FREEZER_KERNEL_THREADS 0
+#define FREEZER_USER_SPACE 1
+
+static void __thaw_tasks(int user_space)
 {
 	struct task_struct *g, *p;
-	int pass = 0; /* Pass 0 = Kernel space, 1 = Userspace */
 
-	printk("Restarting tasks... ");
 	read_lock(&tasklist_lock);
-	do {
-		do_each_thread(g, p) {
-			/*
-			 * is_user = 0 if kernel thread or borrowed mm,
-			 * 1 otherwise.
-			 */
-			int is_user = !!(p->mm && !(p->flags & PF_BORROWED_MM));
-			if (!freezeable(p) || (is_user != pass))
+	do_each_thread(g, p) {
+		if (!freezeable(p))
+			continue;
+
+		if (p->mm && !(p->flags & PF_BORROWED_MM)) {
+			/* It's a user space process */
+			if (!user_space)
 				continue;
-			if (!thaw_process(p))
-				printk(KERN_INFO
-					"Strange, %s not stopped\n", p->comm);
-		} while_each_thread(g, p);
+		} else {
+			/* It's a kernel thread */
+			if (user_space)
+				continue;
+		}
+		if (!thaw_process(p))
+			printk(KERN_INFO " Strange, %s not stopped\n", p->comm );
+	} while_each_thread(g, p);
+	read_unlock(&tasklist_lock);
+}
 
-		pass++;
-	} while (pass < 2 && all);
+void thaw_processes(void)
+{
+	printk("Restarting tasks ... ");
+	__thaw_tasks(FREEZER_KERNEL_THREADS);
+	thaw_filesystems();
+	__thaw_tasks(FREEZER_USER_SPACE);
+	schedule();
+	printk("done.\n");
+}
 
-	read_unlock(&tasklist_lock);
+void thaw_kernel_threads(void)
+{
+	printk("Restarting kernel threads ... ");
+	__thaw_tasks(FREEZER_KERNEL_THREADS);
 	schedule();
 	printk("done.\n");
 }
_

Patches currently in -mm which might be from rjw@xxxxxxx are

git-acpi.patch
uswsusp-add-pmops-prepareenterfinish-support-aka-platform-mode.patch
swsusp-use-partition-device-and-offset-to-identify-swap-areas.patch
swsusp-rearrange-swap-handling-code.patch
swsusp-use-block-device-offsets-to-identify-swap-locations-rev-2.patch
swsusp-add-resume_offset-command-line-parameter-rev-2.patch
swsusp-document-support-for-swap-files-rev-2.patch
swsusp-add-ioctl-for-swap-files-support.patch
swsusp-update-userland-interface-documentation.patch
swsusp-improve-handling-of-highmem.patch
swsusp-improve-handling-of-highmem-fix.patch
swsusp-use-__gfp_wait.patch
swsusp-fix-platform-mode.patch
add-include-linux-freezerh-and-move-definitions-from.patch
add-include-linux-freezerh-and-move-definitions-from-ueagle-fix.patch
quieten-freezer-if-config_pm_debug.patch
swsusp-cleanup-whitespace-in-freezer-output.patch
swsusp-thaw-userspace-and-kernel-space-separately.patch
swsusp-support-i386-systems-with-pae-or-without-pse.patch
swsusp-freeze-filesystems-during-suspend-rev-2.patch
swsusp-freeze-filesystems-during-suspend-rev-2-comments.patch
swsusp-freeze-filesystems-during-suspend-rev-2-freeze-thaw-fs-when-block=n.patch
suspend-dont-change-cpus_allowed-for-task-initiating-the-suspend.patch
swsusp-measure-memory-shrinking-time.patch
suspend-to-disk-fails-if-gdb-is-suspended-with-a-traced-child.patch
convert-pm_sem-to-a-mutex.patch
support-for-freezeable-workqueues.patch
use-freezeable-workqueues-in-xfs.patch
md-change-lifetime-rules-for-md-devices.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux