public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@osdl.org>
Cc: Dave Jones <davej@redhat.com>, Pavel Machek <pavel@ucw.cz>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm 4/6] swsusp: Add resume_offset command line parameter
Date: Sat, 23 Sep 2006 12:08:25 +0200	[thread overview]
Message-ID: <200609231208.25670.rjw@sisk.pl> (raw)
In-Reply-To: <200609231158.00147.rjw@sisk.pl>

Add the kernel command line parameter "resume_offset=" allowing us to specify
the offset, in <PAGE_SIZE> units, from the beginning of the partition pointed
to by the "resume=" parameter at which the swap header is located.

This offset can be determined, for example, by an application using the FIBMAP
ioctl to obtain the swap header's block number for given file.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
 kernel/power/disk.c  |   15 +++++++++++++++
 kernel/power/power.h |    1 +
 kernel/power/swap.c  |   15 ++++++++++-----
 3 files changed, 26 insertions(+), 5 deletions(-)

Index: linux-2.6.18-rc7-mm1/kernel/power/disk.c
===================================================================
--- linux-2.6.18-rc7-mm1.orig/kernel/power/disk.c
+++ linux-2.6.18-rc7-mm1/kernel/power/disk.c
@@ -27,6 +27,7 @@
 static int noresume = 0;
 char resume_file[256] = CONFIG_PM_STD_PARTITION;
 dev_t swsusp_resume_device;
+sector_t swsusp_resume_block;
 
 /**
  *	power_down - Shut machine down for hibernate.
@@ -404,6 +405,19 @@ static int __init resume_setup(char *str
 	return 1;
 }
 
+static int __init resume_offset_setup(char *str)
+{
+	loff_t offset;
+
+	if (noresume)
+		return 1;
+
+	if (sscanf(str, "%llu", &offset) == 1)
+		swsusp_resume_block = offset;
+
+	return 1;
+}
+
 static int __init noresume_setup(char *str)
 {
 	noresume = 1;
@@ -411,4 +425,5 @@ static int __init noresume_setup(char *s
 }
 
 __setup("noresume", noresume_setup);
+__setup("resume_offset=", resume_offset_setup);
 __setup("resume=", resume_setup);
Index: linux-2.6.18-rc7-mm1/kernel/power/power.h
===================================================================
--- linux-2.6.18-rc7-mm1.orig/kernel/power/power.h
+++ linux-2.6.18-rc7-mm1/kernel/power/power.h
@@ -42,6 +42,7 @@ extern const void __nosave_begin, __nosa
 extern unsigned long image_size;
 extern int in_suspend;
 extern dev_t swsusp_resume_device;
+extern sector_t swsusp_resume_block;
 
 extern asmlinkage int swsusp_arch_suspend(void);
 extern asmlinkage int swsusp_arch_resume(void);
Index: linux-2.6.18-rc7-mm1/kernel/power/swap.c
===================================================================
--- linux-2.6.18-rc7-mm1.orig/kernel/power/swap.c
+++ linux-2.6.18-rc7-mm1/kernel/power/swap.c
@@ -160,13 +160,14 @@ static int mark_swapfiles(loff_t start)
 {
 	int error;
 
-	bio_read_page(0, &swsusp_header, NULL);
+	bio_read_page(swsusp_resume_block, &swsusp_header, NULL);
 	if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
 	    !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
 		memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
 		memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
 		swsusp_header.image = start;
-		error = bio_write_page(0, &swsusp_header, NULL);
+		error = bio_write_page(swsusp_resume_block,
+					&swsusp_header, NULL);
 	} else {
 		printk(KERN_ERR "swsusp: Swap header not found!\n");
 		error = -ENODEV;
@@ -183,7 +184,7 @@ static int swsusp_swap_check(void) /* Th
 {
 	int res;
 
-	res = swap_type_of(swsusp_resume_device, 0);
+	res = swap_type_of(swsusp_resume_device, swsusp_resume_block);
 	if (res < 0)
 		return res;
 
@@ -606,12 +607,16 @@ int swsusp_check(void)
 	if (!IS_ERR(resume_bdev)) {
 		set_blocksize(resume_bdev, PAGE_SIZE);
 		memset(&swsusp_header, 0, sizeof(swsusp_header));
-		if ((error = bio_read_page(0, &swsusp_header, NULL)))
+		error = bio_read_page(swsusp_resume_block,
+					&swsusp_header, NULL);
+		if (error)
 			return error;
+
 		if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
 			memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
 			/* Reset swap signature now */
-			error = bio_write_page(0, &swsusp_header, NULL);
+			error = bio_write_page(swsusp_resume_block,
+						&swsusp_header, NULL);
 		} else {
 			return -EINVAL;
 		}


  parent reply	other threads:[~2006-09-23 10:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23  9:57 [PATCH -mm] swsusp: Add support for swap files Rafael J. Wysocki
2006-09-23 10:01 ` [PATCH -mm 1/6] swsusp: Use partition device and offset to identify swap areas Rafael J. Wysocki
2006-09-23 10:02 ` [PATCH -mm 2/6] swsusp: Rearrange swap-handling code Rafael J. Wysocki
2006-09-23 10:04 ` [PATCH -mm 3/6] swsusp: Use block device offsets to identify swap locations Rafael J. Wysocki
2006-09-26 19:38   ` Andrew Morton
2006-09-26 20:04     ` Rafael J. Wysocki
2006-09-26 21:51       ` Rafael J. Wysocki
2006-09-23 10:08 ` Rafael J. Wysocki [this message]
2006-09-26 19:38   ` [PATCH -mm 4/6] swsusp: Add resume_offset command line parameter Andrew Morton
2006-09-26 20:10     ` Rafael J. Wysocki
2006-09-23 10:10 ` [PATCH -mm 5/6] mm: Print first block offset for swap areas Rafael J. Wysocki
2006-09-26 19:39   ` Andrew Morton
2006-09-26 20:13     ` Rafael J. Wysocki
2006-09-26 20:49       ` Andrew Morton
2006-09-26 21:04         ` Rafael J. Wysocki
2006-09-23 10:13 ` [PATCH -mm 6/6] swsusp: Document support for swap files Rafael J. Wysocki
2006-09-26 21:56   ` Rafael J. Wysocki
2006-09-23 10:17 ` [PATCH -mm] swsusp: Add " Pavel Machek
2006-09-23 20:30   ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2006-09-20 19:20 [PATCH -mm 0/6] " Rafael J. Wysocki
2006-09-20 19:46 ` [PATCH -mm 4/6] swsusp: Add resume_offset command line parameter Rafael J. Wysocki
2006-09-21 21:31   ` Pavel Machek
2006-09-21 22:18     ` Rafael J. Wysocki
2006-09-22 13:34       ` Pavel Machek

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