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
26 26
27if BLOCK27if BLOCK
28 28
29config 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
29config BLK_RQ_ALLOC_TIME41config BLK_RQ_ALLOC_TIME
30 bool42 bool
31 43
block/bdev.c+6−3
@@ -733,12 +733,15 @@ struct block_device *blkdev_get_no_open(dev_t dev) · 732 unmodified lines
733 struct inode *inode;733 struct inode *inode;
734 734
735 inode = ilookup(blockdev_superblock, dev);735 inode = ilookup(blockdev_superblock, dev);
736 if (!inode) {736 if (!inode && IS_ENABLED(CONFIG_BLOCK_LEGACY_AUTOLOAD)) {
737 blk_request_module(dev);737 blk_request_module(dev);
738 inode = ilookup(blockdev_superblock, dev);738 inode = ilookup(blockdev_superblock, dev);
739 if (!inode)739 if (inode)
740 return NULL;740 pr_warn_ratelimited(
741"block device autoloading is deprecated. It will be removed in Linux 5.19\n");
741 }742 }
743 if (!inode)
744 return NULL;
742 745
743 /* switch from the inode reference to a device mode one: */746 /* switch from the inode reference to a device mode one: */
744 bdev = &BDEV_I(inode)->bdev;747 bdev = &BDEV_I(inode)->bdev;
block/genhd.c+6−0
@@ -185,7 +185,9 @@ static struct blk_major_name { · 184 unmodified lines
185 struct blk_major_name *next;185 struct blk_major_name *next;
186 int major;186 int major;
187 char name[16];187 char name[16];
188#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
188 void (*probe)(dev_t devt);189 void (*probe)(dev_t devt);
190#endif
189} *major_names[BLKDEV_MAJOR_HASH_SIZE];191} *major_names[BLKDEV_MAJOR_HASH_SIZE];
190static DEFINE_MUTEX(major_names_lock);192static DEFINE_MUTEX(major_names_lock);
191static DEFINE_SPINLOCK(major_names_spinlock);193static DEFINE_SPINLOCK(major_names_spinlock);
@@ -275,7 +277,9 @@ int __register_blkdev(unsigned int major, const char *name, · 83 unmodified lines
275 }277 }
276 278
277 p->major = major;279 p->major = major;
280#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
278 p->probe = probe;281 p->probe = probe;
282#endif
279 strlcpy(p->name, name, sizeof(p->name));283 strlcpy(p->name, name, sizeof(p->name));
280 p->next = NULL;284 p->next = NULL;
281 index = major_to_index(major);285 index = major_to_index(major);
@@ -679,6 +683,7 @@ static ssize_t disk_badblocks_store(struct device *dev, · 397 unmodified lines
679 return badblocks_store(disk->bb, page, len, 0);683 return badblocks_store(disk->bb, page, len, 0);
680}684}
681 685
686#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
682void blk_request_module(dev_t devt)687void blk_request_module(dev_t devt)
683{688{
684 unsigned int major = MAJOR(devt);689 unsigned int major = MAJOR(devt);
@@ -698,6 +703,7 @@ void blk_request_module(dev_t devt) · 13 unmodified lines
698 /* Make old-style 2.4 aliases work */703 /* Make old-style 2.4 aliases work */
699 request_module("block-major-%d", MAJOR(devt));704 request_module("block-major-%d", MAJOR(devt));
700}705}
706#endif /* CONFIG_BLOCK_LEGACY_AUTOLOAD */
701 707
702/*708/*
703 * print a full list of all partitions - intended for places where the root709 * print a full list of all partitions - intended for places where the root