]> www.infradead.org Git - users/hch/block.git/commitdiff
block: deprecate autoloading based on dev_t block-deprecate-autoloading
authorChristoph Hellwig <hch@lst.de>
Mon, 3 Jan 2022 09:39:34 +0000 (10:39 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 3 Jan 2022 09:44:03 +0000 (10:44 +0100)
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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/Kconfig
block/bdev.c
block/genhd.c

index d5d4197b7ed2d304f68d572b189bc5f0974505c4..66425637724d08446143a0370f433ef4e3a54baa 100644 (file)
@@ -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 linux-block@vger.kernel.org and your distribution.
+
 config BLK_RQ_ALLOC_TIME
        bool
 
index 8bf93a19041b7beb925069ae33b86891c4ade7f9..dd6fd5b807b30d652ff3c719f80ddeebf5642881 100644 (file)
@@ -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;
index 626c8406f21a6a5b5def739ea87a8678e9732303..6ae990ff026603a7a24a71816de594081351fd01 100644 (file)
@@ -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