]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents()
authorFilipe Manana <fdmanana@suse.com>
Mon, 20 Apr 2026 10:28:47 +0000 (11:28 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:30 +0000 (15:53 +0200)
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>
fs/btrfs/file.c

index 7e08d6e53687b1d861513cf654150512f9d492a1..a63d2ac676594dc28b74340b140318acdab5827f 100644 (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;
 
        /*