]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
ddf: fix up detection of failed/missing devices.
[thirdparty/mdadm.git] / super-ddf.c
index 93de75022d7626cad1d11b5785dba63a13a8b965..792936452dc55abc56fab9d76c630ce7a5d5f343 100644 (file)
@@ -3033,23 +3033,33 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
                        struct mdinfo *dev;
                        struct dl *d;
                        int stt;
+                       int pd;
 
                        if (vc->conf.phys_refnum[i] == 0xFFFFFFFF)
                                continue;
 
-                       for (d = ddf->dlist; d ; d=d->next)
-                               if (d->disk.refnum == vc->conf.phys_refnum[i])
+                       for (pd = __be16_to_cpu(ddf->phys->used_pdes);
+                            pd--;)
+                               if (ddf->phys->entries[pd].refnum
+                                   == vc->conf.phys_refnum[i])
                                        break;
-                       if (d == NULL)
-                               /* Haven't found that one yet, maybe there are others */
+                       if (pd < 0)
                                continue;
-                       stt = __be16_to_cpu(ddf->phys->entries[d->pdnum].state);
+
+                       stt = __be16_to_cpu(ddf->phys->entries[pd].state);
                        if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding))
                            != DDF_Online)
                                continue;
 
                        this->array.working_disks++;
 
+                       for (d = ddf->dlist; d ; d=d->next)
+                               if (d->disk.refnum == vc->conf.phys_refnum[i])
+                                       break;
+                       if (d == NULL)
+                               /* Haven't found that one yet, maybe there are others */
+                               continue;
+
                        dev = malloc(sizeof(*dev));
                        memset(dev, 0, sizeof(*dev));
                        dev->next = this->devs;