summaryrefslogtreecommitdiff
path: root/Grow.c
diff options
context:
space:
mode:
authormartin f. krafft <madduck@debian.org>2009-07-20 15:43:15 +0200
committermartin f. krafft <madduck@debian.org>2009-07-20 15:43:15 +0200
commit10802ab98243de8463be354cce22068046278e16 (patch)
treee5fb289354743317f582c2c0eba0daf52d36119f /Grow.c
parent725ef18c4ca5e77a018f9bd726c189494f0c517a (diff)
parent7b0e1cec677583cd35f1c10d3d053e9ef3168eeb (diff)
merge experimental branch into master for unstable upload
Diffstat (limited to 'Grow.c')
-rw-r--r--Grow.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/Grow.c b/Grow.c
index a8194bf0..15cec5f1 100644
--- a/Grow.c
+++ b/Grow.c
@@ -69,7 +69,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
return 1;
}
- nfd = open(newdev, O_RDWR|O_EXCL);
+ nfd = open(newdev, O_RDWR|O_EXCL|O_DIRECT);
if (nfd < 0) {
fprintf(stderr, Name ": cannot open %s\n", newdev);
return 1;
@@ -396,7 +396,8 @@ struct mdp_backup_super {
__u64 arraystart;
__u64 length;
__u32 sb_csum; /* csum of preceeding bytes. */
-};
+ __u8 pad[512-68];
+} __attribute__((aligned(512))) bsb;
int bsb_csum(char *buf, int len)
{
@@ -420,7 +421,6 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
struct mdu_array_info_s array;
char *c;
- struct mdp_backup_super bsb;
struct supertype *st;
int nlevel, olevel;
@@ -720,7 +720,8 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
* a leading superblock 4K earlier.
*/
for (i=array.raid_disks; i<d; i++) {
- char buf[4096];
+ char abuf[4096+512];
+ char *buf = (char*)(((unsigned long)abuf+511)& ~511);
if (i==d-1 && backup_file) {
/* This is the backup file */
offsets[i] = 8;
@@ -731,7 +732,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
fprintf(stderr, Name ": could not seek...\n");
goto abort;
}
- memset(buf, 0, sizeof(buf));
+ memset(buf, 0, 4096);
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));
@@ -793,7 +794,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
if (lseek64(fdlist[i], (offsets[i]+last_block)<<9, 0) < 0 ||
write(fdlist[i], &bsb, sizeof(bsb)) != sizeof(bsb) ||
fsync(fdlist[i]) != 0) {
- fprintf(stderr, Name ": %s: fail to save metadata for critical region backups.\n",
+ fprintf(stderr, Name ": %s: failed to save metadata for critical region backups.\n",
devname);
goto abort_resume;
}
@@ -808,12 +809,21 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
/* wait for reshape to pass the critical region */
while(1) {
unsigned long long comp;
+
if (sysfs_get_ll(sra, NULL, "sync_completed", &comp)<0) {
sleep(5);
break;
}
if (comp >= nstripe)
break;
+ if (comp == 0) {
+ /* Maybe it finished already */
+ char action[20];
+ if (sysfs_get_str(sra, NULL, "sync_action",
+ action, 20) > 0 &&
+ strncmp(action, "reshape", 7) != 0)
+ break;
+ }
sleep(1);
}
@@ -882,7 +892,6 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
for (i=old_disks-(backup_file?1:0); i<cnt; i++) {
struct mdinfo dinfo;
- struct mdp_backup_super bsb;
char buf[4096];
int fd;