Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: abort transaction on failure to update inode for hole punching and reflinking
Date: Thu, 17 Sep 2026 06:56:51 +0930	[thread overview]
Message-ID: <4530c488-d7cc-44da-aab2-dfb7564d4fbd@suse.com> (raw)
In-Reply-To: <5eaff5e851684919160420f975c26574d05d4c44.1789570705.git.fdmanana@suse.com>



在 2026/9/17 00:32, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If we fail to update the inode we error out without aborting the
> transaction, which can result in a persistent inconsistency if after
> the failure the transaction is committed, as we have dropped file
> extent items from a range and either punched a hole or insert a new file
> extent item for that range (for reflinks).
> 
> So add the missing transaction abort.
> 
> Fixes: 2aaa66558172 ("Btrfs: add hole punching")
> 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, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 20e15dc30bfb..f978c6524aa0 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2509,8 +2509,10 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
>   					      inode_set_ctime_current(&inode->vfs_inode));
>   
>   		ret = btrfs_update_inode(trans, inode);
> -		if (ret)
> +		if (unlikely(ret)) {
> +			btrfs_abort_transaction(trans, ret);
>   			break;
> +		}
>   
>   		btrfs_end_transaction(trans);
>   		btrfs_btree_balance_dirty(fs_info);


      reply	other threads:[~2026-09-16 21:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 15:02 [PATCH] btrfs: abort transaction on failure to update inode for hole punching and reflinking fdmanana
2026-09-16 21:26 ` Qu Wenruo [this message]

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=4530c488-d7cc-44da-aab2-dfb7564d4fbd@suse.com \
    --to=wqu@suse.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