lkml.org 
[lkml]   [2006]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Suspend2][ 26/32] [Suspend2] Read a page of the image.
Date
Read a page of the image, using readahead if synchronous i/o is requested.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/suspend_block_io.c | 63 +++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/kernel/power/suspend_block_io.c b/kernel/power/suspend_block_io.c
index c746f9f..c095eac 100644
--- a/kernel/power/suspend_block_io.c
+++ b/kernel/power/suspend_block_io.c
@@ -856,3 +856,66 @@ static int suspend_rw_page(int rw, struc
return 0;
}

+static int suspend_bio_read_chunk(struct page *buffer_page, int sync)
+{
+ static int last_result;
+ unsigned long *virt;
+
+ if (sync == SUSPEND_ASYNC)
+ return suspend_rw_page(READ, buffer_page, -1, sync, 0);
+
+ /* Start new readahead while we wait for our page */
+ if (readahead_index == -1) {
+ last_result = 0;
+ readahead_index = readahead_submit_index = 0;
+ }
+
+ /* Start a new readahead? */
+ if (last_result) {
+ /* We failed to submit a read, and have cleaned up
+ * all the readahead previously submitted */
+ if (readahead_submit_index == readahead_index)
+ return -EPERM;
+ goto wait;
+ }
+
+ do {
+ if (suspend_prepare_readahead(readahead_submit_index))
+ break;
+
+ last_result = suspend_rw_page(
+ READ,
+ suspend_readahead_pages[readahead_submit_index],
+ readahead_submit_index, SUSPEND_ASYNC, 0);
+ if (last_result) {
+ printk("Begin read chunk for page %d returned %d.\n",
+ readahead_submit_index, last_result);
+ suspend_cleanup_readahead(readahead_submit_index);
+ break;
+ }
+
+ readahead_submit_index++;
+
+ if (readahead_submit_index == MAX_OUTSTANDING_IO)
+ readahead_submit_index = 0;
+
+ } while((!last_result) && (readahead_submit_index != readahead_index) &&
+ (!suspend_readahead_ready(readahead_index)));
+
+wait:
+ suspend_wait_on_readahead(readahead_index);
+
+ virt = kmap_atomic(buffer_page, KM_USER1);
+ memcpy(virt, page_address(suspend_readahead_pages[readahead_index]),
+ PAGE_SIZE);
+ kunmap_atomic(virt, KM_USER1);
+
+ suspend_cleanup_readahead(readahead_index);
+
+ readahead_index++;
+ if (readahead_index == MAX_OUTSTANDING_IO)
+ readahead_index = 0;
+
+ return 0;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-06-27 01:13    [W:0.098 / U:7.276 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site