VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   30 Branches   50 Tags
author: Filipe Manana <fdmanana@suse.com> 2023-06-08 11:27:40 +0100 committer: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2023-07-19 16:36:57 +0200 commit: 82270e7f284fd23914d7b6b71ec2873e385e4c4a parent: 796eb12aa5e4bc3bd217e6fff0d37f7bf6f6a8ea
Commit Summary:
btrfs: do not BUG_ON() on tree mod log failure at __btrfs_cow_block()
Diffstat:
1 file changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 05717580dfbf..4912d624ca3d 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -583,9 +583,14 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
 		    btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
 			parent_start = buf->start;
 
-		atomic_inc(&cow->refs);
 		ret = btrfs_tree_mod_log_insert_root(root->node, cow, true);
-		BUG_ON(ret < 0);
+		if (ret < 0) {
+			btrfs_tree_unlock(cow);
+			free_extent_buffer(cow);
+			btrfs_abort_transaction(trans, ret);
+			return ret;
+		}
+		atomic_inc(&cow->refs);
 		rcu_assign_pointer(root->node, cow);
 
 		btrfs_free_tree_block(trans, btrfs_root_id(root), buf,