From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 05/32] [Suspend2] Cleanup one page.
Date: Tue, 27 Jun 2006 08:37:24 +1000 [thread overview]
Message-ID: <20060626223722.4376.34259.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223706.4376.96042.stgit@nigel.suspend2.net>
Clean up upon completion of the I/O for a page.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/suspend_block_io.c | 96 +++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/kernel/power/suspend_block_io.c b/kernel/power/suspend_block_io.c
index 09682c4..037535b 100644
--- a/kernel/power/suspend_block_io.c
+++ b/kernel/power/suspend_block_io.c
@@ -179,3 +179,99 @@ static void suspend_check_io_stats(void)
nr_schedule_calls[i]);
}
+/*
+ * __suspend_bio_cleanup_one
+ *
+ * Description: Clean up after completing I/O on a page.
+ * Arguments: struct io_info: Data for I/O to be completed.
+ */
+static void __suspend_bio_cleanup_one(struct io_info *io_info)
+{
+ struct page *buffer_page;
+ struct page *data_page;
+ char *buffer_address, *data_address;
+ int reading;
+
+ buffer_page = io_info->buffer_page;
+ data_page = io_info->data_page;
+
+ reading = test_bit(IO_AWAITING_READ, &io_info->flags);
+ suspend_message(SUSPEND_WRITER, SUSPEND_HIGH, 0,
+ "Cleanup IO: [%p]\n",
+ io_info);
+
+ if (reading && io_info->readahead_index == -1) {
+ /*
+ * Copy the page we read into the buffer our caller provided.
+ */
+ data_address = (char *) kmap(data_page);
+ buffer_address = (char *) kmap(buffer_page);
+ memcpy(data_address, buffer_address, PAGE_SIZE);
+ kunmap(data_page);
+ kunmap(buffer_page);
+
+ }
+
+ if (!reading || io_info->readahead_index == -1) {
+ /* Sanity check */
+ if (page_count(buffer_page) != 2)
+ printk(KERN_EMERG "Cleanup IO: Page count on page %p"
+ " is %d. Not good!\n",
+ buffer_page, page_count(buffer_page));
+ put_page(buffer_page);
+ __free_page(buffer_page);
+ atomic_inc(&buffer_frees);
+ } else
+ put_page(buffer_page);
+
+ bio_put(io_info->sys_struct);
+ io_info->sys_struct = NULL;
+ io_info->flags = 0;
+}
+
+/* suspend_bio_cleanup_one
+ */
+
+static int suspend_bio_cleanup_one(void *data)
+{
+ struct io_info *io_info = (struct io_info *) data;
+ int readahead_index;
+ unsigned long flags;
+
+ /*
+ * If this I/O was a readahead, remember its index.
+ */
+ readahead_index = io_info->readahead_index;
+
+ /*
+ * Add it to the free list.
+ */
+ list_del_init(&io_info->list);
+
+ /*
+ * Do the cleanup.
+ */
+ __suspend_bio_cleanup_one(io_info);
+
+ /*
+ * Record the readahead as done.
+ */
+ if (readahead_index > -1) {
+ int index = readahead_index/BITS_PER_LONG;
+ int bit = readahead_index - (index * BITS_PER_LONG);
+ spin_lock_irqsave(&suspend_readahead_flags_lock, flags);
+ set_bit(bit, &suspend_readahead_flags[index]);
+ spin_unlock_irqrestore(&suspend_readahead_flags_lock, flags);
+ }
+
+ spin_lock_irqsave(&ioinfo_free_lock, flags);
+ list_add_tail(&io_info->list, &ioinfo_free);
+ spin_unlock_irqrestore(&ioinfo_free_lock, flags);
+
+ /* Important: Must be last thing we do to avoid a race with
+ * finish_all_io when using keventd to do the cleanup */
+ atomic_dec(&outstanding_io);
+
+ return 0;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 22:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 22:37 [Suspend2][ 00/32] Block i/o patches Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 01/32] [Suspend2] Block I/O Header File Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 02/32] [Suspend2] Block io c file header Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 03/32] [Suspend2] Reset block io stats Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 04/32] [Suspend2] Check the " Nigel Cunningham
2006-06-26 22:37 ` Nigel Cunningham [this message]
2006-06-26 22:37 ` [Suspend2][ 06/32] [Suspend2] Cleanup some completed I/O Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 07/32] [Suspend2] Wait for bio completion Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 08/32] [Suspend2] Finish and cleanup all outstanding I/O Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 09/32] [Suspend2] Wait on a particular page Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 10/32] [Suspend2] Wait on readahead Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 11/32] [Suspend2] Test whether readahead is ready Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 12/32] [Suspend2] Prepare & cleanup readahead pages Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 13/32] [Suspend2] Suspend bio completion Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 14/32] [Suspend2] Submit io on a page Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 15/32] [Suspend2] Submit batched i/o Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 16/32] [Suspend2] Add page io to a batch Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 17/32] [Suspend2] Get an io_info struct Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 18/32] [Suspend2] Prepare to do i/o on a page Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 19/32] [Suspend2] Do " Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 20/32] [Suspend2] Return memory needed for block io Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 21/32] [Suspend2] Set device info Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 22/32] [Suspend2] Move forward extra blocks in a page Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 23/32] [Suspend2] Advance one page in the extent state Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 24/32] [Suspend2] Set extra page forward flag Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 25/32] [Suspend2] Do io on a page in the image proper Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 26/32] [Suspend2] Read a page of the image Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 27/32] [Suspend2] Init and cleanup routines for pageset i/o Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 28/32] [Suspend2] Write a page in the image proper Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 29/32] [Suspend2] Read or write a chunk of the header Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 30/32] [Suspend2] Finish writing an image header Nigel Cunningham
2006-06-26 22:38 ` [Suspend2][ 31/32] [Suspend2] Suspend block io ops Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 32/32] [Suspend2] Module ops for the block i/o functions 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=20060626223722.4376.34259.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