aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2015-02-01 19:49:10 -0500
committerNeilBrown <neilb@suse.de>2015-02-03 16:35:51 -0500
commita9d56950f763fa3e9d831541e62d223197d2ff60 (patch)
tree10e6bf867b7a1c9faf93e6d801610a3a4be8fbae /drivers/md/raid5.c
parenta79cfe12c619aa0fc401f9148d78faa6fc61a331 (diff)
md/raid5: need_this_block: start simplifying the last two conditions.
Both the last two cases are only relevant if something has failed and something needs to be written (but not over-written), and if it is OK to pre-read blocks at this point. So factor out those tests and explain them. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 21c1e796a0d6..bb42551c1a42 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2930,16 +2930,34 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
2930 */ 2930 */
2931 return 1; 2931 return 1;
2932 2932
2933 /* Sometimes neither read-modify-write nor reconstruct-write
2934 * cycles can work. In those cases we read every block we
2935 * can. Then the parity-update is certain to have enough to
2936 * work with.
2937 * This can only be a problem when we need to write something,
2938 * and some device has failed. If either of those tests
2939 * fail we need look no further.
2940 */
2941 if (!s->failed || !s->to_write)
2942 return 0;
2943
2944 if (test_bit(R5_Insync, &dev->flags) &&
2945 !test_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
2946 /* Pre-reads at not permitted until after short delay
2947 * to gather multiple requests. However if this
2948 * device is no Insync, the block could only be be computed
2949 * and there is no need to delay that.
2950 */
2951 return 0;
2933 if ( 2952 if (
2934 (sh->raid_conf->level <= 5 && s->failed && fdev[0]->towrite && 2953 (sh->raid_conf->level <= 5 && fdev[0]->towrite &&
2935 (!test_bit(R5_Insync, &dev->flags) || test_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) &&
2936 !test_bit(R5_OVERWRITE, &fdev[0]->flags)) || 2954 !test_bit(R5_OVERWRITE, &fdev[0]->flags)) ||
2937 ((sh->raid_conf->level == 6 || 2955 ((sh->raid_conf->level == 6 ||
2938 sh->sector >= sh->raid_conf->mddev->recovery_cp) 2956 sh->sector >= sh->raid_conf->mddev->recovery_cp)
2939 && s->failed && s->to_write && 2957 &&
2940 (s->to_write - s->non_overwrite < 2958 (s->to_write - s->non_overwrite <
2941 sh->raid_conf->raid_disks - sh->raid_conf->max_degraded) && 2959 sh->raid_conf->raid_disks - sh->raid_conf->max_degraded)
2942 (!test_bit(R5_Insync, &dev->flags) || test_bit(STRIPE_PREREAD_ACTIVE, &sh->state)))) 2960 ))
2943 return 1; 2961 return 1;
2944 return 0; 2962 return 0;
2945} 2963}