From 5630e2bcfe22392611a88a2a1e6240ff910c480c Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Tue, 21 Mar 2023 11:13:58 +0000 Subject: btrfs: use a constant for the number of metadata units needed for an unlink Instead of hard coding the number of metadata units for an unlink operation in a couple places, define a macro and use it instead. This eliminates the problem of one place getting out of sync with the other, such as recently fixed by the previous patch in the series ("btrfs: fix calculation of the global block reserve's size"). Reviewed-by: Josef Bacik Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/block-rsv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'fs/btrfs/block-rsv.c') diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c index 6edcb32ed4c9..b4a1f1bc340f 100644 --- a/fs/btrfs/block-rsv.c +++ b/fs/btrfs/block-rsv.c @@ -350,14 +350,15 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info) /* * But we also want to reserve enough space so we can do the fallback - * global reserve for an unlink, which is an additional 6 items (see the - * comment in __unlink_start_trans for what we're modifying.) + * global reserve for an unlink, which is an additional + * BTRFS_UNLINK_METADATA_UNITS items. * * But we also need space for the delayed ref updates from the unlink, - * so its 12, 6 for the actual operation, and 6 for the delayed ref - * updates. + * 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. */ - min_items += 12; + min_items += BTRFS_UNLINK_METADATA_UNITS * 2; num_bytes = max_t(u64, num_bytes, btrfs_calc_insert_metadata_size(fs_info, min_items)); -- cgit v1.2.3