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][ 06/35] [Suspend2] Filewriter populate block list.
Date
Populate the extent chain that contains the list of sectors we'll use for
writing the image.

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

kernel/power/suspend_file.c | 67 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/kernel/power/suspend_file.c b/kernel/power/suspend_file.c
index 9046b80..97f97be 100644
--- a/kernel/power/suspend_file.c
+++ b/kernel/power/suspend_file.c
@@ -168,3 +168,70 @@ static int size_ignoring_ignored_pages(v
return filewriter_storage_available();
}

+static void __populate_block_list(int min, int max)
+{
+ if (test_action_state(SUSPEND_TEST_BIO))
+ printk("Adding extent %d-%d.\n", min << devinfo.bmap_shift,
+ ((max + 1) << devinfo.bmap_shift) - 1);
+
+ suspend_add_to_extent_chain(&block_chain, min, max);
+}
+
+static void populate_block_list(void)
+{
+ int i;
+
+ if (block_chain.first)
+ suspend_put_extent_chain(&block_chain);
+
+ if (target_is_normal_file()) {
+ int extent_min = -1, extent_max = -1, got_header = 0;
+
+ for (i = 0;
+ i < (target_inode->i_size >> PAGE_SHIFT);
+ i++) {
+ sector_t new_sector;
+
+ if (!has_contiguous_blocks(i))
+ continue;
+
+ new_sector = bmap(target_inode,
+ (i * devinfo.blocks_per_page));
+
+ /*
+ * Ignore the first block in the file.
+ * It gets the header.
+ */
+ if (new_sector == target_firstblock >> devinfo.bmap_shift) {
+ got_header = 1;
+ continue;
+ }
+
+ /*
+ * I'd love to be able to fill in holes and resize
+ * files, but not yet...
+ */
+
+ if (new_sector == extent_max + 1)
+ extent_max+= devinfo.blocks_per_page;
+ else {
+ if (extent_min > -1)
+ __populate_block_list(extent_min,
+ extent_max);
+
+ extent_min = new_sector;
+ extent_max = extent_min +
+ devinfo.blocks_per_page - 1;
+ }
+ }
+ if (extent_min > -1)
+ __populate_block_list(extent_min, extent_max);
+
+ BUG_ON(!got_header);
+ } else
+ if (target_storage_available > 0)
+ __populate_block_list(devinfo.blocks_per_page,
+ (min(main_pages, target_storage_available) + 1) *
+ devinfo.blocks_per_page - 1);
+}
+
--
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:08    [from the cache]
©2003-2011 Jasper Spaans