diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-12-06 23:34:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:27 -0500 |
commit | 915bae9ebe41e52d71ad8b06d50e4ab26189f964 (patch) | |
tree | daf0c9a370d3a551c1bb5beea69a3a0cfecd9885 /kernel/power | |
parent | 3592695c363c3f3119621bdcf5ed852d6b9d1a5c (diff) |
[PATCH] swsusp: use partition device and offset to identify swap areas
The Linux kernel handles swap files almost in the same way as it handles swap
partitions and there are only two differences between these two types of swap
areas:
(1) swap files need not be contiguous,
(2) the header of a swap file is not in the first block of the partition
that holds it. From the swsusp's point of view (1) is not a problem,
because it is already taken care of by the swap-handling code, but (2) has
to be taken into consideration.
In principle the location of a swap file's header may be determined with the
help of appropriate filesystem driver. Unfortunately, however, it requires
the filesystem holding the swap file to be mounted, and if this filesystem is
journaled, it cannot be mounted during a resume from disk. For this reason we
need some other means by which swap areas can be identified.
For example, to identify a swap area we can use the partition that holds the
area and the offset from the beginning of this partition at which the swap
header is located.
The following patch allows swsusp to identify swap areas this way. It changes
swap_type_of() so that it takes an additional argument representing an offset
of the swap header within the partition represented by its first argument.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/swap.c | 2 | ||||
-rw-r--r-- | kernel/power/user.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 1a3b0dd2c3fc..7b10da16389e 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
@@ -74,7 +74,7 @@ static int mark_swapfiles(swp_entry_t start) | |||
74 | 74 | ||
75 | static int swsusp_swap_check(void) /* This is called before saving image */ | 75 | static int swsusp_swap_check(void) /* This is called before saving image */ |
76 | { | 76 | { |
77 | int res = swap_type_of(swsusp_resume_device); | 77 | int res = swap_type_of(swsusp_resume_device, 0); |
78 | 78 | ||
79 | if (res >= 0) { | 79 | if (res >= 0) { |
80 | root_swap = res; | 80 | root_swap = res; |
diff --git a/kernel/power/user.c b/kernel/power/user.c index 4c24ca5d62e3..a327b18a5ffd 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -55,7 +55,8 @@ static int snapshot_open(struct inode *inode, struct file *filp) | |||
55 | filp->private_data = data; | 55 | filp->private_data = data; |
56 | memset(&data->handle, 0, sizeof(struct snapshot_handle)); | 56 | memset(&data->handle, 0, sizeof(struct snapshot_handle)); |
57 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) { | 57 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) { |
58 | data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1; | 58 | data->swap = swsusp_resume_device ? |
59 | swap_type_of(swsusp_resume_device, 0) : -1; | ||
59 | data->mode = O_RDONLY; | 60 | data->mode = O_RDONLY; |
60 | } else { | 61 | } else { |
61 | data->swap = -1; | 62 | data->swap = -1; |
@@ -265,7 +266,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, | |||
265 | * so we need to recode them | 266 | * so we need to recode them |
266 | */ | 267 | */ |
267 | if (old_decode_dev(arg)) { | 268 | if (old_decode_dev(arg)) { |
268 | data->swap = swap_type_of(old_decode_dev(arg)); | 269 | data->swap = swap_type_of(old_decode_dev(arg), 0); |
269 | if (data->swap < 0) | 270 | if (data->swap < 0) |
270 | error = -ENODEV; | 271 | error = -ENODEV; |
271 | } else { | 272 | } else { |