Skip to content

Commit 45a4d8f

Browse files
ChangSyun Pengliu-song-6
authored andcommitted
md/raid5: Allow degraded raid6 to do rmw
Degraded raid6 always do reconstruct-write now. With raid6 xor supported, we can do rmw in degraded raid6. This patch can reduce many read IOs to improve performance. If the failed disk is P, Q or the disk we want to write to, we may need to do reconstruct-write in max degraded raid6. In this situation we can not read enough data from handle_stripe_dirtying() so we have to set force_rcw in handle_stripe_fill() to read all data. Reviewed-by: Alex Wu <alexwu@synology.com> Reviewed-by: BingJing Chang <bingjingc@synology.com> Reviewed-by: Danny Shih <dannyshih@synology.com> Signed-off-by: ChangSyun Peng <allenpeng@synology.com> Signed-off-by: Song Liu <songliubraving@fb.com>
1 parent a1c6ae3 commit 45a4d8f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/md/raid5.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,6 +3557,7 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
35573557
struct r5dev *fdev[2] = { &sh->dev[s->failed_num[0]],
35583558
&sh->dev[s->failed_num[1]] };
35593559
int i;
3560+
bool force_rcw = (sh->raid_conf->rmw_level == PARITY_DISABLE_RMW);
35603561

35613562

35623563
if (test_bit(R5_LOCKED, &dev->flags) ||
@@ -3615,18 +3616,27 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
36153616
* devices must be read.
36163617
*/
36173618
return 1;
3619+
3620+
if (s->failed >= 2 &&
3621+
(fdev[i]->towrite ||
3622+
s->failed_num[i] == sh->pd_idx ||
3623+
s->failed_num[i] == sh->qd_idx) &&
3624+
!test_bit(R5_UPTODATE, &fdev[i]->flags))
3625+
/* In max degraded raid6, If the failed disk is P, Q,
3626+
* or we want to read the failed disk, we need to do
3627+
* reconstruct-write.
3628+
*/
3629+
force_rcw = true;
36183630
}
36193631

3620-
/* If we are forced to do a reconstruct-write, either because
3621-
* the current RAID6 implementation only supports that, or
3622-
* because parity cannot be trusted and we are currently
3623-
* recovering it, there is extra need to be careful.
3632+
/* If we are forced to do a reconstruct-write, because parity
3633+
* cannot be trusted and we are currently recovering it, there
3634+
* is extra need to be careful.
36243635
* If one of the devices that we would need to read, because
36253636
* it is not being overwritten (and maybe not written at all)
36263637
* is missing/faulty, then we need to read everything we can.
36273638
*/
3628-
if (sh->raid_conf->level != 6 &&
3629-
sh->raid_conf->rmw_level != PARITY_DISABLE_RMW &&
3639+
if (!force_rcw &&
36303640
sh->sector < sh->raid_conf->mddev->recovery_cp)
36313641
/* reconstruct-write isn't being forced */
36323642
return 0;

0 commit comments

Comments
 (0)