mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@osdl.org>
Cc: Pavel Machek <pavel@suse.cz>, Dave Jones <davej@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm 1/1] swsusp: fix breakage with swap on LVM
Date: Thu, 16 Feb 2006 16:05:25 +0100	[thread overview]
Message-ID: <200602161605.25686.rjw@sisk.pl> (raw)
In-Reply-To: <200602161558.57702.rjw@sisk.pl>

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 <rjw@sisk.pl>
---
 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)
  *

      parent reply	other threads:[~2006-02-16 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-16 14:58 [PATCH 0/1] " Rafael J. Wysocki
2006-02-16 15:03 ` [PATCH 1/1] " Rafael J. Wysocki
2006-02-16 15:05 ` Rafael J. Wysocki [this message]

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=200602161605.25686.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@osdl.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®