summaryrefslogtreecommitdiffstats
path: root/Assemble.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2005-09-05 01:14:26 +0000
committerNeil Brown <neilb@suse.de>2005-09-05 01:14:26 +0000
commit6e6dc574d60f108fdc49f3b755d9baeec1335ba2 (patch)
tree770cdad9dfa89f9e00b53aa10b59fe88a9f669ad /Assemble.c
parentbaa2cd47e56f0a387685fb923ce9663b42df9fc2 (diff)
downloadmdadm-6e6dc574d60f108fdc49f3b755d9baeec1335ba2.tar.gz
mdadm-6e6dc574d60f108fdc49f3b755d9baeec1335ba2.tar.xz
mdadm-6e6dc574d60f108fdc49f3b755d9baeec1335ba2.zip
Fix assembling of raid10 in the face of missing devices.stable-1
We now check if enough devices are present properly, so --force can be used to good effect. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/Assemble.c b/Assemble.c
index ace5717..49639cd 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -119,6 +119,7 @@ int Assemble(char *mddev, int mdfd,
int start_partial_ok = force || devlist==NULL;
unsigned int num_devs;
mddev_dev_t tmpdev;
+ char *avail;
vers = md_get_version(mdfd);
if (vers <= 0) {
@@ -389,6 +390,8 @@ int Assemble(char *mddev, int mdfd,
/* now we have some devices that might be suitable.
* I wonder how many
*/
+ avail = malloc(first_super.raid_disks);
+ memset(avail, 0, first_super.raid_disks);
okcnt = 0;
sparecnt=0;
for (i=0; i< bestcnt ;i++) {
@@ -407,13 +410,16 @@ int Assemble(char *mddev, int mdfd,
if (devices[j].events+event_margin >=
devices[most_recent].events) {
devices[j].uptodate = 1;
- if (i < first_super.raid_disks)
+ if (i < first_super.raid_disks) {
okcnt++;
- else
+ avail[i]=1;
+ } else
sparecnt++;
}
}
- while (force && !enough(first_super.level, first_super.raid_disks, okcnt)) {
+ while (force && !enough(first_super.level, first_super.raid_disks,
+ first_super.layout,
+ avail, okcnt)) {
/* Choose the newest best drive which is
* not up-to-date, update the superblock
* and add it.
@@ -466,6 +472,7 @@ int Assemble(char *mddev, int mdfd,
close(fd);
devices[chosen_drive].events = devices[most_recent].events;
devices[chosen_drive].uptodate = 1;
+ avail[chosen_drive] = 1;
okcnt++;
}
@@ -624,7 +631,7 @@ This doesnt work yet
if (runstop == 1 ||
(runstop == 0 &&
- ( enough(first_super.level, first_super.raid_disks, okcnt) &&
+ ( enough(first_super.level, first_super.raid_disks, first_super.layout, avail, okcnt) &&
(okcnt >= req_cnt || start_partial_ok)
))) {
if (ioctl(mdfd, RUN_ARRAY, NULL)==0) {
@@ -649,7 +656,7 @@ This doesnt work yet
fprintf(stderr, Name ": %s assembled from %d drive%s", mddev, okcnt, okcnt==1?"":"s");
if (sparecnt)
fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
- if (!enough(first_super.level, first_super.raid_disks, okcnt))
+ if (!enough(first_super.level, first_super.raid_disks, first_super.layout, avail, okcnt))
fprintf(stderr, " - not enough to start the array.\n");
else {
if (req_cnt == first_super.raid_disks)