Skip to content

Commit

Permalink
md: raid5: avoid sector values going negative when testing reshape pr…
Browse files Browse the repository at this point in the history
…ogress.

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 <[email protected]>
  • Loading branch information
neilbrown committed May 26, 2009
1 parent b6a9ce6 commit 848b318
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 848b318

Please sign in to comment.