]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: handle degraded->normal transitions in set_disk
authorDan Williams <dan.j.williams@intel.com>
Fri, 25 Jul 2008 00:26:23 +0000 (17:26 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 25 Jul 2008 00:26:23 +0000 (17:26 -0700)
Removes the need for the call to ->set_array_state when sync_action
transitions from 'recover' to 'idle'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
monitor.c
super-intel.c

index 347cde79f78c96699729e126928d1298d81b7a10..7cce5a8b2f283eaf45d5f7c33e68fd293c9cf3a6 100644 (file)
--- 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) {
index 9c5252d0fe1cd85bb02917f9f2bdd4f86c945e38..618baf68800aa6f6dab39f47d4a120906b507185 100644 (file)
@@ -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)