Commit 849815fe007950418ee816d1e8c7c6ce26233a07

Authored by NeilBrown
Committed by Greg Kroah-Hartman
1 parent 4d57fec84b

md/raid1: be more cautious where we read-balance during resync.

commit c6d119cf1b5a778e9ed60a006e2a434fcc4471a2 upstream.

commit 79ef3a8aa1cb1523cc231c9a90a278333c21f761 made
it possible for reads to happen concurrently with resync.
This means that we need to be more careful where read_balancing
is allowed during resync - we can no longer be sure that any
resync that has already started will definitely finish.

So keep read_balancing to before recovery_cp, which is conservative
but safe.

This bug makes it possible to read from a device that doesn't
have up-to-date data, so it can cause data corruption.
So it is suitable for any kernel since 3.11.

Fixes: 79ef3a8aa1cb1523cc231c9a90a278333c21f761
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 1 additions and 5 deletions Side-by-side Diff

... ... @@ -540,11 +540,7 @@
540 540 has_nonrot_disk = 0;
541 541 choose_next_idle = 0;
542 542  
543   - if (conf->mddev->recovery_cp < MaxSector &&
544   - (this_sector + sectors >= conf->next_resync))
545   - choose_first = 1;
546   - else
547   - choose_first = 0;
  543 + choose_first = (conf->mddev->recovery_cp < this_sector + sectors);
548 544  
549 545 for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) {
550 546 sector_t dist;