summaryrefslogtreecommitdiff
path: root/Create.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2017-04-28 15:05:50 +1000
committerJes Sorensen <jsorensen@fb.com>2017-05-02 09:41:39 -0400
commitcd6cbb08c458cee07acb1d854e04532b29ec87bf (patch)
treeca6482225586ea4d423af1e674dd5ca7021daa4a /Create.c
parentf8c432bfc9929dbbcb659b2d11552dc9fc76ad24 (diff)
downloadmdadm-cd6cbb08c458cee07acb1d854e04532b29ec87bf.tar.gz
Create: tell udev md device is not ready when first created.
When an array is created the content is not initialized, so it could have remnants of an old filesystem or md array etc on it. udev will see this and might try to activate it, which is almost certainly not what is wanted. So create a mechanism for mdadm to communicate with udev to tell it that the device isn't ready. This mechanism is the existance of a file /run/mdadm/created-mdXXX where mdXXX is the md device name. When creating an array, mdadm will create the file. A new udev rule file, 01-md-raid-creating.rules, will detect the precense of thst file and set ENV{SYSTEMD_READY}="0". This is fairly uniformly used to suppress actions based on the contents of the device. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Create.c')
-rw-r--r--Create.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Create.c b/Create.c
index 6ca0924..df1bc20 100644
--- a/Create.c
+++ b/Create.c
@@ -605,7 +605,7 @@ int Create(struct supertype *st, char *mddev,
/* We need to create the device */
map_lock(&map);
- mdfd = create_mddev(mddev, name, c->autof, LOCAL, chosen_name);
+ mdfd = create_mddev(mddev, name, c->autof, LOCAL, chosen_name, 1);
if (mdfd < 0) {
map_unlock(&map);
return 1;
@@ -620,6 +620,7 @@ int Create(struct supertype *st, char *mddev,
chosen_name);
close(mdfd);
map_unlock(&map);
+ udev_unblock();
return 1;
}
mddev = chosen_name;
@@ -1053,9 +1054,15 @@ int Create(struct supertype *st, char *mddev,
pr_err("not starting array - not enough devices.\n");
}
close(mdfd);
+ /* Give udev a moment to process the Change event caused
+ * by the close.
+ */
+ usleep(100*1000);
+ udev_unblock();
return 0;
abort:
+ udev_unblock();
map_lock(&map);
abort_locked:
map_remove(&map, fd2devnm(mdfd));