ddf: fix up detection of failed/missing devices.

If a device hasn't been found yet we can still tell if it is
expected to be working, and we must to do to make sure
'working_disks' is correct.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-03-22 10:32:09 +11:00
parent b306624e2b
commit 7c19b781d5
1 changed files with 16 additions and 6 deletions

View File

@ -3033,22 +3033,32 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
struct mdinfo *dev; struct mdinfo *dev;
struct dl *d; struct dl *d;
int stt; int stt;
int pd;
if (vc->conf.phys_refnum[i] == 0xFFFFFFFF) if (vc->conf.phys_refnum[i] == 0xFFFFFFFF)
continue; continue;
for (pd = __be16_to_cpu(ddf->phys->used_pdes);
pd--;)
if (ddf->phys->entries[pd].refnum
== vc->conf.phys_refnum[i])
break;
if (pd < 0)
continue;
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) for (d = ddf->dlist; d ; d=d->next)
if (d->disk.refnum == vc->conf.phys_refnum[i]) if (d->disk.refnum == vc->conf.phys_refnum[i])
break; break;
if (d == NULL) if (d == NULL)
/* Haven't found that one yet, maybe there are others */ /* Haven't found that one yet, maybe there are others */
continue; continue;
stt = __be16_to_cpu(ddf->phys->entries[d->pdnum].state);
if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding))
!= DDF_Online)
continue;
this->array.working_disks++;
dev = malloc(sizeof(*dev)); dev = malloc(sizeof(*dev));
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));