[PATCH 17/21] Hibernation: Remove swap_map_pages

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nigel Cunningham
Date: Wednesday, June 2, 2010 - 5:19 am

Stop storing swap_map pages in the image. This removes the need
for a wait_on_bio_chain every MAP_PAGE_ENTRIES pages and thus
allows the whole image to be written using async I/O.

Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
---
 kernel/power/block_io.c |   61 +++-------------------------------------------
 1 files changed, 4 insertions(+), 57 deletions(-)

diff --git a/kernel/power/block_io.c b/kernel/power/block_io.c
index c9569e5..66cdc5a 100644
--- a/kernel/power/block_io.c
+++ b/kernel/power/block_io.c
@@ -156,7 +156,6 @@ struct swap_map_page {
 
 struct swap_map_handle {
 	struct swap_map_page *cur;
-	sector_t cur_swap;
 	unsigned int k;
 };
 
@@ -168,8 +167,7 @@ extern struct hib_extent_state sector_extents;
 /* Calculate the overhead needed for storing n pages */
 unsigned int hib_bio_overhead(unsigned int nr_pages)
 {
-	return DIV_ROUND_UP(nr_pages, MAP_PAGE_ENTRIES) +
-	       DIV_ROUND_UP(hib_extents_storage_needed(&sector_extents),
+	return DIV_ROUND_UP(hib_extents_storage_needed(&sector_extents),
 			PAGE_SIZE);
 }
 
@@ -235,12 +233,8 @@ int hib_bio_prepare_write(void)
 	result = hib_extents_store(&sector_extents);
 	result2 = hib_flush_write_buffer();
 
-	handle.cur_swap = hib_extent_next(&sector_extents);
 	handle.k = 0;
 
-	if (!handle.cur_swap)
-		result = -ENOSPC;
-
 	if (result || result2)
 		release_swap_writer();
 
@@ -249,41 +243,17 @@ int hib_bio_prepare_write(void)
 
 int swap_write_page(void *buf, int sync)
 {
-	int error = 0;
 	sector_t offset;
 
 	if (!handle.cur)
 		return -EINVAL;
 	offset = hib_extent_next(&sector_extents);
-	error = write_page(buf, offset, sync);
-	if (error)
-		return error;
-	handle.cur->entries[handle.k++] = offset;
-	if (handle.k >= MAP_PAGE_ENTRIES) {
-		error = hib_wait_on_bio_chain();
-		if (error)
-			goto out;
-		offset = hib_extent_next(&sector_extents);
-		if (!offset)
-			return -ENOSPC;
-		handle.cur->next_swap = offset;
-		error = write_page(handle.cur, handle.cur_swap, 1);
-		if (error)
-			goto out;
-		memset(handle.cur, 0, PAGE_SIZE);
-		handle.cur_swap = offset;
-		handle.k = 0;
-	}
- out:
-	return error;
+	return write_page(buf, offset, sync);
 }
 
 int flush_swap_writer(void)
 {
-	if (handle.cur && handle.cur_swap)
-		return write_page(handle.cur, handle.cur_swap, 1);
-	else
-		return -EINVAL;
+	return hib_wait_on_bio_chain();
 }
 
 /**
@@ -301,7 +271,6 @@ void release_swap_reader(void)
 int get_swap_reader(unsigned int *flags_p, sector_t first_page)
 {
 	int error;
-	sector_t offset;
 
 	handle.cur = (struct swap_map_page *)get_zeroed_page(__GFP_WAIT | __GFP_HIGH);
 	if (!handle.cur)
@@ -330,41 +299,19 @@ int get_swap_reader(unsigned int *flags_p, sector_t first_page)
 		return error;
 	}
 
-	offset = hib_extent_next(&sector_extents);
-
-	/* Now read the first swap_map_page */
-	error = hib_bio_read_page(offset, handle.cur, 1);
-	if (error) {
-		release_swap_reader();
-		return error;
-	}
-
 	return error;
 }
 
 int swap_read_page(void *buf, int sync)
 {
 	sector_t offset;
-	int error;
 
 	if (!handle.cur)
 		return -EINVAL;
 	offset = hib_extent_next(&sector_extents);
 	if (!offset)
 		return -EFAULT;
-	error = hib_bio_read_page(offset, buf, sync);
-	if (error)
-		return error;
-	if (++handle.k >= MAP_PAGE_ENTRIES) {
-		error = hib_wait_on_bio_chain();
-		handle.k = 0;
-		offset = hib_extent_next(&sector_extents);
-		if (!offset)
-			release_swap_reader();
-		else if (!error)
-			error = hib_bio_read_page(offset, handle.cur, 1);
-	}
-	return error;
+	return hib_bio_read_page(offset, buf, sync);
 }
 
 /* Part Page I/O functions */
-- 
1.7.0.4

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Nigel's current for-rafael queue, Nigel Cunningham, (Wed Jun 2, 5:18 am)
[PATCH 01/21] Hibernation: Swap iteration functions., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 02/21] Hibernation: Move root_swap declaration., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 03/21] Hibernation: Add mass swap allocation routine, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 04/21] Hibernation: Switch to preallocating swap., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 05/21] Hiberation: Fix speed display., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 06/21] Hibernation: Generic extents support., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 09/21] Hibernation: Stop passing bio_chain around, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 10/21] Hibernation: Move block i/o fns to block_io.c, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 11/21] Hibernation: Partial page I/O support., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 12/21] Hibernation: Extent save/load routines., Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 15/21] Remove first_sector from swap_map_handle, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 16/21] Hibernation: Replace bio chain, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 17/21] Hibernation: Remove swap_map_pages, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 18/21] Hibernation: Remove wait_on_bio_chain result, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 19/21] Hibernation: Prepare for handle.cur removal, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 20/21] Hibernation: Remove swap_map structure, Nigel Cunningham, (Wed Jun 2, 5:19 am)
[PATCH 21/21] Hibernation: Remove now-empty routines., Nigel Cunningham, (Wed Jun 2, 5:19 am)
Re: Nigel's current for-rafael queue, Pavel Machek, (Mon Aug 2, 11:55 pm)
Re: Nigel's current for-rafael queue, Nigel Cunningham, (Tue Aug 3, 12:00 am)