diff options
author | NeilBrown <neilb@suse.de> | 2009-05-26 12:41:08 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-05-26 12:41:08 +1000 |
commit | 848b3182365fdf5a05bcd5ed949071cac2c894b3 (patch) | |
tree | cfb09457f8d8d582d443a92c2a47f1f9862a2036 | |
parent | b6a9ce688f613e2ee5f15e6720e0bb8520efc36e (diff) | |
download | op-kernel-dev-848b3182365fdf5a05bcd5ed949071cac2c894b3.zip op-kernel-dev-848b3182365fdf5a05bcd5ed949071cac2c894b3.tar.gz |
md: raid5: avoid sector values going negative when testing reshape progress.
As sector_t in unsigned, we cannot afford to let 'safepos' etc go
negative.
So replace
a -= b;
by
a -= min(b,a);
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/raid5.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 4616bc3..3c3626d 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -3811,13 +3811,13 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped safepos = conf->reshape_safe; sector_div(safepos, data_disks); if (mddev->delta_disks < 0) { - writepos -= reshape_sectors; + writepos -= min(reshape_sectors, writepos); readpos += reshape_sectors; safepos += reshape_sectors; } else { writepos += reshape_sectors; - readpos -= reshape_sectors; - safepos -= reshape_sectors; + readpos -= min(reshape_sectors, readpos); + safepos -= min(reshape_sectors, safepos); } /* 'writepos' is the most advanced device address we might write. |