From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: abort transaction on failure to update inode after hole punching
Date: Sat, 14 Nov 2026 08:05:30 +1030 [thread overview]
Message-ID: <d7ba75fa-9284-4da3-a19c-bf652041558e@gmx.com> (raw)
In-Reply-To: <76a5dcd7dd6a05e2790ddb9ee021ad890e88b35c.1794590636.git.fdmanana@suse.com>
在 2026/11/14 03:54, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> If we fail to update the inode we simply release the transaction and don't
> abort the transaction. This means the transaction can get committed and we
> will not persist important updates to the inode item such as nbytes (which
> gets reduced after punching holes) and the timestamps. Fix this by adding
> the missing abort.
>
> Link: https://sashiko.dev/#/bug/linux-d8b4cb7a-8dfe-454f-9b19-a67af28b81bd
> 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 | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index f568ded02300..83804dc454b8 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2769,7 +2769,10 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
> if (update_times)
> inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
> ret = btrfs_update_inode(trans, BTRFS_I(inode));
> - updated_inode = true;
> + if (ret)
> + btrfs_abort_transaction(trans, ret);
> + else
> + updated_inode = true;
> btrfs_end_transaction(trans);
> btrfs_btree_balance_dirty(fs_info);
> out:
> @@ -2794,6 +2797,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
> int ret2;
>
> ret = btrfs_update_inode(trans, BTRFS_I(inode));
> + if (ret)
> + btrfs_abort_transaction(trans, ret);
> ret2 = btrfs_end_transaction(trans);
> if (!ret)
> ret = ret2;
prev parent reply other threads:[~2026-11-13 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 17:24 [PATCH] btrfs: abort transaction on failure to update inode after hole punching fdmanana
2026-11-13 21:35 ` 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=d7ba75fa-9284-4da3-a19c-bf652041558e@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