diff options
author | NeilBrown <neilb@suse.de> | 2012-09-18 22:52:30 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-09-18 22:52:30 -0400 |
commit | e5c86471f933608db5d43679f84cb4346c32033e (patch) | |
tree | e596b35a134b9cc4e308f90090ecf9998a5b58a4 | |
parent | a852d7b8a0cf29499905c9243fa6d3fb93898b82 (diff) |
md/raid5: fix calculate of 'degraded' when a replacement becomes active.
When a replacement device becomes active, we mark the device that it
replaces as 'faulty' so that it can subsequently get removed.
However 'calc_degraded' only pays attention to the primary device, not
the replacement, so the array appears to become degraded, which is
wrong.
So teach 'calc_degraded' to consider any replacement if a primary
device is faulty.
This is suitable for -stable as an incorrect 'degraded' value can
confuse md and could lead to data corruption.
This is only relevant for 3.3 and later.
Cc: stable@vger.kernel.org
Reported-by: Robin Hill <robin@robinhill.me.uk>
Reported-by: John Drescher <drescherjm@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/raid5.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 380cb68856b..7031b865b3a 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -393,6 +393,8 @@ static int calc_degraded(struct r5conf *conf) | |||
393 | degraded = 0; | 393 | degraded = 0; |
394 | for (i = 0; i < conf->previous_raid_disks; i++) { | 394 | for (i = 0; i < conf->previous_raid_disks; i++) { |
395 | struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev); | 395 | struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev); |
396 | if (rdev && test_bit(Faulty, &rdev->flags)) | ||
397 | rdev = rcu_dereference(conf->disks[i].replacement); | ||
396 | if (!rdev || test_bit(Faulty, &rdev->flags)) | 398 | if (!rdev || test_bit(Faulty, &rdev->flags)) |
397 | degraded++; | 399 | degraded++; |
398 | else if (test_bit(In_sync, &rdev->flags)) | 400 | else if (test_bit(In_sync, &rdev->flags)) |
@@ -417,6 +419,8 @@ static int calc_degraded(struct r5conf *conf) | |||
417 | degraded2 = 0; | 419 | degraded2 = 0; |
418 | for (i = 0; i < conf->raid_disks; i++) { | 420 | for (i = 0; i < conf->raid_disks; i++) { |
419 | struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev); | 421 | struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev); |
422 | if (rdev && test_bit(Faulty, &rdev->flags)) | ||
423 | rdev = rcu_dereference(conf->disks[i].replacement); | ||
420 | if (!rdev || test_bit(Faulty, &rdev->flags)) | 424 | if (!rdev || test_bit(Faulty, &rdev->flags)) |
421 | degraded2++; | 425 | degraded2++; |
422 | else if (test_bit(In_sync, &rdev->flags)) | 426 | else if (test_bit(In_sync, &rdev->flags)) |