From: Christoph Hellwig on
On Tue, May 25, 2010 at 10:46:51AM -0500, Will Drewry wrote:
> This change only adds EXPORT_SYMBOL() for name_to_dev_t.
>
> name_to_dev_t is in use outside of init/ but is not 'officially'
> exported. It provides behavior that is useful for any code that may be
> need to lookup a block device by major:minor or registered kernel name,
> especially before there is a root filesystem.
>
> Hopefully, this is the appropriate use of EXPORT_SYMBOL(). This
> specific function seems to be a stable interface and is available
> in include/linux/mount.h.

NACK. It's really a hack for the boot code, there's no offical name to
dev_t mapping.

What are you trying to use it for?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Alasdair G Kergon on
On Tue, May 25, 2010 at 11:55:35AM -0400, Christoph Hellwig wrote:
> NACK. It's really a hack for the boot code, there's no offical name to
> dev_t mapping.
> What are you trying to use it for?

Device-mapper contains a subset of that code, so he's proposing we
use it here:

@@ -434,17 +435,13 @@ static int __table_get_device(struct dm_
int r;
dev_t uninitialized_var(dev);
struct dm_dev_internal *dd;
- unsigned int major, minor;

BUG_ON(!t);

- if (sscanf(path, "%u:%u", &major, &minor) == 2) {
- /* Extract the major/minor numbers */
- dev = MKDEV(major, minor);
- if (MAJOR(dev) != major || MINOR(dev) != minor)
- return -EOVERFLOW;
- } else {
- /* convert the path to a device */
+ /* lookup by major:minor or registered device name */
+ dev = name_to_dev_t(path);
+ if (!dev) {
+ /* convert the path to a device by finding its inode */
struct block_device *bdev = lookup_bdev(path);

if (IS_ERR(bdev))

Alasdair

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Will Drewry on
On Tue, May 25, 2010 at 11:05 AM, Alasdair G Kergon <agk(a)redhat.com> wrote:
> On Tue, May 25, 2010 at 11:55:35AM -0400, Christoph Hellwig wrote:
>> NACK. �It's really a hack for the boot code, there's no offical name to
>> dev_t mapping.
>> What are you trying to use it for?
>
> Device-mapper contains a subset of that code, so he's proposing we
> use it here:
>
> @@ -434,17 +435,13 @@ static int __table_get_device(struct dm_
> � � � �int r;
> � � � �dev_t uninitialized_var(dev);
> � � � �struct dm_dev_internal *dd;
> - � � � unsigned int major, minor;
>
> � � � �BUG_ON(!t);
>
> - � � � if (sscanf(path, "%u:%u", &major, &minor) == 2) {
> - � � � � � � � /* Extract the major/minor numbers */
> - � � � � � � � dev = MKDEV(major, minor);
> - � � � � � � � if (MAJOR(dev) != major || MINOR(dev) != minor)
> - � � � � � � � � � � � return -EOVERFLOW;
> - � � � } else {
> - � � � � � � � /* convert the path to a device */
> + � � � /* lookup by major:minor or registered device name */
> + � � � dev = name_to_dev_t(path);
> + � � � if (!dev) {
> + � � � � � � � /* convert the path to a device by finding its inode */
> � � � � � � � �struct block_device *bdev = lookup_bdev(path);
>
> � � � � � � � �if (IS_ERR(bdev))

In addition to getting rid of the code duplication, I'd like device-mapper
to be able to resolve slave devices at boot-time to accommodate a
do_mounts_dm.c equivalent to do_mounts_md.c:

https://patchwork.kernel.org/patch/101024/

(which I neglected to mail to the other init-related maintainers - sorry!
I'll correct that when I mail out the next revision.)

thanks!
will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Christoph Hellwig on
On Tue, May 25, 2010 at 11:11:33AM -0500, Will Drewry wrote:
> In addition to getting rid of the code duplication, I'd like device-mapper
> to be able to resolve slave devices at boot-time to accommodate a
> do_mounts_dm.c equivalent to do_mounts_md.c:

So please add a do_mounts_dm.c instead of pushing this somewhere it
doesn't belong to.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Mike Snitzer on
On Tue, May 25 2010 at 1:21pm -0400,
Christoph Hellwig <hch(a)infradead.org> wrote:

> On Tue, May 25, 2010 at 11:11:33AM -0500, Will Drewry wrote:
> > In addition to getting rid of the code duplication, I'd like device-mapper
> > to be able to resolve slave devices at boot-time to accommodate a
> > do_mounts_dm.c equivalent to do_mounts_md.c:
>
> So please add a do_mounts_dm.c instead of pushing this somewhere it
> doesn't belong to.

He is proposing doing just that, you cut out the patchwork url he
already shared: https://patchwork.kernel.org/patch/101024/

Will's intentions are good: avoid code duplication.

He is also trying to keep DM-specific common code in drivers/md/

So in this instance, avoiding the need to export name_to_dev_t would
require splitting the internal DM __table_get_device (or more likely:
dm_get_device) out to a public facing interface that takes a dev_t.

Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/