summaryrefslogtreecommitdiffstats
path: root/Assemble.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-12-14 17:31:13 +1100
committerNeil Brown <neilb@suse.de>2006-12-14 17:31:13 +1100
commit583315d9c522c310c89d5640ae884ef7984b9c30 (patch)
treee3a1f9d2e617fc90460b7786fc01e8c255cbe211 /Assemble.c
parent757234466509aae6221c2cb96e8366f41ba7e532 (diff)
downloadmdadm-583315d9c522c310c89d5640ae884ef7984b9c30.tar.gz
mdadm-583315d9c522c310c89d5640ae884ef7984b9c30.tar.xz
mdadm-583315d9c522c310c89d5640ae884ef7984b9c30.zip
Give useful message if raid4/5/6 cannot be started because it is not clean and is also degraded.
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/Assemble.c b/Assemble.c
index 23e3583..59f4239 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -111,6 +111,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
* START_ARRAY
*
*/
+ int clean = 0;
int must_close = 0;
int old_linux = 0;
int vers = 0; /* Keep gcc quite - it really is initialised */
@@ -583,6 +584,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
}
st->ss->getinfo_super(&info, first_super);
+ clean = info.array.state & 1;
/* now we have some devices that might be suitable.
* I wonder how many
@@ -617,7 +619,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
}
}
while (force && !enough(info.array.level, info.array.raid_disks,
- info.array.layout,
+ info.array.layout, 1,
avail, okcnt)) {
/* Choose the newest best drive which is
* not up-to-date, update the superblock
@@ -758,6 +760,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
change += st->ss->update_super(&info, super, "force-array",
devices[chosen_drive].devname, verbose,
0, NULL);
+ clean = 1;
}
if (change) {
@@ -894,7 +897,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
if (runstop == 1 ||
(runstop <= 0 &&
- ( enough(info.array.level, info.array.raid_disks, info.array.layout, avail, okcnt) &&
+ ( enough(info.array.level, info.array.raid_disks,
+ info.array.layout, clean, avail, okcnt) &&
(okcnt >= req_cnt || start_partial_ok)
))) {
if (ioctl(mdfd, RUN_ARRAY, NULL)==0) {
@@ -937,6 +941,19 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
}
fprintf(stderr, Name ": failed to RUN_ARRAY %s: %s\n",
mddev, strerror(errno));
+
+ if (!enough(info.array.level, info.array.raid_disks,
+ info.array.layout, 1, avail, okcnt))
+ fprintf(stderr, Name ": Not enough devices to "
+ "start the array.\n");
+ else if (!enough(info.array.level,
+ info.array.raid_disks,
+ info.array.layout, clean,
+ avail, okcnt))
+ fprintf(stderr, Name ": Not enough devices to "
+ "start the array while not clean "
+ "- consider --force.\n");
+
if (must_close) close(mdfd);
return 1;
}
@@ -953,8 +970,16 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
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(info.array.level, info.array.raid_disks, info.array.layout, avail, okcnt))
+ if (!enough(info.array.level, info.array.raid_disks,
+ info.array.layout, 1, avail, okcnt))
fprintf(stderr, " - not enough to start the array.\n");
+ else if (!enough(info.array.level,
+ info.array.raid_disks,
+ info.array.layout, clean,
+ avail, okcnt))
+ fprintf(stderr, " - not enough to start the "
+ "array while not clean - consider "
+ "--force.\n");
else {
if (req_cnt == info.array.raid_disks)
fprintf(stderr, " - need all %d to start it", req_cnt);