提交 05ce7fb9 编写于 作者: C Chris Webb 提交者: Jens Axboe

md: Explicitly create command-line configured devices

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: NChris Webb <chris@arachsys.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NSong Liu <song@kernel.org>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 9973f0fa
...@@ -169,6 +169,7 @@ static void __init md_setup_drive(struct md_setup_args *args) ...@@ -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); pr_info("md: Loading %s: %s\n", name, args->device_names);
md_alloc(mdev, name);
bdev = blkdev_get_by_dev(mdev, FMODE_READ, NULL); bdev = blkdev_get_by_dev(mdev, FMODE_READ, NULL);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
pr_err("md: open failed - cannot start array %s\n", name); pr_err("md: open failed - cannot start array %s\n", name);
......
...@@ -5623,7 +5623,7 @@ int mddev_init_writes_pending(struct mddev *mddev) ...@@ -5623,7 +5623,7 @@ int mddev_init_writes_pending(struct mddev *mddev)
} }
EXPORT_SYMBOL_GPL(mddev_init_writes_pending); 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 * If dev is zero, name is the name of a device to allocate with
......
...@@ -765,6 +765,7 @@ extern int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev); ...@@ -765,6 +765,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 int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
extern void mddev_init(struct mddev *mddev); 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_run(struct mddev *mddev);
extern int md_start(struct mddev *mddev); extern int md_start(struct mddev *mddev);
extern void md_stop(struct mddev *mddev); extern void md_stop(struct mddev *mddev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册