>On Thu, 28 Feb 2013 15:51:01 +0800 majianpeng <majianpeng@xxxxxxxxx> wrote: > >> For badsector,it took two steps:rewrite and reread.So for >> write-operation,it make no sense to rewrite after write-operation. > >Please please please please please try to explain yourself better. > Sorry for that. >This patch doesn't make any sense. The write succeeded. We set the MadeGood >flag so that later code will remove the block from the bad-block list. >There will be no re-read or re-write. > For a striep which contain badsector is doing write-operation. In analyse_stripe, it check badsector and set R5_ReadError. write--->MadeGood->clear badblock log. But it can't clear R5_ReadError flag. So it will exec those code in func handle_stripe: > /* If the failed drives are just a ReadError, then we might need > * to progress the repair/check process > */ > if (s.failed <= conf->max_degraded && !conf->mddev->ro) > for (i = 0; i < s.failed; i++) { > struct r5dev *dev = &sh->dev[s.failed_num[i]]; > if (test_bit(R5_ReadError, &dev->flags) > && !test_bit(R5_LOCKED, &dev->flags) > && test_bit(R5_UPTODATE, &dev->flags) > ) { > if (!test_bit(R5_ReWrite, &dev->flags)) { > set_bit(R5_Wantwrite, &dev->flags); > set_bit(R5_ReWrite, &dev->flags); > set_bit(R5_LOCKED, &dev->flags); > s.locked++; > } else { > /* let's read it back */ > set_bit(R5_Wantread, &dev->flags); > set_bit(R5_LOCKED, &dev->flags); > s.locked++; > } > } > } But the flag ReWrite can't set. So it do write-operatoin again.Then do read-operation. Thanks! Jianpeng Ma >NeilBrown > > >> >> Signed-off-by: Jianpeng Ma <majianpeng@xxxxxxxxx> >> --- >> drivers/md/raid5.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c >> index 19d77a0..59c0569 100644 >> --- a/drivers/md/raid5.c >> +++ b/drivers/md/raid5.c >> @@ -1921,8 +1921,10 @@ static void raid5_end_write_request(struct bio *bi, int error) >> &rdev->mddev->recovery); >> } else if (is_badblock(rdev, sh->sector, >> STRIPE_SECTORS, >> - &first_bad, &bad_sectors)) >> + &first_bad, &bad_sectors)) { >> set_bit(R5_MadeGood, &sh->dev[i].flags); >> + set_bit(R5_ReWrite, &sh->dev[i].flags); >> + } >> } >> rdev_dec_pending(rdev, conf->mddev); >> > >?韬{.n?????%??檩??w?{.n???{炳盯w???塄}?财??j:+v??????2??璀??摺?囤??z夸z罐?+?????w棹f