btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents()

There's no need to calculate again the size for the temporary block
reserve in btrfs_replace_file_extents() - we have already calculated it
and stored it in the 'min_size' variable.

So use the variable to make it more clear and also make the variable const
since it's not supposed to change during the whole function.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana
2026-04-20 11:28:47 +01:00
committed by David Sterba
parent 18d32b0013
commit 2d1e969b44

View File

@@ -2381,7 +2381,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
struct btrfs_drop_extents_args drop_args = { 0 };
struct btrfs_root *root = inode->root;
struct btrfs_fs_info *fs_info = root->fs_info;
u64 min_size = btrfs_calc_insert_metadata_size(fs_info, 1);
const u64 min_size = btrfs_calc_insert_metadata_size(fs_info, 1);
u64 ino_size = round_up(inode->vfs_inode.i_size, fs_info->sectorsize);
struct btrfs_trans_handle *trans = NULL;
struct btrfs_block_rsv rsv;
@@ -2394,7 +2394,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
return -EINVAL;
btrfs_init_metadata_block_rsv(fs_info, &rsv, BTRFS_BLOCK_RSV_TEMP);
rsv.size = btrfs_calc_insert_metadata_size(fs_info, 1);
rsv.size = min_size;
rsv.failfast = true;
/*