From ff94fb86fd22842c06e8fad08c27a4e365d7834a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 17 Nov 2009 13:15:33 +1100 Subject: Grow: various fixes to recent breakages. - I forgot to write the send backup-super-block on spares. - I wasn't adding the data_offset to an offset Signed-off-by: NeilBrown --- Grow.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Grow.c b/Grow.c index 36c35f9..7764bdb 100644 --- a/Grow.c +++ b/Grow.c @@ -381,7 +381,7 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int /* * When reshaping an array we might need to backup some data. * This is written to all spares with a 'super_block' describing it. - * The superblock goes 1K form the end of the used space on the + * The superblock goes 4K from the end of the used space on the * device. * It if written after the backup is complete. * It has the following structure. @@ -982,7 +982,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, char *dn = map_dev(sd->disk.major, sd->disk.minor, 1); fdlist[d] = dev_open(dn, O_RDWR); - offsets[d] = (sra->component_size - blocks - 8)*512; + offsets[d] = (sd->data_offset + sra->component_size - blocks - 8)*512; if (fdlist[d]<0) { fprintf(stderr, Name ": %s: cannot open component %s\n", devname, dn?dn:"-unknown"); @@ -1308,6 +1308,10 @@ int grow_backup(struct mdinfo *sra, lseek64(destfd[i], destoffsets[i] - 4096, 0); write(destfd[i], &bsb, 512); + if (destoffsets[i] > 4096) { + lseek64(destfd[i], destoffsets[i]+stripes*chunk*odata, 0); + write(destfd[i], &bsb, 512); + } fsync(destfd[i]); } @@ -1628,7 +1632,6 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt old_disks = cnt; for (i=old_disks-(backup_file?1:0); i