]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: scrub: replace max_t()/min_t() with clamp() in scrub_throttle_dev_io()
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 1 Sep 2025 15:01:44 +0000 (17:01 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:16 +0000 (08:49 +0200)
commita7f3dfb8293c4cee99743132d69863a92e8f4875
tree5540fb6bbcf909ccf9d31253cae7153069ac12a7
parent17dc82dc1e77a6fce07252ce894748190d1487d0
btrfs: scrub: replace max_t()/min_t() with clamp() in scrub_throttle_dev_io()

Replace max_t() followed by min_t() with a single clamp().

As was pointed by David Laight in
https://lore.kernel.org/linux-btrfs/20250906122458.75dfc8f0@pumpkin/
the calculation may overflow u32 when the input value is too large, so
clamp_t() is not used.  In practice the expected values are in range of
megabytes to gigabytes (throughput limit) so the bug would not happen.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: David Sterba <dsterba@suse.com>
[ Use clamp() and add explanation. ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c