Initialisation and cleanup routines for writing the image header.
Signed-off-by: Nigel Cunningham <[email protected]>
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]