aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-07-27 21:39:23 -0400
committerNeilBrown <neilb@suse.de>2011-07-27 21:39:23 -0400
commitb84db560ead5417b5594349512baf8837959df4f (patch)
tree77f8cfe305a32ace5f4ead4eb820e3f9fa14ce67 /drivers/md/raid5.c
parent73e92e51b7969ef5477dd28fe2ae4d77675896f4 (diff)
md/raid5: Clear bad blocks on successful write.
On a successful write to a known bad block, flag the sh so that raid5d can remove the known bad block from the list. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 3fa3f20dc5f5..dbae459fb02d 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1675,6 +1675,8 @@ static void raid5_end_write_request(struct bio *bi, int error)
1675 raid5_conf_t *conf = sh->raid_conf; 1675 raid5_conf_t *conf = sh->raid_conf;
1676 int disks = sh->disks, i; 1676 int disks = sh->disks, i;
1677 int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags); 1677 int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags);
1678 sector_t first_bad;
1679 int bad_sectors;
1678 1680
1679 for (i=0 ; i<disks; i++) 1681 for (i=0 ; i<disks; i++)
1680 if (bi == &sh->dev[i].req) 1682 if (bi == &sh->dev[i].req)
@@ -1691,7 +1693,9 @@ static void raid5_end_write_request(struct bio *bi, int error)
1691 if (!uptodate) { 1693 if (!uptodate) {
1692 set_bit(WriteErrorSeen, &conf->disks[i].rdev->flags); 1694 set_bit(WriteErrorSeen, &conf->disks[i].rdev->flags);
1693 set_bit(R5_WriteError, &sh->dev[i].flags); 1695 set_bit(R5_WriteError, &sh->dev[i].flags);
1694 } 1696 } else if (is_badblock(conf->disks[i].rdev, sh->sector, STRIPE_SECTORS,
1697 &first_bad, &bad_sectors))
1698 set_bit(R5_MadeGood, &sh->dev[i].flags);
1695 1699
1696 rdev_dec_pending(conf->disks[i].rdev, conf->mddev); 1700 rdev_dec_pending(conf->disks[i].rdev, conf->mddev);
1697 1701
@@ -3078,6 +3082,13 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
3078 } else 3082 } else
3079 clear_bit(R5_WriteError, &dev->flags); 3083 clear_bit(R5_WriteError, &dev->flags);
3080 } 3084 }
3085 if (test_bit(R5_MadeGood, &dev->flags)) {
3086 if (!test_bit(Faulty, &rdev->flags)) {
3087 s->handle_bad_blocks = 1;
3088 atomic_inc(&rdev->nr_pending);
3089 } else
3090 clear_bit(R5_MadeGood, &dev->flags);
3091 }
3081 if (!test_bit(R5_Insync, &dev->flags)) { 3092 if (!test_bit(R5_Insync, &dev->flags)) {
3082 /* The ReadError flag will just be confusing now */ 3093 /* The ReadError flag will just be confusing now */
3083 clear_bit(R5_ReadError, &dev->flags); 3094 clear_bit(R5_ReadError, &dev->flags);
@@ -3340,6 +3351,12 @@ finish:
3340 md_error(conf->mddev, rdev); 3351 md_error(conf->mddev, rdev);
3341 rdev_dec_pending(rdev, conf->mddev); 3352 rdev_dec_pending(rdev, conf->mddev);
3342 } 3353 }
3354 if (test_and_clear_bit(R5_MadeGood, &dev->flags)) {
3355 rdev = conf->disks[i].rdev;
3356 rdev_clear_badblocks(rdev, sh->sector,
3357 STRIPE_SECTORS);
3358 rdev_dec_pending(rdev, conf->mddev);
3359 }
3343 } 3360 }
3344 3361
3345 if (s.ops_request) 3362 if (s.ops_request)