block: deprecate autoloading based on dev_t
PATCH 1/1 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.
--- block/Kconfig | 11 +++++++++++ block/bdev.c | 9 ++++++--- block/genhd.c | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-)
block/Kconfig +11 -0
@@ -26,6 +26,17 @@ menuconfig BLOCK if BLOCK +config BLOCK_LEGACY_AUTOLOAD + bool "Legacy autoloading support" + help + Enable loading modules and creating block device instances based on + accesses through their device special file. This is a historic Linux + feature and makes no sense in a udev world where device files are + created on demand. + + Say N here unless your boot broke without it, in which case you should + send a report to [email protected] and your distribution. + config BLK_RQ_ALLOC_TIME bool
block/bdev.c +6 -3
@@ -738,12 +738,15 @@ struct block_device *blkdev_get_no_open(dev_t dev)struct inode *inode; inode =ilookup (blockdev_superblock, dev); -if (!inode) { +if (!inode &&IS_ENABLED (CONFIG_BLOCK_LEGACY_AUTOLOAD )) {blk_request_module (dev); inode =ilookup (blockdev_superblock, dev); -if (!inode) -return NULL ; +if (inode) +pr_warn_ratelimited ( +"block device autoloading is deprecated in will be removed in Linux 5.19\n" ); } +if (!inode) +return NULL ;/* switch from the inode reference to a device mode one: */ bdev = &BDEV_I (inode)->bdev;
block/genhd.c +6 -0
@@ -185,7 +185,9 @@ static struct blk_major_name {struct blk_major_name *next;int major;char name[16 ]; +#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD void (*probe)(dev_t devt); +#endif } *major_names[BLKDEV_MAJOR_HASH_SIZE ];static DEFINE_MUTEX (major_names_lock);static DEFINE_SPINLOCK (major_names_spinlock);
@@ -275,7 +277,9 @@ int __register_blkdev(unsigned int major, const char *name, } p->major = major; +#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD p->probe = probe; +#endif strlcpy (p->name, name,sizeof (p->name)); p->next =NULL ; index =major_to_index (major);
@@ -679,6 +683,7 @@ static ssize_t disk_badblocks_store(struct device *dev,return badblocks_store (disk->bb, page, len,0 ); } +#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD void blk_request_module (dev_t devt) {unsigned int major =MAJOR (devt);
@@ -698,6 +703,7 @@ void blk_request_module(dev_t devt)/* Make old-style 2.4 aliases work */ request_module("block-major-%d", MAJOR(devt)); } +#endif /* CONFIG_BLOCK_LEGACY_AUTOLOAD */ /* * print a full list of all partitions - intended for places where the root
Signature · 1 line
2.30.2
Quoted 3 lines · Christoph Hellwig
Make the legacy
dev_tbased autoloading optional and add a deprecation warning. This kind of autoloading has ceased to be useful about 20 years ago.
This is good for locking dependency simplification. But
Quoted 16 lines
Signed-off-by Christoph Hellwig <[email protected]>--- block/Kconfig | 11 +++++++++++ block/bdev.c | 9 ++++++--- block/genhd.c | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-)block/Kconfig +0
-0@@ -26,6 +26,17 @@ menuconfig BLOCK if BLOCK
block/Kconfig menuconfig BLOCK · line 38
Quoted 10 lines
block/Kconfig +10
-0+config BLOCK_LEGACY_AUTOLOAD + bool "Legacy autoloading support" + help + Enable loading modules and creating block device instances based on + accesses through their device special file. This is a historic Linux + feature and makes no sense in a udev world where device files are + created on demand. + + Say N here unless your boot broke without it, in which case you should + send a report to [email protected] and your distribution.
I don't think the affected scope is limited to the boot process. This change affects userspace programs which do not run in the boot process. A program which do not use ioctl(LOOP_CTL_GET_FREE) would be possible.
Current:
----------
root@fuzz:~# ls -l /dev/loop* crw-rw---- 1 root disk 10, 237 Jan 4 09:29 /dev/loop-control root@fuzz:~# mknod /dev/loop0 b 7 0 root@fuzz:~# cat /dev/loop0 root@fuzz:~# echo $? 0 ----------
With CONFIG_BLOCK_LEGACY_AUTOLOAD=n:
----------
root@fuzz:~# ls -l /dev/loop* crw-rw---- 1 root disk 10, 237 Jan 4 09:33 /dev/loop-control root@fuzz:~# mknod /dev/loop0 b 7 0 root@fuzz:~# cat /dev/loop0 cat: /dev/loop0: No such device or address root@fuzz:~# echo $? 1 root@fuzz:~# losetup /dev/loop0 testfile losetup: /dev/loop0: failed to set up loop device: No such device or address ----------
Quoted 11 lines
block/Kconfig +1
-0+ config BLK_RQ_ALLOC_TIME boolblock/bdev.c +0
-0@@ -738,12 +738,15 @@ struct block_device *blkdev_get_no_open(dev_t dev)struct inode *inode;
block/bdev.c struct block_device *blkdev_get_no_open(dev_t dev) · line 746
Quoted 10 lines
block/bdev.c +4
-3inode =ilookup (blockdev_superblock, dev); -if (!inode) { +if (!inode &&IS_ENABLED (CONFIG_BLOCK_LEGACY_AUTOLOAD )) {blk_request_module (dev); inode =ilookup (blockdev_superblock, dev); -if (!inode) -return NULL ; +if (inode) +pr_warn_ratelimited ( +"block device autoloading is deprecated in will be removed in Linux 5.19\n" );
s/deprecated in/deprecated; it/
Quoted 6 lines
block/bdev.c +2
-0} +if (!inode) +return NULL ;/* switch from the inode reference to a device mode one: */ bdev = &BDEV_I (inode)->bdev;