From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/3] btrfs: do not free data reservation in fallback from inline due to -ENOSPC
Date: Mon, 15 Dec 2025 20:15:39 +1030 [thread overview]
Message-ID: <1ef636ea-48a9-4ff8-8c73-e954497ed4ed@gmx.com> (raw)
In-Reply-To: <d73d7cef875d6fca9cca0d6db39fdd5d77f55c6f.1765743479.git.fdmanana@suse.com>
在 2025/12/15 20:08, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> If we fail to create an inline extent due to -ENOSPC, we will attempt to
> go through the normal COW path, reserve an extent, create an ordered
> extent, etc. However we were always freeing the reserved qgroup data,
> which is wrong since we will use data. Fix this by freeing the reserved
> qgroup data in __cow_file_range_inline() only if we are not doing the
> fallback (ret is <= 0).
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 566780eb80ff..605589f29da7 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -675,8 +675,12 @@ static noinline int __cow_file_range_inline(struct btrfs_inode *inode,
> * it won't count as data extent, free them directly here.
> * And at reserve time, it's always aligned to page size, so
> * just free one page here.
> + *
> + * If we fallback to non-inline (ret == 1) due to -ENOSPC, then we need
> + * to keep the data reservation.
> */
> - btrfs_qgroup_free_data(inode, NULL, 0, fs_info->sectorsize, NULL);
> + if (ret <= 0)
> + btrfs_qgroup_free_data(inode, NULL, 0, fs_info->sectorsize, NULL);
> btrfs_free_path(path);
> btrfs_end_transaction(trans);
> return ret;
next prev parent reply other threads:[~2025-12-15 9:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 9:38 [PATCH 0/3] btrfs: fixes for inline extent fallback and error handling fdmanana
2025-12-15 9:38 ` [PATCH 1/3] btrfs: do not free data reservation in fallback from inline due to -ENOSPC fdmanana
2025-12-15 9:45 ` Qu Wenruo [this message]
2025-12-15 9:38 ` [PATCH 2/3] btrfs: fix reservation leak in some error paths when inserting inline extent fdmanana
2025-12-15 9:38 ` [PATCH 3/3] btrfs: update stale comment in __cow_file_range_inline() fdmanana
2025-12-15 9:47 ` Qu Wenruo
2025-12-15 9:49 ` Filipe Manana
2025-12-15 9:50 ` Qu Wenruo
2025-12-15 18:43 ` [PATCH 0/3] btrfs: fixes for inline extent fallback and error handling 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=1ef636ea-48a9-4ff8-8c73-e954497ed4ed@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