From 83b6208e890f29115c56a252de82dfd7c50488d0 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 23 May 2006 06:33:28 +0000 Subject: When assembly arrays using incomplete detail, prefer arrays built for this host. i.e. if assembling with --name or --super-minor, then if we find two different arrays with the same apparent identity, and one was built for 'this' host, then prefer that one instead of giving up in disgust. Signed-off-by: Neil Brown --- Assemble.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'Assemble.c') diff --git a/Assemble.c b/Assemble.c index ecee624..4516b62 100644 --- a/Assemble.c +++ b/Assemble.c @@ -277,9 +277,11 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, continue; } - /* If we are this far, then we are commited to this device. + /* If we are this far, then we are nearly commited to this device. * If the super_block doesn't exist, or doesn't match others, - * then we cannot continue + * then we probably cannot continue + * However if one of the arrays is for the homehost, and + * the other isn't that can disambiguate. */ if (!super) { @@ -289,9 +291,37 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, return 1; } - - st = tst; /* commit to this format, if haven't already */ - if (st->ss->compare_super(&first_super, super)) { + if (st == NULL) + st = tst; + if (st->ss != tst->ss || + st->minor_version != tst->minor_version || + st->ss->compare_super(&first_super, super) != 0) { + /* Some mismatch. If exactly one array matches this host, + * we can resolve on that one + */ + if (homehost) { + int first = st->ss->match_home(first_super, homehost); + int last = tst->ss->match_home(super, homehost); + if (first+last == 1) { + /* We can do something */ + if (first) {/* just ignore this one */ + if ((inargv && verbose >= 0) || verbose > 0) + fprintf(stderr, Name ": %s misses out due to wrong homehost\n", + devname); + continue; + } else { /* reject all those sofar */ + mddev_dev_t td; + if ((inargv && verbose >= 0) || verbose > 0) + fprintf(stderr, Name ": %s overrides previous devices due to good homehost\n", + devname); + for (td=devlist; td != tmpdev; td=td->next) + if (td->used == 1) + td->used = 0; + tmpdev->used = 1; + continue; + } + } + } fprintf(stderr, Name ": superblock on %s doesn't match others - assembly aborted\n", devname); free(super); -- cgit