From e8bf7042ed064590abf44b61ad8d99b1592c0af4 Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Thu, 8 Apr 2010 16:56:02 -0400 Subject: Make Incremental container assembly behave like native array assembly Signed-off-by: Doug Ledford --- Assemble.c | 6 ++++-- Incremental.c | 34 +++++++++++++++++++++++----------- super-intel.c | 17 ++++++++++++++++- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Assemble.c b/Assemble.c index 1504f1f..d059155 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1327,8 +1327,10 @@ int assemble_container_content(struct supertype *st, int mdfd, content->text_version, content->uuid, chosen_name); - if (runstop > 0 || - (working + preexist) >= content->array.working_disks) { + if ((runstop > 0 && + (working + preexist) >= content->array.working_disks) || + (runstop == 0 && + (working + preexist) == content->array.raid_disks)) { int err; switch(content->array.level) { diff --git a/Incremental.c b/Incremental.c index d32a8e5..9d77d4d 100644 --- a/Incremental.c +++ b/Incremental.c @@ -424,20 +424,21 @@ int Incremental(char *devname, int verbose, int runstop, sysfs_uevent(&info, "change"); if (verbose >= 0) fprintf(stderr, Name - ": container %s now has %d devices\n", - chosen_name, info.array.working_disks); + ": container %s now has %d out of %d devices\n", + chosen_name, info.array.working_disks, + info.array.raid_disks); wait_for(chosen_name, mdfd); close(mdfd); - if (runstop < 0) - return 0; /* don't try to assemble */ - rv = Incremental(chosen_name, verbose, runstop, - NULL, homehost, require_homehost, autof); - if (rv == 1) - /* Don't fail the whole -I if a subarray didn't - * have enough devices to start yet + if (runstop > 0 || + info.array.working_disks == info.array.raid_disks) + /* The return value of our container assembly doesn't + * depend on whether or not subarrays assembled + * properly, so no need to preserve the return value + * here. */ - rv = 0; - return rv; + Incremental(chosen_name, verbose, runstop, NULL, + homehost, require_homehost, autof); + return 0; } avail = NULL; active_disks = count_active(st, mdfd, &avail, &info); @@ -666,6 +667,17 @@ int IncrementalScan(int verbose) if (mdfd < 0) continue; + if (strcmp("imsm",me->metadata) == 0) { + /* + * Just do a blind incremental assembly on the + * container. If there's anything to be started, + * we will, if it's already started, we'll silently + * exit, if there's a problem, incremental will + * catch it. + */ + Incremental(me->path, verbose, 1, NULL, "", 0, 1); + continue; + } if (ioctl(mdfd, GET_ARRAY_INFO, &array) == 0 || errno != ENODEV) { close(mdfd); diff --git a/super-intel.c b/super-intel.c index 999b970..7bcfcdb 100644 --- a/super-intel.c +++ b/super-intel.c @@ -1536,12 +1536,27 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info) if (super->current_vol >= 0) { getinfo_super_imsm_volume(st, info); return; + } else { + struct mdinfo vol_info; + + super->current_vol = 0; + getinfo_super_imsm_volume(st, &vol_info); + super->current_vol = -1; + info->array.raid_disks = vol_info.array.raid_disks; } /* Set raid_disks to zero so that Assemble will always pull in valid * spares - */ + * + * Note: my testing with assemble shows that it still works even + * when we set the raid_disks to a proper setting. However, without + * this it is impossible to tell when a container has the right + * number of disks to start cleanly without violating layering + * boundaries. So, not violating layering boundaries trumps spare + * disk issues. Doug Ledford + * info->array.raid_disks = 0; + */ info->array.level = LEVEL_CONTAINER; info->array.layout = 0; info->array.md_minor = -1; -- cgit