History

block: deprecate autoloading based on dev_t

Make the legacy dev_t based autoloading optional and add a deprecation warning. This kind of autoloading has ceased to be useful about 20 years ago.

Christoph Hellwig committed 4 years ago

Commit fbdee711 parent 26291c53 files · +24 −3Browse files

Unified · Split

3 files
  1. block/Kconfig +12 −0
  2. block/bdev.c +6 −3
  3. block/genhd.c +6 −0
block/Kconfig+12−0
@@ -26,6 +26,18 @@ menuconfig BLOCK · 25 unmodified lines
2626
2727 if BLOCK
2828
29+config BLOCK_LEGACY_AUTOLOAD
30+ bool "Legacy autoloading support"
31+ help
32+ Enable loading modules and creating block device instances based on
33+ accesses through their device special file. This is a historic Linux
34+ feature and makes no sense in a udev world where device files are
35+ created on demand.
36+
37+ Say N here unless booting or other functionality broke without it, in
38+ which case you should also send a report to your distribution and
39+ linux-block@vger.kernel.org.
40+
2941 config BLK_RQ_ALLOC_TIME
3042 bool
3143
block/bdev.c+6−3
@@ -733,12 +733,15 @@ struct block_device *blkdev_get_no_open(dev_t dev) · 732 unmodified lines
733733 struct inode *inode;
734734
735735 inode = ilookup(blockdev_superblock, dev);
736− if (!inode) {
736+ if (!inode && IS_ENABLED(CONFIG_BLOCK_LEGACY_AUTOLOAD)) {
737737 blk_request_module(dev);
738738 inode = ilookup(blockdev_superblock, dev);
739− if (!inode)
740− return NULL;
739+ if (inode)
740+ pr_warn_ratelimited(
741+"block device autoloading is deprecated. It will be removed in Linux 5.19\n");
741742 }
743+ if (!inode)
744+ return NULL;
742745
743746 /* switch from the inode reference to a device mode one: */
744747 bdev = &BDEV_I(inode)->bdev;
block/genhd.c+6−0
@@ -185,7 +185,9 @@ static struct blk_major_name { · 184 unmodified lines
185185 struct blk_major_name *next;
186186 int major;
187187 char name[16];
188+#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
188189 void (*probe)(dev_t devt);
190+#endif
189191 } *major_names[BLKDEV_MAJOR_HASH_SIZE];
190192 static DEFINE_MUTEX(major_names_lock);
191193 static DEFINE_SPINLOCK(major_names_spinlock);
@@ -275,7 +277,9 @@ int __register_blkdev(unsigned int major, const char *name, · 83 unmodified lines
275277 }
276278
277279 p->major = major;
280+#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
278281 p->probe = probe;
282+#endif
279283 strlcpy(p->name, name, sizeof(p->name));
280284 p->next = NULL;
281285 index = major_to_index(major);
@@ -679,6 +683,7 @@ static ssize_t disk_badblocks_store(struct device *dev, · 397 unmodified lines
679683 return badblocks_store(disk->bb, page, len, 0);
680684 }
681685
686+#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
682687 void blk_request_module(dev_t devt)
683688 {
684689 unsigned int major = MAJOR(devt);
@@ -698,6 +703,7 @@ void blk_request_module(dev_t devt) · 13 unmodified lines
698703 /* Make old-style 2.4 aliases work */
699704 request_module("block-major-%d", MAJOR(devt));
700705 }
706+#endif /* CONFIG_BLOCK_LEGACY_AUTOLOAD */
701707
702708 /*
703709 * print a full list of all partitions - intended for places where the root