Re: [PATCH 5/9] PM / Hibernate: add chunk i/o support
From: Rafael J. Wysocki
Date: Fri Jun 25 2010 - 09:46:34 EST
On Wednesday, June 02, 2010, Jiri Slaby wrote:
> Chunk support is useful when not writing whole pages at once. It takes
> care of joining the buffers into the pages and writing at once when
> needed.
>
> This adds functions for both reads and writes.
>
> In the end when pages are compressed they use this interface as well
> (because they are indeed shorter than PAGE_SIZE).
This one looks good up to a couple of minor things below.
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Cc: "Rafael J. Wysocki" <rjw@xxxxxxx>
> ---
> kernel/power/block_io.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++
> kernel/power/power.h | 16 ++++++
> 2 files changed, 142 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/power/block_io.c b/kernel/power/block_io.c
> index 97024fd..5b6413d 100644
> --- a/kernel/power/block_io.c
> +++ b/kernel/power/block_io.c
> @@ -3,6 +3,7 @@
> *
> * Copyright (C) 1998,2001-2005 Pavel Machek <pavel@xxxxxx>
> * Copyright (C) 2006 Rafael J. Wysocki <rjw@xxxxxxx>
> + * Copyright (C) 2004-2008 Nigel Cunningham (nigel at tuxonice net)
Please use the e-mail address.
> *
> * This file is released under the GPLv2.
> */
> @@ -74,6 +75,131 @@ int hib_bio_write_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
> virt_to_page(addr), bio_chain);
> }
>
> +static int hib_buffer_init_rw(struct hibernate_io_handle *io_handle,
> + int writing)
> +{
> + /* should never happen - it means we didn't finish properly last time */
> + BUG_ON(io_handle->chunk_buffer || io_handle->chunk_buffer_pos);
Please use if (WARN_ON(...)) retuirn -EINVAL; instead. The BUG_ON() will kill
an otherwise perfectly useable system just because we happen to have a bug in
the hibernation code.
Generally, please don't use BUG_ON() unless you _have_ _to_ (ie. the system
would crash anyway causing data loss and possibly other damage to happen if
we didn't do it).
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/