diff options
author | Filipe Manana <fdmanana@suse.com> | 2023-03-21 11:13:55 +0000 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-04-17 18:01:19 +0200 |
commit | 0e55a54502b977ded5fba30f8afdf450fdee94b7 (patch) | |
tree | d06914c0f9336e2ef34e871d7bb3c4cc26e38cc9 /fs/btrfs/space-info.c | |
parent | f4160ee8789806a74445db3592b08fdd8eceeea2 (diff) |
btrfs: add helper to calculate space for delayed references
Instead of duplicating the logic for calculating how much space is
required for a given number of delayed references, add an inline helper
to encapsulate that logic and use it everywhere we are calculating the
space required.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/space-info.c')
-rw-r--r-- | fs/btrfs/space-info.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index a2e14c410416..75e7fa337e66 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -553,21 +553,9 @@ static inline u64 calc_reclaim_items_nr(const struct btrfs_fs_info *fs_info, static inline u64 calc_delayed_refs_nr(const struct btrfs_fs_info *fs_info, u64 to_reclaim) { - u64 bytes; + const u64 bytes = btrfs_calc_delayed_ref_bytes(fs_info, 1); u64 nr; - bytes = btrfs_calc_insert_metadata_size(fs_info, 1); - /* - * We have to check the mount option here because we could be enabling - * the free space tree for the first time and don't have the compat_ro - * option set yet. - * - * We need extra reservations if we have the free space tree because - * we'll have to modify that tree as well. - */ - if (btrfs_test_opt(fs_info, FREE_SPACE_TREE)) - bytes *= 2; - nr = div64_u64(to_reclaim, bytes); if (!nr) nr = 1; |