On 7/6/05, Nigel Cunningham <[email protected]> wrote:
> diff -ruNp 611-io.patch-old/kernel/power/suspend2_core/io.c 611-io.patch-new/kernel/power/suspend2_core/io.c
> --- 611-io.patch-old/kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000
> +++ 611-io.patch-new/kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000
> @@ -0,0 +1,1006 @@
> +/*
> + * kernel/power/io.c
> + *
> + * Copyright (C) 1998-2001 Gabor Kuti <[email protected]>
> + * Copyright (C) 1998,2001,2002 Pavel Machek <[email protected]>
^
Whitespace damage (appears elsewhere too).
> + * Copyright (C) 2002-2003 Florent Chabaud <[email protected]>
> + * Copyright (C) 2002-2005 Nigel Cunningham <[email protected]>
> + *
[snip]
> + pc = size / 5;
> +
> + /* Write the data */
> + for (i=0; i<size; i++) {
> + int was_mapped = 0;
> + struct page * page = pfn_to_page(current_page_index);
> +
> + /* Status update */
> + if ((i+base) >= nextupdate)
> + nextupdate = suspend2_update_status(i + base, barmax,
> + " %d/%d MB ", MB(base+i+1), MB(barmax));
> +
> + if ((i + 1) == pc) {
> + printk("%d%%...", 20 * step);
> + step++;
> + pc = size * step / 5;
> + }
> +
> + /* Write */
> + was_mapped = suspend_map_kernel_page(page, 1);
> + ret = first_filter->ops.filter.write_chunk(page);
> + if (!was_mapped)
> + suspend_map_kernel_page(page, 0);
> +
> + if (ret) {
> + printk("Write chunk returned %d.\n", ret);
> + abort_suspend("Failed to write a chunk of the "
> + "image.");
> + error = -1;
> + goto write_pageset_free_buffers;
> + }
> +
> + /* Interactivity */
> + check_shift_keys(0, NULL);
> +
> + if (TEST_RESULT_STATE(SUSPEND_ABORTED)) {
Why is the above in upper case but test_action_state is in lower case?
> + abort_suspend("Aborting as requested.");
> + error = -1;
> + goto write_pageset_free_buffers;
> + }
> +
> + /* Prepare next */
> + current_page_index = __get_next_bit_on(*pageflags, current_page_index);
> + }
> +
> + printk("done.\n");
> +
> + suspend2_update_status(base+size, barmax, " %d/%d MB ",
> + MB(base+size), MB(barmax));
> +
> +write_pageset_free_buffers:
> +
> + /* Cleanup other plugins */
> + list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) {
> + if (this_plugin->disabled)
> + continue;
> + if ((this_plugin->type == FILTER_PLUGIN) ||
> + (this_plugin->type == WRITER_PLUGIN))
> + continue;
> + if (this_plugin->write_cleanup)
> + this_plugin->write_cleanup();
> + }
> +
> + /* Flush data and cleanup */
> + list_for_each_entry(this_plugin, &suspend_filters, ops.filter.filter_list) {
> + if (this_plugin->disabled)
> + continue;
> + if (this_plugin->write_cleanup)
> + this_plugin->write_cleanup();
> + }
> + active_writer->write_cleanup();
> +
> + /* Statistics */
> + end_time = jiffies;
> +
> + if ((end_time - start_time) && (!TEST_RESULT_STATE(SUSPEND_ABORTED))) {
> + suspend_io_time[0][0] += size,
> + suspend_io_time[0][1] += (end_time - start_time);
> + }
> +
> + return error;
> +}
> +
> +/* read_pageset()
> + *
> + * Description: Read a pageset from disk.
> + * Arguments: pagedir: Pointer to the pagedir to be saved.
> + * whichtowrite: Controls what debugging output is printed.
> + * overwrittenpagesonly: Whether to read the whole pageset or
> + * only part.
> + * Returns: Zero on success or -1 on failure.
> + */
> +
> +static int read_pageset(struct pagedir * pagedir, int whichtoread,
> + int overwrittenpagesonly)
> +{
> + int nextupdate = 0, result = 0, base = 0;
> + int start_time, end_time, finish_at = pagedir->pageset_size;
> + int barmax = pagedir1.pageset_size + pagedir2.pageset_size;
> + int i, pc, step = 1;
> + struct suspend_plugin_ops * this_plugin, * first_filter = get_next_filter(NULL);
> + dyn_pageflags_t *pageflags;
> + int current_page_index;
> +
> + if (whichtoread == 1) {
> + suspend2_prepare_status(1, 1, "Reading kernel & process data...");
> + pageflags = &pageset1_copy_map;
> + } else {
> + suspend2_prepare_status(1, 0, "Reading caches...");
> + if (overwrittenpagesonly)
> + barmax = finish_at = min(pageset1_size, pageset2_size);
> + else {
> + base = pagedir1.pageset_size;
> + }
> + pageflags = &pageset2_map;
> + }
> +
> + start_time=jiffies;
> +
> + /* Initialise page transformers */
> + list_for_each_entry(this_plugin, &suspend_filters, ops.filter.filter_list) {
> + if (this_plugin->disabled)
> + continue;
> + if (this_plugin->read_init &&
> + this_plugin->read_init(whichtoread)) {
> + abort_suspend("Failed to initialise a filter.");
> + result = 1;
> + goto read_pageset_free_buffers;
> + }
> + }
> +
> + /* Initialise writer */
> + if (active_writer->read_init(whichtoread)) {
> + abort_suspend("Failed to initialise the writer.");
> + result = 1;
> + goto read_pageset_free_buffers;
> + }
> +
> + /* Initialise other plugins */
> + list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) {
> + if (this_plugin->disabled)
> + continue;
> + if ((this_plugin->type == FILTER_PLUGIN) ||
> + (this_plugin->type == WRITER_PLUGIN))
> + continue;
> + if (this_plugin->read_init)
> + if (this_plugin->read_init(whichtoread)) {
> + SET_RESULT_STATE(SUSPEND_ABORTED);
> + goto read_pageset_free_buffers;
> + }
> + }
> +
> + current_page_index = __get_next_bit_on(*pageflags, -1);
> +
> + pc = finish_at / 5;
What's the magic number 5 that pops up everywhere?
-
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]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|