Skip to content

Commit 7471fb7

Browse files
NeilBrownshligit
authored andcommitted
md/raid6: Fix anomily when recovering a single device in RAID6.
When recoverying a single missing/failed device in a RAID6, those stripes where the Q block is on the missing device are handled a bit differently. In these cases it is easy to check that the P block is correct, so we do. This results in the P block be destroy. Consequently the P block needs to be read a second time in order to compute Q. This causes lots of seeks and hurts performance. It shouldn't be necessary to re-read P as it can be computed from the DATA. But we only compute blocks on missing devices, since c337869 ("md: do not compute parity unless it is on a failed drive"). So relax the change made in that commit to allow computing of the P block in a RAID6 which it is the only missing that block. This makes RAID6 recovery run much faster as the disk just "before" the recovering device is no longer seeking back-and-forth. Reported-by-tested-by: Brad Campbell <lists2009@fnarfbargle.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 583da48 commit 7471fb7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/md/raid5.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3619,9 +3619,20 @@ static int fetch_block(struct stripe_head *sh, struct stripe_head_state *s,
36193619
BUG_ON(test_bit(R5_Wantcompute, &dev->flags));
36203620
BUG_ON(test_bit(R5_Wantread, &dev->flags));
36213621
BUG_ON(sh->batch_head);
3622+
3623+
/*
3624+
* In the raid6 case if the only non-uptodate disk is P
3625+
* then we already trusted P to compute the other failed
3626+
* drives. It is safe to compute rather than re-read P.
3627+
* In other cases we only compute blocks from failed
3628+
* devices, otherwise check/repair might fail to detect
3629+
* a real inconsistency.
3630+
*/
3631+
36223632
if ((s->uptodate == disks - 1) &&
3633+
((sh->qd_idx >= 0 && sh->pd_idx == disk_idx) ||
36233634
(s->failed && (disk_idx == s->failed_num[0] ||
3624-
disk_idx == s->failed_num[1]))) {
3635+
disk_idx == s->failed_num[1])))) {
36253636
/* have disk failed, and we're requested to fetch it;
36263637
* do compute it
36273638
*/

0 commit comments

Comments
 (0)