summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2026-01-21 16:35:56 +0000
committerDavid Sterba <dsterba@suse.com>2026-02-03 07:56:19 +0100
commit571e75f4c0dba42e57496015987285ed4380d041 (patch)
tree9a761751445c916b090af59d0b01684875091026
parenta8bec25e014eab671ec8a25b03d391cad3e55230 (diff)
btrfs: unfold transaction aborts in btrfs_finish_one_ordered()
We have a single transaction abort that can be caused either by a failure from a call to btrfs_mark_extent_written(), if we are dealing with a write to a prealloc extent, or otherwise from a call to insert_ordered_extent_file_extent(). So when the transaction abort happens we can not know for sure which case failed. Unfold the aborts so that it's clear in case of a failure. Reviewed-by: Boris Burkov <boris@bur.io> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/inode.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fa110827aaab..6637e451992f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3256,19 +3256,21 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
logical_len);
btrfs_zoned_release_data_reloc_bg(fs_info, ordered_extent->disk_bytenr,
ordered_extent->disk_num_bytes);
+ if (unlikely(ret < 0)) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
+ }
} else {
BUG_ON(root == fs_info->tree_root);
ret = insert_ordered_extent_file_extent(trans, ordered_extent);
- if (!ret) {
- clear_reserved_extent = false;
- btrfs_release_delalloc_bytes(fs_info,
- ordered_extent->disk_bytenr,
- ordered_extent->disk_num_bytes);
+ if (unlikely(ret < 0)) {
+ btrfs_abort_transaction(trans, ret);
+ goto out;
}
- }
- if (unlikely(ret < 0)) {
- btrfs_abort_transaction(trans, ret);
- goto out;
+ clear_reserved_extent = false;
+ btrfs_release_delalloc_bytes(fs_info,
+ ordered_extent->disk_bytenr,
+ ordered_extent->disk_num_bytes);
}
ret = btrfs_unpin_extent_cache(inode, ordered_extent->file_offset,