raid1/raid10: slow down resync if there is non-resync activity pending
[sfrench/cifs-2.6.git] / drivers / md / raid1.c
index a7f2b9c9f8a06fa84aa5f46d6c44c5760894502b..358a08e656f6ee949f0fe5033bdab09b835cd49b 100644 (file)
@@ -1474,8 +1474,8 @@ static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
         * if recovery is running, make sure it aborts.
         */
        set_bit(MD_RECOVERY_INTR, &mddev->recovery);
-       set_bit(MD_CHANGE_DEVS, &mddev->flags);
-       set_bit(MD_CHANGE_PENDING, &mddev->flags);
+       set_mask_bits(&mddev->flags, 0,
+                     BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING));
        printk(KERN_ALERT
               "md/raid1:%s: Disk failure on %s, disabling device.\n"
               "md/raid1:%s: Operation continuing on %d devices.\n",
@@ -2535,6 +2535,13 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
                return sync_blocks;
        }
 
+       /*
+        * If there is non-resync activity waiting for a turn, then let it
+        * though before starting on this new sync request.
+        */
+       if (conf->nr_waiting)
+               schedule_timeout_uninterruptible(1);
+
        /* we are incrementing sector_nr below. To be safe, we check against
         * sector_nr + two times RESYNC_SECTORS
         */