X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=Grow.c;h=18056047819ad4d6affe74b42b7b950151bc2913;hb=af99d9ca67a4dc898e7be1d4a947800deec93c83;hp=c2eae32bbb5645fb0744cfc1f3544d047813d243;hpb=0aa389dc6232370241d6efa811e7fbc59c0dd2a7;p=thirdparty%2Fmdadm.git diff --git a/Grow.c b/Grow.c index c2eae32b..18056047 100644 --- a/Grow.c +++ b/Grow.c @@ -1,7 +1,7 @@ /* * mdadm - manage Linux "md" devices aka RAID arrays. * - * Copyright (C) 2001-2006 Neil Brown + * Copyright (C) 2001-2009 Neil Brown * * * This program is free software; you can redistribute it and/or modify @@ -19,12 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Neil Brown - * Email: - * Paper: Neil Brown - * School of Computer Science and Engineering - * The University of New South Wales - * Sydney, 2052 - * Australia + * Email: */ #include "mdadm.h" #include "dlink.h" @@ -69,7 +64,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 +391,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 +416,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; @@ -686,7 +681,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, } spares = sra->array.spare_disks; if (backup_file) { - fdlist[d] = open(backup_file, O_RDWR|O_CREAT|O_EXCL, 0600); + fdlist[d] = open(backup_file, O_RDWR|O_CREAT|O_EXCL, S_IRUSR | S_IWUSR); if (fdlist[d] < 0) { fprintf(stderr, Name ": %s: cannot create backup file %s: %s\n", devname, backup_file, strerror(errno)); @@ -720,7 +715,8 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, * a leading superblock 4K earlier. */ for (i=array.raid_disks; i= 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 +887,6 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt for (i=old_disks-(backup_file?1:0); i