diff options
author | NeilBrown <neilb@suse.com> | 2015-07-17 12:06:02 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2015-08-31 19:37:33 +0200 |
commit | c5e19d906a658f27fa858b09a95d9551b1a69bd0 (patch) | |
tree | 4f24e56a076c2d544fbda272a85ba25e8d1e0242 /drivers/md/raid5.c | |
parent | a4a3d26d8757a30ae21724d8b0d79e00e113c38d (diff) | |
download | linux-c5e19d906a658f27fa858b09a95d9551b1a69bd0.tar.bz2 |
md: be careful when testing resync_max against curr_resync_completed.
While it generally shouldn't happen, it is not impossible for
curr_resync_completed to exceed resync_max.
This can particularly happen when reshaping RAID5 - the current
status isn't copied to curr_resync_completed promptly, so when it
is, it can exceed resync_max.
This happens when the reshape is 'frozen', resync_max is set low,
and reshape is re-enabled.
Taking a difference between two unsigned numbers is always dangerous
anyway, so add a test to behave correctly if
curr_resync_completed > resync_max
Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r-- | drivers/md/raid5.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 19bbdbe1a52f..1c27aa10f89c 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -5542,7 +5542,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, int *sk sector_nr += reshape_sectors; retn = reshape_sectors; finish: - if ((sector_nr - mddev->curr_resync_completed) * 2 + if (mddev->curr_resync_completed > mddev->resync_max || + (sector_nr - mddev->curr_resync_completed) * 2 >= mddev->resync_max - mddev->curr_resync_completed) { /* Cannot proceed until we've updated the superblock... */ wait_event(conf->wait_for_overlap, |