linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.0-test8] MODULE_ALIAS_BLOCK
@ 2003-10-21 21:20 Erik van Konijnenburg
  2003-10-23  4:11 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Erik van Konijnenburg @ 2003-10-21 21:20 UTC (permalink / raw)
  To: rusty; +Cc: linux-kernel


Hi Rusty,

Automatic loading of the loop device does not work under 2.6.0-test8
unless the loop device is explicitly mentioned in /etc/modules.conf.
This shows up when doing a kernel make install: mkinitrd uses the
loopback device.

This is because loop.c does not have MODULE_ALIAS_BLOCKDEV.
After adding that, the following problem shows: a mismatch between
the use of request_module in drivers/block/genhd.c:

	request_module("block-major-%d", MAJOR(dev));

and the definition of MODULE_ALIAS_BLOCK in blkdev.h:

	MODULE_ALIAS("block-major-" __stringify(major) "-*")

The following patch applies to 2.6.0-test8.  I tested under (mostly) RH9 that
automatic loading of loop.ko works with this patch but not without it.
The only other user of MODULE_ALIAS_BLOCK, floppy.c, also worked for
me with this patch, no idea whether it works without.

Regards,
Erik


diff -r -U3 2.6.0-test8/drivers/block/loop.c 2.6.0-test8-play/drivers/block/loop.c
--- 2.6.0-test8/drivers/block/loop.c	2003-10-18 10:01:44.000000000 +0200
+++ 2.6.0-test8-play/drivers/block/loop.c	2003-10-19 20:48:15.000000000 +0200
@@ -55,6 +55,7 @@
 #include <linux/errno.h>
 #include <linux/major.h>
 #include <linux/wait.h>
+#include <linux/blkdev.h>
 #include <linux/blkpg.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
@@ -1124,6 +1125,7 @@
 MODULE_PARM(max_loop, "i");
 MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-256)");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
 
 int loop_register_transfer(struct loop_func_table *funcs)
 {
diff -r -U3 2.6.0-test8/include/linux/blkdev.h 2.6.0-test8-play/include/linux/blkdev.h
--- 2.6.0-test8/include/linux/blkdev.h	2003-10-18 10:00:05.000000000 +0200
+++ 2.6.0-test8-play/include/linux/blkdev.h	2003-10-19 22:52:04.000000000 +0200
@@ -678,7 +678,7 @@
 #define MODULE_ALIAS_BLOCKDEV(major,minor) \
 	MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
 #define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
-	MODULE_ALIAS("block-major-" __stringify(major) "-*")
+	MODULE_ALIAS("block-major-" __stringify(major))
 
 
 #endif

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2.6.0-test8] MODULE_ALIAS_BLOCK
  2003-10-21 21:20 [PATCH 2.6.0-test8] MODULE_ALIAS_BLOCK Erik van Konijnenburg
@ 2003-10-23  4:11 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2003-10-23  4:11 UTC (permalink / raw)
  To: Erik van Konijnenburg; +Cc: linux-kernel, torvalds

In message <20031021232022.A19672@banaan.localdomain> you write:
> 
> Hi Rusty,
> 
> Automatic loading of the loop device does not work under 2.6.0-test8
> unless the loop device is explicitly mentioned in /etc/modules.conf.
> This shows up when doing a kernel make install: mkinitrd uses the
> loopback device.
> 
> This is because loop.c does not have MODULE_ALIAS_BLOCKDEV.
> After adding that, the following problem shows: a mismatch between
> the use of request_module in drivers/block/genhd.c:
> 
> 	request_module("block-major-%d", MAJOR(dev));
> 
> and the definition of MODULE_ALIAS_BLOCK in blkdev.h:
> 
> 	MODULE_ALIAS("block-major-" __stringify(major) "-*")
> 
> The following patch applies to 2.6.0-test8.  I tested under (mostly) RH9 that
> automatic loading of loop.ko works with this patch but not without it.
> The only other user of MODULE_ALIAS_BLOCK, floppy.c, also worked for
> me with this patch, no idea whether it works without.

Hmm.  Disagree with your change, prefer to go the other way.  Sure,
block drivers generally don't care about the minor, but (1) they might
one day, and (2) this matches with the way char devices are handled.

Linus, please apply.

Name: Block Alias Fix in genhd.c
Author: Rusty Russell
Status: Trivial

D: MODULE_ALIAS_BLOCK and genhd.c's request_module() don't match,
D: which breaks autoloading of loop devices.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2035-linux-2.6.0-test8-bk2/drivers/block/genhd.c .2035-linux-2.6.0-test8-bk2.updated/drivers/block/genhd.c
--- .2035-linux-2.6.0-test8-bk2/drivers/block/genhd.c	2003-10-09 18:02:51.000000000 +1000
+++ .2035-linux-2.6.0-test8-bk2.updated/drivers/block/genhd.c	2003-10-23 14:09:35.000000000 +1000
@@ -296,7 +296,7 @@ extern int blk_dev_init(void);
 
 static struct kobject *base_probe(dev_t dev, int *part, void *data)
 {
-	request_module("block-major-%d", MAJOR(dev));
+	request_module("block-major-%d-%d", MAJOR(dev), MINOR(dev));
 	return NULL;
 }
 


--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-23  4:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-21 21:20 [PATCH 2.6.0-test8] MODULE_ALIAS_BLOCK Erik van Konijnenburg
2003-10-23  4:11 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).