From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: use min_size variable to setup block rsv in btrfs_replace_file_extents()
Date: Tue, 21 Apr 2026 07:27:02 +0930 [thread overview]
Message-ID: <4012d713-1d94-4e57-bf6c-09a008cc6430@gmx.com> (raw)
In-Reply-To: <efc156002e21e5453d58c2c0856f605575f27642.1776693213.git.fdmanana@suse.com>
在 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;
>
> /*
next prev parent reply other threads:[~2026-04-20 21:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-04-21 3:14 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4012d713-1d94-4e57-bf6c-09a008cc6430@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox