md/raid5: Fix livelock when array is both resyncing and degraded.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / md / raid5.c
index 4daf5c03b33bfdc626d53e6015ccb7c565060117..1b6986ce5da9af6c4cc424c56b15c5ebe73f91ad 100644 (file)
@@ -2853,7 +2853,8 @@ static void handle_stripe_dirtying(struct r5conf *conf,
         * generate correct data from the parity.
         */
        if (conf->max_degraded == 2 ||
-           (recovery_cp < MaxSector && sh->sector >= recovery_cp)) {
+           (recovery_cp < MaxSector && sh->sector >= recovery_cp &&
+            s->failed == 0)) {
                /* Calculate the real rcw later - for now make it
                 * look like rcw is cheaper
                 */