From: Zizhi Wo Commit bb8d5587bdc3 ("blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative") changed the type of "io_allowed" and "bytes_allowed", and added "io_allowed > 0" and "bytes_allowed > 0" checks to handle the case where carryover_ios/bytes could be negative. Since commit 6cc477c36875 ("blk-throttle: carry over directly") removed the "carryover" fields, the allowed values are now computed solely by calculate_io_allowed() and calculate_bytes_allowed(), which always return non-negative results. The extra checks are therefore no longer necessary. Remove the now-unnecessary "> 0" checks and restore the types of "io_allowed" and "bytes_allowed" to unsigned to match the return types of the corresponding calculate functions. Signed-off-by: Zizhi Wo --- block/blk-throttle.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 97188a795848..b82da0dfa8e8 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -760,7 +760,7 @@ static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio u32 iops_limit) { bool rw = bio_data_dir(bio); - int io_allowed; + unsigned int io_allowed; unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; jiffy_elapsed = jiffies - tg->slice_start[rw]; @@ -768,7 +768,7 @@ static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio /* Round up to the next throttle slice, wait time must be nonzero */ jiffy_elapsed_rnd = roundup(jiffy_elapsed + 1, DFL_THROTL_SLICE); io_allowed = calculate_io_allowed(iops_limit, jiffy_elapsed_rnd); - if (io_allowed > 0 && tg->io_disp[rw] + 1 <= io_allowed) + if (tg->io_disp[rw] + 1 <= io_allowed) return 0; /* Calc approx time to dispatch */ @@ -783,8 +783,7 @@ static unsigned long tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, u64 bps_limit) { bool rw = bio_data_dir(bio); - long long bytes_allowed; - u64 extra_bytes; + u64 bytes_allowed, extra_bytes; unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; unsigned int bio_size = throtl_bio_data_size(bio); @@ -796,9 +795,7 @@ static unsigned long tg_within_bps_limit(struct throtl_grp *tg, struct bio *bio, jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, DFL_THROTL_SLICE); bytes_allowed = calculate_bytes_allowed(bps_limit, jiffy_elapsed_rnd); - /* Need to consider the case of bytes_allowed overflow. */ - if ((bytes_allowed > 0 && tg->bytes_disp[rw] + bio_size <= bytes_allowed) - || bytes_allowed < 0) + if (tg->bytes_disp[rw] + bio_size <= bytes_allowed) return 0; /* Calc approx time to dispatch */ -- 2.39.2