diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-12-06 23:34:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:27 -0500 |
commit | 9a154d9d95b7b9845938242f5c62505b3cab5bcd (patch) | |
tree | fd3c51434298b139671f5accd42ab112a310555c | |
parent | 3aef83e0ef1ffb8ea3bea97be46821a45c952173 (diff) |
[PATCH] swsusp: add resume_offset command line parameter
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.
[akpm@osdl.org: we don't know what type sector_t is]
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | kernel/power/disk.c | 15 | ||||
-rw-r--r-- | kernel/power/power.h | 1 | ||||
-rw-r--r-- | kernel/power/swap.c | 15 |
3 files changed, 26 insertions, 5 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index b1fb7866b0b3..d79feeb45459 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -27,6 +27,7 @@ | |||
27 | static int noresume = 0; | 27 | static int noresume = 0; |
28 | char resume_file[256] = CONFIG_PM_STD_PARTITION; | 28 | char resume_file[256] = CONFIG_PM_STD_PARTITION; |
29 | dev_t swsusp_resume_device; | 29 | dev_t swsusp_resume_device; |
30 | sector_t swsusp_resume_block; | ||
30 | 31 | ||
31 | /** | 32 | /** |
32 | * power_down - Shut machine down for hibernate. | 33 | * power_down - Shut machine down for hibernate. |
@@ -423,6 +424,19 @@ static int __init resume_setup(char *str) | |||
423 | return 1; | 424 | return 1; |
424 | } | 425 | } |
425 | 426 | ||
427 | static int __init resume_offset_setup(char *str) | ||
428 | { | ||
429 | unsigned long long offset; | ||
430 | |||
431 | if (noresume) | ||
432 | return 1; | ||
433 | |||
434 | if (sscanf(str, "%llu", &offset) == 1) | ||
435 | swsusp_resume_block = offset; | ||
436 | |||
437 | return 1; | ||
438 | } | ||
439 | |||
426 | static int __init noresume_setup(char *str) | 440 | static int __init noresume_setup(char *str) |
427 | { | 441 | { |
428 | noresume = 1; | 442 | noresume = 1; |
@@ -430,4 +444,5 @@ static int __init noresume_setup(char *str) | |||
430 | } | 444 | } |
431 | 445 | ||
432 | __setup("noresume", noresume_setup); | 446 | __setup("noresume", noresume_setup); |
447 | __setup("resume_offset=", resume_offset_setup); | ||
433 | __setup("resume=", resume_setup); | 448 | __setup("resume=", resume_setup); |
diff --git a/kernel/power/power.h b/kernel/power/power.h index 210ebba26020..adaf7d4fbdaf 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -42,6 +42,7 @@ extern const void __nosave_begin, __nosave_end; | |||
42 | extern unsigned long image_size; | 42 | extern unsigned long image_size; |
43 | extern int in_suspend; | 43 | extern int in_suspend; |
44 | extern dev_t swsusp_resume_device; | 44 | extern dev_t swsusp_resume_device; |
45 | extern sector_t swsusp_resume_block; | ||
45 | 46 | ||
46 | extern asmlinkage int swsusp_arch_suspend(void); | 47 | extern asmlinkage int swsusp_arch_suspend(void); |
47 | extern asmlinkage int swsusp_arch_resume(void); | 48 | extern asmlinkage int swsusp_arch_resume(void); |
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 1b08f46bbb7e..aa5a9bff01f1 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
@@ -161,13 +161,14 @@ static int mark_swapfiles(sector_t start) | |||
161 | { | 161 | { |
162 | int error; | 162 | int error; |
163 | 163 | ||
164 | bio_read_page(0, &swsusp_header, NULL); | 164 | bio_read_page(swsusp_resume_block, &swsusp_header, NULL); |
165 | if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) || | 165 | if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) || |
166 | !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) { | 166 | !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) { |
167 | memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10); | 167 | memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10); |
168 | memcpy(swsusp_header.sig,SWSUSP_SIG, 10); | 168 | memcpy(swsusp_header.sig,SWSUSP_SIG, 10); |
169 | swsusp_header.image = start; | 169 | swsusp_header.image = start; |
170 | error = bio_write_page(0, &swsusp_header, NULL); | 170 | error = bio_write_page(swsusp_resume_block, |
171 | &swsusp_header, NULL); | ||
171 | } else { | 172 | } else { |
172 | printk(KERN_ERR "swsusp: Swap header not found!\n"); | 173 | printk(KERN_ERR "swsusp: Swap header not found!\n"); |
173 | error = -ENODEV; | 174 | error = -ENODEV; |
@@ -184,7 +185,7 @@ static int swsusp_swap_check(void) /* This is called before saving image */ | |||
184 | { | 185 | { |
185 | int res; | 186 | int res; |
186 | 187 | ||
187 | res = swap_type_of(swsusp_resume_device, 0); | 188 | res = swap_type_of(swsusp_resume_device, swsusp_resume_block); |
188 | if (res < 0) | 189 | if (res < 0) |
189 | return res; | 190 | return res; |
190 | 191 | ||
@@ -610,12 +611,16 @@ int swsusp_check(void) | |||
610 | if (!IS_ERR(resume_bdev)) { | 611 | if (!IS_ERR(resume_bdev)) { |
611 | set_blocksize(resume_bdev, PAGE_SIZE); | 612 | set_blocksize(resume_bdev, PAGE_SIZE); |
612 | memset(&swsusp_header, 0, sizeof(swsusp_header)); | 613 | memset(&swsusp_header, 0, sizeof(swsusp_header)); |
613 | if ((error = bio_read_page(0, &swsusp_header, NULL))) | 614 | error = bio_read_page(swsusp_resume_block, |
615 | &swsusp_header, NULL); | ||
616 | if (error) | ||
614 | return error; | 617 | return error; |
618 | |||
615 | if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { | 619 | if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { |
616 | memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); | 620 | memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); |
617 | /* Reset swap signature now */ | 621 | /* Reset swap signature now */ |
618 | error = bio_write_page(0, &swsusp_header, NULL); | 622 | error = bio_write_page(swsusp_resume_block, |
623 | &swsusp_header, NULL); | ||
619 | } else { | 624 | } else { |
620 | return -EINVAL; | 625 | return -EINVAL; |
621 | } | 626 | } |