diff options
author | Nikolay Borisov <nborisov@suse.com> | 2021-01-11 11:58:11 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-02-08 22:58:51 +0100 |
commit | 9db4dc241e87fccd8301357d5ef908f40b50f2e3 (patch) | |
tree | cee9af39a3bc30b46e0952ccd696bf170d1018db /fs/btrfs/space-info.c | |
parent | btrfs: send: remove stale code when checking for shared extents (diff) | |
download | linux-9db4dc241e87fccd8301357d5ef908f40b50f2e3.tar.xz linux-9db4dc241e87fccd8301357d5ef908f40b50f2e3.zip |
btrfs: make btrfs_start_delalloc_root's nr argument a long
It's currently u64 which gets instantly translated either to LONG_MAX
(if U64_MAX is passed) or cast to an unsigned long (which is in fact,
wrong because writeback_control::nr_to_write is a signed, long type).
Just convert the function's argument to be long time which obviates the
need to manually convert u64 value to a long. Adjust all call sites
which pass U64_MAX to pass LONG_MAX. Finally ensure that in
shrink_delalloc the u64 is converted to a long without overflowing,
resulting in a negative number.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to '')
-rw-r--r-- | fs/btrfs/space-info.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index e8347461c8dd..84fb94e78a8f 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -532,7 +532,8 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, loops = 0; while ((delalloc_bytes || dio_bytes) && loops < 3) { - u64 nr_pages = min(delalloc_bytes, to_reclaim) >> PAGE_SHIFT; + u64 temp = min(delalloc_bytes, to_reclaim) >> PAGE_SHIFT; + long nr_pages = min_t(u64, temp, LONG_MAX); btrfs_start_delalloc_roots(fs_info, nr_pages, true); |