* [PATCH -mm 0/3] swsusp: swap handling improvements
@ 2005-12-27 16:47 Rafael J. Wysocki
2005-12-27 16:52 ` [PATCH -mm 1/3] mm: add a new function (needed for swap suspend) Rafael J. Wysocki
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2005-12-27 16:47 UTC (permalink / raw)
To: Andrew Morton; +Cc: Pavel Machek, LKML
Hi,
The following series of patches improves the handling of swap partitions
by swsusp and changes the way it writes the image to swap. As a result,
the swap-handling part of swsusp is simplified quite a bit.
The patches in this series are also necessary for implementing the swsusp's
userland interface (coming soon).
The third patch has been acked by Pavel, but of course it depends on the
previous two. Still, I posted them for comments some time ago and there
have not been any, so I assume there are no objections. ;-)
Please apply.
Greetings,
Rafael
--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH -mm 1/3] mm: add a new function (needed for swap suspend)
2005-12-27 16:47 [PATCH -mm 0/3] swsusp: swap handling improvements Rafael J. Wysocki
@ 2005-12-27 16:52 ` Rafael J. Wysocki
2006-01-04 7:31 ` Andrew Morton
2005-12-27 16:57 ` [PATCH -mm 2/3] swsusp: improve handling of swap partitions Rafael J. Wysocki
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2005-12-27 16:52 UTC (permalink / raw)
To: Andrew Morton; +Cc: Pavel Machek, LKML
This patch adds the function get_swap_page_of_type() allowing us to
specify an index in swap_info[] and select a swap_info_struct
structure to be used for allocating a swap page.
This function (or another one of similar functionality) will be necessary for
implementing the image-writing part of swsusp in the user space. It can also
be used for simplifying the current in-kernel implementation of the
image-writing part of swsusp.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
include/linux/swap.h | 1 +
mm/swapfile.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
Index: linux-2.6.15-rc5-mm3/mm/swapfile.c
===================================================================
--- linux-2.6.15-rc5-mm3.orig/mm/swapfile.c 2005-12-15 12:01:39.000000000 +0100
+++ linux-2.6.15-rc5-mm3/mm/swapfile.c 2005-12-15 19:00:45.000000000 +0100
@@ -211,6 +211,26 @@
return (swp_entry_t) {0};
}
+swp_entry_t get_swap_page_of_type(int type)
+{
+ struct swap_info_struct *si;
+ pgoff_t offset;
+
+ spin_lock(&swap_lock);
+ si = swap_info + type;
+ if (si->flags & SWP_WRITEOK) {
+ nr_swap_pages--;
+ offset = scan_swap_map(si);
+ if (offset) {
+ spin_unlock(&swap_lock);
+ return swp_entry(type, offset);
+ }
+ nr_swap_pages++;
+ }
+ spin_unlock(&swap_lock);
+ return (swp_entry_t) {0};
+}
+
static struct swap_info_struct * swap_info_get(swp_entry_t entry)
{
struct swap_info_struct * p;
Index: linux-2.6.15-rc5-mm3/include/linux/swap.h
===================================================================
--- linux-2.6.15-rc5-mm3.orig/include/linux/swap.h 2005-12-15 12:03:26.000000000 +0100
+++ linux-2.6.15-rc5-mm3/include/linux/swap.h 2005-12-15 19:00:46.000000000 +0100
@@ -216,6 +216,7 @@
extern struct swap_info_struct swap_info[];
extern void si_swapinfo(struct sysinfo *);
extern swp_entry_t get_swap_page(void);
+extern swp_entry_t get_swap_page_of_type(int type);
extern int swap_duplicate(swp_entry_t);
extern int valid_swaphandles(swp_entry_t, unsigned long *);
extern void swap_free(swp_entry_t);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH -mm 2/3] swsusp: improve handling of swap partitions
2005-12-27 16:47 [PATCH -mm 0/3] swsusp: swap handling improvements Rafael J. Wysocki
2005-12-27 16:52 ` [PATCH -mm 1/3] mm: add a new function (needed for swap suspend) Rafael J. Wysocki
@ 2005-12-27 16:57 ` Rafael J. Wysocki
2005-12-27 17:07 ` [PATCH -mm 3/3] swsusp: save image header first Rafael J. Wysocki
2005-12-27 17:27 ` [PATCH -mm 0/3] swsusp: swap handling improvements Pavel Machek
3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2005-12-27 16:57 UTC (permalink / raw)
To: Andrew Morton; +Cc: Pavel Machek, LKML
This patch changes the handling of swap partitions by swsusp to avoid
locking of the swap devices that are not used for suspend and, consequently,
simplifies the code.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
kernel/power/swsusp.c | 128 ++++++++++++++------------------------------------
1 files changed, 36 insertions(+), 92 deletions(-)
Index: linux-2.6.15-rc5-mm3/kernel/power/swsusp.c
===================================================================
--- linux-2.6.15-rc5-mm3.orig/kernel/power/swsusp.c 2005-12-15 23:00:12.000000000 +0100
+++ linux-2.6.15-rc5-mm3/kernel/power/swsusp.c 2005-12-16 23:15:14.000000000 +0100
@@ -104,13 +104,7 @@ static struct swsusp_info swsusp_info;
* Saving part...
*/
-/* We memorize in swapfile_used what swap devices are used for suspension */
-#define SWAPFILE_UNUSED 0
-#define SWAPFILE_SUSPEND 1 /* This is the suspending device */
-#define SWAPFILE_IGNORED 2 /* Those are other swap devices ignored for suspension */
-
-static unsigned short swapfile_used[MAX_SWAPFILES];
-static unsigned short root_swap;
+static unsigned short root_swap = 0xffff;
static int mark_swapfiles(swp_entry_t prev)
{
@@ -146,7 +140,7 @@ static int mark_swapfiles(swp_entry_t pr
* devfs, since the resume code can only recognize the form /dev/hda4,
* but the suspend code would see the long name.)
*/
-static int is_resume_device(const struct swap_info_struct *swap_info)
+static inline int is_resume_device(const struct swap_info_struct *swap_info)
{
struct file *file = swap_info->swap_file;
struct inode *inode = file->f_dentry->d_inode;
@@ -157,54 +151,22 @@ static int is_resume_device(const struct
static int swsusp_swap_check(void) /* This is called before saving image */
{
- int i, len;
-
- len=strlen(resume_file);
- root_swap = 0xFFFF;
-
- spin_lock(&swap_lock);
- for (i=0; i<MAX_SWAPFILES; i++) {
- if (!(swap_info[i].flags & SWP_WRITEOK)) {
- swapfile_used[i]=SWAPFILE_UNUSED;
- } else {
- if (!len) {
- printk(KERN_WARNING "resume= option should be used to set suspend device" );
- if (root_swap == 0xFFFF) {
- swapfile_used[i] = SWAPFILE_SUSPEND;
- root_swap = i;
- } else
- swapfile_used[i] = SWAPFILE_IGNORED;
- } else {
- /* we ignore all swap devices that are not the resume_file */
- if (is_resume_device(&swap_info[i])) {
- swapfile_used[i] = SWAPFILE_SUSPEND;
- root_swap = i;
- } else {
- swapfile_used[i] = SWAPFILE_IGNORED;
- }
- }
- }
- }
- spin_unlock(&swap_lock);
- return (root_swap != 0xffff) ? 0 : -ENODEV;
-}
-
-/**
- * This is called after saving image so modification
- * will be lost after resume... and that's what we want.
- * we make the device unusable. A new call to
- * lock_swapdevices can unlock the devices.
- */
-static void lock_swapdevices(void)
-{
int i;
+ if (!swsusp_resume_device)
+ return -ENODEV;
spin_lock(&swap_lock);
- for (i = 0; i< MAX_SWAPFILES; i++)
- if (swapfile_used[i] == SWAPFILE_IGNORED) {
- swap_info[i].flags ^= SWP_WRITEOK;
+ for (i = 0; i < MAX_SWAPFILES; i++) {
+ if (!(swap_info[i].flags & SWP_WRITEOK))
+ continue;
+ if (is_resume_device(swap_info + i)) {
+ spin_unlock(&swap_lock);
+ root_swap = i;
+ return 0;
}
+ }
spin_unlock(&swap_lock);
+ return -ENODEV;
}
/**
@@ -222,19 +184,14 @@ static void lock_swapdevices(void)
static int write_page(unsigned long addr, swp_entry_t *loc)
{
swp_entry_t entry;
- int error = 0;
+ int error = -ENOSPC;
- entry = get_swap_page();
- if (swp_offset(entry) &&
- swapfile_used[swp_type(entry)] == SWAPFILE_SUSPEND) {
- error = rw_swap_page_sync(WRITE, entry,
- virt_to_page(addr));
- if (error == -EIO)
- error = 0;
- if (!error)
+ entry = get_swap_page_of_type(root_swap);
+ if (swp_offset(entry)) {
+ error = rw_swap_page_sync(WRITE, entry, virt_to_page(addr));
+ if (!error || error == -EIO)
*loc = entry;
- } else
- error = -ENOSPC;
+ }
return error;
}
@@ -539,31 +496,38 @@ static int save_image_metadata(struct pb
* enough_swap - Make sure we have enough swap to save the image.
*
* Returns TRUE or FALSE after checking the total amount of swap
- * space avaiable.
- *
- * FIXME: si_swapinfo(&i) returns all swap devices information.
- * We should only consider resume_device.
+ * space avaiable from the resume partition.
*/
static int enough_swap(unsigned int nr_pages)
{
- struct sysinfo i;
+ unsigned int free_swap = swap_info[root_swap].pages -
+ swap_info[root_swap].inuse_pages;
- si_swapinfo(&i);
- pr_debug("swsusp: available swap: %lu pages\n", i.freeswap);
- return i.freeswap > (nr_pages + PAGES_FOR_IO +
+ pr_debug("swsusp: free swap pages: %u\n", free_swap);
+ return free_swap > (nr_pages + PAGES_FOR_IO +
(nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
}
/**
- * write_suspend_image - Write entire image and metadata.
+ * swsusp_write - Write entire image and metadata.
+ *
+ * It is important _NOT_ to umount filesystems at this point. We want
+ * them synced (in case something goes wrong) but we DO not want to mark
+ * filesystem clean: it is not. (And it does not matter, if we resume
+ * correctly, we'll mark system clean, anyway.)
*/
-static int write_suspend_image(struct pbe *pblist, unsigned int nr_pages)
+
+int swsusp_write(struct pbe *pblist, unsigned int nr_pages)
{
struct swap_map_page *swap_map;
struct swap_map_handle handle;
int error;
+ if ((error = swsusp_swap_check())) {
+ printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n");
+ return error;
+ }
if (!enough_swap(nr_pages)) {
printk(KERN_ERR "swsusp: Not enough free swap\n");
return -ENOSPC;
@@ -601,26 +565,6 @@ Free_image_entries:
goto Free_swap_map;
}
-/* It is important _NOT_ to umount filesystems at this point. We want
- * them synced (in case something goes wrong) but we DO not want to mark
- * filesystem clean: it is not. (And it does not matter, if we resume
- * correctly, we'll mark system clean, anyway.)
- */
-int swsusp_write(struct pbe *pblist, unsigned int nr_pages)
-{
- int error;
-
- if ((error = swsusp_swap_check())) {
- printk(KERN_ERR "swsusp: cannot find swap device, try swapon -a.\n");
- return error;
- }
- lock_swapdevices();
- error = write_suspend_image(pblist, nr_pages);
- /* This will unlock ignored swap devices since writing is finished */
- lock_swapdevices();
- return error;
-}
-
/**
* swsusp_shrink_memory - Try to free as much memory as needed
*
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH -mm 3/3] swsusp: save image header first
2005-12-27 16:47 [PATCH -mm 0/3] swsusp: swap handling improvements Rafael J. Wysocki
2005-12-27 16:52 ` [PATCH -mm 1/3] mm: add a new function (needed for swap suspend) Rafael J. Wysocki
2005-12-27 16:57 ` [PATCH -mm 2/3] swsusp: improve handling of swap partitions Rafael J. Wysocki
@ 2005-12-27 17:07 ` Rafael J. Wysocki
2005-12-27 17:27 ` [PATCH -mm 0/3] swsusp: swap handling improvements Pavel Machek
3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2005-12-27 17:07 UTC (permalink / raw)
To: Andrew Morton; +Cc: Pavel Machek, LKML
This patch makes the swsusp_info structure become the header of the image
in the literal sense (ie. it is saved to the swap and read before any other
image data with the help of the swsusp's swap map structure, so generally
it is treated in the same way as the rest of the image).
The main thing it does is to make swsusp_header contain the offset of the
swap map used to track the image data pages rather than the offset
of swsusp_info. Simultaneously, swsusp_info becomes the first image page
written to the swap.
The other changes are generally consequences of the above
with a few exceptions (there's some consolidation in the image reading
part as a few functions turn into trivial wrappers around something
else).
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@suse.cz>
kernel/power/power.h | 1
kernel/power/swsusp.c | 190 +++++++++++++++++---------------------------------
2 files changed, 65 insertions(+), 126 deletions(-)
Index: linux-2.6.15-rc5-mm3/kernel/power/swsusp.c
===================================================================
--- linux-2.6.15-rc5-mm3.orig/kernel/power/swsusp.c 2005-12-21 15:43:16.000000000 +0100
+++ linux-2.6.15-rc5-mm3/kernel/power/swsusp.c 2005-12-21 18:12:52.000000000 +0100
@@ -93,7 +93,7 @@
static struct swsusp_header {
char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
- swp_entry_t swsusp_info;
+ swp_entry_t image;
char orig_sig[10];
char sig[10];
} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
@@ -106,7 +106,7 @@
static unsigned short root_swap = 0xffff;
-static int mark_swapfiles(swp_entry_t prev)
+static int mark_swapfiles(swp_entry_t start)
{
int error;
@@ -117,7 +117,7 @@
!memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
- swsusp_header.swsusp_info = prev;
+ swsusp_header.image = start;
error = rw_swap_page_sync(WRITE,
swp_entry(root_swap, 0),
virt_to_page((unsigned long)
@@ -423,22 +423,7 @@
swsusp_info.cpus = num_online_cpus();
swsusp_info.image_pages = nr_pages;
swsusp_info.pages = nr_pages +
- ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT);
-}
-
-static int close_swap(void)
-{
- swp_entry_t entry;
- int error;
-
- dump_info();
- error = write_page((unsigned long)&swsusp_info, &entry);
- if (!error) {
- printk( "S" );
- error = mark_swapfiles(entry);
- printk( "|\n" );
- }
- return error;
+ ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
}
/**
@@ -522,6 +507,7 @@
{
struct swap_map_page *swap_map;
struct swap_map_handle handle;
+ swp_entry_t start;
int error;
if ((error = swsusp_swap_check())) {
@@ -539,18 +525,23 @@
return -ENOMEM;
init_swap_map_handle(&handle, swap_map);
- error = save_image_metadata(pblist, &handle);
+ error = swap_map_write_page(&handle, (unsigned long)&swsusp_info);
+ if (!error)
+ error = save_image_metadata(pblist, &handle);
if (!error)
error = save_image_data(pblist, &handle, nr_pages);
if (error)
goto Free_image_entries;
swap_map = reverse_swap_map(swap_map);
- error = save_swap_map(swap_map, &swsusp_info.start);
+ error = save_swap_map(swap_map, &start);
if (error)
goto Free_map_entries;
- error = close_swap();
+ dump_info();
+ printk( "S" );
+ error = mark_swapfiles(start);
+ printk( "|\n" );
if (error)
goto Free_map_entries;
@@ -840,70 +831,28 @@
return error;
}
-/*
- * Sanity check if this image makes sense with this kernel/swap context
- * I really don't think that it's foolproof but more than nothing..
- */
-
-static const char *sanity_check(void)
+static int check_header(void)
{
+ char *reason = NULL;
+
dump_info();
if (swsusp_info.version_code != LINUX_VERSION_CODE)
- return "kernel version";
+ reason = "kernel version";
if (swsusp_info.num_physpages != num_physpages)
- return "memory size";
+ reason = "memory size";
if (strcmp(swsusp_info.uts.sysname,system_utsname.sysname))
- return "system type";
+ reason = "system type";
if (strcmp(swsusp_info.uts.release,system_utsname.release))
- return "kernel release";
+ reason = "kernel release";
if (strcmp(swsusp_info.uts.version,system_utsname.version))
- return "version";
+ reason = "version";
if (strcmp(swsusp_info.uts.machine,system_utsname.machine))
- return "machine";
-#if 0
- /* We can't use number of online CPUs when we use hotplug to remove them ;-))) */
- if (swsusp_info.cpus != num_possible_cpus())
- return "number of cpus";
-#endif
- return NULL;
-}
-
-static int check_header(void)
-{
- const char *reason = NULL;
- int error;
-
- if ((error = bio_read_page(swp_offset(swsusp_header.swsusp_info), &swsusp_info)))
- return error;
-
- /* Is this same machine? */
- if ((reason = sanity_check())) {
- printk(KERN_ERR "swsusp: Resume mismatch: %s\n",reason);
+ reason = "machine";
+ if (reason) {
+ printk(KERN_ERR "swsusp: Resume mismatch: %s\n", reason);
return -EPERM;
}
- return error;
-}
-
-static int check_sig(void)
-{
- int error;
-
- memset(&swsusp_header, 0, sizeof(swsusp_header));
- if ((error = bio_read_page(0, &swsusp_header)))
- 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);
- } else {
- return -EINVAL;
- }
- if (!error)
- pr_debug("swsusp: Signature found, resuming\n");
- return error;
+ return 0;
}
/**
@@ -989,33 +938,29 @@
return error;
}
-static int check_suspend_image(void)
-{
- int error = 0;
-
- if ((error = check_sig()))
- return error;
-
- if ((error = check_header()))
- return error;
-
- return 0;
-}
-
-static int read_suspend_image(struct pbe **pblist_ptr)
+int swsusp_read(struct pbe **pblist_ptr)
{
- int error = 0;
+ int error;
struct pbe *p, *pblist;
struct swap_map_handle handle;
- unsigned int nr_pages = swsusp_info.image_pages;
+ unsigned int nr_pages;
+ if (IS_ERR(resume_bdev)) {
+ pr_debug("swsusp: block device not initialised\n");
+ return PTR_ERR(resume_bdev);
+ }
+
+ error = get_swap_map_reader(&handle, swsusp_header.image);
+ if (!error)
+ error = swap_map_read_page(&handle, &swsusp_info);
+ if (!error)
+ error = check_header();
+ if (error)
+ return error;
+ nr_pages = swsusp_info.image_pages;
p = alloc_pagedir(nr_pages, GFP_ATOMIC, 0);
if (!p)
return -ENOMEM;
- error = get_swap_map_reader(&handle, swsusp_info.start);
- if (error)
- /* The PBE list at p will be released by swsusp_free() */
- return error;
error = load_image_metadata(p, &handle);
if (!error) {
mark_unsafe_pages(p);
@@ -1037,11 +982,18 @@
*pblist_ptr = pblist;
}
release_swap_map_reader(&handle);
+
+ blkdev_put(resume_bdev);
+
+ if (!error)
+ pr_debug("swsusp: Reading resume file was successful\n");
+ else
+ pr_debug("swsusp: Error %d resuming\n", error);
return error;
}
/**
- * swsusp_check - Check for saved image in swap
+ * swsusp_check - Check for swsusp signature in the resume device
*/
int swsusp_check(void)
@@ -1051,39 +1003,27 @@
resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
if (!IS_ERR(resume_bdev)) {
set_blocksize(resume_bdev, PAGE_SIZE);
- error = check_suspend_image();
+ memset(&swsusp_header, 0, sizeof(swsusp_header));
+ if ((error = bio_read_page(0, &swsusp_header)))
+ 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);
+ } else {
+ return -EINVAL;
+ }
if (error)
- blkdev_put(resume_bdev);
- } else
+ blkdev_put(resume_bdev);
+ else
+ pr_debug("swsusp: Signature found, resuming\n");
+ } else {
error = PTR_ERR(resume_bdev);
-
- if (!error)
- pr_debug("swsusp: resume file found\n");
- else
- pr_debug("swsusp: Error %d check for resume file\n", error);
- return error;
-}
-
-/**
- * swsusp_read - Read saved image from swap.
- */
-
-int swsusp_read(struct pbe **pblist_ptr)
-{
- int error;
-
- if (IS_ERR(resume_bdev)) {
- pr_debug("swsusp: block device not initialised\n");
- return PTR_ERR(resume_bdev);
}
- error = read_suspend_image(pblist_ptr);
- blkdev_put(resume_bdev);
+ if (error)
+ pr_debug("swsusp: Error %d check for resume file\n", error);
- if (!error)
- pr_debug("swsusp: Reading resume file was successful\n");
- else
- pr_debug("swsusp: Error %d resuming\n", error);
return error;
}
Index: linux-2.6.15-rc5-mm3/kernel/power/power.h
===================================================================
--- linux-2.6.15-rc5-mm3.orig/kernel/power/power.h 2005-12-21 15:43:16.000000000 +0100
+++ linux-2.6.15-rc5-mm3/kernel/power/power.h 2005-12-21 17:08:09.000000000 +0100
@@ -16,7 +16,6 @@
int cpus;
unsigned long image_pages;
unsigned long pages;
- swp_entry_t start;
} __attribute__((aligned(PAGE_SIZE)));
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -mm 0/3] swsusp: swap handling improvements
2005-12-27 16:47 [PATCH -mm 0/3] swsusp: swap handling improvements Rafael J. Wysocki
` (2 preceding siblings ...)
2005-12-27 17:07 ` [PATCH -mm 3/3] swsusp: save image header first Rafael J. Wysocki
@ 2005-12-27 17:27 ` Pavel Machek
3 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2005-12-27 17:27 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Andrew Morton, LKML
On Út 27-12-05 17:47:42, Rafael J. Wysocki wrote:
> Hi,
>
> The following series of patches improves the handling of swap partitions
> by swsusp and changes the way it writes the image to swap. As a result,
> the swap-handling part of swsusp is simplified quite a bit.
>
> The patches in this series are also necessary for implementing the swsusp's
> userland interface (coming soon).
>
> The third patch has been acked by Pavel, but of course it depends on the
> previous two. Still, I posted them for comments some time ago and there
> have not been any, so I assume there are no objections. ;-)
Just for the record, all the patches look good to me.
Pavel
--
Thanks, Sharp!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -mm 1/3] mm: add a new function (needed for swap suspend)
2005-12-27 16:52 ` [PATCH -mm 1/3] mm: add a new function (needed for swap suspend) Rafael J. Wysocki
@ 2006-01-04 7:31 ` Andrew Morton
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2006-01-04 7:31 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: pavel, linux-kernel
"Rafael J. Wysocki" <rjw@sisk.pl> wrote:
>
> @@ -211,6 +211,26 @@
> return (swp_entry_t) {0};
> }
>
> +swp_entry_t get_swap_page_of_type(int type)
> +{
> + struct swap_info_struct *si;
> + pgoff_t offset;
> +
> + spin_lock(&swap_lock);
> + si = swap_info + type;
> + if (si->flags & SWP_WRITEOK) {
> + nr_swap_pages--;
> + offset = scan_swap_map(si);
> + if (offset) {
> + spin_unlock(&swap_lock);
> + return swp_entry(type, offset);
> + }
> + nr_swap_pages++;
> + }
> + spin_unlock(&swap_lock);
> + return (swp_entry_t) {0};
> +}
A little introductory comment would have been nice..
Would it be appropriate to put this under CONFIG_SOMETHING to save a little
space?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-01-04 7:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-27 16:47 [PATCH -mm 0/3] swsusp: swap handling improvements Rafael J. Wysocki
2005-12-27 16:52 ` [PATCH -mm 1/3] mm: add a new function (needed for swap suspend) Rafael J. Wysocki
2006-01-04 7:31 ` Andrew Morton
2005-12-27 16:57 ` [PATCH -mm 2/3] swsusp: improve handling of swap partitions Rafael J. Wysocki
2005-12-27 17:07 ` [PATCH -mm 3/3] swsusp: save image header first Rafael J. Wysocki
2005-12-27 17:27 ` [PATCH -mm 0/3] swsusp: swap handling improvements Pavel Machek
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®