From: Artem Bityutskiy <dedekind1@gmail.com>
To: David Wagner <david.wagner@free-electrons.com>
Cc: linux-mtd <linux-mtd@lists.infradead.org>,
linux-embedded <linux-embedded@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>,
Tim Bird <tim.bird@am.sony.com>,
David Woodhouse <dwmw2@infradead.org>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCHv6] UBI: new module ubiblk: block layer on top of UBI
Date: Fri, 23 Sep 2011 13:58:50 +0300 [thread overview]
Message-ID: <1316775538.19921.19.camel@sauron> (raw)
In-Reply-To: <1316678312-8913-1-git-send-email-david.wagner@free-electrons.com>
On Thu, 2011-09-22 at 09:58 +0200, David Wagner wrote:
> +MODULE_PARM_DESC(volume,
> + "Format: volume=<ubi_num>:<vol_id>\n"
> + "Create a ubiblk device at init time. Useful for mounting it as root "
> + "device.");
I encourage people to use names, not IDs, because names are persistent,
while IDs may change when the configuration changes.
Take a look at UBI and how it handles the "mtd=" parameter. Do something
similar when you are parsing vol_id. IOW, I, as a user, would want to be
able to do:
ubimkvol -N "kuku" ...
modprobe ubiblk volume=0:kuku
(specify volume name "kuku").
> +/**
> + * ubiblk_inittime_volume - create a volume at init time
Please, stick to the same rule as UBI is using:
1. If the function is non-static, always add an ubiblk prefix
2. If the function is static, but it just makes sense to start with
ubiblk_ prefix, fine. For example, ubiblk_init().
3. Otherwise, no need to add ubiblk_ prefix for a static function.
IOW, please, do not automatically prefix all your functions with ubiblk_
prefix, especially when it brings no value and makes names longer.
I think this function is one of those which does not need that prefix.
> +/**
> + * ubi_ubiblk_init - initialize the module
> + *
> + * Get a major number and register to UBI notifications ; register the ioctl
> + * handler device
Nitpick: please, for consistency, put dots at the end of description.
> + */
> +static int __init ubi_ubiblk_init(void)
Name it ubiblk_init() please.
> +{
> + int ret = 0;
The initialization is not needed.
> +
> + ret = register_blkdev(0, "ubiblk");
> + if (ret < 0)
> + return ret;
> + ubiblk_major = ret;
> +
> + /* Check if the user wants a volume to be proxified at init time */
> + if (volume)
> + ubiblk_inittime_volume();
If you fail to create the block device the user requested using the
module parameters, you should exit with error code. IOW,
'ubiblk_inittime_volume()' has to return an error on failure.
> +
> + ret = ubi_register_volume_notifier(&ubiblk_notifier, 1);
> + if (ret < 0)
> + goto out_unreg_blk;
If you previously created a block device in 'ubiblk_inittime_volume()',
and fail here, the error path will not destroy the block device, but it
should. IOW, you have a problem in your error path here.
> +
> + ret = misc_register(&ctrl_dev);
> + if (ret) {
> + pr_err("can't register control device\n");
> + goto out_unreg_notifier;
> + }
> +
> + pr_info("major device number is %d\n", ubiblk_major);
> +
> + return ret;
> +
> +out_unreg_notifier:
> + ubi_unregister_volume_notifier(&ubiblk_notifier);
> +out_unreg_blk:
if (volumes)
ubiblk_destroy(xxx);
or something like that is needed here.
> + unregister_blkdev(ubiblk_major, "ubiblk");
> +
> + return ret;
> +}
> +/**
> + * ubi_ubiblk_exit - end of life
> + *
> + * unregister the block device major, unregister from UBI notifications,
Nitpick: please, start description with capital letter, for consistency.
> + * unregister the ioctl handler device stop the threads and free the memory.
> + */
> +static void __exit ubi_ubiblk_exit(void)
Please, name it simply 'ubiblk_exit()' instead.
> +{
> + struct ubiblk_dev *next;
> + struct ubiblk_dev *dev;
> +
> + ubi_unregister_volume_notifier(&ubiblk_notifier);
> + misc_deregister(&ctrl_dev);
> +
> + list_for_each_entry_safe(dev, next, &ubiblk_devs, list) {
> + /* The module is being forcefully removed */
> + WARN_ON(dev->desc);
> +
> + del_gendisk(dev->gd);
> + blk_cleanup_queue(dev->rq);
> + kthread_stop(dev->req_task);
> + put_disk(dev->gd);
> +
> + kfree(dev);
1. I think you should have an "ubiblk_destroy()" function, symmetric to
the "ubiblk_create()". And you'll also use it in the error path of the
init function, see above.
2. Please, could you explain what prevents the following crash/issue:
modprobe ubiblk volumes=0:0
mkfs.ext3 /dev/ubiblk0
mount -t ext3 /dev/ubiblk0 /mnt/fs
rmmod ubiblk
Not that I think this is a problem, I just do not realize what would
prevent ubiblk from being unloaded when it is mounted. Did you test this
scenario?
> +/*
> + * Copyright © Free Electrons, 2011
> + * Copyright © International Business Machines Corp., 2006
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> + * the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + *
> + * Author: David Wagner
> + * Some code taken from ubi-user.h
Since this will be living in the UBI directory and be kind of part of
UBI sources, this comment is probably not needed. The same for the
ubiblk.c file.
> +/**
> + * ubiblk_ctrl_req - additional ioctl data structure
Nitpick: please, let's be consistent with the rest of the UBI code and
put dot at the end of the "heading" line of the kernel-doc comments for
structures, and functions as well.
--
Best Regards,
Artem Bityutskiy
WARNING: multiple messages have this Message-ID (diff)
From: Artem Bityutskiy <dedekind1@gmail.com>
To: David Wagner <david.wagner@free-electrons.com>
Cc: linux-embedded <linux-embedded@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
lkml <linux-kernel@vger.kernel.org>,
linux-mtd <linux-mtd@lists.infradead.org>,
Tim Bird <tim.bird@am.sony.com>,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCHv6] UBI: new module ubiblk: block layer on top of UBI
Date: Fri, 23 Sep 2011 13:58:50 +0300 [thread overview]
Message-ID: <1316775538.19921.19.camel@sauron> (raw)
In-Reply-To: <1316678312-8913-1-git-send-email-david.wagner@free-electrons.com>
On Thu, 2011-09-22 at 09:58 +0200, David Wagner wrote:
> +MODULE_PARM_DESC(volume,
> + "Format: volume=<ubi_num>:<vol_id>\n"
> + "Create a ubiblk device at init time. Useful for mounting it as root "
> + "device.");
I encourage people to use names, not IDs, because names are persistent,
while IDs may change when the configuration changes.
Take a look at UBI and how it handles the "mtd=" parameter. Do something
similar when you are parsing vol_id. IOW, I, as a user, would want to be
able to do:
ubimkvol -N "kuku" ...
modprobe ubiblk volume=0:kuku
(specify volume name "kuku").
> +/**
> + * ubiblk_inittime_volume - create a volume at init time
Please, stick to the same rule as UBI is using:
1. If the function is non-static, always add an ubiblk prefix
2. If the function is static, but it just makes sense to start with
ubiblk_ prefix, fine. For example, ubiblk_init().
3. Otherwise, no need to add ubiblk_ prefix for a static function.
IOW, please, do not automatically prefix all your functions with ubiblk_
prefix, especially when it brings no value and makes names longer.
I think this function is one of those which does not need that prefix.
> +/**
> + * ubi_ubiblk_init - initialize the module
> + *
> + * Get a major number and register to UBI notifications ; register the ioctl
> + * handler device
Nitpick: please, for consistency, put dots at the end of description.
> + */
> +static int __init ubi_ubiblk_init(void)
Name it ubiblk_init() please.
> +{
> + int ret = 0;
The initialization is not needed.
> +
> + ret = register_blkdev(0, "ubiblk");
> + if (ret < 0)
> + return ret;
> + ubiblk_major = ret;
> +
> + /* Check if the user wants a volume to be proxified at init time */
> + if (volume)
> + ubiblk_inittime_volume();
If you fail to create the block device the user requested using the
module parameters, you should exit with error code. IOW,
'ubiblk_inittime_volume()' has to return an error on failure.
> +
> + ret = ubi_register_volume_notifier(&ubiblk_notifier, 1);
> + if (ret < 0)
> + goto out_unreg_blk;
If you previously created a block device in 'ubiblk_inittime_volume()',
and fail here, the error path will not destroy the block device, but it
should. IOW, you have a problem in your error path here.
> +
> + ret = misc_register(&ctrl_dev);
> + if (ret) {
> + pr_err("can't register control device\n");
> + goto out_unreg_notifier;
> + }
> +
> + pr_info("major device number is %d\n", ubiblk_major);
> +
> + return ret;
> +
> +out_unreg_notifier:
> + ubi_unregister_volume_notifier(&ubiblk_notifier);
> +out_unreg_blk:
if (volumes)
ubiblk_destroy(xxx);
or something like that is needed here.
> + unregister_blkdev(ubiblk_major, "ubiblk");
> +
> + return ret;
> +}
> +/**
> + * ubi_ubiblk_exit - end of life
> + *
> + * unregister the block device major, unregister from UBI notifications,
Nitpick: please, start description with capital letter, for consistency.
> + * unregister the ioctl handler device stop the threads and free the memory.
> + */
> +static void __exit ubi_ubiblk_exit(void)
Please, name it simply 'ubiblk_exit()' instead.
> +{
> + struct ubiblk_dev *next;
> + struct ubiblk_dev *dev;
> +
> + ubi_unregister_volume_notifier(&ubiblk_notifier);
> + misc_deregister(&ctrl_dev);
> +
> + list_for_each_entry_safe(dev, next, &ubiblk_devs, list) {
> + /* The module is being forcefully removed */
> + WARN_ON(dev->desc);
> +
> + del_gendisk(dev->gd);
> + blk_cleanup_queue(dev->rq);
> + kthread_stop(dev->req_task);
> + put_disk(dev->gd);
> +
> + kfree(dev);
1. I think you should have an "ubiblk_destroy()" function, symmetric to
the "ubiblk_create()". And you'll also use it in the error path of the
init function, see above.
2. Please, could you explain what prevents the following crash/issue:
modprobe ubiblk volumes=0:0
mkfs.ext3 /dev/ubiblk0
mount -t ext3 /dev/ubiblk0 /mnt/fs
rmmod ubiblk
Not that I think this is a problem, I just do not realize what would
prevent ubiblk from being unloaded when it is mounted. Did you test this
scenario?
> +/*
> + * Copyright © Free Electrons, 2011
> + * Copyright © International Business Machines Corp., 2006
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> + * the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + *
> + * Author: David Wagner
> + * Some code taken from ubi-user.h
Since this will be living in the UBI directory and be kind of part of
UBI sources, this comment is probably not needed. The same for the
ubiblk.c file.
> +/**
> + * ubiblk_ctrl_req - additional ioctl data structure
Nitpick: please, let's be consistent with the rest of the UBI code and
put dot at the end of the "heading" line of the kernel-doc comments for
structures, and functions as well.
--
Best Regards,
Artem Bityutskiy
next prev parent reply other threads:[~2011-09-23 10:58 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 13:34 [RFC] ubiblk: read-only block layer on top of UBI david.wagner
2011-06-24 13:34 ` david.wagner
2011-06-24 13:34 ` [PATCH] UBI: new module ubiblk: " david.wagner
2011-06-24 13:34 ` david.wagner
2011-06-27 19:26 ` Artem Bityutskiy
2011-06-27 19:26 ` Artem Bityutskiy
2011-06-28 11:35 ` David Wagner
2011-06-28 11:35 ` David Wagner
2011-06-29 6:52 ` Artem Bityutskiy
2011-06-29 6:52 ` Artem Bityutskiy
2011-06-28 14:50 ` Matthieu CASTET
2011-06-28 14:50 ` Matthieu CASTET
2011-06-28 15:32 ` David Wagner
2011-06-28 15:32 ` David Wagner
2011-06-29 6:25 ` Artem Bityutskiy
2011-06-29 6:25 ` Artem Bityutskiy
2011-06-24 13:45 ` [Addendum][RFC] ubiblk: read-only " David Wagner
2011-06-27 19:14 ` [RFC] " Artem Bityutskiy
2011-06-27 19:14 ` Artem Bityutskiy
2011-06-28 15:24 ` [RFC PATCHv2] UBI: new module ubiblk: " david.wagner
2011-06-28 15:24 ` david.wagner
2011-06-28 15:24 ` david.wagner
2011-06-29 6:54 ` Artem Bityutskiy
2011-06-29 6:54 ` Artem Bityutskiy
2011-07-26 12:27 ` [PATCH] " David Wagner
2011-07-26 12:27 ` David Wagner
2011-07-26 12:34 ` Christoph Hellwig
2011-07-26 12:34 ` Christoph Hellwig
2011-07-26 12:34 ` Christoph Hellwig
2011-07-26 12:58 ` David Wagner
2011-07-26 12:58 ` David Wagner
2011-07-28 6:14 ` Artem Bityutskiy
2011-07-28 6:14 ` Artem Bityutskiy
2011-08-15 11:56 ` Artem Bityutskiy
2011-08-15 11:56 ` Artem Bityutskiy
2011-08-17 13:17 ` [PATCHv3] " david.wagner
2011-08-17 13:17 ` david.wagner
2011-08-17 14:20 ` [PATCH] Tools for controling ubiblk David Wagner
2011-08-17 14:20 ` David Wagner
2011-08-22 8:17 ` Artem Bityutskiy
2011-08-22 8:17 ` Artem Bityutskiy
2011-08-22 7:39 ` [PATCHv3] UBI: new module ubiblk: block layer on top of UBI Artem Bityutskiy
2011-08-22 7:39 ` Artem Bityutskiy
2011-08-22 7:42 ` Artem Bityutskiy
2011-08-22 7:42 ` Artem Bityutskiy
2011-08-24 16:23 ` Arnd Bergmann
2011-08-24 16:23 ` Arnd Bergmann
2011-08-25 7:06 ` Artem Bityutskiy
2011-08-25 7:06 ` Artem Bityutskiy
2011-08-25 15:12 ` Arnd Bergmann
2011-08-25 15:12 ` Arnd Bergmann
2011-08-25 15:12 ` Arnd Bergmann
2011-09-01 12:55 ` David Wagner
2011-09-01 12:55 ` David Wagner
2011-09-01 12:55 ` David Wagner
2011-09-06 3:44 ` Artem Bityutskiy
2011-09-06 3:44 ` Artem Bityutskiy
2011-09-06 4:10 ` Artem Bityutskiy
2011-09-06 4:10 ` Artem Bityutskiy
2011-09-06 4:10 ` Artem Bityutskiy
2011-09-06 4:29 ` Artem Bityutskiy
2011-09-06 4:29 ` Artem Bityutskiy
2011-09-08 15:26 ` Arnd Bergmann
2011-09-08 15:26 ` Arnd Bergmann
2011-09-08 15:26 ` Arnd Bergmann
2011-09-09 11:53 ` Artem Bityutskiy
2011-09-09 11:53 ` Artem Bityutskiy
2011-09-09 12:02 ` Artem Bityutskiy
2011-09-09 12:02 ` Artem Bityutskiy
2011-09-09 14:25 ` Arnd Bergmann
2011-09-09 14:25 ` Arnd Bergmann
2011-09-09 15:27 ` Artem Bityutskiy
2011-09-09 15:27 ` Artem Bityutskiy
2011-09-09 14:41 ` David Wagner
2011-09-09 14:41 ` David Wagner
2011-09-09 14:41 ` David Wagner
2011-09-09 14:51 ` Arnd Bergmann
2011-09-09 14:51 ` Arnd Bergmann
2011-09-11 10:18 ` Artem Bityutskiy
2011-09-11 10:18 ` Artem Bityutskiy
2011-09-11 10:18 ` Artem Bityutskiy
2011-09-11 10:35 ` David Wagner
2011-09-11 10:35 ` David Wagner
2011-08-24 16:15 ` [PATCHv4] " david.wagner
2011-08-24 16:15 ` david.wagner
2011-08-24 16:21 ` [PATCH] document ubiblk's usage of the same ioctl magic as a part " David Wagner
2011-08-24 16:21 ` David Wagner
2011-09-06 4:58 ` Artem Bityutskiy
2011-09-06 4:58 ` Artem Bityutskiy
2011-09-06 4:55 ` [PATCHv4] UBI: new module ubiblk: block layer on top " Artem Bityutskiy
2011-09-06 4:55 ` Artem Bityutskiy
2011-09-12 9:51 ` [PATCHv5] " David Wagner
2011-09-12 9:51 ` David Wagner
2011-09-12 9:51 ` David Wagner
2011-09-19 4:50 ` Artem Bityutskiy
2011-09-19 4:50 ` Artem Bityutskiy
2011-09-22 7:58 ` [PATCHv6] " David Wagner
2011-09-22 7:58 ` David Wagner
2011-09-23 10:58 ` Artem Bityutskiy [this message]
2011-09-23 10:58 ` Artem Bityutskiy
2011-09-26 12:58 ` David Wagner
2011-09-26 12:58 ` David Wagner
2011-09-26 9:17 ` Ricard Wanderlof
2011-09-26 9:17 ` Ricard Wanderlof
2011-09-26 9:17 ` Ricard Wanderlof
2011-09-26 12:11 ` Ricard Wanderlof
2011-09-26 12:38 ` [PATCHv7] " David Wagner
2011-09-26 12:38 ` David Wagner
2011-09-26 13:20 ` Artem Bityutskiy
2011-09-26 13:20 ` Artem Bityutskiy
2011-09-26 14:25 ` [PATCHv8] " David Wagner
2011-09-26 14:25 ` David Wagner
2011-09-26 14:36 ` Artem Bityutskiy
2011-09-26 14:36 ` Artem Bityutskiy
2011-09-26 14:40 ` [PATCHv9] " David Wagner
2011-09-26 14:40 ` David Wagner
2011-10-01 14:08 ` Artem Bityutskiy
2011-10-01 14:08 ` 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=1316775538.19921.19.camel@sauron \
--to=dedekind1@gmail.com \
--cc=arnd@arndb.de \
--cc=david.wagner@free-electrons.com \
--cc=dwmw2@infradead.org \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=tim.bird@am.sony.com \
/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.