From 5802a8118e447833749cbf0fe7b909f3c7d8349d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 24 Jul 2008 17:26:23 -0700 Subject: [PATCH] imsm: handle degraded->normal transitions in set_disk Removes the need for the call to ->set_array_state when sync_action transitions from 'recover' to 'idle'. Signed-off-by: Dan Williams --- monitor.c | 1 - super-intel.c | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/monitor.c b/monitor.c index 347cde79..7cce5a8b 100644 --- a/monitor.c +++ b/monitor.c @@ -277,7 +277,6 @@ static int read_and_act(struct active_array *a) if (! (mdi->curr_state & DS_INSYNC)) check_degraded = 1; } - a->container->ss->set_array_state(a, 0); } for (mdi = a->info.devs ; mdi ; mdi = mdi->next) { diff --git a/super-intel.c b/super-intel.c index 9c5252d0..618baf68 100644 --- a/super-intel.c +++ b/super-intel.c @@ -1865,26 +1865,37 @@ static void imsm_set_disk(struct active_array *a, int n, int state) disk = get_imsm_disk(super->mpb, get_imsm_disk_idx(map, n)); - /* check if we have seen this failure before */ + /* check for new failures */ status = __le32_to_cpu(disk->status); if ((state & DS_FAULTY) && !(status & FAILED_DISK)) { status |= FAILED_DISK; disk->status = __cpu_to_le32(status); new_failure = 1; + super->updates_pending++; } - /** - * the number of failures have changed, count up 'failed' to determine + /* the number of failures have changed, count up 'failed' to determine * degraded / failed status */ if (new_failure && map->map_state != IMSM_T_STATE_FAILED) failed = imsm_count_failed(super->mpb, map); + /* determine map_state based on failed or in_sync count */ if (failed) map->map_state = imsm_check_degraded(super->mpb, inst, failed); + else if (map->map_state == IMSM_T_STATE_DEGRADED) { + struct mdinfo *d; + int working = 0; - if (new_failure) - super->updates_pending++; + for (d = a->info.devs ; d ; d = d->next) + if (d->curr_state & DS_INSYNC) + working++; + + if (working == a->info.array.raid_disks) { + map->map_state = IMSM_T_STATE_NORMAL; + super->updates_pending++; + } + } } static int store_imsm_mpb(int fd, struct intel_super *super) -- 2.39.2