From: Artem Bityutskiy <dedekind@infradead.org>
To: dpervushin@gmail.com
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] [UBI] 1/4 UBI volume notifications - UBI changes
Date: Tue, 09 Dec 2008 12:36:29 +0200 [thread overview]
Message-ID: <1228818989.13686.172.camel@sauron> (raw)
In-Reply-To: <1228759160.7622.28.camel@hp.diimka.lan>
On Mon, 2008-12-08 at 20:59 +0300, dmitry pervushin wrote:
<snip>
> /**
> + * ubi_enum_volumes - enumerate all existing volumes
> + */
> +int ubi_enum_volumes(void *context,
> + void (*enumerator)(void *context, int ubi, const char *volume_name))
> +{
> + int ubi_num, i, count = 0;
> + struct ubi_device *ubi;
> +
> + spin_lock(&ubi_devices_lock);
> + for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++) {
> + ubi = ubi_devices[ubi_num];
> + if (!ubi)
> + continue;
> + spin_lock(&ubi->volumes_lock);
> + for (i = 0; i < ubi->vtbl_slots; i++) {
> + if (!ubi->volumes[i])
> + continue;
> + enumerator(context, ubi_num, ubi->volumes[i]->name);
> + count++;
> + }
> + spin_unlock(&ubi->volumes_lock);
> + }
> + spin_unlock(&ubi_devices_lock);
> + return count;
> +}
Could you please initialize 'struct ubi_volume_notification' straight in
this function, instead of having 'enumerator' call-back? I think this
would be much more readable. I do not see the reason for this
complexity.
<snip>
> +/**
> * ubi_get_device - get UBI device.
> * @ubi_num: UBI device number
> *
> @@ -842,6 +870,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
> goto out_detach;
> }
>
> + /* when processing uif_init, we already might want to open the volume */
> + ubi_devices[ubi_num] = ubi;
> err = uif_init(ubi);
> if (err)
> goto out_nofree;
I do not understand this change. The point is to prevent anyone from
opening the volume before it is completely initialized. What you do -
you allow the volume to be opened while it is in the middle of
initialization, which is wrong. E.g., what if the initialization fails
at some point?
And this change does not seem to be relevant to this patch.
<snip>
> --- a/drivers/mtd/ubi/cdev.c
> +++ b/drivers/mtd/ubi/cdev.c
> @@ -395,7 +395,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
> vol->corrupted = 1;
> }
> vol->checked = 1;
> - ubi_gluebi_updated(vol);
> + ubi_volume_notify(UBI_VOLUME_CHANGED, ubi->ubi_num, vol->name);
> revoke_exclusive(desc, UBI_READWRITE);
> }
Could you please remove gluebi as a separate patch?
> diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
<snip>
> +
> +static void do_notify_added(void *context, int ubi, const char *name)
> +{
> + struct notifier_block *nb = context;
> + struct ubi_volume_notification nt;
> +
> + nt.ubi_device = ubi;
> + nt.volume_name = name;
> + nb->notifier_call(context, UBI_VOLUME_ADDED, &nt);
> +}
As I said above, this call-back function does not seem to be reasonable.
> diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
<snip>
> -#ifdef CONFIG_MTD_UBI_GLUEBI
> - /*
> - * Gluebi-related stuff may be compiled out.
> - * Note: this should not be built into UBI but should be a separate
> - * ubimtd driver which works on top of UBI and emulates MTD devices.
> - */
> - struct ubi_volume_desc *gluebi_desc;
> - int gluebi_refcount;
> - struct mtd_info gluebi_mtd;
> -#endif
> };
Similar. May this stuff be removed in a separate patch please? It'll
make things easier to review.
<snip>
> +int ubi_register_volume_notifier(struct notifier_block *nb,
> + int ignore_existing);
> +int ubi_unregister_volume_notifier(struct notifier_block *nb);
> +
> +struct ubi_volume_notification {
> + int ubi_device;
> + const char *volume_name;
> +};
This should have volume ID instead of name. Indeed, the ID is unique and
never changes, while name may change, so ID is better for volume
identification purposes.
<snip>
> +enum ubi_volume_notification_type {
> + UBI_VOLUME_ADDED,
> + UBI_VOLUME_DELETED,
> + UBI_VOLUME_CHANGED,
> + UBI_VOLUME_RENAMING,
> + UBI_VOLUME_RENAMED,
> +};
I do not see a reason for 2 rename notifications. Why? For me it looks
like one is enough.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
next prev parent reply other threads:[~2008-12-09 10:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-08 17:59 [PATCH] [UBI] 1/4 UBI volume notifications - UBI changes dmitry pervushin
2008-12-09 10:36 ` Artem Bityutskiy [this message]
2008-12-10 19:50 ` dmitry pervushin
2008-12-11 6:07 ` Artem Bityutskiy
2008-12-11 9:25 ` dmitry pervushin
2008-12-11 19:20 ` Artem Bityutskiy
2008-12-15 11:13 ` dmitry pervushin
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=1228818989.13686.172.camel@sauron \
--to=dedekind@infradead.org \
--cc=dpervushin@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox