summaryrefslogtreecommitdiffstats
path: root/mdassemble.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-11-04 10:35:37 +1100
committerNeilBrown <neilb@suse.de>2008-11-04 10:35:37 +1100
commit7f91af49ad09adc1b93346f7ad654e25534f35b7 (patch)
tree1b98d19f9382cf17ac7df5db4f07ea8ea48bda8a /mdassemble.c
parentadf0493cba2355fc3714e6ab265f2b6b7de894d8 (diff)
downloadmdadm-7f91af49ad09adc1b93346f7ad654e25534f35b7.tar.gz
mdadm-7f91af49ad09adc1b93346f7ad654e25534f35b7.tar.xz
mdadm-7f91af49ad09adc1b93346f7ad654e25534f35b7.zip
Delay creation of array devices for assemble/build/create
We will shortly be feeding more information into the process of creating array devices, so delay the creation. Still open them early if the device already exists. This involves making sure the autof flag is in the right place so that it can be found at creation time. Also, Assemble, Build, and Create now always close 'mdfd'. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdassemble.c')
-rw-r--r--mdassemble.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/mdassemble.c b/mdassemble.c
index 66d8213..1e3f104 100644
--- a/mdassemble.c
+++ b/mdassemble.c
@@ -55,7 +55,7 @@ mapping_t pers[] = {
#ifndef MDASSEMBLE_AUTO
/* from mdopen.c */
-int create_mddev(char *dev, int autof/*unused */)
+int open_mddev(char *dev, int report_errors/*unused*/)
{
int mdfd = open(dev, O_RDWR);
if (mdfd < 0)
@@ -69,6 +69,10 @@ int create_mddev(char *dev, int autof/*unused */)
}
return mdfd;
}
+int create_mddev(char *dev, int autof/*unused*/)
+{
+ return open_mddev(dev, 0);
+}
#endif
int rv;
@@ -86,19 +90,16 @@ int main(int argc, char *argv[]) {
} else
for (; array_list; array_list = array_list->next) {
mdu_array_info_t array;
- mdfd = create_mddev(array_list->devname, array_list->autof);
- if (mdfd < 0) {
- rv |= 1;
- continue;
- }
- if (ioctl(mdfd, GET_ARRAY_INFO, &array) < 0) {
- rv |= Assemble(array_list->st, array_list->devname, mdfd,
- array_list, NULL, NULL,
- readonly, runstop, NULL, NULL, verbose, force);
- } else {
+ mdfd = open_mddev(array_list->devname, 0);
+ if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
+ continue;
}
- close(mdfd);
+ if (mdfd >= 0)
+ close(mdfd);
+ rv |= Assemble(array_list->st, array_list->devname,
+ array_list, NULL, NULL,
+ readonly, runstop, NULL, NULL, verbose, force);
}
return rv;
}