int must_sync;
                        int any_working;
                        int need_recover = 0;
-                       int need_replace = 0;
                        struct raid10_info *mirror = &conf->mirrors[i];
                        struct md_rdev *mrdev, *mreplace;
 
                            !test_bit(Faulty, &mrdev->flags) &&
                            !test_bit(In_sync, &mrdev->flags))
                                need_recover = 1;
-                       if (mreplace != NULL &&
-                           !test_bit(Faulty, &mreplace->flags))
-                               need_replace = 1;
+                       if (mreplace && test_bit(Faulty, &mreplace->flags))
+                               mreplace = NULL;
 
-                       if (!need_recover && !need_replace) {
+                       if (!need_recover && !mreplace) {
                                rcu_read_unlock();
                                continue;
                        }
                                rcu_read_unlock();
                                continue;
                        }
-                       if (mreplace && test_bit(Faulty, &mreplace->flags))
-                               mreplace = NULL;
                        /* Unless we are doing a full sync, or a replacement
                         * we only need to recover the block if it is set in
                         * the bitmap
                                bio = r10_bio->devs[1].repl_bio;
                                if (bio)
                                        bio->bi_end_io = NULL;
-                               /* Note: if need_replace, then bio
+                               /* Note: if replace is not NULL, then bio
                                 * cannot be NULL as r10buf_pool_alloc will
                                 * have allocated it.
                                 */
-                               if (!need_replace)
+                               if (!mreplace)
                                        break;
                                bio->bi_next = biolist;
                                biolist = bio;