Skip to content

Commit

Permalink
md/raid5: fix refcount problem when blocked_rdev is set.
Browse files Browse the repository at this point in the history
commit 43220aa
    md/raid5: fix a hang on device failure.

fixed a hang, but introduced a refcounting in-balance so
that if the presence of bad-blocks ever caused an rdev to
be 'blocked' we would increment the refcount on the rdev and
never decrement it.

So added the needed rdev_dec_pending when md_wait_for_blocked_rdev
is not called.

Reported-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Jul 3, 2012
1 parent 7c2c57c commit 5f066c6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -3588,8 +3588,18 @@ static void handle_stripe(struct stripe_head *sh)

finish:
/* wait for this device to become unblocked */
if (conf->mddev->external && unlikely(s.blocked_rdev))
md_wait_for_blocked_rdev(s.blocked_rdev, conf->mddev);
if (unlikely(s.blocked_rdev)) {
if (conf->mddev->external)
md_wait_for_blocked_rdev(s.blocked_rdev,
conf->mddev);
else
/* Internal metadata will immediately
* be written by raid5d, so we don't
* need to wait here.
*/
rdev_dec_pending(s.blocked_rdev,
conf->mddev);
}

if (s.handle_bad_blocks)
for (i = disks; i--; ) {
Expand Down

0 comments on commit 5f066c6

Please sign in to comment.