X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=Assemble.c;h=897c33f0261762c81fcd7dae133118debd92ff16;hb=8131b493df02ad22c8600f4c99d97003a807e5a7;hp=05558545ca08a8364bb4809c2bc2aefc4e027da1;hpb=7d99579f6a52fbf575e4707121ece51d0672277b;p=thirdparty%2Fmdadm.git diff --git a/Assemble.c b/Assemble.c index 05558545..897c33f0 100644 --- a/Assemble.c +++ b/Assemble.c @@ -31,7 +31,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, mddev_ident_t ident, char *conffile, - mddev_dev_t devlist, + mddev_dev_t devlist, char *backup_file, int readonly, int runstop, char *update, int verbose, int force) @@ -117,7 +117,6 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, unsigned int num_devs; mddev_dev_t tmpdev; struct mdinfo info; - struct mddev_ident_s ident2; char *avail; int nextspare = 0; @@ -215,11 +214,11 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, fprintf( stderr, Name ": no RAID superblock on %s\n", devname); } else { - tst->ss->getinfo_super(&info, &ident2, super); + tst->ss->getinfo_super(&info, super); } if (dfd >= 0) close(dfd); - if (ident->uuid_set && (!update && strcmp(update, "uuid")!= 0) && + if (ident->uuid_set && (!update || strcmp(update, "uuid")!= 0) && (!super || same_uuid(info.uuid, ident->uuid, tst->ss->swapuuid)==0)) { if ((inargv && verbose >= 0) || verbose > 0) fprintf(stderr, Name ": %s has wrong uuid.\n", @@ -227,7 +226,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, continue; } if (ident->name[0] && - (!super || strncmp(ident2.name, ident->name, 32)!=0)) { + (!super || strncmp(info.name, ident->name, 32)!=0)) { if ((inargv && verbose >= 0) || verbose > 0) fprintf(stderr, Name ": %s has wrong name.\n", devname); @@ -266,6 +265,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, free(first_super); return 1; } + + st = tst; /* commit to this format, if haven't already */ if (st->ss->compare_super(&first_super, super)) { fprintf(stderr, Name ": superblock on %s doesn't match others - assembly aborted\n", @@ -307,6 +308,10 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, devname); if (dfd >= 0) close(dfd); + + if (strcmp(update, "uuid")==0 && + ident->bitmap_fd) + bitmap_update_uuid(ident->bitmap_fd, info.uuid); } if (verbose > 0) @@ -372,7 +377,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, return 1; } - st->ss->getinfo_super(&info, &ident2, first_super); + st->ss->getinfo_super(&info, first_super); /* now we have some devices that might be suitable. * I wonder how many @@ -498,7 +503,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, fprintf(stderr, Name ": No suitable drives found for %s\n", mddev); return 1; } - st->ss->getinfo_super(&info, &ident2, super); + st->ss->getinfo_super(&info, super); 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, backup_file); + 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; + } + } +#endif /* count number of in-sync devices according to the superblock. * We must have this number to start the array without -s or -R */ @@ -589,8 +627,22 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, fprintf(stderr, Name ": SET_BITMAP_FILE failed.\n"); return 1; } + } else if (ident->bitmap_file) { + /* From config file */ + int bmfd = open(ident->bitmap_file, O_RDWR); + if (bmfd < 0) { + fprintf(stderr, Name ": Could not open bitmap file %s\n", + ident->bitmap_file); + return 1; + } + if (ioctl(mdfd, SET_BITMAP_FILE, bmfd) != 0) { + fprintf(stderr, Name ": Failed to set bitmapfile for %s\n", mddev); + close(bmfd); + return 1; + } + close(bmfd); } - + /* First, add the raid disks, but add the chosen one last */ for (i=0; i<= bestcnt; i++) { int j;