Re: [RFC 09/15] PM / Hibernate: user, implement user_ops writer

From: Pavel Machek
Date: Wed Mar 24 2010 - 16:43:14 EST


Hi!

> Switch /dev/snapshot writer to sws_module_ops approach so that we
> can transparently rewrite the rest of the snapshot from pages pulling
> to their pushing through layers.
>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Cc: Nigel Cunningham <ncunningham@xxxxxxxxxxx>
> Cc: "Rafael J. Wysocki" <rjw@xxxxxxx>
> ---
> kernel/power/user.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++----
> 1 files changed, 105 insertions(+), 8 deletions(-)
>

> + if (test_bit(TODO_CLOSED, to_do_flags))
> + return -EIO;
> +
> + to_do_buf = buf;
> + wmb();
> + set_bit(TODO_WORK, to_do_flags);
> + wake_up_interruptible(&to_do_wait);

Uhuh, open-coded barriers... these need to be commented, and I guess
you just should not play this kind of trickery.

spnlocks? Normal locks?

> +
> + wait_event(to_do_done, !test_bit(TODO_WORK, to_do_flags) ||
> + (err = test_bit(TODO_CLOSED, to_do_flags)));
> +
> + return err ? -EIO : 0;
> +}
> +
> +static int put_user_writer(unsigned int flags, int error)
> +{
> + int err = 0;
> +
> + if (error)
> + set_bit(TODO_ERROR, to_do_flags);
> + set_bit(TODO_FINISH, to_do_flags);
> + wake_up_interruptible(&to_do_wait);
> +
> + wait_event(to_do_done, !test_bit(TODO_FINISH, to_do_flags) ||
> + (err = test_bit(TODO_CLOSED, to_do_flags)));
> +
> + if (!error && err)
> + error = -EIO;
> +
> + return error;
> +}
> +
> struct sws_module_ops user_ops = {
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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/