All of lore.kernel.org
 help / color / mirror / Atom feed
* [mdadm PATCH] mdopen: call "modprobe md_mod" if it might be needed.
@ 2017-09-25  5:52 NeilBrown
  2017-09-25 15:26 ` John Stoffel
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: NeilBrown @ 2017-09-25  5:52 UTC (permalink / raw)
  To: jes.sorensen; +Cc: Linux Raid

[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]


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>
---
 mdopen.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mdopen.c b/mdopen.c
index 3c0052f2db23..dcdc6f23e6c1 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);
-- 
2.14.0.rc0.dirty


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-10-15 22:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25  5:52 [mdadm PATCH] mdopen: call "modprobe md_mod" if it might be needed NeilBrown
2017-09-25 15:26 ` John Stoffel
2017-09-25 23:50   ` NeilBrown
2017-09-26 15:11     ` Jes Sorensen
2017-09-26 19:12       ` Wols Lists
2017-09-26 20:55         ` John Stoffel
2017-09-27 21:30 ` Jes Sorensen
     [not found] ` <cba5f77f-d6de-7a6b-35b0-70b7c56eb3f7@suse.com>
2017-10-10 20:16   ` NeilBrown
2017-10-11  7:39     ` Zhilong Liu
2017-10-12  0:06       ` NeilBrown
2017-10-12  3:55         ` Zhilong Liu
2017-10-12  8:48           ` NeilBrown
2017-10-13  9:16             ` Zhilong Liu
2017-10-15 22:41               ` NeilBrown
2017-10-12  9:55         ` Wols Lists

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.