Re: [PATCH] blk-throttle: fix divide-by-zero on legacy iops limit of 0
From: David Laight
Date: Wed Jul 15 2026 - 11:02:47 EST
On Wed, 15 Jul 2026 20:44:19 +0800
Tao Cui <cui.tao@xxxxxxxxx> wrote:
> 在 2026/7/14 19:37, David Laight 写道:
...
> >> tg_update_slice(tg, rw);
> >> @@ -1386,7 +1391,8 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of,
> >> if (is_u64)
> >> *(u64 *)((void *)tg + of_cft(of)->private) = v;
> >> else
> >> - *(unsigned int *)((void *)tg + of_cft(of)->private) = v;
> >> + *(unsigned int *)((void *)tg + of_cft(of)->private) =
> >> + min_t(u64, v, UINT_MAX);
> >
> > The LHS casts look horrid - there has to be a nicer way to do that.
> >
> > And you don't need min_t() a plain min() will be fine.
> >
> Hi David,
>
> Both done in v2 — introduced a void *field local so the writes read
> *(u64 *)field / *(unsigned int *)field, and switched to
> min(v, (u64)UINT_MAX).
You don't need the cast either.
David
>
> Thanks,
> Tao
> > David
> >
> >
> >
> >>
> >> tg_conf_updated(tg, false);
> >> ret = 0;
> >
>