diff options
author | Filipe Manana <fdmanana@suse.com> | 2023-03-21 12:13:59 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-04-17 18:01:20 +0200 |
commit | f8f210dc84709804c9f952297f2bfafa6ea6b4bd (patch) | |
tree | b874ab87ec28109e162aeb7f5f4ea022cce75eee /fs/btrfs/block-rsv.c | |
parent | btrfs: use a constant for the number of metadata units needed for an unlink (diff) | |
download | linux-f8f210dc84709804c9f952297f2bfafa6ea6b4bd.tar.xz linux-f8f210dc84709804c9f952297f2bfafa6ea6b4bd.zip |
btrfs: calculate the right space for delayed refs when updating global reserve
When updating the global block reserve, we account for the 6 items needed
by an unlink operation and the 6 delayed references for each one of those
items. However the calculation for the delayed references is not correct
in case we have the free space tree enabled, as in that case we need to
touch the free space tree as well and therefore need twice the number of
bytes. So use the btrfs_calc_delayed_ref_bytes() helper to calculate the
number of bytes need for the delayed references at
btrfs_update_global_block_rsv().
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/block-rsv.c')
-rw-r--r-- | fs/btrfs/block-rsv.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c index b4a1f1bc340f..3ab707e26fa2 100644 --- a/fs/btrfs/block-rsv.c +++ b/fs/btrfs/block-rsv.c @@ -354,14 +354,15 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info) * BTRFS_UNLINK_METADATA_UNITS items. * * But we also need space for the delayed ref updates from the unlink, - * so it's BTRFS_UNLINK_METADATA_UNITS * 2, BTRFS_UNLINK_METADATA_UNITS - * for the actual operation, and BTRFS_UNLINK_METADATA_UNITS more for - * the delayed ref updates. + * so add BTRFS_UNLINK_METADATA_UNITS units for delayed refs, one for + * each unlink metadata item. */ - min_items += BTRFS_UNLINK_METADATA_UNITS * 2; + min_items += BTRFS_UNLINK_METADATA_UNITS; num_bytes = max_t(u64, num_bytes, - btrfs_calc_insert_metadata_size(fs_info, min_items)); + btrfs_calc_insert_metadata_size(fs_info, min_items) + + btrfs_calc_delayed_ref_bytes(fs_info, + BTRFS_UNLINK_METADATA_UNITS)); spin_lock(&sinfo->lock); spin_lock(&block_rsv->lock); |