From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 08/19] [Suspend2] I/O main loop.
Date: Tue, 27 Jun 2006 08:36:25 +1000 [thread overview]
Message-ID: <20060626223624.4219.85909.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223557.4219.53030.stgit@nigel.suspend2.net>
Main I/O loop in the core of Suspend2. Submits pages for I/O to the first
plugin in the pipeline and sends status updates to any userui component.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/io.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/kernel/power/io.c b/kernel/power/io.c
index be13f42..f237231 100644
--- a/kernel/power/io.c
+++ b/kernel/power/io.c
@@ -241,3 +241,68 @@ static int rw_cleanup_modules(int rw)
return result;
}
+/*
+ * do_rw_loop
+ *
+ * The main I/O loop for reading or writing pages.
+ */
+static int do_rw_loop(int write, int finish_at, dyn_pageflags_t *pageflags,
+ int base, int barmax)
+{
+ int current_page_index = -1, pc, step = 1, nextupdate = 0, i;
+ int result;
+ struct suspend_module_ops *first_filter = suspend_get_next_filter(NULL);
+
+ current_page_index = get_next_bit_on(*pageflags, -1);
+
+ pc = finish_at / 5;
+
+ /* Read the pages */
+ for (i=0; i< finish_at; i++) {
+ struct page *page = pfn_to_page(current_page_index);
+
+ /* Status */
+ if ((i+base) >= nextupdate)
+ nextupdate = suspend_update_status(i+base, barmax,
+ " %d/%d MB ", MB(base+i+1), MB(barmax));
+
+ if ((i + 1) == pc) {
+ printk("%d%%...", 20 * step);
+ step++;
+ pc = finish_at * step / 5;
+ }
+
+ if (write)
+ result = first_filter->write_chunk(page);
+ else
+ result = first_filter->read_chunk(page, SUSPEND_ASYNC);
+
+ if (result) {
+ if (write) {
+ printk("Write chunk returned %d.\n", result);
+ abort_suspend("Failed to write a chunk of the "
+ "image.");
+ return result;
+ } else
+ panic("Failed to read chunk %d/%d of the image. (%d)",
+ i, finish_at, result);
+ }
+
+ /* Interactivity*/
+ suspend_cond_pause(0, NULL);
+
+ if (test_result_state(SUSPEND_ABORTED) && write)
+ return 1;
+
+ /* Prepare next */
+ current_page_index = get_next_bit_on(*pageflags,
+ current_page_index);
+ }
+
+ printk("done.\n");
+
+ suspend_update_status(base + finish_at, barmax, " %d/%d MB ",
+ MB(base + finish_at), MB(barmax));
+ return 0;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 23:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 22:35 [Suspend2][ 00/19] Highlevel I/O routines Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 01/19] [Suspend2] Core io.c header Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 02/19] [Suspend2] Attempt to parse resume device Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 03/19] [Suspend2] Attempt to parse resume device (wrapped) Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 04/19] [Suspend2] Reset modules after invalidating an image Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 05/19] [Suspend2] Fill the suspend header fields Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 06/19] [Suspend2] Initialise modules before doing I/O Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 07/19] [Suspend2] Cleanup modules after doing I/O on a portion of the image Nigel Cunningham
2006-06-26 22:36 ` Nigel Cunningham [this message]
2006-06-26 22:36 ` [Suspend2][ 09/19] [Suspend2] Write a pageset Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 10/19] [Suspend2] Read a portion of the image from storage Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 11/19] [Suspend2] Write module configurations in an image header Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 12/19] [Suspend2] Read module configs from " Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 13/19] [Suspend2] Write " Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 14/19] [Suspend2] Sanity check " Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 15/19] [Suspend2] Core of code for reading pageset1 Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 16/19] [Suspend2] Read pageset1 Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 17/19] [Suspend2] Get image_exists data Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 18/19] [Suspend2] Read pageset2 Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 19/19] [Suspend2] I/O header file Nigel Cunningham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060626223624.4219.85909.stgit@nigel.suspend2.net \
--to=nigel@suspend2.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome