blkio-throttle: Fix possible multiplication overflow in iops calculations
authorVivek Goyal <vgoyal@redhat.com>
Fri, 1 Oct 2010 19:16:42 +0000 (21:16 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 1 Oct 2010 19:16:42 +0000 (21:16 +0200)
commitc49c06e4960949a9bced708858433fcf6ca36a9c
tree071c65544a98b6b0b599896591855f8ac69ab79a
parent9355aede5a3c4975e0ba8bbfe2b9d1fd73308916
blkio-throttle: Fix possible multiplication overflow in iops calculations

o User can specify max iops value of 32bit (UINT_MAX), through cgroup
  interface. If a user has specified say 4294967294 (UNIT_MAX  - 2), then
  on 32bit platform, following multiplication can overflow.

  io_allowed = (tg->iops[rw] * jiffy_elapsed_rnd)

o Explicitly cast the multiplication to 64bit and then perform division and
  then check whether result is still great then UNINT_MAX.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
block/blk-throttle.c