]> www.infradead.org Git - nvme.git/commitdiff
md: Explicitly create command-line configured devices
authorChris Webb <chris@arachsys.com>
Wed, 1 Jun 2022 11:03:07 +0000 (12:03 +0100)
committerSong Liu <song@kernel.org>
Sun, 3 Jul 2022 14:55:39 +0000 (07:55 -0700)
Boot-time assembly of arrays with md= command-line arguments breaks when
CONFIG_BLOCK_LEGACY_AUTOLOAD is unset. md_setup_drive() in md-autodetect.c
calls blkdev_get_by_dev(), assuming this implicitly creates the block
device.

Fix this by attempting to md_alloc() the array first. As in the probe path,
ignore any error as failure is caught by blkdev_get_by_dev() anyway.

Signed-off-by: Chris Webb <chris@arachsys.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Song Liu <song@kernel.org>
drivers/md/md-autodetect.c
drivers/md/md.c
drivers/md/md.h

index 2cf973722f59624f478875151169f6bc26f1e58c..344910ba435c53aaa0ccaa776bf63065646053a5 100644 (file)
@@ -169,6 +169,7 @@ static void __init md_setup_drive(struct md_setup_args *args)
 
        pr_info("md: Loading %s: %s\n", name, args->device_names);
 
+       md_alloc(mdev, name);
        bdev = blkdev_get_by_dev(mdev, FMODE_READ, NULL);
        if (IS_ERR(bdev)) {
                pr_err("md: open failed - cannot start array %s\n", name);
index cbb53e53c5425c7c5e319d4776769d1d1b381865..ce9d2845d3ace1e7900aef334d8a3ab91c321aae 100644 (file)
@@ -5623,7 +5623,7 @@ int mddev_init_writes_pending(struct mddev *mddev)
 }
 EXPORT_SYMBOL_GPL(mddev_init_writes_pending);
 
-static int md_alloc(dev_t dev, char *name)
+int md_alloc(dev_t dev, char *name)
 {
        /*
         * If dev is zero, name is the name of a device to allocate with
index e3361f6a734178392e14cd84e517c3c700c1bd25..1a85dbe78a71c15252c8efc6f791be8882a2e4bd 100644 (file)
@@ -766,6 +766,7 @@ extern int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev);
 extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
 
 extern void mddev_init(struct mddev *mddev);
+int md_alloc(dev_t dev, char *name);
 extern int md_run(struct mddev *mddev);
 extern int md_start(struct mddev *mddev);
 extern void md_stop(struct mddev *mddev);