From: Artem Bityutskiy <dedekind@infradead.org>
To: Kevin Cernekee <kpc.mtd@gmail.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MTD: Add UBI reboot notifier
Date: Tue, 09 Jun 2009 15:32:55 +0300 [thread overview]
Message-ID: <1244550775.5847.385.camel@localhost.localdomain> (raw)
In-Reply-To: <018abcd2d98090bda0f75d3c95c9ec85@localhost>
Looks good to me. I'm though wandering if UBIFS should also
register a reboot notifier an sync write-buffers in it...
But this is not related to your patch.
Some nit-picking.
On Mon, 2009-06-08 at 22:14 -0700, Kevin Cernekee wrote:
> /**
> + * ubi_reboot_notifier - halt UBI transactions immediately prior to a reboot
> + * @n: notifier_block struct (inside our struct ubi_device)
> + * @val: unused
> + * @v: unused
> + */
> +static int ubi_reboot_notifier(struct notifier_block *n, unsigned long val,
> + void *v)
> +{
> + struct ubi_device *ubi = container_of(n, struct ubi_device,
> + reboot_notifier);
> +
> + if (ubi->bgt_thread)
> + kthread_stop(ubi->bgt_thread);
> + return NOTIFY_DONE;
> +}
Several small things in comments and indentations. Take a look how
other UBI funcs do things, I'd be happier to keep the code consistent.
> +/**
> * ubi_attach_mtd_dev - attach an MTD device.
> * @mtd: MTD device description object
> * @ubi_num: number to assign to the new UBI device
> @@ -876,6 +894,11 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
> ubi->thread_enabled = 1;
> wake_up_process(ubi->bgt_thread);
>
> + /* Flash device priority is 0. UBI needs to shut down first. */
> + ubi->reboot_notifier.priority = 1;
> + ubi->reboot_notifier.notifier_call = ubi_reboot_notifier;
> + register_reboot_notifier(&ubi->reboot_notifier);
> +
> ubi_devices[ubi_num] = ubi;
> return ubi_num;
>
> @@ -945,6 +968,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
> * Before freeing anything, we have to stop the background thread to
> * prevent it from doing anything on this device while we are freeing.
> */
> + unregister_reboot_notifier(&ubi->reboot_notifier);
> if (ubi->bgt_thread)
> kthread_stop(ubi->bgt_thread);
>
> diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
> index c055511..44a45b9 100644
> --- a/drivers/mtd/ubi/ubi.h
> +++ b/drivers/mtd/ubi/ubi.h
> @@ -36,6 +36,7 @@
> #include <linux/device.h>
> #include <linux/string.h>
> #include <linux/vmalloc.h>
> +#include <linux/notifier.h>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/ubi.h>
>
> @@ -420,6 +421,7 @@ struct ubi_device {
> struct task_struct *bgt_thread;
> int thread_enabled;
> char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2];
> + struct notifier_block reboot_notifier;
How about commenting this field above the struct ubi_device
definition?
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
WARNING: multiple messages have this Message-ID (diff)
From: Artem Bityutskiy <dedekind@infradead.org>
To: Kevin Cernekee <kpc.mtd@gmail.com>
Cc: dwmw2@infradead.org, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MTD: Add UBI reboot notifier
Date: Tue, 09 Jun 2009 15:32:55 +0300 [thread overview]
Message-ID: <1244550775.5847.385.camel@localhost.localdomain> (raw)
In-Reply-To: <018abcd2d98090bda0f75d3c95c9ec85@localhost>
Looks good to me. I'm though wandering if UBIFS should also
register a reboot notifier an sync write-buffers in it...
But this is not related to your patch.
Some nit-picking.
On Mon, 2009-06-08 at 22:14 -0700, Kevin Cernekee wrote:
> /**
> + * ubi_reboot_notifier - halt UBI transactions immediately prior to a reboot
> + * @n: notifier_block struct (inside our struct ubi_device)
> + * @val: unused
> + * @v: unused
> + */
> +static int ubi_reboot_notifier(struct notifier_block *n, unsigned long val,
> + void *v)
> +{
> + struct ubi_device *ubi = container_of(n, struct ubi_device,
> + reboot_notifier);
> +
> + if (ubi->bgt_thread)
> + kthread_stop(ubi->bgt_thread);
> + return NOTIFY_DONE;
> +}
Several small things in comments and indentations. Take a look how
other UBI funcs do things, I'd be happier to keep the code consistent.
> +/**
> * ubi_attach_mtd_dev - attach an MTD device.
> * @mtd: MTD device description object
> * @ubi_num: number to assign to the new UBI device
> @@ -876,6 +894,11 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
> ubi->thread_enabled = 1;
> wake_up_process(ubi->bgt_thread);
>
> + /* Flash device priority is 0. UBI needs to shut down first. */
> + ubi->reboot_notifier.priority = 1;
> + ubi->reboot_notifier.notifier_call = ubi_reboot_notifier;
> + register_reboot_notifier(&ubi->reboot_notifier);
> +
> ubi_devices[ubi_num] = ubi;
> return ubi_num;
>
> @@ -945,6 +968,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
> * Before freeing anything, we have to stop the background thread to
> * prevent it from doing anything on this device while we are freeing.
> */
> + unregister_reboot_notifier(&ubi->reboot_notifier);
> if (ubi->bgt_thread)
> kthread_stop(ubi->bgt_thread);
>
> diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
> index c055511..44a45b9 100644
> --- a/drivers/mtd/ubi/ubi.h
> +++ b/drivers/mtd/ubi/ubi.h
> @@ -36,6 +36,7 @@
> #include <linux/device.h>
> #include <linux/string.h>
> #include <linux/vmalloc.h>
> +#include <linux/notifier.h>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/ubi.h>
>
> @@ -420,6 +421,7 @@ struct ubi_device {
> struct task_struct *bgt_thread;
> int thread_enabled;
> char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2];
> + struct notifier_block reboot_notifier;
How about commenting this field above the struct ubi_device
definition?
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
next prev parent reply other threads:[~2009-06-09 12:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 5:14 [PATCH] MTD: Add UBI reboot notifier Kevin Cernekee
2009-06-09 5:14 ` Kevin Cernekee
2009-06-09 12:13 ` Artem Bityutskiy
2009-06-09 12:13 ` Artem Bityutskiy
2009-06-09 12:32 ` Artem Bityutskiy [this message]
2009-06-09 12:32 ` Artem Bityutskiy
2009-06-09 17:59 ` [PATCHv2] " Kevin Cernekee
2009-06-09 17:59 ` Kevin Cernekee
2009-06-10 9:35 ` Artem Bityutskiy
2009-06-10 9:35 ` Artem Bityutskiy
2009-06-10 11:59 ` Artem Bityutskiy
2009-06-10 11:59 ` Artem Bityutskiy
2009-06-10 17:27 ` Kevin Cernekee
2009-06-10 17:27 ` Kevin Cernekee
2010-02-12 13:13 ` Artem Bityutskiy
2010-02-12 13:13 ` Artem Bityutskiy
2010-02-12 13:45 ` Norbert van Bolhuis
2010-02-12 13:45 ` Norbert van Bolhuis
2010-02-12 15:20 ` David Woodhouse
2010-02-12 15:20 ` David Woodhouse
2010-02-12 15:21 ` Artem Bityutskiy
2010-02-12 15:21 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244550775.5847.385.camel@localhost.localdomain \
--to=dedekind@infradead.org \
--cc=dwmw2@infradead.org \
--cc=kpc.mtd@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.