summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2017-09-25 07:52:19 +0200
committerJes Sorensen <jsorensen@fb.com>2017-09-27 23:30:27 +0200
commitfdbf7aaa19564520055971724b70ae1652e35788 (patch)
tree579faf06095085057ee4c7c1a2ed5244552d09bd
parentmdadm/test: add new testcase for testing readonly/readwrite (diff)
downloadmdadm-fdbf7aaa19564520055971724b70ae1652e35788.tar.xz
mdadm-fdbf7aaa19564520055971724b70ae1652e35788.zip
mdopen: call "modprobe md_mod" if it might be needed.
Creating an array by opening a block-device with major number of 9 will transparently load the md module if needed. Creating an array by opening /sys/module/md_mod/parameters/new_array and writing to it won't, it will just fail if md_mod isn't loaded. So when opening that file fails with ENOENT, run "modprobe md_mod" and try again. This fixes a bug whereby if you have "CREATE names=yes" in mdadm.conf, and the md modules isn't loaded, then creating or assembling an array will not honor the "names=yes" configuration. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
-rw-r--r--mdopen.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mdopen.c b/mdopen.c
index 3c0052f2..dcdc6f23 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -312,6 +312,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
if (block_udev)
udev_block(devnm);
fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
+ if (fd < 0 && errno == ENOENT) {
+ system("modprobe md_mod");
+ fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
+ }
if (fd >= 0) {
n = write(fd, devnm, strlen(devnm));
close(fd);