diff options
author | NeilBrown <neilb@suse.com> | 2017-04-12 08:29:04 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-04-12 19:34:44 +0200 |
commit | 039df36231335fabe4da1a22fa3accb160d8bc1b (patch) | |
tree | 488c2a2a062858f4a418c6df97afd39bccecb5f1 /mdopen.c | |
parent | super1: Clean up various style abuses (diff) | |
download | mdadm-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.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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) { |