diff options
author | NeilBrown <neilb@suse.de> | 2010-05-07 18:20:17 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-18 01:28:00 -0400 |
commit | af3a2cd6b8a479345786e7fe5e199ad2f6240e56 (patch) | |
tree | 10690853d80455e69bcc0d027ad6c8b9c7951332 /drivers/md/raid1.c | |
parent | 2dc40f80945ac3e5ec05c3a6c75baf09b13cee51 (diff) |
md: Fix read balancing in RAID1 and RAID10 on drives > 2TB
read_balance uses a "unsigned long" for a sector number which
will get truncated beyond 2TB.
This will cause read-balancing to be non-optimal, and can cause
data to be read from the 'wrong' branch during a resync. This has a
very small chance of returning wrong data.
Reported-by: Jordan Russell <jr-list-2010@quo.to>
Cc: stable@kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 1db02c4955a9..a9b9972ff703 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -418,7 +418,7 @@ static void raid1_end_write_request(struct bio *bio, int error) | |||
418 | */ | 418 | */ |
419 | static int read_balance(conf_t *conf, r1bio_t *r1_bio) | 419 | static int read_balance(conf_t *conf, r1bio_t *r1_bio) |
420 | { | 420 | { |
421 | const unsigned long this_sector = r1_bio->sector; | 421 | const sector_t this_sector = r1_bio->sector; |
422 | int new_disk = conf->last_used, disk = new_disk; | 422 | int new_disk = conf->last_used, disk = new_disk; |
423 | int wonly_disk = -1; | 423 | int wonly_disk = -1; |
424 | const int sectors = r1_bio->sectors; | 424 | const int sectors = r1_bio->sectors; |
@@ -434,7 +434,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) | |||
434 | retry: | 434 | retry: |
435 | if (conf->mddev->recovery_cp < MaxSector && | 435 | if (conf->mddev->recovery_cp < MaxSector && |
436 | (this_sector + sectors >= conf->next_resync)) { | 436 | (this_sector + sectors >= conf->next_resync)) { |
437 | /* Choose the first operation device, for consistancy */ | 437 | /* Choose the first operational device, for consistancy */ |
438 | new_disk = 0; | 438 | new_disk = 0; |
439 | 439 | ||
440 | for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); | 440 | for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); |