swsusp: fix breakage with swap on LVM
Subsystems (4)
cover swsusp: fix breakage with swap on LVM
Hi,
In the following two replies to this message there are two versions of the same fix, one of which applies to 2.6.16-rc3 and the second to the recent -mm.
The fix is needed to restore the compatibility with the older code that allowed to suspend even if the kernel command line didn't contain the "resume=" argument. This feature is necessary so that swsusp can work in the default Fedora setup where the swap partition is on an LVM.
I consider the first patch, against 2.6.16-rc3, as an urgent fix that should go in 2.6.16, if possible. It has been tested by Dave and evidently fixes the Fedora issue. Unfortunately it doesn't apply to the recent -mm, because in -mm the code in question is split between mm/swapfile.c and kernel/power/swap.c, so the other patch is needed.
Please apply.
Greetings,
Rafael
PATCH 1/1 swsusp: fix breakage with swap on LVM
Restore the compatibility with the older code and make it possible to suspend if the kernel command line doesn't contain the "resume=" argument
--- kernel/power/swsusp.c | 4 +--- 1 files changed, 1 insertion(+), 3 deletions(-)
kernel/power/swsusp.c +1 -3
@@ -153,13 +153,11 @@ static int swsusp_swap_check(void) /* Th {int i; -if (!swsusp_resume_device) -return -ENODEV ;spin_lock (&swap_lock);for (i =0 ; i <MAX_SWAPFILES ; i++) {if (!(swap_info[i].flags &SWP_WRITEOK ))continue ; -if (is_resume_device (swap_info + i)) { +if (!swsusp_resume_device ||is_resume_device (swap_info + i)) {spin_unlock (&swap_lock); root_swap = i;return 0 ;
PATCH 1/1 swsusp: fix breakage with swap on LVM
In reply to Rafael J. WysockiRestore the compatibility with the older code and make it possible to suspend if the kernel command line doesn't contain the "resume=" argument.
--- include/linux/swap.h | 1 + kernel/power/swap.c | 3 ++- mm/swapfile.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)
include/linux/swap.h +1 -0
@@ -246,6 +246,7 @@ extern int valid_swaphandles(swp_entry_textern 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 );
kernel/power/swap.c +2 -1
@@ -75,8 +75,9 @@ static int mark_swapfiles(swp_entry_t ststatic 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 ;
mm/swapfile.c +17 -0
@@ -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) *