md/raid5: Fix rmw/rcw parametrization check
Commit 584acdd49cd2472ca0f5a06adbe979db82d0b4af (activate rmw feature) and
commit d06f191f8ecaef4d524e765fdb455f96392fbd42 (rmw_level) allow to set the
desired rmw/rcw handling for a raid456 device. For the corner case that IO
costs of rmw and rcw are equal setting PARITY_PREFER_RMW should favour rmw
over rcw. The implementation is slightly messed. Instead the default setting
PARITY_ENABLE_RMW already favours rmw. Fix that.
Signed-off-by: Markus Stockhausen <redacted>
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f8630c1..f94c389 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3564,7 +3564,7 @@ static void handle_stripe_dirtying(struct r5conf *conf,
/* Calculate the real rcw later - for now make it
* look like rcw is cheaper
*/
- rcw = 1; rmw = 2;
+ rcw = 1; rmw = 3;
pr_debug("force RCW rmw_level=%u, recovery_cp=%llu sh->sector=%llu\n",
conf->rmw_level, (unsigned long long)recovery_cp,
(unsigned long long)sh->sector);@@ -3584,7 +3584,9 @@ static void handle_stripe_dirtying(struct r5conf *conf,
}
pr_debug("for sector %llu, rmw=%d rcw=%d\n",
(unsigned long long)sh->sector, rmw, rcw);
- if ((rmw < rcw || (rmw == rcw && conf->rmw_level == PARITY_ENABLE_RMW)) && rmw > 0) {
+ if (rcw && conf->rmw_level == PARITY_PREFER_RMW)
+ rcw++;
+ if (rmw && rmw < rcw) {
/* prefer read-modify-write, but need to get some data */
if (conf->mddev->queue)
blk_add_trace_msg(conf->mddev->queue,@@ -3611,7 +3613,7 @@ static void handle_stripe_dirtying(struct r5conf *conf,
}
}
}
- if ((rcw < rmw || (rcw == rmw && conf->rmw_level != PARITY_ENABLE_RMW)) && rcw > 0) {
+ if (rcw && rcw <= rmw) {
/* want reconstruct write, but need to get some data */
int qread =0;
rcw = 0;