From 353632d927d6e46282ef4f51d4ad17940a30cdf0 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 20 Mar 2006 03:17:31 +0000 Subject: Support restarting of a reshape on --assemble Signed-off-by: Neil Brown --- Assemble.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'Assemble.c') 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= 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 */ -- cgit