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][ 16/35] [Suspend2] Filewriter header writing init/cleanup.
Date
Initialisation and cleanup routines for writing the image header.

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

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

diff --git a/kernel/power/suspend_file.c b/kernel/power/suspend_file.c
index cdc0261..46527f1 100644
--- a/kernel/power/suspend_file.c
+++ b/kernel/power/suspend_file.c
@@ -480,3 +480,67 @@ static int filewriter_allocate_storage(i
return result;
}

+static int filewriter_write_header_init(void)
+{
+ suspend_extent_state_goto_start(&suspend_writer_posn);
+
+ suspend_writer_buffer = (char *) get_zeroed_page(GFP_ATOMIC);
+ suspend_writer_buffer_posn = suspend_header_bytes_used = 0;
+
+ /* Info needed to bootstrap goes at the start of the header.
+ * First we save the basic info needed for reading, including the number
+ * of header pages. Then we save the structs containing data needed
+ * for reading the header pages back.
+ * Note that even if header pages take more than one page, when we
+ * read back the info, we will have restored the location of the
+ * next header page by the time we go to use it.
+ */
+
+ suspend_bio_ops.rw_header_chunk(WRITE, &filewriterops,
+ (char *) &suspend_writer_posn_save,
+ sizeof(suspend_writer_posn_save));
+
+ suspend_bio_ops.rw_header_chunk(WRITE, &filewriterops,
+ (char *) &devinfo, sizeof(devinfo));
+
+ suspend_serialise_extent_chain(&filewriterops, &block_chain);
+
+ return 0;
+}
+
+static int filewriter_write_header_cleanup(void)
+{
+ struct filewriter_header *header;
+
+ /* Write any unsaved data */
+ if (suspend_writer_buffer_posn)
+ suspend_bio_ops.write_header_chunk_finish();
+
+ suspend_bio_ops.finish_all_io();
+
+ suspend_extent_state_goto_start(&suspend_writer_posn);
+ suspend_bio_ops.forward_one_page();
+
+ /* Adjust image header */
+ suspend_bio_ops.bdev_page_io(READ, filewriter_target_bdev,
+ target_firstblock,
+ virt_to_page(suspend_writer_buffer));
+
+ header = (struct filewriter_header *) suspend_writer_buffer;
+
+ prepare_signature(header,
+ suspend_writer_posn.current_offset <<
+ devinfo.bmap_shift);
+
+ suspend_bio_ops.bdev_page_io(WRITE, filewriter_target_bdev,
+ target_firstblock,
+ virt_to_page(suspend_writer_buffer));
+
+ free_page((unsigned long) suspend_writer_buffer);
+ suspend_writer_buffer = NULL;
+
+ suspend_bio_ops.finish_all_io();
+
+ 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:03    [W:0.151 / U:0.204 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site