summaryrefslogtreecommitdiffstats
path: root/mdopen.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2017-04-12 08:29:04 +0200
committerJes Sorensen <jsorensen@fb.com>2017-04-12 19:34:44 +0200
commit039df36231335fabe4da1a22fa3accb160d8bc1b (patch)
tree488c2a2a062858f4a418c6df97afd39bccecb5f1 /mdopen.c
parentsuper1: Clean up various style abuses (diff)
downloadmdadm-039df36231335fabe4da1a22fa3accb160d8bc1b.tar.xz
mdadm-039df36231335fabe4da1a22fa3accb160d8bc1b.zip
mdopen: use parameters/new_array to create arrays whenever possible.
In a sufficiently recent kernel, an md%d array can be created by writing to .../parameters/new_array. If mdadm does this consistently, then another new feature, disabling create_on_open, can be enabled. This avoids races on shutdown. An added benefit of using new_array (where available) is that it allows md arrays with numbers larger than 511 (e.g. md999) to be created. The old create_on_open mechanism doesn't support such devices since Commit: af5628f05db6 ("md: disable probing for md devices 512 and over.") in Linux 3.17. After a few more mdadm releases it would be good to have mdadm disable create_on_open automatically. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'mdopen.c')
-rw-r--r--mdopen.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/mdopen.c b/mdopen.c
index fe240e5c..82b97fc9 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -313,6 +313,18 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
if (n < 0)
devnm[0] = 0;
}
+ if (num >= 0) {
+ int fd;
+ int n = -1;
+ sprintf(devnm, "md%d", num);
+ fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
+ if (fd >= 0) {
+ n = write(fd, devnm, strlen(devnm));
+ close(fd);
+ }
+ if (n < 0)
+ devnm[0] = 0;
+ }
if (devnm[0])
;
else if (num < 0) {