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][ 17/32] [Suspend2] Get an io_info struct.
Date
Allocate the struct used to store the details of an i/o in flight.

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

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

diff --git a/kernel/power/suspend_block_io.c b/kernel/power/suspend_block_io.c
index 728df04..48a2d09 100644
--- a/kernel/power/suspend_block_io.c
+++ b/kernel/power/suspend_block_io.c
@@ -573,3 +573,62 @@ static void add_to_batch(struct io_info
submit_batched();
}

+/*
+ * get_io_info_struct
+ *
+ * Description: Get an I/O struct.
+ * Returns: Pointer to the struct prepared for use.
+ */
+static struct io_info *get_io_info_struct(void)
+{
+ unsigned long newpage = 0, flags;
+ struct io_info *this = NULL;
+ int remaining = 0;
+
+ do {
+ while (atomic_read(&outstanding_io) >= MAX_OUTSTANDING_IO)
+ do_bio_wait(0);
+
+ /* Can start a new I/O. Is there a free one? */
+ if (!list_empty(&ioinfo_free)) {
+ /* Yes. Grab it. */
+ spin_lock_irqsave(&ioinfo_free_lock, flags);
+ break;
+ }
+
+ /* No. Need to allocate a new page for I/O info structs. */
+ newpage = get_zeroed_page(GFP_ATOMIC);
+ if (!newpage) {
+ do_bio_wait(1);
+ continue;
+ }
+
+ suspend_message(SUSPEND_MEMORY, SUSPEND_VERBOSE, 0,
+ "[NewIOPage %lx]", newpage);
+ infopages++;
+ if (infopages > maxinfopages)
+ maxinfopages++;
+
+ /* Prepare the new page for use. */
+ this = (struct io_info *) newpage;
+ remaining = PAGE_SIZE;
+ spin_lock_irqsave(&ioinfo_free_lock, flags);
+ while (remaining >= (sizeof(struct io_info))) {
+ list_add_tail(&this->list, &ioinfo_free);
+ this = (struct io_info *) (((char *) this) +
+ sizeof(struct io_info));
+ remaining -= sizeof(struct io_info);
+ }
+ break;
+ } while (1);
+
+ /*
+ * We have an I/O info struct. Remove it from the free list.
+ * It will be added to the submit or busy list later.
+ */
+ this = list_entry(ioinfo_free.next, struct io_info, list);
+ list_del_init(&this->list);
+ spin_unlock_irqrestore(&ioinfo_free_lock, flags);
+ return this;
+}
+
--
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:18    [W:0.217 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site