btrfs: add unlikely annotations to branches leading to transaction abort

The unlikely() annotation is a static prediction hint that compiler may
use to reorder code out of hot path. We use it elsewhere (namely
tree-checker.c) for error branches that almost never happen.

Transaction abort is one such error, the btrfs_abort_transaction()
inlines code to check the state and print a warning, this ought to be
out of the hot path.

The most common pattern is when transaction abort is called after
checking a return value and the control flow leads to a quick return.
In other cases it may not be necessary to add unlikely() e.g. when the
function returns anyway or the control flow is not changed noticeably.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2025-09-17 19:53:56 +02:00
parent cc53bd2085
commit a929904cf7
20 changed files with 231 additions and 232 deletions

View File

@ -3248,7 +3248,7 @@ again:
*/ */
BTRFS_I(inode)->generation = 0; BTRFS_I(inode)->generation = 0;
ret = btrfs_update_inode(trans, BTRFS_I(inode)); ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) { if (unlikely(ret)) {
/* /*
* So theoretically we could recover from this, simply set the * So theoretically we could recover from this, simply set the
* super cache generation to 0 so we know to invalidate the * super cache generation to 0 so we know to invalidate the
@ -3995,7 +3995,7 @@ static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans
struct btrfs_space_info *sys_space_info; struct btrfs_space_info *sys_space_info;
sys_space_info = btrfs_find_space_info(trans->fs_info, sys_flags); sys_space_info = btrfs_find_space_info(trans->fs_info, sys_flags);
if (!sys_space_info) { if (unlikely(!sys_space_info)) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -4009,17 +4009,17 @@ static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans
} }
ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg); ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = btrfs_chunk_alloc_add_chunk_item(trans, bg); ret = btrfs_chunk_alloc_add_chunk_item(trans, bg);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
} else if (ret) { } else if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }

View File

@ -293,11 +293,11 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) { if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) {
ret = btrfs_inc_ref(trans, root, cow, 1); ret = btrfs_inc_ref(trans, root, cow, 1);
if (ret) if (unlikely(ret))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
} else { } else {
ret = btrfs_inc_ref(trans, root, cow, 0); ret = btrfs_inc_ref(trans, root, cow, 0);
if (ret) if (unlikely(ret))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
} }
if (ret) { if (ret) {
@ -536,14 +536,14 @@ int btrfs_force_cow_block(struct btrfs_trans_handle *trans,
write_extent_buffer_fsid(cow, fs_info->fs_devices->metadata_uuid); write_extent_buffer_fsid(cow, fs_info->fs_devices->metadata_uuid);
ret = update_ref_for_cow(trans, root, buf, cow, &last_ref); ret = update_ref_for_cow(trans, root, buf, cow, &last_ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) { if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) {
ret = btrfs_reloc_cow_block(trans, root, buf, cow); ret = btrfs_reloc_cow_block(trans, root, buf, cow);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
@ -556,7 +556,7 @@ int btrfs_force_cow_block(struct btrfs_trans_handle *trans,
parent_start = buf->start; parent_start = buf->start;
ret = btrfs_tree_mod_log_insert_root(root->node, cow, true); ret = btrfs_tree_mod_log_insert_root(root->node, cow, true);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
@ -567,7 +567,7 @@ int btrfs_force_cow_block(struct btrfs_trans_handle *trans,
parent_start, last_ref); parent_start, last_ref);
free_extent_buffer(buf); free_extent_buffer(buf);
add_root_to_dirty_list(root); add_root_to_dirty_list(root);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
@ -575,7 +575,7 @@ int btrfs_force_cow_block(struct btrfs_trans_handle *trans,
WARN_ON(trans->transid != btrfs_header_generation(parent)); WARN_ON(trans->transid != btrfs_header_generation(parent));
ret = btrfs_tree_mod_log_insert_key(parent, parent_slot, ret = btrfs_tree_mod_log_insert_key(parent, parent_slot,
BTRFS_MOD_LOG_KEY_REPLACE); BTRFS_MOD_LOG_KEY_REPLACE);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
@ -586,14 +586,14 @@ int btrfs_force_cow_block(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(trans, parent); btrfs_mark_buffer_dirty(trans, parent);
if (last_ref) { if (last_ref) {
ret = btrfs_tree_mod_log_free_eb(buf); ret = btrfs_tree_mod_log_free_eb(buf);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
} }
ret = btrfs_free_tree_block(trans, btrfs_root_id(root), buf, ret = btrfs_free_tree_block(trans, btrfs_root_id(root), buf,
parent_start, last_ref); parent_start, last_ref);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_unlock_cow; goto error_unlock_cow;
} }
@ -922,7 +922,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
} }
ret = btrfs_tree_mod_log_insert_root(root->node, child, true); ret = btrfs_tree_mod_log_insert_root(root->node, child, true);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_tree_unlock(child); btrfs_tree_unlock(child);
free_extent_buffer(child); free_extent_buffer(child);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -944,7 +944,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1);
/* once for the root ptr */ /* once for the root ptr */
free_extent_buffer_stale(mid); free_extent_buffer_stale(mid);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1019,7 +1019,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
right, 0, 1); right, 0, 1);
free_extent_buffer_stale(right); free_extent_buffer_stale(right);
right = NULL; right = NULL;
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1028,7 +1028,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
btrfs_node_key(right, &right_key, 0); btrfs_node_key(right, &right_key, 0);
ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1,
BTRFS_MOD_LOG_KEY_REPLACE); BTRFS_MOD_LOG_KEY_REPLACE);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1080,7 +1080,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1);
free_extent_buffer_stale(mid); free_extent_buffer_stale(mid);
mid = NULL; mid = NULL;
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1090,7 +1090,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
btrfs_node_key(mid, &mid_key, 0); btrfs_node_key(mid, &mid_key, 0);
ret = btrfs_tree_mod_log_insert_key(parent, pslot, ret = btrfs_tree_mod_log_insert_key(parent, pslot,
BTRFS_MOD_LOG_KEY_REPLACE); BTRFS_MOD_LOG_KEY_REPLACE);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1195,7 +1195,7 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
btrfs_node_key(mid, &disk_key, 0); btrfs_node_key(mid, &disk_key, 0);
ret = btrfs_tree_mod_log_insert_key(parent, pslot, ret = btrfs_tree_mod_log_insert_key(parent, pslot,
BTRFS_MOD_LOG_KEY_REPLACE); BTRFS_MOD_LOG_KEY_REPLACE);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_tree_unlock(left); btrfs_tree_unlock(left);
free_extent_buffer(left); free_extent_buffer(left);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -1255,7 +1255,7 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
btrfs_node_key(right, &disk_key, 0); btrfs_node_key(right, &disk_key, 0);
ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1,
BTRFS_MOD_LOG_KEY_REPLACE); BTRFS_MOD_LOG_KEY_REPLACE);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_tree_unlock(right); btrfs_tree_unlock(right);
free_extent_buffer(right); free_extent_buffer(right);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -2737,7 +2737,7 @@ static int push_node_left(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
ret = btrfs_tree_mod_log_eb_copy(dst, src, dst_nritems, 0, push_items); ret = btrfs_tree_mod_log_eb_copy(dst, src, dst_nritems, 0, push_items);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -2822,7 +2822,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
ret = btrfs_tree_mod_log_eb_copy(dst, src, 0, src_nritems - push_items, ret = btrfs_tree_mod_log_eb_copy(dst, src, 0, src_nritems - push_items,
push_items); push_items);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -2892,7 +2892,7 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,
btrfs_clear_buffer_dirty(trans, c); btrfs_clear_buffer_dirty(trans, c);
ret2 = btrfs_free_tree_block(trans, btrfs_root_id(root), c, 0, 1); ret2 = btrfs_free_tree_block(trans, btrfs_root_id(root), c, 0, 1);
if (ret2 < 0) if (unlikely(ret2 < 0))
btrfs_abort_transaction(trans, ret2); btrfs_abort_transaction(trans, ret2);
btrfs_tree_unlock(c); btrfs_tree_unlock(c);
free_extent_buffer(c); free_extent_buffer(c);
@ -2937,7 +2937,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans,
if (level) { if (level) {
ret = btrfs_tree_mod_log_insert_move(lower, slot + 1, ret = btrfs_tree_mod_log_insert_move(lower, slot + 1,
slot, nritems - slot); slot, nritems - slot);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -2950,7 +2950,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans,
if (level) { if (level) {
ret = btrfs_tree_mod_log_insert_key(lower, slot, ret = btrfs_tree_mod_log_insert_key(lower, slot,
BTRFS_MOD_LOG_KEY_ADD); BTRFS_MOD_LOG_KEY_ADD);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -3026,7 +3026,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
ASSERT(btrfs_header_level(c) == level); ASSERT(btrfs_header_level(c) == level);
ret = btrfs_tree_mod_log_eb_copy(split, c, 0, mid, c_nritems - mid); ret = btrfs_tree_mod_log_eb_copy(split, c, 0, mid, c_nritems - mid);
if (ret) { if (unlikely(ret)) {
btrfs_tree_unlock(split); btrfs_tree_unlock(split);
free_extent_buffer(split); free_extent_buffer(split);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -4383,7 +4383,7 @@ int btrfs_del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
if (level) { if (level) {
ret = btrfs_tree_mod_log_insert_move(parent, slot, ret = btrfs_tree_mod_log_insert_move(parent, slot,
slot + 1, nritems - slot - 1); slot + 1, nritems - slot - 1);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -4396,7 +4396,7 @@ int btrfs_del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
} else if (level) { } else if (level) {
ret = btrfs_tree_mod_log_insert_key(parent, slot, ret = btrfs_tree_mod_log_insert_key(parent, slot,
BTRFS_MOD_LOG_KEY_REMOVE); BTRFS_MOD_LOG_KEY_REMOVE);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }

View File

@ -1038,7 +1038,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
* transaction, because we could leave the inode with the * transaction, because we could leave the inode with the
* improper counts behind. * improper counts behind.
*/ */
if (ret != -ENOENT) if (unlikely(ret != -ENOENT))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1066,7 +1066,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
btrfs_release_path(path); btrfs_release_path(path);
ret = btrfs_search_slot(trans, root, &key, path, -1, 1); ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto err_out; goto err_out;
} }
@ -1175,7 +1175,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans, int nr)
while (curr_node && (!count || nr--)) { while (curr_node && (!count || nr--)) {
ret = __btrfs_commit_inode_delayed_items(trans, path, ret = __btrfs_commit_inode_delayed_items(trans, path,
curr_node); curr_node);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }

View File

@ -2157,7 +2157,7 @@ again:
delayed_refs->run_delayed_start = find_middle(&delayed_refs->root); delayed_refs->run_delayed_start = find_middle(&delayed_refs->root);
#endif #endif
ret = __btrfs_run_delayed_refs(trans, min_bytes); ret = __btrfs_run_delayed_refs(trans, min_bytes);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -2982,26 +2982,26 @@ static int do_free_extent_accounting(struct btrfs_trans_handle *trans,
csum_root = btrfs_csum_root(trans->fs_info, bytenr); csum_root = btrfs_csum_root(trans->fs_info, bytenr);
ret = btrfs_del_csums(trans, csum_root, bytenr, num_bytes); ret = btrfs_del_csums(trans, csum_root, bytenr, num_bytes);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
ret = btrfs_delete_raid_extent(trans, bytenr, num_bytes); ret = btrfs_delete_raid_extent(trans, bytenr, num_bytes);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
} }
ret = btrfs_record_squota_delta(trans->fs_info, delta); ret = btrfs_record_squota_delta(trans->fs_info, delta);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
ret = btrfs_add_to_free_space_tree(trans, bytenr, num_bytes); ret = btrfs_add_to_free_space_tree(trans, bytenr, num_bytes);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -3115,7 +3115,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID; is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID;
if (!is_data && refs_to_drop != 1) { if (unlikely(!is_data && refs_to_drop != 1)) {
btrfs_crit(info, btrfs_crit(info,
"invalid refs_to_drop, dropping more than 1 refs for tree block %llu refs_to_drop %u", "invalid refs_to_drop, dropping more than 1 refs for tree block %llu refs_to_drop %u",
node->bytenr, refs_to_drop); node->bytenr, refs_to_drop);
@ -3172,7 +3172,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
/* Must be SHARED_* item, remove the backref first */ /* Must be SHARED_* item, remove the backref first */
ret = remove_extent_backref(trans, extent_root, path, ret = remove_extent_backref(trans, extent_root, path,
NULL, refs_to_drop, is_data); NULL, refs_to_drop, is_data);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3221,7 +3221,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
"umm, got %d back from search, was looking for %llu, slot %d", "umm, got %d back from search, was looking for %llu, slot %d",
ret, bytenr, path->slots[0]); ret, bytenr, path->slots[0]);
} }
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3298,7 +3298,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
if (found_extent) { if (found_extent) {
ret = remove_extent_backref(trans, extent_root, path, ret = remove_extent_backref(trans, extent_root, path,
iref, refs_to_drop, is_data); iref, refs_to_drop, is_data);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3363,7 +3363,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
ret = btrfs_del_items(trans, extent_root, path, path->slots[0], ret = btrfs_del_items(trans, extent_root, path, path->slots[0],
num_to_del); num_to_del);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -5472,17 +5472,17 @@ static noinline int walk_down_proc(struct btrfs_trans_handle *trans,
if (!(wc->flags[level] & flag)) { if (!(wc->flags[level] & flag)) {
ASSERT(path->locks[level]); ASSERT(path->locks[level]);
ret = btrfs_inc_ref(trans, root, eb, 1); ret = btrfs_inc_ref(trans, root, eb, 1);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
ret = btrfs_dec_ref(trans, root, eb, 0); ret = btrfs_dec_ref(trans, root, eb, 0);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
ret = btrfs_set_disk_extent_flags(trans, eb, flag); ret = btrfs_set_disk_extent_flags(trans, eb, flag);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -5885,7 +5885,7 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
} }
} else { } else {
ret = btrfs_dec_ref(trans, root, eb, 0); ret = btrfs_dec_ref(trans, root, eb, 0);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -6180,13 +6180,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root, bool update_ref, bool for_reloc
while (1) { while (1) {
ret = walk_down_tree(trans, root, path, wc); ret = walk_down_tree(trans, root, path, wc);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL); ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -6213,7 +6213,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, bool update_ref, bool for_reloc
ret = btrfs_update_root(trans, tree_root, ret = btrfs_update_root(trans, tree_root,
&root->root_key, &root->root_key,
root_item); root_item);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -6249,7 +6249,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, bool update_ref, bool for_reloc
goto out_end_trans; goto out_end_trans;
ret = btrfs_del_root(trans, &root->root_key); ret = btrfs_del_root(trans, &root->root_key);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -6257,7 +6257,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, bool update_ref, bool for_reloc
if (!is_reloc_root) { if (!is_reloc_root) {
ret = btrfs_find_root(tree_root, &root->root_key, path, ret = btrfs_find_root(tree_root, &root->root_key, path,
NULL, NULL); NULL, NULL);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} else if (ret > 0) { } else if (ret > 0) {

View File

@ -1011,7 +1011,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
* item changed size or key * item changed size or key
*/ */
ret = btrfs_split_item(trans, root, path, &key, offset); ret = btrfs_split_item(trans, root, path, &key, offset);
if (ret && ret != -EAGAIN) { if (unlikely(ret && ret != -EAGAIN)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }

View File

@ -327,7 +327,7 @@ next_slot:
args->start - extent_offset, args->start - extent_offset,
0, false); 0, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -426,7 +426,7 @@ delete_extent_item:
key.offset - extent_offset, key.offset - extent_offset,
0, false); 0, false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -443,7 +443,7 @@ delete_extent_item:
ret = btrfs_del_items(trans, root, path, del_slot, ret = btrfs_del_items(trans, root, path, del_slot,
del_nr); del_nr);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -587,21 +587,20 @@ again:
leaf = path->nodes[0]; leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
if (key.objectid != ino || if (unlikely(key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY)) {
key.type != BTRFS_EXTENT_DATA_KEY) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
fi = btrfs_item_ptr(leaf, path->slots[0], fi = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_file_extent_item); struct btrfs_file_extent_item);
if (btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_PREALLOC) { if (unlikely(btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_PREALLOC)) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi); extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi);
if (key.offset > start || extent_end < end) { if (unlikely(key.offset > start || extent_end < end)) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -676,7 +675,7 @@ again:
btrfs_release_path(path); btrfs_release_path(path);
goto again; goto again;
} }
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -704,7 +703,7 @@ again:
ref.ref_root = btrfs_root_id(root); ref.ref_root = btrfs_root_id(root);
btrfs_init_data_ref(&ref, ino, orig_offset, 0, false); btrfs_init_data_ref(&ref, ino, orig_offset, 0, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -712,7 +711,7 @@ again:
if (split == start) { if (split == start) {
key.offset = start; key.offset = start;
} else { } else {
if (start != key.offset) { if (unlikely(start != key.offset)) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -744,7 +743,7 @@ again:
del_slot = path->slots[0] + 1; del_slot = path->slots[0] + 1;
del_nr++; del_nr++;
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -762,7 +761,7 @@ again:
del_slot = path->slots[0]; del_slot = path->slots[0];
del_nr++; del_nr++;
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -783,7 +782,7 @@ again:
extent_end - key.offset); extent_end - key.offset);
ret = btrfs_del_items(trans, root, path, del_slot, del_nr); ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -2460,9 +2459,9 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
* got EOPNOTSUPP via prealloc then we messed up and * got EOPNOTSUPP via prealloc then we messed up and
* need to abort. * need to abort.
*/ */
if (ret && if (unlikely(ret &&
(ret != -EOPNOTSUPP || (ret != -EOPNOTSUPP ||
(extent_info && extent_info->is_new_extent))) (extent_info && extent_info->is_new_extent))))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -2473,7 +2472,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
cur_offset < ino_size) { cur_offset < ino_size) {
ret = fill_holes(trans, inode, path, cur_offset, ret = fill_holes(trans, inode, path, cur_offset,
drop_args.drop_end); drop_args.drop_end);
if (ret) { if (unlikely(ret)) {
/* /*
* If we failed then we didn't insert our hole * If we failed then we didn't insert our hole
* entries for the area we dropped, so now the * entries for the area we dropped, so now the
@ -2493,7 +2492,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
ret = btrfs_inode_clear_file_extent_range(inode, ret = btrfs_inode_clear_file_extent_range(inode,
cur_offset, cur_offset,
drop_args.drop_end - cur_offset); drop_args.drop_end - cur_offset);
if (ret) { if (unlikely(ret)) {
/* /*
* We couldn't clear our area, so we could * We couldn't clear our area, so we could
* presumably adjust up and corrupt the fs, so * presumably adjust up and corrupt the fs, so
@ -2512,7 +2511,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
ret = btrfs_insert_replace_extent(trans, inode, path, ret = btrfs_insert_replace_extent(trans, inode, path,
extent_info, replace_len, extent_info, replace_len,
drop_args.bytes_found); drop_args.bytes_found);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -2607,7 +2606,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
cur_offset < drop_args.drop_end) { cur_offset < drop_args.drop_end) {
ret = fill_holes(trans, inode, path, cur_offset, ret = fill_holes(trans, inode, path, cur_offset,
drop_args.drop_end); drop_args.drop_end);
if (ret) { if (unlikely(ret)) {
/* Same comment as above. */ /* Same comment as above. */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_trans; goto out_trans;
@ -2616,7 +2615,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
/* See the comment in the loop above for the reasoning here. */ /* See the comment in the loop above for the reasoning here. */
ret = btrfs_inode_clear_file_extent_range(inode, cur_offset, ret = btrfs_inode_clear_file_extent_range(inode, cur_offset,
drop_args.drop_end - cur_offset); drop_args.drop_end - cur_offset);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_trans; goto out_trans;
} }
@ -2626,7 +2625,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
ret = btrfs_insert_replace_extent(trans, inode, path, ret = btrfs_insert_replace_extent(trans, inode, path,
extent_info, extent_info->data_len, extent_info, extent_info->data_len,
drop_args.bytes_found); drop_args.bytes_found);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_trans; goto out_trans;
} }

View File

@ -4142,7 +4142,7 @@ int btrfs_set_free_space_cache_v1_active(struct btrfs_fs_info *fs_info, bool act
if (!active) { if (!active) {
set_bit(BTRFS_FS_CLEANUP_SPACE_CACHE_V1, &fs_info->flags); set_bit(BTRFS_FS_CLEANUP_SPACE_CACHE_V1, &fs_info->flags);
ret = cleanup_free_space_cache_v1(fs_info, trans); ret = cleanup_free_space_cache_v1(fs_info, trans);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
goto out; goto out;

View File

@ -218,7 +218,7 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
bitmap_size = free_space_bitmap_size(fs_info, block_group->length); bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
bitmap = alloc_bitmap(bitmap_size); bitmap = alloc_bitmap(bitmap_size);
if (!bitmap) { if (unlikely(!bitmap)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -233,7 +233,7 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
while (!done) { while (!done) {
ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -271,7 +271,7 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
} }
ret = btrfs_del_items(trans, root, path, path->slots[0], nr); ret = btrfs_del_items(trans, root, path, path->slots[0], nr);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -320,7 +320,7 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
ret = btrfs_insert_empty_item(trans, root, path, &key, ret = btrfs_insert_empty_item(trans, root, path, &key,
data_size); data_size);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -361,7 +361,7 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
bitmap_size = free_space_bitmap_size(fs_info, block_group->length); bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
bitmap = alloc_bitmap(bitmap_size); bitmap = alloc_bitmap(bitmap_size);
if (!bitmap) { if (unlikely(!bitmap)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -376,7 +376,7 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
while (!done) { while (!done) {
ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -420,7 +420,7 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
} }
ret = btrfs_del_items(trans, root, path, path->slots[0], nr); ret = btrfs_del_items(trans, root, path, path->slots[0], nr);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -454,7 +454,7 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
key.offset = (end_bit - start_bit) * fs_info->sectorsize; key.offset = (end_bit - start_bit) * fs_info->sectorsize;
ret = btrfs_insert_empty_item(trans, root, path, &key, 0); ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -848,14 +848,14 @@ int btrfs_remove_from_free_space_tree(struct btrfs_trans_handle *trans,
return 0; return 0;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (unlikely(!path)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
block_group = btrfs_lookup_block_group(trans->fs_info, start); block_group = btrfs_lookup_block_group(trans->fs_info, start);
if (!block_group) { if (unlikely(!block_group)) {
DEBUG_WARN("no block group found for start=%llu", start); DEBUG_WARN("no block group found for start=%llu", start);
ret = -ENOENT; ret = -ENOENT;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -1030,14 +1030,14 @@ int btrfs_add_to_free_space_tree(struct btrfs_trans_handle *trans,
return 0; return 0;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (unlikely(!path)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
block_group = btrfs_lookup_block_group(trans->fs_info, start); block_group = btrfs_lookup_block_group(trans->fs_info, start);
if (!block_group) { if (unlikely(!block_group)) {
DEBUG_WARN("no block group found for start=%llu", start); DEBUG_WARN("no block group found for start=%llu", start);
ret = -ENOENT; ret = -ENOENT;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -1185,7 +1185,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
goto out_clear; goto out_clear;
} }
ret = btrfs_global_root_insert(free_space_root); ret = btrfs_global_root_insert(free_space_root);
if (ret) { if (unlikely(ret)) {
btrfs_put_root(free_space_root); btrfs_put_root(free_space_root);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
@ -1197,7 +1197,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
block_group = rb_entry(node, struct btrfs_block_group, block_group = rb_entry(node, struct btrfs_block_group,
cache_node); cache_node);
ret = populate_free_space_tree(trans, block_group); ret = populate_free_space_tree(trans, block_group);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
goto out_clear; goto out_clear;
@ -1290,14 +1290,14 @@ int btrfs_delete_free_space_tree(struct btrfs_fs_info *fs_info)
btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID); btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID);
ret = clear_free_space_tree(trans, free_space_root); ret = clear_free_space_tree(trans, free_space_root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
} }
ret = btrfs_del_root(trans, &free_space_root->root_key); ret = btrfs_del_root(trans, &free_space_root->root_key);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
@ -1315,7 +1315,7 @@ int btrfs_delete_free_space_tree(struct btrfs_fs_info *fs_info)
ret = btrfs_free_tree_block(trans, btrfs_root_id(free_space_root), ret = btrfs_free_tree_block(trans, btrfs_root_id(free_space_root),
free_space_root->node, 0, 1); free_space_root->node, 0, 1);
btrfs_put_root(free_space_root); btrfs_put_root(free_space_root);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
@ -1344,7 +1344,7 @@ int btrfs_rebuild_free_space_tree(struct btrfs_fs_info *fs_info)
set_bit(BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, &fs_info->flags); set_bit(BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, &fs_info->flags);
ret = clear_free_space_tree(trans, free_space_root); ret = clear_free_space_tree(trans, free_space_root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
@ -1362,7 +1362,7 @@ int btrfs_rebuild_free_space_tree(struct btrfs_fs_info *fs_info)
goto next; goto next;
ret = populate_free_space_tree(trans, block_group); ret = populate_free_space_tree(trans, block_group);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
@ -1422,7 +1422,7 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
if (!path) { if (!path) {
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (unlikely(!path)) {
btrfs_abort_transaction(trans, -ENOMEM); btrfs_abort_transaction(trans, -ENOMEM);
return -ENOMEM; return -ENOMEM;
} }
@ -1430,7 +1430,7 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
} }
ret = add_new_free_space_info(trans, block_group, path); ret = add_new_free_space_info(trans, block_group, path);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1481,7 +1481,7 @@ int btrfs_remove_block_group_free_space(struct btrfs_trans_handle *trans,
} }
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (unlikely(!path)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -1496,7 +1496,7 @@ int btrfs_remove_block_group_free_space(struct btrfs_trans_handle *trans,
while (!done) { while (!done) {
ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -1527,7 +1527,7 @@ int btrfs_remove_block_group_free_space(struct btrfs_trans_handle *trans,
} }
ret = btrfs_del_items(trans, root, path, path->slots[0], nr); ret = btrfs_del_items(trans, root, path, path->slots[0], nr);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }

View File

@ -137,7 +137,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
*/ */
extref = btrfs_find_name_in_ext_backref(path->nodes[0], path->slots[0], extref = btrfs_find_name_in_ext_backref(path->nodes[0], path->slots[0],
ref_objectid, name); ref_objectid, name);
if (!extref) { if (unlikely(!extref)) {
btrfs_abort_transaction(trans, -ENOENT); btrfs_abort_transaction(trans, -ENOENT);
return -ENOENT; return -ENOENT;
} }
@ -627,7 +627,7 @@ delete:
if (control->clear_extent_range) { if (control->clear_extent_range) {
ret = btrfs_inode_clear_file_extent_range(control->inode, ret = btrfs_inode_clear_file_extent_range(control->inode,
clear_start, clear_len); clear_start, clear_len);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -666,7 +666,7 @@ delete:
btrfs_init_data_ref(&ref, control->ino, extent_offset, btrfs_init_data_ref(&ref, control->ino, extent_offset,
btrfs_root_id(root), false); btrfs_root_id(root), false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -684,7 +684,7 @@ delete:
ret = btrfs_del_items(trans, root, path, ret = btrfs_del_items(trans, root, path,
pending_del_slot, pending_del_slot,
pending_del_nr); pending_del_nr);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -720,7 +720,7 @@ out:
int ret2; int ret2;
ret2 = btrfs_del_items(trans, root, path, pending_del_slot, pending_del_nr); ret2 = btrfs_del_items(trans, root, path, pending_del_slot, pending_del_nr);
if (ret2) { if (unlikely(ret2)) {
btrfs_abort_transaction(trans, ret2); btrfs_abort_transaction(trans, ret2);
ret = ret2; ret = ret2;
} }

View File

@ -634,7 +634,7 @@ static noinline int __cow_file_range_inline(struct btrfs_inode *inode,
drop_args.replace_extent = true; drop_args.replace_extent = true;
drop_args.extent_item_size = btrfs_file_extent_calc_inline_size(data_len); drop_args.extent_item_size = btrfs_file_extent_calc_inline_size(data_len);
ret = btrfs_drop_extents(trans, root, inode, &drop_args); ret = btrfs_drop_extents(trans, root, inode, &drop_args);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -642,7 +642,7 @@ static noinline int __cow_file_range_inline(struct btrfs_inode *inode,
ret = insert_inline_extent(trans, path, inode, drop_args.extent_inserted, ret = insert_inline_extent(trans, path, inode, drop_args.extent_inserted,
size, compressed_size, compress_type, size, compressed_size, compress_type,
compressed_folio, update_i_size); compressed_folio, update_i_size);
if (ret && ret != -ENOSPC) { if (unlikely(ret && ret != -ENOSPC)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} else if (ret == -ENOSPC) { } else if (ret == -ENOSPC) {
@ -652,7 +652,7 @@ static noinline int __cow_file_range_inline(struct btrfs_inode *inode,
btrfs_update_inode_bytes(inode, size, drop_args.bytes_found); btrfs_update_inode_bytes(inode, size, drop_args.bytes_found);
ret = btrfs_update_inode(trans, inode); ret = btrfs_update_inode(trans, inode);
if (ret && ret != -ENOSPC) { if (unlikely(ret && ret != -ENOSPC)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} else if (ret == -ENOSPC) { } else if (ret == -ENOSPC) {
@ -3150,7 +3150,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
trans->block_rsv = &inode->block_rsv; trans->block_rsv = &inode->block_rsv;
ret = btrfs_insert_raid_extent(trans, ordered_extent); ret = btrfs_insert_raid_extent(trans, ordered_extent);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3158,7 +3158,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
/* Logic error */ /* Logic error */
ASSERT(list_empty(&ordered_extent->list)); ASSERT(list_empty(&ordered_extent->list));
if (!list_empty(&ordered_extent->list)) { if (unlikely(!list_empty(&ordered_extent->list))) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -3166,7 +3166,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
btrfs_inode_safe_disk_i_size_write(inode, 0); btrfs_inode_safe_disk_i_size_write(inode, 0);
ret = btrfs_update_inode_fallback(trans, inode); ret = btrfs_update_inode_fallback(trans, inode);
if (ret) { if (unlikely(ret)) {
/* -ENOMEM or corruption */ /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
} }
@ -3193,20 +3193,20 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
ordered_extent->disk_num_bytes); ordered_extent->disk_num_bytes);
} }
} }
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = btrfs_unpin_extent_cache(inode, ordered_extent->file_offset, ret = btrfs_unpin_extent_cache(inode, ordered_extent->file_offset,
ordered_extent->num_bytes, trans->transid); ordered_extent->num_bytes, trans->transid);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = add_pending_csums(trans, &ordered_extent->list); ret = add_pending_csums(trans, &ordered_extent->list);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3224,7 +3224,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
btrfs_inode_safe_disk_i_size_write(inode, 0); btrfs_inode_safe_disk_i_size_write(inode, 0);
ret = btrfs_update_inode_fallback(trans, inode); ret = btrfs_update_inode_fallback(trans, inode);
if (ret) { /* -ENOMEM or corruption */ if (unlikely(ret)) { /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3539,7 +3539,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
int ret; int ret;
ret = btrfs_insert_orphan_item(trans, inode->root, btrfs_ino(inode)); ret = btrfs_insert_orphan_item(trans, inode->root, btrfs_ino(inode));
if (ret && ret != -EEXIST) { if (unlikely(ret && ret != -EEXIST)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -4288,7 +4288,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
} }
ret = btrfs_del_inode_ref(trans, root, name, ino, dir_ino, &index); ret = btrfs_del_inode_ref(trans, root, name, ino, dir_ino, &index);
if (ret) { if (unlikely(ret)) {
btrfs_crit(fs_info, btrfs_crit(fs_info,
"failed to delete reference to %.*s, root %llu inode %llu parent %llu", "failed to delete reference to %.*s, root %llu inode %llu parent %llu",
name->len, name->name, btrfs_root_id(root), ino, dir_ino); name->len, name->name, btrfs_root_id(root), ino, dir_ino);
@ -4300,7 +4300,7 @@ skip_backref:
rename_ctx->index = index; rename_ctx->index = index;
ret = btrfs_delete_delayed_dir_index(trans, dir, index); ret = btrfs_delete_delayed_dir_index(trans, dir, index);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -4455,7 +4455,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
btrfs_dir_item_key_to_cpu(leaf, di, &key); btrfs_dir_item_key_to_cpu(leaf, di, &key);
WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid); WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid);
ret = btrfs_delete_one_dir_name(trans, root, path, di); ret = btrfs_delete_one_dir_name(trans, root, path, di);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -4486,14 +4486,14 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
ret = btrfs_del_root_ref(trans, objectid, ret = btrfs_del_root_ref(trans, objectid,
btrfs_root_id(root), dir_ino, btrfs_root_id(root), dir_ino,
&index, &fname.disk_name); &index, &fname.disk_name);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
} }
ret = btrfs_delete_delayed_dir_index(trans, dir, index); ret = btrfs_delete_delayed_dir_index(trans, dir, index);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -4665,13 +4665,13 @@ int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
btrfs_record_snapshot_destroy(trans, dir); btrfs_record_snapshot_destroy(trans, dir);
ret = btrfs_unlink_subvol(trans, dir, dentry); ret = btrfs_unlink_subvol(trans, dir, dentry);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
ret = btrfs_record_root_in_trans(trans, dest); ret = btrfs_record_root_in_trans(trans, dest);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -4685,7 +4685,7 @@ int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
ret = btrfs_insert_orphan_item(trans, ret = btrfs_insert_orphan_item(trans,
fs_info->tree_root, fs_info->tree_root,
btrfs_root_id(dest)); btrfs_root_id(dest));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -4693,7 +4693,7 @@ int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
ret = btrfs_uuid_tree_remove(trans, dest->root_item.uuid, ret = btrfs_uuid_tree_remove(trans, dest->root_item.uuid,
BTRFS_UUID_KEY_SUBVOL, btrfs_root_id(dest)); BTRFS_UUID_KEY_SUBVOL, btrfs_root_id(dest));
if (ret && ret != -ENOENT) { if (unlikely(ret && ret != -ENOENT)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -4702,7 +4702,7 @@ int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
dest->root_item.received_uuid, dest->root_item.received_uuid,
BTRFS_UUID_KEY_RECEIVED_SUBVOL, BTRFS_UUID_KEY_RECEIVED_SUBVOL,
btrfs_root_id(dest)); btrfs_root_id(dest));
if (ret && ret != -ENOENT) { if (unlikely(ret && ret != -ENOENT)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -5106,7 +5106,7 @@ static int maybe_insert_hole(struct btrfs_inode *inode, u64 offset, u64 len)
drop_args.drop_cache = true; drop_args.drop_cache = true;
ret = btrfs_drop_extents(trans, root, inode, &drop_args); ret = btrfs_drop_extents(trans, root, inode, &drop_args);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
@ -6559,7 +6559,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
batch.total_data_size = sizes[0] + (args->orphan ? 0 : sizes[1]); batch.total_data_size = sizes[0] + (args->orphan ? 0 : sizes[1]);
batch.nr = args->orphan ? 1 : 2; batch.nr = args->orphan ? 1 : 2;
ret = btrfs_insert_empty_items(trans, root, path, &batch); ret = btrfs_insert_empty_items(trans, root, path, &batch);
if (ret != 0) { if (unlikely(ret != 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto discard; goto discard;
} }
@ -6636,7 +6636,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
*/ */
if (!args->subvol) { if (!args->subvol) {
ret = btrfs_init_inode_security(trans, args); ret = btrfs_init_inode_security(trans, args);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto discard; goto discard;
} }
@ -6656,14 +6656,14 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
if (args->orphan) { if (args->orphan) {
ret = btrfs_orphan_add(trans, BTRFS_I(inode)); ret = btrfs_orphan_add(trans, BTRFS_I(inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto discard; goto discard;
} }
} else { } else {
ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name, ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
0, BTRFS_I(inode)->dir_index); 0, BTRFS_I(inode)->dir_index);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto discard; goto discard;
} }
@ -6727,7 +6727,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
btrfs_inode_type(inode), index); btrfs_inode_type(inode), index);
if (ret == -EEXIST || ret == -EOVERFLOW) if (ret == -EEXIST || ret == -EOVERFLOW)
goto fail_dir_item; goto fail_dir_item;
else if (ret) { else if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -6883,7 +6883,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
/* Link added now we update the inode item with the new link count. */ /* Link added now we update the inode item with the new link count. */
inc_nlink(inode); inc_nlink(inode);
ret = btrfs_update_inode(trans, BTRFS_I(inode)); ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -6894,7 +6894,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
* open(2) O_TMPFILE flag. * open(2) O_TMPFILE flag.
*/ */
ret = btrfs_orphan_del(trans, BTRFS_I(inode)); ret = btrfs_orphan_del(trans, BTRFS_I(inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -8208,7 +8208,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
btrfs_ino(BTRFS_I(old_dir)), btrfs_ino(BTRFS_I(old_dir)),
new_idx); new_idx);
if (ret) { if (ret) {
if (need_abort) if (unlikely(need_abort))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8256,7 +8256,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
/* src is a subvolume */ /* src is a subvolume */
if (old_ino == BTRFS_FIRST_FREE_OBJECTID) { if (old_ino == BTRFS_FIRST_FREE_OBJECTID) {
ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry); ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8264,12 +8264,12 @@ static int btrfs_rename_exchange(struct inode *old_dir,
ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir),
BTRFS_I(old_dentry->d_inode), BTRFS_I(old_dentry->d_inode),
old_name, &old_rename_ctx); old_name, &old_rename_ctx);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
ret = btrfs_update_inode(trans, BTRFS_I(old_inode)); ret = btrfs_update_inode(trans, BTRFS_I(old_inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8278,7 +8278,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
/* dest is a subvolume */ /* dest is a subvolume */
if (new_ino == BTRFS_FIRST_FREE_OBJECTID) { if (new_ino == BTRFS_FIRST_FREE_OBJECTID) {
ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry); ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8286,12 +8286,12 @@ static int btrfs_rename_exchange(struct inode *old_dir,
ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir), ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir),
BTRFS_I(new_dentry->d_inode), BTRFS_I(new_dentry->d_inode),
new_name, &new_rename_ctx); new_name, &new_rename_ctx);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
ret = btrfs_update_inode(trans, BTRFS_I(new_inode)); ret = btrfs_update_inode(trans, BTRFS_I(new_inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8299,14 +8299,14 @@ static int btrfs_rename_exchange(struct inode *old_dir,
ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode), ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
new_name, 0, old_idx); new_name, 0, old_idx);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode), ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode),
old_name, 0, new_idx); old_name, 0, new_idx);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8547,7 +8547,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) { if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) {
ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry); ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8555,12 +8555,12 @@ static int btrfs_rename(struct mnt_idmap *idmap,
ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir),
BTRFS_I(d_inode(old_dentry)), BTRFS_I(d_inode(old_dentry)),
&old_fname.disk_name, &rename_ctx); &old_fname.disk_name, &rename_ctx);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
ret = btrfs_update_inode(trans, BTRFS_I(old_inode)); ret = btrfs_update_inode(trans, BTRFS_I(old_inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8571,7 +8571,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
if (unlikely(btrfs_ino(BTRFS_I(new_inode)) == if (unlikely(btrfs_ino(BTRFS_I(new_inode)) ==
BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry); ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8580,7 +8580,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir), ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir),
BTRFS_I(d_inode(new_dentry)), BTRFS_I(d_inode(new_dentry)),
&new_fname.disk_name); &new_fname.disk_name);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8588,7 +8588,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
if (new_inode->i_nlink == 0) { if (new_inode->i_nlink == 0) {
ret = btrfs_orphan_add(trans, ret = btrfs_orphan_add(trans,
BTRFS_I(d_inode(new_dentry))); BTRFS_I(d_inode(new_dentry)));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8597,7 +8597,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode), ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
&new_fname.disk_name, 0, index); &new_fname.disk_name, 0, index);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} }
@ -8611,7 +8611,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
if (flags & RENAME_WHITEOUT) { if (flags & RENAME_WHITEOUT) {
ret = btrfs_create_new_inode(trans, &whiteout_args); ret = btrfs_create_new_inode(trans, &whiteout_args);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
} else { } else {
@ -8905,7 +8905,7 @@ static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
goto out; goto out;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (unlikely(!path)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
discard_new_inode(inode); discard_new_inode(inode);
@ -8917,7 +8917,7 @@ static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
key.offset = 0; key.offset = 0;
datasize = btrfs_file_extent_calc_inline_size(name_len); datasize = btrfs_file_extent_calc_inline_size(name_len);
ret = btrfs_insert_empty_item(trans, root, path, &key, datasize); ret = btrfs_insert_empty_item(trans, root, path, &key, datasize);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_free_path(path); btrfs_free_path(path);
discard_new_inode(inode); discard_new_inode(inode);
@ -9130,7 +9130,7 @@ next:
ret = btrfs_update_inode(trans, BTRFS_I(inode)); ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
if (own_trans) if (own_trans)
btrfs_end_transaction(trans); btrfs_end_transaction(trans);

View File

@ -376,13 +376,13 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
if (comp) { if (comp) {
ret = btrfs_set_prop(trans, inode, "btrfs.compression", ret = btrfs_set_prop(trans, inode, "btrfs.compression",
comp, strlen(comp), 0); comp, strlen(comp), 0);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
} else { } else {
ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL, 0, 0); ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL, 0, 0);
if (ret && ret != -ENODATA) { if (unlikely(ret && ret != -ENODATA)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
@ -633,7 +633,7 @@ static noinline int create_subvol(struct mnt_idmap *idmap,
btrfs_clear_buffer_dirty(trans, leaf); btrfs_clear_buffer_dirty(trans, leaf);
btrfs_tree_unlock(leaf); btrfs_tree_unlock(leaf);
ret2 = btrfs_free_tree_block(trans, objectid, leaf, 0, 1); ret2 = btrfs_free_tree_block(trans, objectid, leaf, 0, 1);
if (ret2 < 0) if (unlikely(ret2 < 0))
btrfs_abort_transaction(trans, ret2); btrfs_abort_transaction(trans, ret2);
free_extent_buffer(leaf); free_extent_buffer(leaf);
goto out; goto out;
@ -654,14 +654,14 @@ static noinline int create_subvol(struct mnt_idmap *idmap,
/* ... and new_root is owned by new_inode_args.inode now. */ /* ... and new_root is owned by new_inode_args.inode now. */
ret = btrfs_record_root_in_trans(trans, new_root); ret = btrfs_record_root_in_trans(trans, new_root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = btrfs_uuid_tree_add(trans, root_item->uuid, ret = btrfs_uuid_tree_add(trans, root_item->uuid,
BTRFS_UUID_KEY_SUBVOL, objectid); BTRFS_UUID_KEY_SUBVOL, objectid);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -669,7 +669,7 @@ static noinline int create_subvol(struct mnt_idmap *idmap,
btrfs_record_new_subvolume(trans, BTRFS_I(dir)); btrfs_record_new_subvolume(trans, BTRFS_I(dir));
ret = btrfs_create_new_inode(trans, &new_inode_args); ret = btrfs_create_new_inode(trans, &new_inode_args);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -4008,7 +4008,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid, ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid,
BTRFS_UUID_KEY_RECEIVED_SUBVOL, BTRFS_UUID_KEY_RECEIVED_SUBVOL,
btrfs_root_id(root)); btrfs_root_id(root));
if (ret && ret != -ENOENT) { if (unlikely(ret && ret != -ENOENT)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
goto out; goto out;
@ -4032,7 +4032,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
ret = btrfs_uuid_tree_add(trans, sa->uuid, ret = btrfs_uuid_tree_add(trans, sa->uuid,
BTRFS_UUID_KEY_RECEIVED_SUBVOL, BTRFS_UUID_KEY_RECEIVED_SUBVOL,
btrfs_root_id(root)); btrfs_root_id(root));
if (ret < 0 && ret != -EEXIST) { if (unlikely(ret < 0 && ret != -EEXIST)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
goto out; goto out;

View File

@ -1069,7 +1069,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
} }
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (unlikely(!path)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_root; goto out_free_root;
@ -1081,7 +1081,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
ret = btrfs_insert_empty_item(trans, quota_root, path, &key, ret = btrfs_insert_empty_item(trans, quota_root, path, &key,
sizeof(*ptr)); sizeof(*ptr));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1111,7 +1111,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
ret = btrfs_search_slot_for_read(tree_root, &key, path, 1, 0); ret = btrfs_search_slot_for_read(tree_root, &key, path, 1, 0);
if (ret > 0) if (ret > 0)
goto out_add_root; goto out_add_root;
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1129,7 +1129,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
/* We should not have a stray @prealloc pointer. */ /* We should not have a stray @prealloc pointer. */
ASSERT(prealloc == NULL); ASSERT(prealloc == NULL);
prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS); prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
if (!prealloc) { if (unlikely(!prealloc)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
@ -1137,7 +1137,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
ret = add_qgroup_item(trans, quota_root, ret = add_qgroup_item(trans, quota_root,
found_key.offset); found_key.offset);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1145,13 +1145,13 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
qgroup = add_qgroup_rb(fs_info, prealloc, found_key.offset); qgroup = add_qgroup_rb(fs_info, prealloc, found_key.offset);
prealloc = NULL; prealloc = NULL;
ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup); ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
ret = btrfs_search_slot_for_read(tree_root, &found_key, ret = btrfs_search_slot_for_read(tree_root, &found_key,
path, 1, 0); path, 1, 0);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1165,7 +1165,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
} }
} }
ret = btrfs_next_item(tree_root, path); ret = btrfs_next_item(tree_root, path);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1176,7 +1176,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
out_add_root: out_add_root:
btrfs_release_path(path); btrfs_release_path(path);
ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID); ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1190,7 +1190,7 @@ out_add_root:
qgroup = add_qgroup_rb(fs_info, prealloc, BTRFS_FS_TREE_OBJECTID); qgroup = add_qgroup_rb(fs_info, prealloc, BTRFS_FS_TREE_OBJECTID);
prealloc = NULL; prealloc = NULL;
ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup); ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_free_path; goto out_free_path;
} }
@ -1376,13 +1376,13 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info)
btrfs_free_qgroup_config(fs_info); btrfs_free_qgroup_config(fs_info);
ret = btrfs_clean_quota_tree(trans, quota_root); ret = btrfs_clean_quota_tree(trans, quota_root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = btrfs_del_root(trans, &quota_root->root_key); ret = btrfs_del_root(trans, &quota_root->root_key);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }

View File

@ -304,7 +304,7 @@ int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans,
int ret; int ret;
stripe_extent = kzalloc(item_size, GFP_NOFS); stripe_extent = kzalloc(item_size, GFP_NOFS);
if (!stripe_extent) { if (!unlikely(stripe_extent)) {
btrfs_abort_transaction(trans, -ENOMEM); btrfs_abort_transaction(trans, -ENOMEM);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return -ENOMEM; return -ENOMEM;

View File

@ -43,7 +43,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
} }
ret = btrfs_update_inode(trans, BTRFS_I(inode)); ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
@ -268,12 +268,12 @@ copy_inline_extent:
drop_args.end = aligned_end; drop_args.end = aligned_end;
drop_args.drop_cache = true; drop_args.drop_cache = true;
ret = btrfs_drop_extents(trans, root, inode, &drop_args); ret = btrfs_drop_extents(trans, root, inode, &drop_args);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = btrfs_insert_empty_item(trans, root, path, new_key, size); ret = btrfs_insert_empty_item(trans, root, path, new_key, size);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -285,7 +285,7 @@ copy_inline_extent:
btrfs_update_inode_bytes(inode, datal, drop_args.bytes_found); btrfs_update_inode_bytes(inode, datal, drop_args.bytes_found);
btrfs_set_inode_full_sync(inode); btrfs_set_inode_full_sync(inode);
ret = btrfs_inode_set_file_extent_range(inode, 0, aligned_end); ret = btrfs_inode_set_file_extent_range(inode, 0, aligned_end);
if (ret) if (unlikely(ret))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
out: out:
if (!ret && !trans) { if (!ret && !trans) {

View File

@ -967,7 +967,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
btrfs_init_data_ref(&ref, key.objectid, key.offset, btrfs_init_data_ref(&ref, key.objectid, key.offset,
btrfs_root_id(root), false); btrfs_root_id(root), false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -981,7 +981,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
btrfs_init_data_ref(&ref, key.objectid, key.offset, btrfs_init_data_ref(&ref, key.objectid, key.offset,
btrfs_root_id(root), false); btrfs_root_id(root), false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -1192,7 +1192,7 @@ again:
ref.ref_root = btrfs_root_id(src); ref.ref_root = btrfs_root_id(src);
btrfs_init_tree_ref(&ref, level - 1, 0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -1205,7 +1205,7 @@ again:
ref.ref_root = btrfs_root_id(dest); ref.ref_root = btrfs_root_id(dest);
btrfs_init_tree_ref(&ref, level - 1, 0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -1219,7 +1219,7 @@ again:
ref.ref_root = btrfs_root_id(src); ref.ref_root = btrfs_root_id(src);
btrfs_init_tree_ref(&ref, level - 1, 0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -1233,7 +1233,7 @@ again:
ref.ref_root = btrfs_root_id(dest); ref.ref_root = btrfs_root_id(dest);
btrfs_init_tree_ref(&ref, level - 1, 0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
break; break;
} }
@ -1784,7 +1784,7 @@ again:
list_add(&reloc_root->root_list, &reloc_roots); list_add(&reloc_root->root_list, &reloc_roots);
btrfs_put_root(root); btrfs_put_root(root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
if (!err) if (!err)
err = ret; err = ret;
@ -2325,7 +2325,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
if (!ret) if (!ret)
ret = btrfs_drop_subtree(trans, root, eb, ret = btrfs_drop_subtree(trans, root, eb,
upper->eb); upper->eb);
if (ret) if (unlikely(ret))
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
} }
next: next:

View File

@ -168,20 +168,20 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_release_path(path); btrfs_release_path(path);
ret = btrfs_search_slot(trans, root, key, path, ret = btrfs_search_slot(trans, root, key, path,
-1, 1); -1, 1);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
btrfs_release_path(path); btrfs_release_path(path);
ret = btrfs_insert_empty_item(trans, root, path, ret = btrfs_insert_empty_item(trans, root, path,
key, sizeof(*item)); key, sizeof(*item));
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -421,7 +421,7 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
again: again:
ret = btrfs_insert_empty_item(trans, tree_root, path, &key, ret = btrfs_insert_empty_item(trans, tree_root, path, &key,
sizeof(*ref) + name->len); sizeof(*ref) + name->len);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }

View File

@ -1569,7 +1569,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
* qgroup counters could end up wrong. * qgroup counters could end up wrong.
*/ */
ret = btrfs_run_delayed_refs(trans, U64_MAX); ret = btrfs_run_delayed_refs(trans, U64_MAX);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -1710,7 +1710,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
* insert the directory item * insert the directory item
*/ */
ret = btrfs_set_inode_index(parent_inode, &index); ret = btrfs_set_inode_index(parent_inode, &index);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1731,7 +1731,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
ret = btrfs_create_qgroup(trans, objectid); ret = btrfs_create_qgroup(trans, objectid);
if (ret && ret != -EEXIST) { if (ret && ret != -EEXIST) {
if (ret != -ENOTCONN || btrfs_qgroup_enabled(fs_info)) { if (unlikely(ret != -ENOTCONN || btrfs_qgroup_enabled(fs_info))) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1744,13 +1744,13 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
* snapshot * snapshot
*/ */
ret = btrfs_run_delayed_items(trans); ret = btrfs_run_delayed_items(trans);
if (ret) { /* Transaction aborted */ if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
ret = record_root_in_trans(trans, root, 0); ret = record_root_in_trans(trans, root, 0);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1785,7 +1785,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
old = btrfs_lock_root_node(root); old = btrfs_lock_root_node(root);
ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, ret = btrfs_cow_block(trans, root, old, NULL, 0, &old,
BTRFS_NESTING_COW); BTRFS_NESTING_COW);
if (ret) { if (unlikely(ret)) {
btrfs_tree_unlock(old); btrfs_tree_unlock(old);
free_extent_buffer(old); free_extent_buffer(old);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
@ -1796,7 +1796,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
/* clean up in any case */ /* clean up in any case */
btrfs_tree_unlock(old); btrfs_tree_unlock(old);
free_extent_buffer(old); free_extent_buffer(old);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1812,7 +1812,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
ret = btrfs_insert_root(trans, tree_root, &key, new_root_item); ret = btrfs_insert_root(trans, tree_root, &key, new_root_item);
btrfs_tree_unlock(tmp); btrfs_tree_unlock(tmp);
free_extent_buffer(tmp); free_extent_buffer(tmp);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1824,7 +1824,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
btrfs_root_id(parent_root), btrfs_root_id(parent_root),
btrfs_ino(parent_inode), index, btrfs_ino(parent_inode), index,
&fname.disk_name); &fname.disk_name);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1839,7 +1839,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
} }
ret = btrfs_reloc_post_snapshot(trans, pending); ret = btrfs_reloc_post_snapshot(trans, pending);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1862,7 +1862,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
ret = btrfs_insert_dir_item(trans, &fname.disk_name, ret = btrfs_insert_dir_item(trans, &fname.disk_name,
parent_inode, &key, BTRFS_FT_DIR, parent_inode, &key, BTRFS_FT_DIR,
index); index);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1872,14 +1872,14 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
inode_set_mtime_to_ts(&parent_inode->vfs_inode, inode_set_mtime_to_ts(&parent_inode->vfs_inode,
inode_set_ctime_current(&parent_inode->vfs_inode)); inode_set_ctime_current(&parent_inode->vfs_inode));
ret = btrfs_update_inode_fallback(trans, parent_inode); ret = btrfs_update_inode_fallback(trans, parent_inode);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
ret = btrfs_uuid_tree_add(trans, new_root_item->uuid, ret = btrfs_uuid_tree_add(trans, new_root_item->uuid,
BTRFS_UUID_KEY_SUBVOL, BTRFS_UUID_KEY_SUBVOL,
objectid); objectid);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
@ -1887,7 +1887,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
ret = btrfs_uuid_tree_add(trans, new_root_item->received_uuid, ret = btrfs_uuid_tree_add(trans, new_root_item->received_uuid,
BTRFS_UUID_KEY_RECEIVED_SUBVOL, BTRFS_UUID_KEY_RECEIVED_SUBVOL,
objectid); objectid);
if (ret && ret != -EEXIST) { if (unlikely(ret && ret != -EEXIST)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }

View File

@ -439,7 +439,7 @@ static int process_one_buffer(struct extent_buffer *eb,
}; };
ret = btrfs_read_extent_buffer(eb, &check); ret = btrfs_read_extent_buffer(eb, &check);
if (ret) { if (unlikely(ret)) {
if (trans) if (trans)
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
else else
@ -451,7 +451,7 @@ static int process_one_buffer(struct extent_buffer *eb,
if (wc->pin) { if (wc->pin) {
ASSERT(trans != NULL); ASSERT(trans != NULL);
ret = btrfs_pin_extent_for_log_replay(trans, eb); ret = btrfs_pin_extent_for_log_replay(trans, eb);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
@ -3570,7 +3570,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level); btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level);
ret = write_all_supers(fs_info, 1); ret = write_all_supers(fs_info, 1);
mutex_unlock(&fs_info->tree_log_mutex); mutex_unlock(&fs_info->tree_log_mutex);
if (ret) { if (unlikely(ret)) {
btrfs_set_log_full_commit(trans); btrfs_set_log_full_commit(trans);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_wake_log_root; goto out_wake_log_root;
@ -7630,7 +7630,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
ret = walk_log_tree(&wc); ret = walk_log_tree(&wc);
wc.log = NULL; wc.log = NULL;
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error; goto error;
} }
@ -7645,7 +7645,7 @@ again:
ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error; goto error;
} }
@ -7672,7 +7672,7 @@ again:
if (IS_ERR(wc.root)) { if (IS_ERR(wc.root)) {
ret = PTR_ERR(wc.root); ret = PTR_ERR(wc.root);
wc.root = NULL; wc.root = NULL;
if (ret != -ENOENT) { if (unlikely(ret != -ENOENT)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error; goto error;
} }
@ -7689,7 +7689,7 @@ again:
* each subsequent pass. * each subsequent pass.
*/ */
ret = btrfs_pin_extent_for_log_replay(trans, wc.log->node); ret = btrfs_pin_extent_for_log_replay(trans, wc.log->node);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error; goto error;
} }
@ -7698,13 +7698,13 @@ again:
wc.root->log_root = wc.log; wc.root->log_root = wc.log;
ret = btrfs_record_root_in_trans(trans, wc.root); ret = btrfs_record_root_in_trans(trans, wc.root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto next; goto next;
} }
ret = walk_log_tree(&wc); ret = walk_log_tree(&wc);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto next; goto next;
} }
@ -7715,7 +7715,7 @@ again:
wc.subvol_path = path; wc.subvol_path = path;
ret = fixup_inode_link_counts(&wc); ret = fixup_inode_link_counts(&wc);
wc.subvol_path = NULL; wc.subvol_path = NULL;
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto next; goto next;
} }
@ -7728,7 +7728,7 @@ again:
* could only happen during mount. * could only happen during mount.
*/ */
ret = btrfs_init_root_free_objectid(root); ret = btrfs_init_root_free_objectid(root);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto next; goto next;
} }

View File

@ -487,12 +487,12 @@ static int rollback_verity(struct btrfs_inode *inode)
inode->ro_flags &= ~BTRFS_INODE_RO_VERITY; inode->ro_flags &= ~BTRFS_INODE_RO_VERITY;
btrfs_sync_inode_flags_to_i_flags(inode); btrfs_sync_inode_flags_to_i_flags(inode);
ret = btrfs_update_inode(trans, inode); ret = btrfs_update_inode(trans, inode);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = del_orphan(trans, inode); ret = del_orphan(trans, inode);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }

View File

@ -2243,7 +2243,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
} }
ret = btrfs_rm_dev_item(trans, device); ret = btrfs_rm_dev_item(trans, device);
if (ret) { if (unlikely(ret)) {
/* Any error in dev item removal is critical */ /* Any error in dev item removal is critical */
btrfs_crit(fs_info, btrfs_crit(fs_info,
"failed to remove device item for devid %llu: %d", "failed to remove device item for devid %llu: %d",
@ -2843,21 +2843,21 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
mutex_lock(&fs_info->chunk_mutex); mutex_lock(&fs_info->chunk_mutex);
ret = init_first_rw_device(trans); ret = init_first_rw_device(trans);
mutex_unlock(&fs_info->chunk_mutex); mutex_unlock(&fs_info->chunk_mutex);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_sysfs; goto error_sysfs;
} }
} }
ret = btrfs_add_dev_item(trans, device); ret = btrfs_add_dev_item(trans, device);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_sysfs; goto error_sysfs;
} }
if (seeding_dev) { if (seeding_dev) {
ret = btrfs_finish_sprout(trans); ret = btrfs_finish_sprout(trans);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto error_sysfs; goto error_sysfs;
} }
@ -3058,7 +3058,7 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
} }
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset); btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -3283,7 +3283,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
ret = btrfs_free_dev_extent(trans, device, ret = btrfs_free_dev_extent(trans, device,
map->stripes[i].physical, map->stripes[i].physical,
&dev_extent_len); &dev_extent_len);
if (ret) { if (unlikely(ret)) {
mutex_unlock(&fs_devices->device_list_mutex); mutex_unlock(&fs_devices->device_list_mutex);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -3353,7 +3353,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
struct btrfs_space_info *space_info; struct btrfs_space_info *space_info;
space_info = btrfs_find_space_info(fs_info, sys_flags); space_info = btrfs_find_space_info(fs_info, sys_flags);
if (!space_info) { if (unlikely(!space_info)) {
ret = -EINVAL; ret = -EINVAL;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -3367,17 +3367,17 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
} }
ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg); ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = remove_chunk_item(trans, map, chunk_offset); ret = remove_chunk_item(trans, map, chunk_offset);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
} else if (ret) { } else if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3386,7 +3386,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) {
ret = btrfs_del_sys_chunk(fs_info, chunk_offset); ret = btrfs_del_sys_chunk(fs_info, chunk_offset);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -3402,7 +3402,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
btrfs_trans_release_chunk_metadata(trans); btrfs_trans_release_chunk_metadata(trans);
ret = btrfs_remove_block_group(trans, map); ret = btrfs_remove_block_group(trans, map);
if (ret) { if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
@ -5041,7 +5041,7 @@ again:
/* Now btrfs_update_device() will change the on-disk size. */ /* Now btrfs_update_device() will change the on-disk size. */
ret = btrfs_update_device(trans, device); ret = btrfs_update_device(trans, device);
btrfs_trans_release_chunk_metadata(trans); btrfs_trans_release_chunk_metadata(trans);
if (ret < 0) { if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
} else { } else {
@ -5701,7 +5701,7 @@ int btrfs_chunk_alloc_add_chunk_item(struct btrfs_trans_handle *trans,
item_size = btrfs_chunk_item_size(map->num_stripes); item_size = btrfs_chunk_item_size(map->num_stripes);
chunk = kzalloc(item_size, GFP_NOFS); chunk = kzalloc(item_size, GFP_NOFS);
if (!chunk) { if (unlikely(!chunk)) {
ret = -ENOMEM; ret = -ENOMEM;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;