summaryrefslogtreecommitdiffstats
path: root/Assemble.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-03-20 03:17:31 +0000
committerNeil Brown <neilb@suse.de>2006-03-20 03:17:31 +0000
commit353632d927d6e46282ef4f51d4ad17940a30cdf0 (patch)
tree7257d93e459937f1b5bffa90ea5b2dccd18a2b00 /Assemble.c
parente86c9dd6d847ec57ec400b118efaf2c1808f10bc (diff)
downloadmdadm-353632d927d6e46282ef4f51d4ad17940a30cdf0.tar.gz
mdadm-353632d927d6e46282ef4f51d4ad17940a30cdf0.tar.xz
mdadm-353632d927d6e46282ef4f51d4ad17940a30cdf0.zip
Support restarting of a reshape on --assemble
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/Assemble.c b/Assemble.c
index cc906db..480c512 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -551,7 +551,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
int fd;
fd = dev_open(devices[chosen_drive].devname, O_RDWR|O_EXCL);
if (fd < 0) {
- fprintf(stderr, Name ": Could open %s for write - cannot Assemble array.\n",
+ fprintf(stderr, Name ": Could not open %s for write - cannot Assemble array.\n",
devices[chosen_drive].devname);
return 1;
}
@@ -564,6 +564,37 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
close(fd);
}
+ /* If we are in the middle of a reshape we may need to restore saved data
+ * that was moved aside due to the reshape overwriting live data
+ * The code of doing this lives in Grow.c
+ */
+ if (info.reshape_active) {
+ int err = 0;
+ int *fdlist = malloc(sizeof(int)* bestcnt);
+ for (i=0; i<bestcnt; i++) {
+ int j = best[i];
+ if (j >= 0) {
+ fdlist[i] = dev_open(devices[j].devname, O_RDWR|O_EXCL);
+ if (fdlist[i] < 0) {
+ fprintf(stderr, Name ": Could not open %s for write - cannot Assemble array.\n",
+ devices[j].devname);
+ err = 1;
+ break;
+ }
+ } else
+ fdlist[i] = -1;
+ }
+ if (!err)
+ err = Grow_restart(st, &info, fdlist, bestcnt);
+ while (i>0) {
+ i--;
+ if (fdlist[i]>=0) close(fdlist[i]);
+ }
+ if (err) {
+ fprintf(stderr, Name ": Failed to restore critical section for reshape, sorry.\n");
+ return err;
+ }
+ }
/* count number of in-sync devices according to the superblock.
* We must have this number to start the array without -s or -R
*/