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