From f2919e92d213feaad4b34ea7133bee6a8d27aed1 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Fri, 1 Oct 2010 21:16:42 +0200 Subject: [PATCH] --- yaml --- r: 213067 b: refs/heads/master c: c49c06e4960949a9bced708858433fcf6ca36a9c h: refs/heads/master i: 213065: 2e1f3c8dca9fdb0d69c4c0bbdd5dda1d3785ea27 213063: e66dc18835141b672f0355e00b1504c89ff0cc96 v: v3 --- [refs] | 2 +- trunk/block/blk-throttle.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index cf28bdc36a48..8c1d1aaeab87 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9355aede5a3c4975e0ba8bbfe2b9d1fd73308916 +refs/heads/master: c49c06e4960949a9bced708858433fcf6ca36a9c diff --git a/trunk/block/blk-throttle.c b/trunk/block/blk-throttle.c index c1bc1b6c887a..56ad4531b412 100644 --- a/trunk/block/blk-throttle.c +++ b/trunk/block/blk-throttle.c @@ -430,6 +430,7 @@ static bool tg_with_in_iops_limit(struct throtl_data *td, struct throtl_grp *tg, bool rw = bio_data_dir(bio); unsigned int io_allowed; unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; + u64 tmp; jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw]; @@ -439,7 +440,20 @@ static bool tg_with_in_iops_limit(struct throtl_data *td, struct throtl_grp *tg, jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice); - io_allowed = (tg->iops[rw] * jiffy_elapsed_rnd) / HZ; + /* + * jiffy_elapsed_rnd should not be a big value as minimum iops can be + * 1 then at max jiffy elapsed should be equivalent of 1 second as we + * will allow dispatch after 1 second and after that slice should + * have been trimmed. + */ + + tmp = (u64)tg->iops[rw] * jiffy_elapsed_rnd; + do_div(tmp, HZ); + + if (tmp > UINT_MAX) + io_allowed = UINT_MAX; + else + io_allowed = tmp; if (tg->io_disp[rw] + 1 <= io_allowed) { if (wait)