On Mon, 02 Jul 2012 09:08:41 +0800 Shaohua Li wrote: > Currently the sequential read detection is global wide. It's natural to make it > per disk based, which can improve the detection for concurrent multiple > sequential reads. And next patch will make SSD read balance not use distance > based algorithm, where this change help detect truly sequential read for SSD. > > Signed-off-by: Shaohua Li > --- > drivers/md/raid1.c | 29 ++++++----------------------- > drivers/md/raid1.h | 11 +++++------ > 2 files changed, 11 insertions(+), 29 deletions(-) > > Index: linux/drivers/md/raid1.c > =================================================================== > --- linux.orig/drivers/md/raid1.c 2012-06-28 10:44:47.550666575 +0800 > +++ linux/drivers/md/raid1.c 2012-06-28 12:01:03.513137377 +0800 > @@ -483,7 +483,6 @@ static int read_balance(struct r1conf *c > const sector_t this_sector = r1_bio->sector; > int sectors; > int best_good_sectors; > - int start_disk; > int best_disk; > int i; > sector_t best_dist; > @@ -503,20 +502,17 @@ static int read_balance(struct r1conf *c > best_good_sectors = 0; > > if (conf->mddev->recovery_cp < MaxSector && > - (this_sector + sectors >= conf->next_resync)) { > + (this_sector + sectors >= conf->next_resync)) > choose_first = 1; > - start_disk = 0; > - } else { > + else > choose_first = 0; > - start_disk = conf->last_used; > - } > > for (i = 0 ; i < conf->raid_disks * 2 ; i++) { > sector_t dist; > sector_t first_bad; > int bad_sectors; > > - int disk = start_disk + i; > + int disk = i; > if (disk >= conf->raid_disks) > disk -= conf->raid_disks; One last little change please. Could you make that loop: for (disk = 0; disk < conf->raid_disks * 2; disk++) and remote the 'if' statement that wraps 'disk' back to zero when it gets too big (which is buggy and has been fixed in my for-next). With that change I'll take the patch. Thanks, NeilBrown