[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1285566238-10966-10-git-send-email-nigel@tuxonice.net>
Date: Mon, 27 Sep 2010 15:43:44 +1000
From: Nigel Cunningham <nigel@...onice.net>
To: "Rafael J. Wysocki" <rjw@...k.pl>,
Linux PM <linux-pm@...ts.linux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
TuxOnIce-devel <tuxonice-devel@...onice.net>
Subject: [PATCH 09/23] Hibernation: Iterate over sectors not swap entries.
Record sectors in extents when allocating storage, and use the
sector numbers instead of swap offsets as we write the image. If
we then store these sector extents at the start of the image (as
following patches will do), we can drop the index pages that are
interspersed with the image, do fully asynchronous I/O (which
should give a speed boost) and perhaps also remove some of the
duplication in the paths for reading and writing pages.
Signed-off-by: Nigel Cunningham <nigel@...onice.net>
---
kernel/power/swap.c | 25 ++++++++++---------------
1 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index f16e973..819d21a 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -58,14 +58,7 @@ struct swsusp_header {
static struct swsusp_header *swsusp_header;
static struct hib_extent_state swap_extents;
-
-static sector_t next_swapdev_block(void)
-{
- unsigned long res = hib_extent_next(&swap_extents);
- if (res)
- res = swapdev_block(root_swap, res);
- return res;
-}
+static struct hib_extent_state sector_extents;
/**
* alloc_swapdev_block - allocate a swap page and register that it has
@@ -74,14 +67,16 @@ static sector_t next_swapdev_block(void)
sector_t alloc_swapdev_block(int swap)
{
- unsigned long offset;
+ unsigned long offset, sector;
offset = swp_offset(get_swap_page_of_type(swap));
if (offset) {
- if (hib_extents_insert(&swap_extents, offset))
+ sector = swapdev_block(swap, offset);
+ if (hib_extents_insert(&swap_extents, offset) ||
+ hib_extents_insert(§or_extents, sector))
swap_free(swp_entry(swap, offset));
else
- return swapdev_block(swap, offset);
+ return sector;
}
return 0;
}
@@ -123,7 +118,7 @@ static int allocate_swap(unsigned int nr_pages, unsigned int flags)
return 0;
}
- hib_reset_extent_pos(&swap_extents);
+ hib_reset_extent_pos(§or_extents);
return 1;
}
@@ -266,7 +261,7 @@ static int get_swap_writer(struct swap_map_handle *handle, unsigned long pages,
ret = -ENOSPC;
goto err_close;
}
- handle->cur_swap = next_swapdev_block();
+ handle->cur_swap = hib_extent_next(§or_extents);
if (!handle->cur_swap) {
ret = -ENOSPC;
goto err_rel;
@@ -289,7 +284,7 @@ int swap_write_page(struct swap_map_handle *handle, void *buf,
if (!handle->cur)
return -EINVAL;
- offset = next_swapdev_block();
+ offset = hib_extent_next(§or_extents);
error = write_page(buf, offset, bio_chain);
if (error)
return error;
@@ -298,7 +293,7 @@ int swap_write_page(struct swap_map_handle *handle, void *buf,
error = hib_wait_on_bio_chain(bio_chain);
if (error)
goto out;
- offset = next_swapdev_block();
+ offset = hib_extent_next(§or_extents);
if (!offset)
return -ENOSPC;
handle->cur->next_swap = offset;
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists