[PATCH -mm 1/1] swsusp: fix breakage with swap on LVM

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

 



Restore the compatibility with the older code and make it possible to
suspend if the kernel command line doesn't contain the "resume="
argument.


Signed-off-by: Rafael J. Wysocki <[email protected]>
---
 include/linux/swap.h |    1 +
 kernel/power/swap.c  |    3 ++-
 mm/swapfile.c        |   17 +++++++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

Index: linux-2.6.16-rc3-mm1/include/linux/swap.h
===================================================================
--- linux-2.6.16-rc3-mm1.orig/include/linux/swap.h
+++ linux-2.6.16-rc3-mm1/include/linux/swap.h
@@ -246,6 +246,7 @@ extern int valid_swaphandles(swp_entry_t
 extern void swap_free(swp_entry_t);
 extern void free_swap_and_cache(swp_entry_t);
 extern int swap_type_of(dev_t);
+extern int find_swap(void);
 extern unsigned int count_swap_pages(int, int);
 extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
 extern struct swap_info_struct *get_swap_info_struct(unsigned);
Index: linux-2.6.16-rc3-mm1/kernel/power/swap.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/kernel/power/swap.c
+++ linux-2.6.16-rc3-mm1/kernel/power/swap.c
@@ -75,8 +75,9 @@ static int mark_swapfiles(swp_entry_t st
 
 static int swsusp_swap_check(void) /* This is called before saving image */
 {
-	int res = swap_type_of(swsusp_resume_device);
+	int res;
 
+	res = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : find_swap();
 	if (res >= 0) {
 		root_swap = res;
 		return 0;
Index: linux-2.6.16-rc3-mm1/mm/swapfile.c
===================================================================
--- linux-2.6.16-rc3-mm1.orig/mm/swapfile.c
+++ linux-2.6.16-rc3-mm1/mm/swapfile.c
@@ -448,6 +448,23 @@ int swap_type_of(dev_t device)
 }
 
 /*
+ * Find first writeable swap.
+ *
+ * This is needed for software suspend in case the resume device is not
+ * specified in the kernel command line
+ */
+int find_swap(void)
+{
+	int i = 0;
+
+	spin_lock(&swap_lock);
+	while (i < nr_swapfiles && !(swap_info[i].flags & SWP_WRITEOK))
+		i++;
+	spin_unlock(&swap_lock);
+	return i < nr_swapfiles ? i : -ENODEV;
+}
+
+/*
  * Return either the total number of swap pages of given type, or the number
  * of free pages of that type (depending on @free)
  *
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux