* [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents()
@ 2026-04-20 13:53 fdmanana
2026-04-20 21:57 ` Qu Wenruo
2026-04-21 3:14 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2026-04-20 13:53 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
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.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f007f1f2fd84..7aab4a98caaa 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2395,7 +2395,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;
@@ -2408,7 +2408,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;
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents()
2026-04-20 13:53 [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents() fdmanana
@ 2026-04-20 21:57 ` Qu Wenruo
2026-04-21 3:14 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-04-20 21:57 UTC (permalink / raw)
To: fdmanana, linux-btrfs
在 2026/4/20 23:23, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index f007f1f2fd84..7aab4a98caaa 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2395,7 +2395,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;
> @@ -2408,7 +2408,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;
>
> /*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents()
2026-04-20 13:53 [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents() fdmanana
2026-04-20 21:57 ` Qu Wenruo
@ 2026-04-21 3:14 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2026-04-21 3:14 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Mon, Apr 20, 2026 at 02:53:56PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-21 3:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 13:53 [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents() fdmanana
2026-04-20 21:57 ` Qu Wenruo
2026-04-21 3:14 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox