From: Neil Brown Date: Mon, 27 Mar 2006 04:14:43 +0000 (+0000) Subject: Put a 'canary' block in front of the backup X-Git-Tag: mdadm-2.4~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2efedc7bd23b4796fcf535cb28f796b235aff9ca;p=thirdparty%2Fmdadm.git Put a 'canary' block in front of the backup .. so corruptio can be detected. Signed-off-by: Neil Brown --- diff --git a/ChangeLog b/ChangeLog index c7722b0f..ade4debb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Changes Prior to 2.4 release + - Rewrite 'reshape' support including performing a backup + of the critical region for a raid5 growth, and restoring that + backup after a crash. + - Put a 'canary' at each end of the backup so a corruption + can be more easily detected. + Changes Prior to 2.3.1 release - Fixed -O2 compile so I could make and RPM. - Type cast number to be printed %llu so it compiles on 64bit diff --git a/Grow.c b/Grow.c index 736afa57..44329228 100644 --- a/Grow.c +++ b/Grow.c @@ -689,13 +689,32 @@ int Grow_reshape(char *devname, int fd, int quiet, spares = sra->spares; - /* Decide offset for the backup and llseek the spares */ + + memcpy(bsb.magic, "md_backup_data-1", 16); + st->ss->uuid_from_super((int*)&bsb.set_uuid, super); + bsb.mtime = __cpu_to_le64(time(0)); + bsb.arraystart = 0; + bsb.length = __cpu_to_le64(last_block); + + /* Decide offset for the backup, llseek the spares, and write + * a leading superblock 4K earlier. + */ for (i=array.raid_disks; icomponent_size - last_block - 8; - if (lseek64(fdlist[i], offsets[i]<<9, 0) != offsets[i]<<9) { + if (lseek64(fdlist[i], (offsets[i]<<9) - 4096, 0) + != (offsets[i]<<9) - 4096) { fprintf(stderr, Name ": could not seek...\n"); goto abort; } + memset(buf, 0, sizeof(buf)); + bsb.devstart = __cpu_to_le64(offsets[i]); + bsb.sb_csum = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb)); + memcpy(buf, &bsb, sizeof(bsb)); + if (write(fdlist[i], buf, 4096) != 4096) { + fprintf(stderr, Name ": could not write leading superblock\n"); + goto abort; + } } array.level = nlevel; array.raid_disks = ndisks; @@ -728,12 +747,7 @@ int Grow_reshape(char *devname, int fd, int quiet, devname); goto abort_resume; } - /* FIXME write superblocks */ - memcpy(bsb.magic, "md_backup_data-1", 16); - st->ss->uuid_from_super((int*)&bsb.set_uuid, super); - bsb.mtime = __cpu_to_le64(time(0)); - bsb.arraystart = 0; - bsb.length = __cpu_to_le64(last_block); + for (i=odisks; iarray.raid_disks);