* [PATCH 1/2] init: make the path argument a const in name_to_dev_t
@ 2010-05-25 15:46 Will Drewry
2010-05-25 15:46 ` [PATCH 2/2] init, mount: export the name_to_dev_t symbol Will Drewry
0 siblings, 1 reply; 8+ messages in thread
From: Will Drewry @ 2010-05-25 15:46 UTC (permalink / raw)
To: linux-kernel
Cc: Al Viro, Nick Piggin, Tejun Heo, Scott James Remnant,
Vegard Nossum, Harald Hoyer, Christoph Lameter, agk, snitzer,
Will Drewry
name_to_dev_t takes a char * argument which it never modifies. This
change converts it to a const char *.
(This is useful with the second patch in the series which exports the
symbol. External consumers of the function will now be able to pass in
a const char * without duping or casting away const-ness.)
Signed-off-by: Will Drewry <wad@chromium.org>
---
include/linux/mount.h | 2 +-
init/do_mounts.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 4bd0547..ad819a0 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -134,6 +134,6 @@ extern int do_add_mount(struct vfsmount *newmnt, struct path *path,
extern void mark_mounts_for_expiry(struct list_head *mounts);
-extern dev_t name_to_dev_t(char *name);
+extern dev_t name_to_dev_t(const char *name);
#endif /* _LINUX_MOUNT_H */
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 0848a5b..a322b13 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -75,7 +75,7 @@ __setup("rw", readwrite);
* bangs.
*/
-dev_t name_to_dev_t(char *name)
+dev_t name_to_dev_t(const char *name)
{
char s[32];
char *p;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 15:46 [PATCH 1/2] init: make the path argument a const in name_to_dev_t Will Drewry
@ 2010-05-25 15:46 ` Will Drewry
2010-05-25 15:55 ` Christoph Hellwig
0 siblings, 1 reply; 8+ messages in thread
From: Will Drewry @ 2010-05-25 15:46 UTC (permalink / raw)
To: linux-kernel
Cc: Al Viro, Nick Piggin, Tejun Heo, Scott James Remnant,
Vegard Nossum, Harald Hoyer, Christoph Lameter, agk, snitzer,
Will Drewry
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.
Signed-off-by: Will Drewry <wad@chromium.org>
---
init/do_mounts.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index a322b13..b9206e7 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -144,6 +144,7 @@ fail:
done:
return res;
}
+EXPORT_SYMBOL(name_to_dev_t);
static int __init root_dev_setup(char *line)
{
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 15:46 ` [PATCH 2/2] init, mount: export the name_to_dev_t symbol Will Drewry
@ 2010-05-25 15:55 ` Christoph Hellwig
2010-05-25 16:05 ` Alasdair G Kergon
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2010-05-25 15:55 UTC (permalink / raw)
To: Will Drewry
Cc: linux-kernel, Al Viro, Nick Piggin, Tejun Heo,
Scott James Remnant, Vegard Nossum, Harald Hoyer,
Christoph Lameter, agk, snitzer
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?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 15:55 ` Christoph Hellwig
@ 2010-05-25 16:05 ` Alasdair G Kergon
2010-05-25 16:11 ` Will Drewry
0 siblings, 1 reply; 8+ messages in thread
From: Alasdair G Kergon @ 2010-05-25 16:05 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Will Drewry, linux-kernel, Al Viro, Nick Piggin, Tejun Heo,
Scott James Remnant, Vegard Nossum, Harald Hoyer,
Christoph Lameter, agk, snitzer
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 16:05 ` Alasdair G Kergon
@ 2010-05-25 16:11 ` Will Drewry
2010-05-25 17:21 ` Christoph Hellwig
0 siblings, 1 reply; 8+ messages in thread
From: Will Drewry @ 2010-05-25 16:11 UTC (permalink / raw)
To: Alasdair G Kergon, Christoph Hellwig, Will Drewry, linux-kernel,
Al Viro, Nick Piggin, Tejun Heo, Scott James Remnant,
Vegard Nossum, Harald Hoyer, Christoph Lameter, snitzer
On Tue, May 25, 2010 at 11:05 AM, Alasdair G Kergon <agk@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 16:11 ` Will Drewry
@ 2010-05-25 17:21 ` Christoph Hellwig
2010-05-25 18:30 ` Mike Snitzer
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2010-05-25 17:21 UTC (permalink / raw)
To: Will Drewry
Cc: Alasdair G Kergon, Christoph Hellwig, linux-kernel, Al Viro,
Nick Piggin, Tejun Heo, Scott James Remnant, Vegard Nossum,
Harald Hoyer, Christoph Lameter, snitzer
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 17:21 ` Christoph Hellwig
@ 2010-05-25 18:30 ` Mike Snitzer
2010-06-08 16:02 ` Will Drewry
0 siblings, 1 reply; 8+ messages in thread
From: Mike Snitzer @ 2010-05-25 18:30 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Will Drewry, Alasdair G Kergon, linux-kernel, Al Viro,
Nick Piggin, Tejun Heo, Scott James Remnant, Vegard Nossum,
Harald Hoyer, Christoph Lameter
On Tue, May 25 2010 at 1:21pm -0400,
Christoph Hellwig <hch@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] init, mount: export the name_to_dev_t symbol
2010-05-25 18:30 ` Mike Snitzer
@ 2010-06-08 16:02 ` Will Drewry
0 siblings, 0 replies; 8+ messages in thread
From: Will Drewry @ 2010-06-08 16:02 UTC (permalink / raw)
To: Mike Snitzer, Christoph Hellwig
Cc: Alasdair G Kergon, linux-kernel, Al Viro, Nick Piggin, Tejun Heo,
Scott James Remnant, Vegard Nossum, Harald Hoyer,
Christoph Lameter
On Tue, May 25, 2010 at 1:30 PM, Mike Snitzer <snitzer@redhat.com> wrote:
> On Tue, May 25 2010 at 1:21pm -0400,
> Christoph Hellwig <hch@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.
FWIW, I mailed out a new patchset which does not expect the dm core
code to understand device paths before there is a root device. Now it
walks the target parameters supplied to do_mounts_dm.c and attempts
a best-guess replacement with major:minor numbers. It's not as succinct,
but it achieves the isolation requested and negates the need for the
patch on this thread.
The relevant init-time patchwork link:
https://patchwork.kernel.org/patch/104861/
(Full patchset is 58-61)
Any and all comments will be appreciated - thanks!
will
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-06-08 16:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 15:46 [PATCH 1/2] init: make the path argument a const in name_to_dev_t Will Drewry
2010-05-25 15:46 ` [PATCH 2/2] init, mount: export the name_to_dev_t symbol Will Drewry
2010-05-25 15:55 ` Christoph Hellwig
2010-05-25 16:05 ` Alasdair G Kergon
2010-05-25 16:11 ` Will Drewry
2010-05-25 17:21 ` Christoph Hellwig
2010-05-25 18:30 ` Mike Snitzer
2010-06-08 16:02 ` Will Drewry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox