summaryrefslogtreecommitdiffstats
path: root/mdadm.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-26 00:50:15 +0000
committerNeil Brown <neilb@suse.de>2006-05-26 00:50:15 +0000
commitda6b5ca9bd6962ea70dfa750f3d85ac1657fb9cf (patch)
tree0a4e5847b4d2d1b8a73c7483e2c0ca26b3c1f1e4 /mdadm.c
parent8a46fe8487986f96e5313156336c02cc551282c8 (diff)
downloadmdadm-da6b5ca9bd6962ea70dfa750f3d85ac1657fb9cf.tar.gz
mdadm-da6b5ca9bd6962ea70dfa750f3d85ac1657fb9cf.tar.xz
mdadm-da6b5ca9bd6962ea70dfa750f3d85ac1657fb9cf.zip
Initial implementation of auto-assembly
This basically works, but needs various improvements and some tests. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c82
1 files changed, 55 insertions, 27 deletions
diff --git a/mdadm.c b/mdadm.c
index 0df7369..6c30058 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -237,6 +237,7 @@ int main(int argc, char *argv[])
dv->disposition = devmode;
dv->writemostly = writemostly;
dv->re_add = re_add;
+ dv->used = 0;
dv->next = NULL;
*devlistend = dv;
devlistend = &dv->next;
@@ -981,36 +982,63 @@ int main(int argc, char *argv[])
}
} else {
mddev_ident_t array_list = conf_get_ident(configfile, NULL);
- if (!array_list) {
- fprintf(stderr, Name ": No arrays found in config file\n");
- rv = 1;
- } else
- if (update) {
- fprintf(stderr, Name ": --update not meaningful with a --scan assembly.\n");
- exit(1);
+ mddev_dev_t devlist = conf_get_devs(configfile);
+ int cnt = 0;
+ if (devlist == NULL) {
+ fprintf(stderr, Name ": No devices listed in conf file were found.\n");
+ exit(1);
+ }
+ if (update) {
+ fprintf(stderr, Name ": --update not meaningful with a --scan assembly.\n");
+ exit(1);
+ }
+ if (backup_file) {
+ fprintf(stderr, Name ": --backup_file not meaningful with a --scan assembly.\n");
+ exit(1);
+ }
+ for (; array_list; array_list = array_list->next) {
+ mdu_array_info_t array;
+ mdfd = open_mddev(array_list->devname,
+ array_list->autof ? array_list->autof : autof);
+ if (mdfd < 0) {
+ rv |= 1;
+ continue;
}
- if (backup_file) {
- fprintf(stderr, Name ": --backup_file not meaningful with a --scan assembly.\n");
- exit(1);
+ if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0)
+ /* already assembled, skip */
+ ;
+ else {
+ rv |= Assemble(ss, array_list->devname, mdfd,
+ array_list, configfile,
+ devlist, NULL,
+ readonly, runstop, NULL, homehost, verbose-quiet, force);
+ if (rv == 0) cnt++;
}
- for (; array_list; array_list = array_list->next) {
- mdu_array_info_t array;
- mdfd = open_mddev(array_list->devname,
- array_list->autof ? array_list->autof : autof);
- if (mdfd < 0) {
- rv |= 1;
- continue;
- }
- if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0)
- /* already assembled, skip */
- ;
- else
- rv |= Assemble(ss, array_list->devname, mdfd,
- array_list, configfile,
- NULL, NULL,
- readonly, runstop, NULL, homehost, verbose-quiet, force);
- close(mdfd);
+ close(mdfd);
+ }
+ if (homehost) {
+ /* Maybe we can auto-assemble something.
+ * Repeatedly call Assemble in auto-assmble mode
+ * until it fails
+ */
+ int rv2;
+ do {
+ ident.autof = autof;
+ rv2 = Assemble(ss, NULL, -1,
+ &ident, configfile,
+ devlist, NULL,
+ readonly, runstop, NULL, homehost, verbose-quiet, force);
+ if (rv2==0)
+ cnt++;
+ } while (rv2==0);
+ if (cnt == 0 && rv == 0) {
+ fprintf(stderr, Name ": No arrays found in config file or automatically\n");
+ rv = 1;
}
+ } else if (cnt == 0 && rv == 0) {
+ fprintf(stderr, Name ": No arrays found in config file\n");
+ rv = 1;
+ }
}
break;
case BUILD: