Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176525
b: refs/heads/master
c: 87968dd
h: refs/heads/master
i:
  176523: 1814a37
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Dec 10, 2009
1 parent 93ea5f2 commit 14b437c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0f398a8403e31c737b429fddc3850093d0bf58d0
refs/heads/master: 87968ddd2f3be1c21b932cac30157a83a1c4f935
22 changes: 15 additions & 7 deletions trunk/drivers/md/dm-raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ static void set_default_mirror(struct mirror *m)
atomic_set(&ms->default_mirror, m - m0);
}

static struct mirror *get_valid_mirror(struct mirror_set *ms)
{
struct mirror *m;

for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
if (!atomic_read(&m->error_count))
return m;

return NULL;
}

/* fail_mirror
* @m: mirror device to fail
* @error_type: one of the enum's, DM_RAID1_*_ERROR
Expand Down Expand Up @@ -226,13 +237,10 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
goto out;
}

for (new = ms->mirror; new < ms->mirror + ms->nr_mirrors; new++)
if (!atomic_read(&new->error_count)) {
set_default_mirror(new);
break;
}

if (unlikely(new == ms->mirror + ms->nr_mirrors))
new = get_valid_mirror(ms);
if (new)
set_default_mirror(new);
else
DMWARN("All sides of mirror have failed.");

out:
Expand Down

0 comments on commit 14b437c

Please sign in to comment.