]> git.hungrycats.org Git - linux/commitdiff
btrfs: abort transaction on failure to update inode for hole punching and reflinking
authorFilipe Manana <fdmanana@suse.com>
Wed, 16 Sep 2026 14:43:41 +0000 (15:43 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 17 Sep 2026 16:20:15 +0000 (18:20 +0200)
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")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c

index 20e15dc30bfb5539b2f95592baa8318b8a3cd7ad..f978c6524aa03f1d66b46510fd3b1a43e30286d1 100644 (file)
@@ -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);