Re: [PATCH 02/12] btrfs: add bps discard rate limit for async discard

David Sterba
2020-01-03T14:40:33Z

On Thu, Jan 02, 2020 at 04:26:36PM -0500, Dennis Zhou wrote:
> + */
> + if (kbps_limit && discard_ctl->prev_discard) {
> + u64 bps_limit = ((u64)kbps_limit) * SZ_1K;
> + u64 bps_delay = div64_u64(discard_ctl->prev_discard *
> + MSEC_PER_SEC, bps_limit);

I hoped we can get rid of the 64bit division when the kbps is u32 but I
don't think it's necessary, bytes as units of the calculation are fine.

> +
> + delay = max(delay, msecs_to_jiffies(bps_delay));
> + }