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>

+231 -232
+5 -5
fs/btrfs/block-group.c
··· 3248 */ 3249 BTRFS_I(inode)->generation = 0; 3250 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 3251 - if (ret) { 3252 /* 3253 * So theoretically we could recover from this, simply set the 3254 * super cache generation to 0 so we know to invalidate the ··· 3995 struct btrfs_space_info *sys_space_info; 3996 3997 sys_space_info = btrfs_find_space_info(trans->fs_info, sys_flags); 3998 - if (!sys_space_info) { 3999 ret = -EINVAL; 4000 btrfs_abort_transaction(trans, ret); 4001 goto out; ··· 4009 } 4010 4011 ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg); 4012 - if (ret) { 4013 btrfs_abort_transaction(trans, ret); 4014 goto out; 4015 } 4016 4017 ret = btrfs_chunk_alloc_add_chunk_item(trans, bg); 4018 - if (ret) { 4019 btrfs_abort_transaction(trans, ret); 4020 goto out; 4021 } 4022 - } else if (ret) { 4023 btrfs_abort_transaction(trans, ret); 4024 goto out; 4025 }
··· 3248 */ 3249 BTRFS_I(inode)->generation = 0; 3250 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 3251 + if (unlikely(ret)) { 3252 /* 3253 * So theoretically we could recover from this, simply set the 3254 * super cache generation to 0 so we know to invalidate the ··· 3995 struct btrfs_space_info *sys_space_info; 3996 3997 sys_space_info = btrfs_find_space_info(trans->fs_info, sys_flags); 3998 + if (unlikely(!sys_space_info)) { 3999 ret = -EINVAL; 4000 btrfs_abort_transaction(trans, ret); 4001 goto out; ··· 4009 } 4010 4011 ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg); 4012 + if (unlikely(ret)) { 4013 btrfs_abort_transaction(trans, ret); 4014 goto out; 4015 } 4016 4017 ret = btrfs_chunk_alloc_add_chunk_item(trans, bg); 4018 + if (unlikely(ret)) { 4019 btrfs_abort_transaction(trans, ret); 4020 goto out; 4021 } 4022 + } else if (unlikely(ret)) { 4023 btrfs_abort_transaction(trans, ret); 4024 goto out; 4025 }
+25 -25
fs/btrfs/ctree.c
··· 293 294 if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) { 295 ret = btrfs_inc_ref(trans, root, cow, 1); 296 - if (ret) 297 btrfs_abort_transaction(trans, ret); 298 } else { 299 ret = btrfs_inc_ref(trans, root, cow, 0); 300 - if (ret) 301 btrfs_abort_transaction(trans, ret); 302 } 303 if (ret) { ··· 536 write_extent_buffer_fsid(cow, fs_info->fs_devices->metadata_uuid); 537 538 ret = update_ref_for_cow(trans, root, buf, cow, &last_ref); 539 - if (ret) { 540 btrfs_abort_transaction(trans, ret); 541 goto error_unlock_cow; 542 } 543 544 if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) { 545 ret = btrfs_reloc_cow_block(trans, root, buf, cow); 546 - if (ret) { 547 btrfs_abort_transaction(trans, ret); 548 goto error_unlock_cow; 549 } ··· 556 parent_start = buf->start; 557 558 ret = btrfs_tree_mod_log_insert_root(root->node, cow, true); 559 - if (ret < 0) { 560 btrfs_abort_transaction(trans, ret); 561 goto error_unlock_cow; 562 } ··· 567 parent_start, last_ref); 568 free_extent_buffer(buf); 569 add_root_to_dirty_list(root); 570 - if (ret < 0) { 571 btrfs_abort_transaction(trans, ret); 572 goto error_unlock_cow; 573 } ··· 575 WARN_ON(trans->transid != btrfs_header_generation(parent)); 576 ret = btrfs_tree_mod_log_insert_key(parent, parent_slot, 577 BTRFS_MOD_LOG_KEY_REPLACE); 578 - if (ret) { 579 btrfs_abort_transaction(trans, ret); 580 goto error_unlock_cow; 581 } ··· 586 btrfs_mark_buffer_dirty(trans, parent); 587 if (last_ref) { 588 ret = btrfs_tree_mod_log_free_eb(buf); 589 - if (ret) { 590 btrfs_abort_transaction(trans, ret); 591 goto error_unlock_cow; 592 } 593 } 594 ret = btrfs_free_tree_block(trans, btrfs_root_id(root), buf, 595 parent_start, last_ref); 596 - if (ret < 0) { 597 btrfs_abort_transaction(trans, ret); 598 goto error_unlock_cow; 599 } ··· 922 } 923 924 ret = btrfs_tree_mod_log_insert_root(root->node, child, true); 925 - if (ret < 0) { 926 btrfs_tree_unlock(child); 927 free_extent_buffer(child); 928 btrfs_abort_transaction(trans, ret); ··· 944 ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); 945 /* once for the root ptr */ 946 free_extent_buffer_stale(mid); 947 - if (ret < 0) { 948 btrfs_abort_transaction(trans, ret); 949 goto out; 950 } ··· 1019 right, 0, 1); 1020 free_extent_buffer_stale(right); 1021 right = NULL; 1022 - if (ret < 0) { 1023 btrfs_abort_transaction(trans, ret); 1024 goto out; 1025 } ··· 1028 btrfs_node_key(right, &right_key, 0); 1029 ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, 1030 BTRFS_MOD_LOG_KEY_REPLACE); 1031 - if (ret < 0) { 1032 btrfs_abort_transaction(trans, ret); 1033 goto out; 1034 } ··· 1080 ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); 1081 free_extent_buffer_stale(mid); 1082 mid = NULL; 1083 - if (ret < 0) { 1084 btrfs_abort_transaction(trans, ret); 1085 goto out; 1086 } ··· 1090 btrfs_node_key(mid, &mid_key, 0); 1091 ret = btrfs_tree_mod_log_insert_key(parent, pslot, 1092 BTRFS_MOD_LOG_KEY_REPLACE); 1093 - if (ret < 0) { 1094 btrfs_abort_transaction(trans, ret); 1095 goto out; 1096 } ··· 1195 btrfs_node_key(mid, &disk_key, 0); 1196 ret = btrfs_tree_mod_log_insert_key(parent, pslot, 1197 BTRFS_MOD_LOG_KEY_REPLACE); 1198 - if (ret < 0) { 1199 btrfs_tree_unlock(left); 1200 free_extent_buffer(left); 1201 btrfs_abort_transaction(trans, ret); ··· 1255 btrfs_node_key(right, &disk_key, 0); 1256 ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, 1257 BTRFS_MOD_LOG_KEY_REPLACE); 1258 - if (ret < 0) { 1259 btrfs_tree_unlock(right); 1260 free_extent_buffer(right); 1261 btrfs_abort_transaction(trans, ret); ··· 2737 return ret; 2738 } 2739 ret = btrfs_tree_mod_log_eb_copy(dst, src, dst_nritems, 0, push_items); 2740 - if (ret) { 2741 btrfs_abort_transaction(trans, ret); 2742 return ret; 2743 } ··· 2822 2823 ret = btrfs_tree_mod_log_eb_copy(dst, src, 0, src_nritems - push_items, 2824 push_items); 2825 - if (ret) { 2826 btrfs_abort_transaction(trans, ret); 2827 return ret; 2828 } ··· 2892 2893 btrfs_clear_buffer_dirty(trans, c); 2894 ret2 = btrfs_free_tree_block(trans, btrfs_root_id(root), c, 0, 1); 2895 - if (ret2 < 0) 2896 btrfs_abort_transaction(trans, ret2); 2897 btrfs_tree_unlock(c); 2898 free_extent_buffer(c); ··· 2937 if (level) { 2938 ret = btrfs_tree_mod_log_insert_move(lower, slot + 1, 2939 slot, nritems - slot); 2940 - if (ret < 0) { 2941 btrfs_abort_transaction(trans, ret); 2942 return ret; 2943 } ··· 2950 if (level) { 2951 ret = btrfs_tree_mod_log_insert_key(lower, slot, 2952 BTRFS_MOD_LOG_KEY_ADD); 2953 - if (ret < 0) { 2954 btrfs_abort_transaction(trans, ret); 2955 return ret; 2956 } ··· 3026 ASSERT(btrfs_header_level(c) == level); 3027 3028 ret = btrfs_tree_mod_log_eb_copy(split, c, 0, mid, c_nritems - mid); 3029 - if (ret) { 3030 btrfs_tree_unlock(split); 3031 free_extent_buffer(split); 3032 btrfs_abort_transaction(trans, ret); ··· 4383 if (level) { 4384 ret = btrfs_tree_mod_log_insert_move(parent, slot, 4385 slot + 1, nritems - slot - 1); 4386 - if (ret < 0) { 4387 btrfs_abort_transaction(trans, ret); 4388 return ret; 4389 } ··· 4396 } else if (level) { 4397 ret = btrfs_tree_mod_log_insert_key(parent, slot, 4398 BTRFS_MOD_LOG_KEY_REMOVE); 4399 - if (ret < 0) { 4400 btrfs_abort_transaction(trans, ret); 4401 return ret; 4402 }
··· 293 294 if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) { 295 ret = btrfs_inc_ref(trans, root, cow, 1); 296 + if (unlikely(ret)) 297 btrfs_abort_transaction(trans, ret); 298 } else { 299 ret = btrfs_inc_ref(trans, root, cow, 0); 300 + if (unlikely(ret)) 301 btrfs_abort_transaction(trans, ret); 302 } 303 if (ret) { ··· 536 write_extent_buffer_fsid(cow, fs_info->fs_devices->metadata_uuid); 537 538 ret = update_ref_for_cow(trans, root, buf, cow, &last_ref); 539 + if (unlikely(ret)) { 540 btrfs_abort_transaction(trans, ret); 541 goto error_unlock_cow; 542 } 543 544 if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) { 545 ret = btrfs_reloc_cow_block(trans, root, buf, cow); 546 + if (unlikely(ret)) { 547 btrfs_abort_transaction(trans, ret); 548 goto error_unlock_cow; 549 } ··· 556 parent_start = buf->start; 557 558 ret = btrfs_tree_mod_log_insert_root(root->node, cow, true); 559 + if (unlikely(ret < 0)) { 560 btrfs_abort_transaction(trans, ret); 561 goto error_unlock_cow; 562 } ··· 567 parent_start, last_ref); 568 free_extent_buffer(buf); 569 add_root_to_dirty_list(root); 570 + if (unlikely(ret < 0)) { 571 btrfs_abort_transaction(trans, ret); 572 goto error_unlock_cow; 573 } ··· 575 WARN_ON(trans->transid != btrfs_header_generation(parent)); 576 ret = btrfs_tree_mod_log_insert_key(parent, parent_slot, 577 BTRFS_MOD_LOG_KEY_REPLACE); 578 + if (unlikely(ret)) { 579 btrfs_abort_transaction(trans, ret); 580 goto error_unlock_cow; 581 } ··· 586 btrfs_mark_buffer_dirty(trans, parent); 587 if (last_ref) { 588 ret = btrfs_tree_mod_log_free_eb(buf); 589 + if (unlikely(ret)) { 590 btrfs_abort_transaction(trans, ret); 591 goto error_unlock_cow; 592 } 593 } 594 ret = btrfs_free_tree_block(trans, btrfs_root_id(root), buf, 595 parent_start, last_ref); 596 + if (unlikely(ret < 0)) { 597 btrfs_abort_transaction(trans, ret); 598 goto error_unlock_cow; 599 } ··· 922 } 923 924 ret = btrfs_tree_mod_log_insert_root(root->node, child, true); 925 + if (unlikely(ret < 0)) { 926 btrfs_tree_unlock(child); 927 free_extent_buffer(child); 928 btrfs_abort_transaction(trans, ret); ··· 944 ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); 945 /* once for the root ptr */ 946 free_extent_buffer_stale(mid); 947 + if (unlikely(ret < 0)) { 948 btrfs_abort_transaction(trans, ret); 949 goto out; 950 } ··· 1019 right, 0, 1); 1020 free_extent_buffer_stale(right); 1021 right = NULL; 1022 + if (unlikely(ret < 0)) { 1023 btrfs_abort_transaction(trans, ret); 1024 goto out; 1025 } ··· 1028 btrfs_node_key(right, &right_key, 0); 1029 ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, 1030 BTRFS_MOD_LOG_KEY_REPLACE); 1031 + if (unlikely(ret < 0)) { 1032 btrfs_abort_transaction(trans, ret); 1033 goto out; 1034 } ··· 1080 ret = btrfs_free_tree_block(trans, btrfs_root_id(root), mid, 0, 1); 1081 free_extent_buffer_stale(mid); 1082 mid = NULL; 1083 + if (unlikely(ret < 0)) { 1084 btrfs_abort_transaction(trans, ret); 1085 goto out; 1086 } ··· 1090 btrfs_node_key(mid, &mid_key, 0); 1091 ret = btrfs_tree_mod_log_insert_key(parent, pslot, 1092 BTRFS_MOD_LOG_KEY_REPLACE); 1093 + if (unlikely(ret < 0)) { 1094 btrfs_abort_transaction(trans, ret); 1095 goto out; 1096 } ··· 1195 btrfs_node_key(mid, &disk_key, 0); 1196 ret = btrfs_tree_mod_log_insert_key(parent, pslot, 1197 BTRFS_MOD_LOG_KEY_REPLACE); 1198 + if (unlikely(ret < 0)) { 1199 btrfs_tree_unlock(left); 1200 free_extent_buffer(left); 1201 btrfs_abort_transaction(trans, ret); ··· 1255 btrfs_node_key(right, &disk_key, 0); 1256 ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, 1257 BTRFS_MOD_LOG_KEY_REPLACE); 1258 + if (unlikely(ret < 0)) { 1259 btrfs_tree_unlock(right); 1260 free_extent_buffer(right); 1261 btrfs_abort_transaction(trans, ret); ··· 2737 return ret; 2738 } 2739 ret = btrfs_tree_mod_log_eb_copy(dst, src, dst_nritems, 0, push_items); 2740 + if (unlikely(ret)) { 2741 btrfs_abort_transaction(trans, ret); 2742 return ret; 2743 } ··· 2822 2823 ret = btrfs_tree_mod_log_eb_copy(dst, src, 0, src_nritems - push_items, 2824 push_items); 2825 + if (unlikely(ret)) { 2826 btrfs_abort_transaction(trans, ret); 2827 return ret; 2828 } ··· 2892 2893 btrfs_clear_buffer_dirty(trans, c); 2894 ret2 = btrfs_free_tree_block(trans, btrfs_root_id(root), c, 0, 1); 2895 + if (unlikely(ret2 < 0)) 2896 btrfs_abort_transaction(trans, ret2); 2897 btrfs_tree_unlock(c); 2898 free_extent_buffer(c); ··· 2937 if (level) { 2938 ret = btrfs_tree_mod_log_insert_move(lower, slot + 1, 2939 slot, nritems - slot); 2940 + if (unlikely(ret < 0)) { 2941 btrfs_abort_transaction(trans, ret); 2942 return ret; 2943 } ··· 2950 if (level) { 2951 ret = btrfs_tree_mod_log_insert_key(lower, slot, 2952 BTRFS_MOD_LOG_KEY_ADD); 2953 + if (unlikely(ret < 0)) { 2954 btrfs_abort_transaction(trans, ret); 2955 return ret; 2956 } ··· 3026 ASSERT(btrfs_header_level(c) == level); 3027 3028 ret = btrfs_tree_mod_log_eb_copy(split, c, 0, mid, c_nritems - mid); 3029 + if (unlikely(ret)) { 3030 btrfs_tree_unlock(split); 3031 free_extent_buffer(split); 3032 btrfs_abort_transaction(trans, ret); ··· 4383 if (level) { 4384 ret = btrfs_tree_mod_log_insert_move(parent, slot, 4385 slot + 1, nritems - slot - 1); 4386 + if (unlikely(ret < 0)) { 4387 btrfs_abort_transaction(trans, ret); 4388 return ret; 4389 } ··· 4396 } else if (level) { 4397 ret = btrfs_tree_mod_log_insert_key(parent, slot, 4398 BTRFS_MOD_LOG_KEY_REMOVE); 4399 + if (unlikely(ret < 0)) { 4400 btrfs_abort_transaction(trans, ret); 4401 return ret; 4402 }
+3 -3
fs/btrfs/delayed-inode.c
··· 1038 * transaction, because we could leave the inode with the 1039 * improper counts behind. 1040 */ 1041 - if (ret != -ENOENT) 1042 btrfs_abort_transaction(trans, ret); 1043 goto out; 1044 } ··· 1066 1067 btrfs_release_path(path); 1068 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); 1069 - if (ret < 0) { 1070 btrfs_abort_transaction(trans, ret); 1071 goto err_out; 1072 } ··· 1175 while (curr_node && (!count || nr--)) { 1176 ret = __btrfs_commit_inode_delayed_items(trans, path, 1177 curr_node); 1178 - if (ret) { 1179 btrfs_abort_transaction(trans, ret); 1180 break; 1181 }
··· 1038 * transaction, because we could leave the inode with the 1039 * improper counts behind. 1040 */ 1041 + if (unlikely(ret != -ENOENT)) 1042 btrfs_abort_transaction(trans, ret); 1043 goto out; 1044 } ··· 1066 1067 btrfs_release_path(path); 1068 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); 1069 + if (unlikely(ret < 0)) { 1070 btrfs_abort_transaction(trans, ret); 1071 goto err_out; 1072 } ··· 1175 while (curr_node && (!count || nr--)) { 1176 ret = __btrfs_commit_inode_delayed_items(trans, path, 1177 curr_node); 1178 + if (unlikely(ret)) { 1179 btrfs_abort_transaction(trans, ret); 1180 break; 1181 }
+19 -19
fs/btrfs/extent-tree.c
··· 2157 delayed_refs->run_delayed_start = find_middle(&delayed_refs->root); 2158 #endif 2159 ret = __btrfs_run_delayed_refs(trans, min_bytes); 2160 - if (ret < 0) { 2161 btrfs_abort_transaction(trans, ret); 2162 return ret; 2163 } ··· 2982 2983 csum_root = btrfs_csum_root(trans->fs_info, bytenr); 2984 ret = btrfs_del_csums(trans, csum_root, bytenr, num_bytes); 2985 - if (ret) { 2986 btrfs_abort_transaction(trans, ret); 2987 return ret; 2988 } 2989 2990 ret = btrfs_delete_raid_extent(trans, bytenr, num_bytes); 2991 - if (ret) { 2992 btrfs_abort_transaction(trans, ret); 2993 return ret; 2994 } 2995 } 2996 2997 ret = btrfs_record_squota_delta(trans->fs_info, delta); 2998 - if (ret) { 2999 btrfs_abort_transaction(trans, ret); 3000 return ret; 3001 } 3002 3003 ret = btrfs_add_to_free_space_tree(trans, bytenr, num_bytes); 3004 - if (ret) { 3005 btrfs_abort_transaction(trans, ret); 3006 return ret; 3007 } ··· 3115 3116 is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID; 3117 3118 - if (!is_data && refs_to_drop != 1) { 3119 btrfs_crit(info, 3120 "invalid refs_to_drop, dropping more than 1 refs for tree block %llu refs_to_drop %u", 3121 node->bytenr, refs_to_drop); ··· 3172 /* Must be SHARED_* item, remove the backref first */ 3173 ret = remove_extent_backref(trans, extent_root, path, 3174 NULL, refs_to_drop, is_data); 3175 - if (ret) { 3176 btrfs_abort_transaction(trans, ret); 3177 goto out; 3178 } ··· 3221 "umm, got %d back from search, was looking for %llu, slot %d", 3222 ret, bytenr, path->slots[0]); 3223 } 3224 - if (ret < 0) { 3225 btrfs_abort_transaction(trans, ret); 3226 goto out; 3227 } ··· 3298 if (found_extent) { 3299 ret = remove_extent_backref(trans, extent_root, path, 3300 iref, refs_to_drop, is_data); 3301 - if (ret) { 3302 btrfs_abort_transaction(trans, ret); 3303 goto out; 3304 } ··· 3363 3364 ret = btrfs_del_items(trans, extent_root, path, path->slots[0], 3365 num_to_del); 3366 - if (ret) { 3367 btrfs_abort_transaction(trans, ret); 3368 goto out; 3369 } ··· 5472 if (!(wc->flags[level] & flag)) { 5473 ASSERT(path->locks[level]); 5474 ret = btrfs_inc_ref(trans, root, eb, 1); 5475 - if (ret) { 5476 btrfs_abort_transaction(trans, ret); 5477 return ret; 5478 } 5479 ret = btrfs_dec_ref(trans, root, eb, 0); 5480 - if (ret) { 5481 btrfs_abort_transaction(trans, ret); 5482 return ret; 5483 } 5484 ret = btrfs_set_disk_extent_flags(trans, eb, flag); 5485 - if (ret) { 5486 btrfs_abort_transaction(trans, ret); 5487 return ret; 5488 } ··· 5885 } 5886 } else { 5887 ret = btrfs_dec_ref(trans, root, eb, 0); 5888 - if (ret) { 5889 btrfs_abort_transaction(trans, ret); 5890 return ret; 5891 } ··· 6180 while (1) { 6181 6182 ret = walk_down_tree(trans, root, path, wc); 6183 - if (ret < 0) { 6184 btrfs_abort_transaction(trans, ret); 6185 break; 6186 } 6187 6188 ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL); 6189 - if (ret < 0) { 6190 btrfs_abort_transaction(trans, ret); 6191 break; 6192 } ··· 6213 ret = btrfs_update_root(trans, tree_root, 6214 &root->root_key, 6215 root_item); 6216 - if (ret) { 6217 btrfs_abort_transaction(trans, ret); 6218 goto out_end_trans; 6219 } ··· 6249 goto out_end_trans; 6250 6251 ret = btrfs_del_root(trans, &root->root_key); 6252 - if (ret) { 6253 btrfs_abort_transaction(trans, ret); 6254 goto out_end_trans; 6255 } ··· 6257 if (!is_reloc_root) { 6258 ret = btrfs_find_root(tree_root, &root->root_key, path, 6259 NULL, NULL); 6260 - if (ret < 0) { 6261 btrfs_abort_transaction(trans, ret); 6262 goto out_end_trans; 6263 } else if (ret > 0) {
··· 2157 delayed_refs->run_delayed_start = find_middle(&delayed_refs->root); 2158 #endif 2159 ret = __btrfs_run_delayed_refs(trans, min_bytes); 2160 + if (unlikely(ret < 0)) { 2161 btrfs_abort_transaction(trans, ret); 2162 return ret; 2163 } ··· 2982 2983 csum_root = btrfs_csum_root(trans->fs_info, bytenr); 2984 ret = btrfs_del_csums(trans, csum_root, bytenr, num_bytes); 2985 + if (unlikely(ret)) { 2986 btrfs_abort_transaction(trans, ret); 2987 return ret; 2988 } 2989 2990 ret = btrfs_delete_raid_extent(trans, bytenr, num_bytes); 2991 + if (unlikely(ret)) { 2992 btrfs_abort_transaction(trans, ret); 2993 return ret; 2994 } 2995 } 2996 2997 ret = btrfs_record_squota_delta(trans->fs_info, delta); 2998 + if (unlikely(ret)) { 2999 btrfs_abort_transaction(trans, ret); 3000 return ret; 3001 } 3002 3003 ret = btrfs_add_to_free_space_tree(trans, bytenr, num_bytes); 3004 + if (unlikely(ret)) { 3005 btrfs_abort_transaction(trans, ret); 3006 return ret; 3007 } ··· 3115 3116 is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID; 3117 3118 + if (unlikely(!is_data && refs_to_drop != 1)) { 3119 btrfs_crit(info, 3120 "invalid refs_to_drop, dropping more than 1 refs for tree block %llu refs_to_drop %u", 3121 node->bytenr, refs_to_drop); ··· 3172 /* Must be SHARED_* item, remove the backref first */ 3173 ret = remove_extent_backref(trans, extent_root, path, 3174 NULL, refs_to_drop, is_data); 3175 + if (unlikely(ret)) { 3176 btrfs_abort_transaction(trans, ret); 3177 goto out; 3178 } ··· 3221 "umm, got %d back from search, was looking for %llu, slot %d", 3222 ret, bytenr, path->slots[0]); 3223 } 3224 + if (unlikely(ret < 0)) { 3225 btrfs_abort_transaction(trans, ret); 3226 goto out; 3227 } ··· 3298 if (found_extent) { 3299 ret = remove_extent_backref(trans, extent_root, path, 3300 iref, refs_to_drop, is_data); 3301 + if (unlikely(ret)) { 3302 btrfs_abort_transaction(trans, ret); 3303 goto out; 3304 } ··· 3363 3364 ret = btrfs_del_items(trans, extent_root, path, path->slots[0], 3365 num_to_del); 3366 + if (unlikely(ret)) { 3367 btrfs_abort_transaction(trans, ret); 3368 goto out; 3369 } ··· 5472 if (!(wc->flags[level] & flag)) { 5473 ASSERT(path->locks[level]); 5474 ret = btrfs_inc_ref(trans, root, eb, 1); 5475 + if (unlikely(ret)) { 5476 btrfs_abort_transaction(trans, ret); 5477 return ret; 5478 } 5479 ret = btrfs_dec_ref(trans, root, eb, 0); 5480 + if (unlikely(ret)) { 5481 btrfs_abort_transaction(trans, ret); 5482 return ret; 5483 } 5484 ret = btrfs_set_disk_extent_flags(trans, eb, flag); 5485 + if (unlikely(ret)) { 5486 btrfs_abort_transaction(trans, ret); 5487 return ret; 5488 } ··· 5885 } 5886 } else { 5887 ret = btrfs_dec_ref(trans, root, eb, 0); 5888 + if (unlikely(ret)) { 5889 btrfs_abort_transaction(trans, ret); 5890 return ret; 5891 } ··· 6180 while (1) { 6181 6182 ret = walk_down_tree(trans, root, path, wc); 6183 + if (unlikely(ret < 0)) { 6184 btrfs_abort_transaction(trans, ret); 6185 break; 6186 } 6187 6188 ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL); 6189 + if (unlikely(ret < 0)) { 6190 btrfs_abort_transaction(trans, ret); 6191 break; 6192 } ··· 6213 ret = btrfs_update_root(trans, tree_root, 6214 &root->root_key, 6215 root_item); 6216 + if (unlikely(ret)) { 6217 btrfs_abort_transaction(trans, ret); 6218 goto out_end_trans; 6219 } ··· 6249 goto out_end_trans; 6250 6251 ret = btrfs_del_root(trans, &root->root_key); 6252 + if (unlikely(ret)) { 6253 btrfs_abort_transaction(trans, ret); 6254 goto out_end_trans; 6255 } ··· 6257 if (!is_reloc_root) { 6258 ret = btrfs_find_root(tree_root, &root->root_key, path, 6259 NULL, NULL); 6260 + if (unlikely(ret < 0)) { 6261 btrfs_abort_transaction(trans, ret); 6262 goto out_end_trans; 6263 } else if (ret > 0) {
+1 -1
fs/btrfs/file-item.c
··· 1011 * item changed size or key 1012 */ 1013 ret = btrfs_split_item(trans, root, path, &key, offset); 1014 - if (ret && ret != -EAGAIN) { 1015 btrfs_abort_transaction(trans, ret); 1016 break; 1017 }
··· 1011 * item changed size or key 1012 */ 1013 ret = btrfs_split_item(trans, root, path, &key, offset); 1014 + if (unlikely(ret && ret != -EAGAIN)) { 1015 btrfs_abort_transaction(trans, ret); 1016 break; 1017 }
+21 -22
fs/btrfs/file.c
··· 327 args->start - extent_offset, 328 0, false); 329 ret = btrfs_inc_extent_ref(trans, &ref); 330 - if (ret) { 331 btrfs_abort_transaction(trans, ret); 332 break; 333 } ··· 426 key.offset - extent_offset, 427 0, false); 428 ret = btrfs_free_extent(trans, &ref); 429 - if (ret) { 430 btrfs_abort_transaction(trans, ret); 431 break; 432 } ··· 443 444 ret = btrfs_del_items(trans, root, path, del_slot, 445 del_nr); 446 - if (ret) { 447 btrfs_abort_transaction(trans, ret); 448 break; 449 } ··· 587 588 leaf = path->nodes[0]; 589 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 590 - if (key.objectid != ino || 591 - key.type != BTRFS_EXTENT_DATA_KEY) { 592 ret = -EINVAL; 593 btrfs_abort_transaction(trans, ret); 594 goto out; 595 } 596 fi = btrfs_item_ptr(leaf, path->slots[0], 597 struct btrfs_file_extent_item); 598 - if (btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_PREALLOC) { 599 ret = -EINVAL; 600 btrfs_abort_transaction(trans, ret); 601 goto out; 602 } 603 extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi); 604 - if (key.offset > start || extent_end < end) { 605 ret = -EINVAL; 606 btrfs_abort_transaction(trans, ret); 607 goto out; ··· 675 btrfs_release_path(path); 676 goto again; 677 } 678 - if (ret < 0) { 679 btrfs_abort_transaction(trans, ret); 680 goto out; 681 } ··· 703 ref.ref_root = btrfs_root_id(root); 704 btrfs_init_data_ref(&ref, ino, orig_offset, 0, false); 705 ret = btrfs_inc_extent_ref(trans, &ref); 706 - if (ret) { 707 btrfs_abort_transaction(trans, ret); 708 goto out; 709 } ··· 711 if (split == start) { 712 key.offset = start; 713 } else { 714 - if (start != key.offset) { 715 ret = -EINVAL; 716 btrfs_abort_transaction(trans, ret); 717 goto out; ··· 743 del_slot = path->slots[0] + 1; 744 del_nr++; 745 ret = btrfs_free_extent(trans, &ref); 746 - if (ret) { 747 btrfs_abort_transaction(trans, ret); 748 goto out; 749 } ··· 761 del_slot = path->slots[0]; 762 del_nr++; 763 ret = btrfs_free_extent(trans, &ref); 764 - if (ret) { 765 btrfs_abort_transaction(trans, ret); 766 goto out; 767 } ··· 782 extent_end - key.offset); 783 784 ret = btrfs_del_items(trans, root, path, del_slot, del_nr); 785 - if (ret < 0) { 786 btrfs_abort_transaction(trans, ret); 787 goto out; 788 } ··· 2459 * got EOPNOTSUPP via prealloc then we messed up and 2460 * need to abort. 2461 */ 2462 - if (ret && 2463 - (ret != -EOPNOTSUPP || 2464 - (extent_info && extent_info->is_new_extent))) 2465 btrfs_abort_transaction(trans, ret); 2466 break; 2467 } ··· 2472 cur_offset < ino_size) { 2473 ret = fill_holes(trans, inode, path, cur_offset, 2474 drop_args.drop_end); 2475 - if (ret) { 2476 /* 2477 * If we failed then we didn't insert our hole 2478 * entries for the area we dropped, so now the ··· 2492 ret = btrfs_inode_clear_file_extent_range(inode, 2493 cur_offset, 2494 drop_args.drop_end - cur_offset); 2495 - if (ret) { 2496 /* 2497 * We couldn't clear our area, so we could 2498 * presumably adjust up and corrupt the fs, so ··· 2511 ret = btrfs_insert_replace_extent(trans, inode, path, 2512 extent_info, replace_len, 2513 drop_args.bytes_found); 2514 - if (ret) { 2515 btrfs_abort_transaction(trans, ret); 2516 break; 2517 } ··· 2606 cur_offset < drop_args.drop_end) { 2607 ret = fill_holes(trans, inode, path, cur_offset, 2608 drop_args.drop_end); 2609 - if (ret) { 2610 /* Same comment as above. */ 2611 btrfs_abort_transaction(trans, ret); 2612 goto out_trans; ··· 2615 /* See the comment in the loop above for the reasoning here. */ 2616 ret = btrfs_inode_clear_file_extent_range(inode, cur_offset, 2617 drop_args.drop_end - cur_offset); 2618 - if (ret) { 2619 btrfs_abort_transaction(trans, ret); 2620 goto out_trans; 2621 } ··· 2625 ret = btrfs_insert_replace_extent(trans, inode, path, 2626 extent_info, extent_info->data_len, 2627 drop_args.bytes_found); 2628 - if (ret) { 2629 btrfs_abort_transaction(trans, ret); 2630 goto out_trans; 2631 }
··· 327 args->start - extent_offset, 328 0, false); 329 ret = btrfs_inc_extent_ref(trans, &ref); 330 + if (unlikely(ret)) { 331 btrfs_abort_transaction(trans, ret); 332 break; 333 } ··· 426 key.offset - extent_offset, 427 0, false); 428 ret = btrfs_free_extent(trans, &ref); 429 + if (unlikely(ret)) { 430 btrfs_abort_transaction(trans, ret); 431 break; 432 } ··· 443 444 ret = btrfs_del_items(trans, root, path, del_slot, 445 del_nr); 446 + if (unlikely(ret)) { 447 btrfs_abort_transaction(trans, ret); 448 break; 449 } ··· 587 588 leaf = path->nodes[0]; 589 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 590 + if (unlikely(key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY)) { 591 ret = -EINVAL; 592 btrfs_abort_transaction(trans, ret); 593 goto out; 594 } 595 fi = btrfs_item_ptr(leaf, path->slots[0], 596 struct btrfs_file_extent_item); 597 + if (unlikely(btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_PREALLOC)) { 598 ret = -EINVAL; 599 btrfs_abort_transaction(trans, ret); 600 goto out; 601 } 602 extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi); 603 + if (unlikely(key.offset > start || extent_end < end)) { 604 ret = -EINVAL; 605 btrfs_abort_transaction(trans, ret); 606 goto out; ··· 676 btrfs_release_path(path); 677 goto again; 678 } 679 + if (unlikely(ret < 0)) { 680 btrfs_abort_transaction(trans, ret); 681 goto out; 682 } ··· 704 ref.ref_root = btrfs_root_id(root); 705 btrfs_init_data_ref(&ref, ino, orig_offset, 0, false); 706 ret = btrfs_inc_extent_ref(trans, &ref); 707 + if (unlikely(ret)) { 708 btrfs_abort_transaction(trans, ret); 709 goto out; 710 } ··· 712 if (split == start) { 713 key.offset = start; 714 } else { 715 + if (unlikely(start != key.offset)) { 716 ret = -EINVAL; 717 btrfs_abort_transaction(trans, ret); 718 goto out; ··· 744 del_slot = path->slots[0] + 1; 745 del_nr++; 746 ret = btrfs_free_extent(trans, &ref); 747 + if (unlikely(ret)) { 748 btrfs_abort_transaction(trans, ret); 749 goto out; 750 } ··· 762 del_slot = path->slots[0]; 763 del_nr++; 764 ret = btrfs_free_extent(trans, &ref); 765 + if (unlikely(ret)) { 766 btrfs_abort_transaction(trans, ret); 767 goto out; 768 } ··· 783 extent_end - key.offset); 784 785 ret = btrfs_del_items(trans, root, path, del_slot, del_nr); 786 + if (unlikely(ret < 0)) { 787 btrfs_abort_transaction(trans, ret); 788 goto out; 789 } ··· 2460 * got EOPNOTSUPP via prealloc then we messed up and 2461 * need to abort. 2462 */ 2463 + if (unlikely(ret && 2464 + (ret != -EOPNOTSUPP || 2465 + (extent_info && extent_info->is_new_extent)))) 2466 btrfs_abort_transaction(trans, ret); 2467 break; 2468 } ··· 2473 cur_offset < ino_size) { 2474 ret = fill_holes(trans, inode, path, cur_offset, 2475 drop_args.drop_end); 2476 + if (unlikely(ret)) { 2477 /* 2478 * If we failed then we didn't insert our hole 2479 * entries for the area we dropped, so now the ··· 2493 ret = btrfs_inode_clear_file_extent_range(inode, 2494 cur_offset, 2495 drop_args.drop_end - cur_offset); 2496 + if (unlikely(ret)) { 2497 /* 2498 * We couldn't clear our area, so we could 2499 * presumably adjust up and corrupt the fs, so ··· 2512 ret = btrfs_insert_replace_extent(trans, inode, path, 2513 extent_info, replace_len, 2514 drop_args.bytes_found); 2515 + if (unlikely(ret)) { 2516 btrfs_abort_transaction(trans, ret); 2517 break; 2518 } ··· 2607 cur_offset < drop_args.drop_end) { 2608 ret = fill_holes(trans, inode, path, cur_offset, 2609 drop_args.drop_end); 2610 + if (unlikely(ret)) { 2611 /* Same comment as above. */ 2612 btrfs_abort_transaction(trans, ret); 2613 goto out_trans; ··· 2616 /* See the comment in the loop above for the reasoning here. */ 2617 ret = btrfs_inode_clear_file_extent_range(inode, cur_offset, 2618 drop_args.drop_end - cur_offset); 2619 + if (unlikely(ret)) { 2620 btrfs_abort_transaction(trans, ret); 2621 goto out_trans; 2622 } ··· 2626 ret = btrfs_insert_replace_extent(trans, inode, path, 2627 extent_info, extent_info->data_len, 2628 drop_args.bytes_found); 2629 + if (unlikely(ret)) { 2630 btrfs_abort_transaction(trans, ret); 2631 goto out_trans; 2632 }
+1 -1
fs/btrfs/free-space-cache.c
··· 4142 if (!active) { 4143 set_bit(BTRFS_FS_CLEANUP_SPACE_CACHE_V1, &fs_info->flags); 4144 ret = cleanup_free_space_cache_v1(fs_info, trans); 4145 - if (ret) { 4146 btrfs_abort_transaction(trans, ret); 4147 btrfs_end_transaction(trans); 4148 goto out;
··· 4142 if (!active) { 4143 set_bit(BTRFS_FS_CLEANUP_SPACE_CACHE_V1, &fs_info->flags); 4144 ret = cleanup_free_space_cache_v1(fs_info, trans); 4145 + if (unlikely(ret)) { 4146 btrfs_abort_transaction(trans, ret); 4147 btrfs_end_transaction(trans); 4148 goto out;
+24 -24
fs/btrfs/free-space-tree.c
··· 218 219 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); 220 bitmap = alloc_bitmap(bitmap_size); 221 - if (!bitmap) { 222 ret = -ENOMEM; 223 btrfs_abort_transaction(trans, ret); 224 goto out; ··· 233 234 while (!done) { 235 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); 236 - if (ret) { 237 btrfs_abort_transaction(trans, ret); 238 goto out; 239 } ··· 271 } 272 273 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); 274 - if (ret) { 275 btrfs_abort_transaction(trans, ret); 276 goto out; 277 } ··· 320 321 ret = btrfs_insert_empty_item(trans, root, path, &key, 322 data_size); 323 - if (ret) { 324 btrfs_abort_transaction(trans, ret); 325 goto out; 326 } ··· 361 362 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); 363 bitmap = alloc_bitmap(bitmap_size); 364 - if (!bitmap) { 365 ret = -ENOMEM; 366 btrfs_abort_transaction(trans, ret); 367 goto out; ··· 376 377 while (!done) { 378 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); 379 - if (ret) { 380 btrfs_abort_transaction(trans, ret); 381 goto out; 382 } ··· 420 } 421 422 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); 423 - if (ret) { 424 btrfs_abort_transaction(trans, ret); 425 goto out; 426 } ··· 454 key.offset = (end_bit - start_bit) * fs_info->sectorsize; 455 456 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); 457 - if (ret) { 458 btrfs_abort_transaction(trans, ret); 459 goto out; 460 } ··· 848 return 0; 849 850 path = btrfs_alloc_path(); 851 - if (!path) { 852 ret = -ENOMEM; 853 btrfs_abort_transaction(trans, ret); 854 goto out; 855 } 856 857 block_group = btrfs_lookup_block_group(trans->fs_info, start); 858 - if (!block_group) { 859 DEBUG_WARN("no block group found for start=%llu", start); 860 ret = -ENOENT; 861 btrfs_abort_transaction(trans, ret); ··· 1030 return 0; 1031 1032 path = btrfs_alloc_path(); 1033 - if (!path) { 1034 ret = -ENOMEM; 1035 btrfs_abort_transaction(trans, ret); 1036 goto out; 1037 } 1038 1039 block_group = btrfs_lookup_block_group(trans->fs_info, start); 1040 - if (!block_group) { 1041 DEBUG_WARN("no block group found for start=%llu", start); 1042 ret = -ENOENT; 1043 btrfs_abort_transaction(trans, ret); ··· 1185 goto out_clear; 1186 } 1187 ret = btrfs_global_root_insert(free_space_root); 1188 - if (ret) { 1189 btrfs_put_root(free_space_root); 1190 btrfs_abort_transaction(trans, ret); 1191 btrfs_end_transaction(trans); ··· 1197 block_group = rb_entry(node, struct btrfs_block_group, 1198 cache_node); 1199 ret = populate_free_space_tree(trans, block_group); 1200 - if (ret) { 1201 btrfs_abort_transaction(trans, ret); 1202 btrfs_end_transaction(trans); 1203 goto out_clear; ··· 1290 btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID); 1291 1292 ret = clear_free_space_tree(trans, free_space_root); 1293 - if (ret) { 1294 btrfs_abort_transaction(trans, ret); 1295 btrfs_end_transaction(trans); 1296 return ret; 1297 } 1298 1299 ret = btrfs_del_root(trans, &free_space_root->root_key); 1300 - if (ret) { 1301 btrfs_abort_transaction(trans, ret); 1302 btrfs_end_transaction(trans); 1303 return ret; ··· 1315 ret = btrfs_free_tree_block(trans, btrfs_root_id(free_space_root), 1316 free_space_root->node, 0, 1); 1317 btrfs_put_root(free_space_root); 1318 - if (ret < 0) { 1319 btrfs_abort_transaction(trans, ret); 1320 btrfs_end_transaction(trans); 1321 return ret; ··· 1344 set_bit(BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, &fs_info->flags); 1345 1346 ret = clear_free_space_tree(trans, free_space_root); 1347 - if (ret) { 1348 btrfs_abort_transaction(trans, ret); 1349 btrfs_end_transaction(trans); 1350 return ret; ··· 1362 goto next; 1363 1364 ret = populate_free_space_tree(trans, block_group); 1365 - if (ret) { 1366 btrfs_abort_transaction(trans, ret); 1367 btrfs_end_transaction(trans); 1368 return ret; ··· 1422 1423 if (!path) { 1424 path = btrfs_alloc_path(); 1425 - if (!path) { 1426 btrfs_abort_transaction(trans, -ENOMEM); 1427 return -ENOMEM; 1428 } ··· 1430 } 1431 1432 ret = add_new_free_space_info(trans, block_group, path); 1433 - if (ret) { 1434 btrfs_abort_transaction(trans, ret); 1435 goto out; 1436 } ··· 1481 } 1482 1483 path = btrfs_alloc_path(); 1484 - if (!path) { 1485 ret = -ENOMEM; 1486 btrfs_abort_transaction(trans, ret); 1487 goto out; ··· 1496 1497 while (!done) { 1498 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); 1499 - if (ret) { 1500 btrfs_abort_transaction(trans, ret); 1501 goto out; 1502 } ··· 1527 } 1528 1529 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); 1530 - if (ret) { 1531 btrfs_abort_transaction(trans, ret); 1532 goto out; 1533 }
··· 218 219 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); 220 bitmap = alloc_bitmap(bitmap_size); 221 + if (unlikely(!bitmap)) { 222 ret = -ENOMEM; 223 btrfs_abort_transaction(trans, ret); 224 goto out; ··· 233 234 while (!done) { 235 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); 236 + if (unlikely(ret)) { 237 btrfs_abort_transaction(trans, ret); 238 goto out; 239 } ··· 271 } 272 273 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); 274 + if (unlikely(ret)) { 275 btrfs_abort_transaction(trans, ret); 276 goto out; 277 } ··· 320 321 ret = btrfs_insert_empty_item(trans, root, path, &key, 322 data_size); 323 + if (unlikely(ret)) { 324 btrfs_abort_transaction(trans, ret); 325 goto out; 326 } ··· 361 362 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); 363 bitmap = alloc_bitmap(bitmap_size); 364 + if (unlikely(!bitmap)) { 365 ret = -ENOMEM; 366 btrfs_abort_transaction(trans, ret); 367 goto out; ··· 376 377 while (!done) { 378 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); 379 + if (unlikely(ret)) { 380 btrfs_abort_transaction(trans, ret); 381 goto out; 382 } ··· 420 } 421 422 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); 423 + if (unlikely(ret)) { 424 btrfs_abort_transaction(trans, ret); 425 goto out; 426 } ··· 454 key.offset = (end_bit - start_bit) * fs_info->sectorsize; 455 456 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); 457 + if (unlikely(ret)) { 458 btrfs_abort_transaction(trans, ret); 459 goto out; 460 } ··· 848 return 0; 849 850 path = btrfs_alloc_path(); 851 + if (unlikely(!path)) { 852 ret = -ENOMEM; 853 btrfs_abort_transaction(trans, ret); 854 goto out; 855 } 856 857 block_group = btrfs_lookup_block_group(trans->fs_info, start); 858 + if (unlikely(!block_group)) { 859 DEBUG_WARN("no block group found for start=%llu", start); 860 ret = -ENOENT; 861 btrfs_abort_transaction(trans, ret); ··· 1030 return 0; 1031 1032 path = btrfs_alloc_path(); 1033 + if (unlikely(!path)) { 1034 ret = -ENOMEM; 1035 btrfs_abort_transaction(trans, ret); 1036 goto out; 1037 } 1038 1039 block_group = btrfs_lookup_block_group(trans->fs_info, start); 1040 + if (unlikely(!block_group)) { 1041 DEBUG_WARN("no block group found for start=%llu", start); 1042 ret = -ENOENT; 1043 btrfs_abort_transaction(trans, ret); ··· 1185 goto out_clear; 1186 } 1187 ret = btrfs_global_root_insert(free_space_root); 1188 + if (unlikely(ret)) { 1189 btrfs_put_root(free_space_root); 1190 btrfs_abort_transaction(trans, ret); 1191 btrfs_end_transaction(trans); ··· 1197 block_group = rb_entry(node, struct btrfs_block_group, 1198 cache_node); 1199 ret = populate_free_space_tree(trans, block_group); 1200 + if (unlikely(ret)) { 1201 btrfs_abort_transaction(trans, ret); 1202 btrfs_end_transaction(trans); 1203 goto out_clear; ··· 1290 btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID); 1291 1292 ret = clear_free_space_tree(trans, free_space_root); 1293 + if (unlikely(ret)) { 1294 btrfs_abort_transaction(trans, ret); 1295 btrfs_end_transaction(trans); 1296 return ret; 1297 } 1298 1299 ret = btrfs_del_root(trans, &free_space_root->root_key); 1300 + if (unlikely(ret)) { 1301 btrfs_abort_transaction(trans, ret); 1302 btrfs_end_transaction(trans); 1303 return ret; ··· 1315 ret = btrfs_free_tree_block(trans, btrfs_root_id(free_space_root), 1316 free_space_root->node, 0, 1); 1317 btrfs_put_root(free_space_root); 1318 + if (unlikely(ret < 0)) { 1319 btrfs_abort_transaction(trans, ret); 1320 btrfs_end_transaction(trans); 1321 return ret; ··· 1344 set_bit(BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, &fs_info->flags); 1345 1346 ret = clear_free_space_tree(trans, free_space_root); 1347 + if (unlikely(ret)) { 1348 btrfs_abort_transaction(trans, ret); 1349 btrfs_end_transaction(trans); 1350 return ret; ··· 1362 goto next; 1363 1364 ret = populate_free_space_tree(trans, block_group); 1365 + if (unlikely(ret)) { 1366 btrfs_abort_transaction(trans, ret); 1367 btrfs_end_transaction(trans); 1368 return ret; ··· 1422 1423 if (!path) { 1424 path = btrfs_alloc_path(); 1425 + if (unlikely(!path)) { 1426 btrfs_abort_transaction(trans, -ENOMEM); 1427 return -ENOMEM; 1428 } ··· 1430 } 1431 1432 ret = add_new_free_space_info(trans, block_group, path); 1433 + if (unlikely(ret)) { 1434 btrfs_abort_transaction(trans, ret); 1435 goto out; 1436 } ··· 1481 } 1482 1483 path = btrfs_alloc_path(); 1484 + if (unlikely(!path)) { 1485 ret = -ENOMEM; 1486 btrfs_abort_transaction(trans, ret); 1487 goto out; ··· 1496 1497 while (!done) { 1498 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); 1499 + if (unlikely(ret)) { 1500 btrfs_abort_transaction(trans, ret); 1501 goto out; 1502 } ··· 1527 } 1528 1529 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); 1530 + if (unlikely(ret)) { 1531 btrfs_abort_transaction(trans, ret); 1532 goto out; 1533 }
+5 -5
fs/btrfs/inode-item.c
··· 137 */ 138 extref = btrfs_find_name_in_ext_backref(path->nodes[0], path->slots[0], 139 ref_objectid, name); 140 - if (!extref) { 141 btrfs_abort_transaction(trans, -ENOENT); 142 return -ENOENT; 143 } ··· 627 if (control->clear_extent_range) { 628 ret = btrfs_inode_clear_file_extent_range(control->inode, 629 clear_start, clear_len); 630 - if (ret) { 631 btrfs_abort_transaction(trans, ret); 632 break; 633 } ··· 666 btrfs_init_data_ref(&ref, control->ino, extent_offset, 667 btrfs_root_id(root), false); 668 ret = btrfs_free_extent(trans, &ref); 669 - if (ret) { 670 btrfs_abort_transaction(trans, ret); 671 break; 672 } ··· 684 ret = btrfs_del_items(trans, root, path, 685 pending_del_slot, 686 pending_del_nr); 687 - if (ret) { 688 btrfs_abort_transaction(trans, ret); 689 break; 690 } ··· 720 int ret2; 721 722 ret2 = btrfs_del_items(trans, root, path, pending_del_slot, pending_del_nr); 723 - if (ret2) { 724 btrfs_abort_transaction(trans, ret2); 725 ret = ret2; 726 }
··· 137 */ 138 extref = btrfs_find_name_in_ext_backref(path->nodes[0], path->slots[0], 139 ref_objectid, name); 140 + if (unlikely(!extref)) { 141 btrfs_abort_transaction(trans, -ENOENT); 142 return -ENOENT; 143 } ··· 627 if (control->clear_extent_range) { 628 ret = btrfs_inode_clear_file_extent_range(control->inode, 629 clear_start, clear_len); 630 + if (unlikely(ret)) { 631 btrfs_abort_transaction(trans, ret); 632 break; 633 } ··· 666 btrfs_init_data_ref(&ref, control->ino, extent_offset, 667 btrfs_root_id(root), false); 668 ret = btrfs_free_extent(trans, &ref); 669 + if (unlikely(ret)) { 670 btrfs_abort_transaction(trans, ret); 671 break; 672 } ··· 684 ret = btrfs_del_items(trans, root, path, 685 pending_del_slot, 686 pending_del_nr); 687 + if (unlikely(ret)) { 688 btrfs_abort_transaction(trans, ret); 689 break; 690 } ··· 720 int ret2; 721 722 ret2 = btrfs_del_items(trans, root, path, pending_del_slot, pending_del_nr); 723 + if (unlikely(ret2)) { 724 btrfs_abort_transaction(trans, ret2); 725 ret = ret2; 726 }
+49 -49
fs/btrfs/inode.c
··· 634 drop_args.replace_extent = true; 635 drop_args.extent_item_size = btrfs_file_extent_calc_inline_size(data_len); 636 ret = btrfs_drop_extents(trans, root, inode, &drop_args); 637 - if (ret) { 638 btrfs_abort_transaction(trans, ret); 639 goto out; 640 } ··· 642 ret = insert_inline_extent(trans, path, inode, drop_args.extent_inserted, 643 size, compressed_size, compress_type, 644 compressed_folio, update_i_size); 645 - if (ret && ret != -ENOSPC) { 646 btrfs_abort_transaction(trans, ret); 647 goto out; 648 } else if (ret == -ENOSPC) { ··· 652 653 btrfs_update_inode_bytes(inode, size, drop_args.bytes_found); 654 ret = btrfs_update_inode(trans, inode); 655 - if (ret && ret != -ENOSPC) { 656 btrfs_abort_transaction(trans, ret); 657 goto out; 658 } else if (ret == -ENOSPC) { ··· 3150 trans->block_rsv = &inode->block_rsv; 3151 3152 ret = btrfs_insert_raid_extent(trans, ordered_extent); 3153 - if (ret) { 3154 btrfs_abort_transaction(trans, ret); 3155 goto out; 3156 } ··· 3158 if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { 3159 /* Logic error */ 3160 ASSERT(list_empty(&ordered_extent->list)); 3161 - if (!list_empty(&ordered_extent->list)) { 3162 ret = -EINVAL; 3163 btrfs_abort_transaction(trans, ret); 3164 goto out; ··· 3166 3167 btrfs_inode_safe_disk_i_size_write(inode, 0); 3168 ret = btrfs_update_inode_fallback(trans, inode); 3169 - if (ret) { 3170 /* -ENOMEM or corruption */ 3171 btrfs_abort_transaction(trans, ret); 3172 } ··· 3193 ordered_extent->disk_num_bytes); 3194 } 3195 } 3196 - if (ret < 0) { 3197 btrfs_abort_transaction(trans, ret); 3198 goto out; 3199 } 3200 3201 ret = btrfs_unpin_extent_cache(inode, ordered_extent->file_offset, 3202 ordered_extent->num_bytes, trans->transid); 3203 - if (ret < 0) { 3204 btrfs_abort_transaction(trans, ret); 3205 goto out; 3206 } 3207 3208 ret = add_pending_csums(trans, &ordered_extent->list); 3209 - if (ret) { 3210 btrfs_abort_transaction(trans, ret); 3211 goto out; 3212 } ··· 3224 3225 btrfs_inode_safe_disk_i_size_write(inode, 0); 3226 ret = btrfs_update_inode_fallback(trans, inode); 3227 - if (ret) { /* -ENOMEM or corruption */ 3228 btrfs_abort_transaction(trans, ret); 3229 goto out; 3230 } ··· 3539 int ret; 3540 3541 ret = btrfs_insert_orphan_item(trans, inode->root, btrfs_ino(inode)); 3542 - if (ret && ret != -EEXIST) { 3543 btrfs_abort_transaction(trans, ret); 3544 return ret; 3545 } ··· 4288 } 4289 4290 ret = btrfs_del_inode_ref(trans, root, name, ino, dir_ino, &index); 4291 - if (ret) { 4292 btrfs_crit(fs_info, 4293 "failed to delete reference to %.*s, root %llu inode %llu parent %llu", 4294 name->len, name->name, btrfs_root_id(root), ino, dir_ino); ··· 4300 rename_ctx->index = index; 4301 4302 ret = btrfs_delete_delayed_dir_index(trans, dir, index); 4303 - if (ret) { 4304 btrfs_abort_transaction(trans, ret); 4305 return ret; 4306 } ··· 4455 btrfs_dir_item_key_to_cpu(leaf, di, &key); 4456 WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid); 4457 ret = btrfs_delete_one_dir_name(trans, root, path, di); 4458 - if (ret) { 4459 btrfs_abort_transaction(trans, ret); 4460 goto out; 4461 } ··· 4486 ret = btrfs_del_root_ref(trans, objectid, 4487 btrfs_root_id(root), dir_ino, 4488 &index, &fname.disk_name); 4489 - if (ret) { 4490 btrfs_abort_transaction(trans, ret); 4491 goto out; 4492 } 4493 } 4494 4495 ret = btrfs_delete_delayed_dir_index(trans, dir, index); 4496 - if (ret) { 4497 btrfs_abort_transaction(trans, ret); 4498 goto out; 4499 } ··· 4665 btrfs_record_snapshot_destroy(trans, dir); 4666 4667 ret = btrfs_unlink_subvol(trans, dir, dentry); 4668 - if (ret) { 4669 btrfs_abort_transaction(trans, ret); 4670 goto out_end_trans; 4671 } 4672 4673 ret = btrfs_record_root_in_trans(trans, dest); 4674 - if (ret) { 4675 btrfs_abort_transaction(trans, ret); 4676 goto out_end_trans; 4677 } ··· 4685 ret = btrfs_insert_orphan_item(trans, 4686 fs_info->tree_root, 4687 btrfs_root_id(dest)); 4688 - if (ret) { 4689 btrfs_abort_transaction(trans, ret); 4690 goto out_end_trans; 4691 } ··· 4693 4694 ret = btrfs_uuid_tree_remove(trans, dest->root_item.uuid, 4695 BTRFS_UUID_KEY_SUBVOL, btrfs_root_id(dest)); 4696 - if (ret && ret != -ENOENT) { 4697 btrfs_abort_transaction(trans, ret); 4698 goto out_end_trans; 4699 } ··· 4702 dest->root_item.received_uuid, 4703 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4704 btrfs_root_id(dest)); 4705 - if (ret && ret != -ENOENT) { 4706 btrfs_abort_transaction(trans, ret); 4707 goto out_end_trans; 4708 } ··· 5106 drop_args.drop_cache = true; 5107 5108 ret = btrfs_drop_extents(trans, root, inode, &drop_args); 5109 - if (ret) { 5110 btrfs_abort_transaction(trans, ret); 5111 btrfs_end_transaction(trans); 5112 return ret; ··· 6559 batch.total_data_size = sizes[0] + (args->orphan ? 0 : sizes[1]); 6560 batch.nr = args->orphan ? 1 : 2; 6561 ret = btrfs_insert_empty_items(trans, root, path, &batch); 6562 - if (ret != 0) { 6563 btrfs_abort_transaction(trans, ret); 6564 goto discard; 6565 } ··· 6636 */ 6637 if (!args->subvol) { 6638 ret = btrfs_init_inode_security(trans, args); 6639 - if (ret) { 6640 btrfs_abort_transaction(trans, ret); 6641 goto discard; 6642 } ··· 6656 6657 if (args->orphan) { 6658 ret = btrfs_orphan_add(trans, BTRFS_I(inode)); 6659 - if (ret) { 6660 btrfs_abort_transaction(trans, ret); 6661 goto discard; 6662 } 6663 } else { 6664 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name, 6665 0, BTRFS_I(inode)->dir_index); 6666 - if (ret) { 6667 btrfs_abort_transaction(trans, ret); 6668 goto discard; 6669 } ··· 6727 btrfs_inode_type(inode), index); 6728 if (ret == -EEXIST || ret == -EOVERFLOW) 6729 goto fail_dir_item; 6730 - else if (ret) { 6731 btrfs_abort_transaction(trans, ret); 6732 return ret; 6733 } ··· 6883 /* Link added now we update the inode item with the new link count. */ 6884 inc_nlink(inode); 6885 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 6886 - if (ret) { 6887 btrfs_abort_transaction(trans, ret); 6888 goto fail; 6889 } ··· 6894 * open(2) O_TMPFILE flag. 6895 */ 6896 ret = btrfs_orphan_del(trans, BTRFS_I(inode)); 6897 - if (ret) { 6898 btrfs_abort_transaction(trans, ret); 6899 goto fail; 6900 } ··· 8208 btrfs_ino(BTRFS_I(old_dir)), 8209 new_idx); 8210 if (ret) { 8211 - if (need_abort) 8212 btrfs_abort_transaction(trans, ret); 8213 goto out_fail; 8214 } ··· 8256 /* src is a subvolume */ 8257 if (old_ino == BTRFS_FIRST_FREE_OBJECTID) { 8258 ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry); 8259 - if (ret) { 8260 btrfs_abort_transaction(trans, ret); 8261 goto out_fail; 8262 } ··· 8264 ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), 8265 BTRFS_I(old_dentry->d_inode), 8266 old_name, &old_rename_ctx); 8267 - if (ret) { 8268 btrfs_abort_transaction(trans, ret); 8269 goto out_fail; 8270 } 8271 ret = btrfs_update_inode(trans, BTRFS_I(old_inode)); 8272 - if (ret) { 8273 btrfs_abort_transaction(trans, ret); 8274 goto out_fail; 8275 } ··· 8278 /* dest is a subvolume */ 8279 if (new_ino == BTRFS_FIRST_FREE_OBJECTID) { 8280 ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry); 8281 - if (ret) { 8282 btrfs_abort_transaction(trans, ret); 8283 goto out_fail; 8284 } ··· 8286 ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir), 8287 BTRFS_I(new_dentry->d_inode), 8288 new_name, &new_rename_ctx); 8289 - if (ret) { 8290 btrfs_abort_transaction(trans, ret); 8291 goto out_fail; 8292 } 8293 ret = btrfs_update_inode(trans, BTRFS_I(new_inode)); 8294 - if (ret) { 8295 btrfs_abort_transaction(trans, ret); 8296 goto out_fail; 8297 } ··· 8299 8300 ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode), 8301 new_name, 0, old_idx); 8302 - if (ret) { 8303 btrfs_abort_transaction(trans, ret); 8304 goto out_fail; 8305 } 8306 8307 ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode), 8308 old_name, 0, new_idx); 8309 - if (ret) { 8310 btrfs_abort_transaction(trans, ret); 8311 goto out_fail; 8312 } ··· 8547 8548 if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) { 8549 ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry); 8550 - if (ret) { 8551 btrfs_abort_transaction(trans, ret); 8552 goto out_fail; 8553 } ··· 8555 ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), 8556 BTRFS_I(d_inode(old_dentry)), 8557 &old_fname.disk_name, &rename_ctx); 8558 - if (ret) { 8559 btrfs_abort_transaction(trans, ret); 8560 goto out_fail; 8561 } 8562 ret = btrfs_update_inode(trans, BTRFS_I(old_inode)); 8563 - if (ret) { 8564 btrfs_abort_transaction(trans, ret); 8565 goto out_fail; 8566 } ··· 8571 if (unlikely(btrfs_ino(BTRFS_I(new_inode)) == 8572 BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { 8573 ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry); 8574 - if (ret) { 8575 btrfs_abort_transaction(trans, ret); 8576 goto out_fail; 8577 } ··· 8580 ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir), 8581 BTRFS_I(d_inode(new_dentry)), 8582 &new_fname.disk_name); 8583 - if (ret) { 8584 btrfs_abort_transaction(trans, ret); 8585 goto out_fail; 8586 } ··· 8588 if (new_inode->i_nlink == 0) { 8589 ret = btrfs_orphan_add(trans, 8590 BTRFS_I(d_inode(new_dentry))); 8591 - if (ret) { 8592 btrfs_abort_transaction(trans, ret); 8593 goto out_fail; 8594 } ··· 8597 8598 ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode), 8599 &new_fname.disk_name, 0, index); 8600 - if (ret) { 8601 btrfs_abort_transaction(trans, ret); 8602 goto out_fail; 8603 } ··· 8611 8612 if (flags & RENAME_WHITEOUT) { 8613 ret = btrfs_create_new_inode(trans, &whiteout_args); 8614 - if (ret) { 8615 btrfs_abort_transaction(trans, ret); 8616 goto out_fail; 8617 } else { ··· 8905 goto out; 8906 8907 path = btrfs_alloc_path(); 8908 - if (!path) { 8909 ret = -ENOMEM; 8910 btrfs_abort_transaction(trans, ret); 8911 discard_new_inode(inode); ··· 8917 key.offset = 0; 8918 datasize = btrfs_file_extent_calc_inline_size(name_len); 8919 ret = btrfs_insert_empty_item(trans, root, path, &key, datasize); 8920 - if (ret) { 8921 btrfs_abort_transaction(trans, ret); 8922 btrfs_free_path(path); 8923 discard_new_inode(inode); ··· 9130 9131 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 9132 9133 - if (ret) { 9134 btrfs_abort_transaction(trans, ret); 9135 if (own_trans) 9136 btrfs_end_transaction(trans);
··· 634 drop_args.replace_extent = true; 635 drop_args.extent_item_size = btrfs_file_extent_calc_inline_size(data_len); 636 ret = btrfs_drop_extents(trans, root, inode, &drop_args); 637 + if (unlikely(ret)) { 638 btrfs_abort_transaction(trans, ret); 639 goto out; 640 } ··· 642 ret = insert_inline_extent(trans, path, inode, drop_args.extent_inserted, 643 size, compressed_size, compress_type, 644 compressed_folio, update_i_size); 645 + if (unlikely(ret && ret != -ENOSPC)) { 646 btrfs_abort_transaction(trans, ret); 647 goto out; 648 } else if (ret == -ENOSPC) { ··· 652 653 btrfs_update_inode_bytes(inode, size, drop_args.bytes_found); 654 ret = btrfs_update_inode(trans, inode); 655 + if (unlikely(ret && ret != -ENOSPC)) { 656 btrfs_abort_transaction(trans, ret); 657 goto out; 658 } else if (ret == -ENOSPC) { ··· 3150 trans->block_rsv = &inode->block_rsv; 3151 3152 ret = btrfs_insert_raid_extent(trans, ordered_extent); 3153 + if (unlikely(ret)) { 3154 btrfs_abort_transaction(trans, ret); 3155 goto out; 3156 } ··· 3158 if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { 3159 /* Logic error */ 3160 ASSERT(list_empty(&ordered_extent->list)); 3161 + if (unlikely(!list_empty(&ordered_extent->list))) { 3162 ret = -EINVAL; 3163 btrfs_abort_transaction(trans, ret); 3164 goto out; ··· 3166 3167 btrfs_inode_safe_disk_i_size_write(inode, 0); 3168 ret = btrfs_update_inode_fallback(trans, inode); 3169 + if (unlikely(ret)) { 3170 /* -ENOMEM or corruption */ 3171 btrfs_abort_transaction(trans, ret); 3172 } ··· 3193 ordered_extent->disk_num_bytes); 3194 } 3195 } 3196 + if (unlikely(ret < 0)) { 3197 btrfs_abort_transaction(trans, ret); 3198 goto out; 3199 } 3200 3201 ret = btrfs_unpin_extent_cache(inode, ordered_extent->file_offset, 3202 ordered_extent->num_bytes, trans->transid); 3203 + if (unlikely(ret < 0)) { 3204 btrfs_abort_transaction(trans, ret); 3205 goto out; 3206 } 3207 3208 ret = add_pending_csums(trans, &ordered_extent->list); 3209 + if (unlikely(ret)) { 3210 btrfs_abort_transaction(trans, ret); 3211 goto out; 3212 } ··· 3224 3225 btrfs_inode_safe_disk_i_size_write(inode, 0); 3226 ret = btrfs_update_inode_fallback(trans, inode); 3227 + if (unlikely(ret)) { /* -ENOMEM or corruption */ 3228 btrfs_abort_transaction(trans, ret); 3229 goto out; 3230 } ··· 3539 int ret; 3540 3541 ret = btrfs_insert_orphan_item(trans, inode->root, btrfs_ino(inode)); 3542 + if (unlikely(ret && ret != -EEXIST)) { 3543 btrfs_abort_transaction(trans, ret); 3544 return ret; 3545 } ··· 4288 } 4289 4290 ret = btrfs_del_inode_ref(trans, root, name, ino, dir_ino, &index); 4291 + if (unlikely(ret)) { 4292 btrfs_crit(fs_info, 4293 "failed to delete reference to %.*s, root %llu inode %llu parent %llu", 4294 name->len, name->name, btrfs_root_id(root), ino, dir_ino); ··· 4300 rename_ctx->index = index; 4301 4302 ret = btrfs_delete_delayed_dir_index(trans, dir, index); 4303 + if (unlikely(ret)) { 4304 btrfs_abort_transaction(trans, ret); 4305 return ret; 4306 } ··· 4455 btrfs_dir_item_key_to_cpu(leaf, di, &key); 4456 WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid); 4457 ret = btrfs_delete_one_dir_name(trans, root, path, di); 4458 + if (unlikely(ret)) { 4459 btrfs_abort_transaction(trans, ret); 4460 goto out; 4461 } ··· 4486 ret = btrfs_del_root_ref(trans, objectid, 4487 btrfs_root_id(root), dir_ino, 4488 &index, &fname.disk_name); 4489 + if (unlikely(ret)) { 4490 btrfs_abort_transaction(trans, ret); 4491 goto out; 4492 } 4493 } 4494 4495 ret = btrfs_delete_delayed_dir_index(trans, dir, index); 4496 + if (unlikely(ret)) { 4497 btrfs_abort_transaction(trans, ret); 4498 goto out; 4499 } ··· 4665 btrfs_record_snapshot_destroy(trans, dir); 4666 4667 ret = btrfs_unlink_subvol(trans, dir, dentry); 4668 + if (unlikely(ret)) { 4669 btrfs_abort_transaction(trans, ret); 4670 goto out_end_trans; 4671 } 4672 4673 ret = btrfs_record_root_in_trans(trans, dest); 4674 + if (unlikely(ret)) { 4675 btrfs_abort_transaction(trans, ret); 4676 goto out_end_trans; 4677 } ··· 4685 ret = btrfs_insert_orphan_item(trans, 4686 fs_info->tree_root, 4687 btrfs_root_id(dest)); 4688 + if (unlikely(ret)) { 4689 btrfs_abort_transaction(trans, ret); 4690 goto out_end_trans; 4691 } ··· 4693 4694 ret = btrfs_uuid_tree_remove(trans, dest->root_item.uuid, 4695 BTRFS_UUID_KEY_SUBVOL, btrfs_root_id(dest)); 4696 + if (unlikely(ret && ret != -ENOENT)) { 4697 btrfs_abort_transaction(trans, ret); 4698 goto out_end_trans; 4699 } ··· 4702 dest->root_item.received_uuid, 4703 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4704 btrfs_root_id(dest)); 4705 + if (unlikely(ret && ret != -ENOENT)) { 4706 btrfs_abort_transaction(trans, ret); 4707 goto out_end_trans; 4708 } ··· 5106 drop_args.drop_cache = true; 5107 5108 ret = btrfs_drop_extents(trans, root, inode, &drop_args); 5109 + if (unlikely(ret)) { 5110 btrfs_abort_transaction(trans, ret); 5111 btrfs_end_transaction(trans); 5112 return ret; ··· 6559 batch.total_data_size = sizes[0] + (args->orphan ? 0 : sizes[1]); 6560 batch.nr = args->orphan ? 1 : 2; 6561 ret = btrfs_insert_empty_items(trans, root, path, &batch); 6562 + if (unlikely(ret != 0)) { 6563 btrfs_abort_transaction(trans, ret); 6564 goto discard; 6565 } ··· 6636 */ 6637 if (!args->subvol) { 6638 ret = btrfs_init_inode_security(trans, args); 6639 + if (unlikely(ret)) { 6640 btrfs_abort_transaction(trans, ret); 6641 goto discard; 6642 } ··· 6656 6657 if (args->orphan) { 6658 ret = btrfs_orphan_add(trans, BTRFS_I(inode)); 6659 + if (unlikely(ret)) { 6660 btrfs_abort_transaction(trans, ret); 6661 goto discard; 6662 } 6663 } else { 6664 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name, 6665 0, BTRFS_I(inode)->dir_index); 6666 + if (unlikely(ret)) { 6667 btrfs_abort_transaction(trans, ret); 6668 goto discard; 6669 } ··· 6727 btrfs_inode_type(inode), index); 6728 if (ret == -EEXIST || ret == -EOVERFLOW) 6729 goto fail_dir_item; 6730 + else if (unlikely(ret)) { 6731 btrfs_abort_transaction(trans, ret); 6732 return ret; 6733 } ··· 6883 /* Link added now we update the inode item with the new link count. */ 6884 inc_nlink(inode); 6885 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 6886 + if (unlikely(ret)) { 6887 btrfs_abort_transaction(trans, ret); 6888 goto fail; 6889 } ··· 6894 * open(2) O_TMPFILE flag. 6895 */ 6896 ret = btrfs_orphan_del(trans, BTRFS_I(inode)); 6897 + if (unlikely(ret)) { 6898 btrfs_abort_transaction(trans, ret); 6899 goto fail; 6900 } ··· 8208 btrfs_ino(BTRFS_I(old_dir)), 8209 new_idx); 8210 if (ret) { 8211 + if (unlikely(need_abort)) 8212 btrfs_abort_transaction(trans, ret); 8213 goto out_fail; 8214 } ··· 8256 /* src is a subvolume */ 8257 if (old_ino == BTRFS_FIRST_FREE_OBJECTID) { 8258 ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry); 8259 + if (unlikely(ret)) { 8260 btrfs_abort_transaction(trans, ret); 8261 goto out_fail; 8262 } ··· 8264 ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), 8265 BTRFS_I(old_dentry->d_inode), 8266 old_name, &old_rename_ctx); 8267 + if (unlikely(ret)) { 8268 btrfs_abort_transaction(trans, ret); 8269 goto out_fail; 8270 } 8271 ret = btrfs_update_inode(trans, BTRFS_I(old_inode)); 8272 + if (unlikely(ret)) { 8273 btrfs_abort_transaction(trans, ret); 8274 goto out_fail; 8275 } ··· 8278 /* dest is a subvolume */ 8279 if (new_ino == BTRFS_FIRST_FREE_OBJECTID) { 8280 ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry); 8281 + if (unlikely(ret)) { 8282 btrfs_abort_transaction(trans, ret); 8283 goto out_fail; 8284 } ··· 8286 ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir), 8287 BTRFS_I(new_dentry->d_inode), 8288 new_name, &new_rename_ctx); 8289 + if (unlikely(ret)) { 8290 btrfs_abort_transaction(trans, ret); 8291 goto out_fail; 8292 } 8293 ret = btrfs_update_inode(trans, BTRFS_I(new_inode)); 8294 + if (unlikely(ret)) { 8295 btrfs_abort_transaction(trans, ret); 8296 goto out_fail; 8297 } ··· 8299 8300 ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode), 8301 new_name, 0, old_idx); 8302 + if (unlikely(ret)) { 8303 btrfs_abort_transaction(trans, ret); 8304 goto out_fail; 8305 } 8306 8307 ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode), 8308 old_name, 0, new_idx); 8309 + if (unlikely(ret)) { 8310 btrfs_abort_transaction(trans, ret); 8311 goto out_fail; 8312 } ··· 8547 8548 if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) { 8549 ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry); 8550 + if (unlikely(ret)) { 8551 btrfs_abort_transaction(trans, ret); 8552 goto out_fail; 8553 } ··· 8555 ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir), 8556 BTRFS_I(d_inode(old_dentry)), 8557 &old_fname.disk_name, &rename_ctx); 8558 + if (unlikely(ret)) { 8559 btrfs_abort_transaction(trans, ret); 8560 goto out_fail; 8561 } 8562 ret = btrfs_update_inode(trans, BTRFS_I(old_inode)); 8563 + if (unlikely(ret)) { 8564 btrfs_abort_transaction(trans, ret); 8565 goto out_fail; 8566 } ··· 8571 if (unlikely(btrfs_ino(BTRFS_I(new_inode)) == 8572 BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { 8573 ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry); 8574 + if (unlikely(ret)) { 8575 btrfs_abort_transaction(trans, ret); 8576 goto out_fail; 8577 } ··· 8580 ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir), 8581 BTRFS_I(d_inode(new_dentry)), 8582 &new_fname.disk_name); 8583 + if (unlikely(ret)) { 8584 btrfs_abort_transaction(trans, ret); 8585 goto out_fail; 8586 } ··· 8588 if (new_inode->i_nlink == 0) { 8589 ret = btrfs_orphan_add(trans, 8590 BTRFS_I(d_inode(new_dentry))); 8591 + if (unlikely(ret)) { 8592 btrfs_abort_transaction(trans, ret); 8593 goto out_fail; 8594 } ··· 8597 8598 ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode), 8599 &new_fname.disk_name, 0, index); 8600 + if (unlikely(ret)) { 8601 btrfs_abort_transaction(trans, ret); 8602 goto out_fail; 8603 } ··· 8611 8612 if (flags & RENAME_WHITEOUT) { 8613 ret = btrfs_create_new_inode(trans, &whiteout_args); 8614 + if (unlikely(ret)) { 8615 btrfs_abort_transaction(trans, ret); 8616 goto out_fail; 8617 } else { ··· 8905 goto out; 8906 8907 path = btrfs_alloc_path(); 8908 + if (unlikely(!path)) { 8909 ret = -ENOMEM; 8910 btrfs_abort_transaction(trans, ret); 8911 discard_new_inode(inode); ··· 8917 key.offset = 0; 8918 datasize = btrfs_file_extent_calc_inline_size(name_len); 8919 ret = btrfs_insert_empty_item(trans, root, path, &key, datasize); 8920 + if (unlikely(ret)) { 8921 btrfs_abort_transaction(trans, ret); 8922 btrfs_free_path(path); 8923 discard_new_inode(inode); ··· 9130 9131 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 9132 9133 + if (unlikely(ret)) { 9134 btrfs_abort_transaction(trans, ret); 9135 if (own_trans) 9136 btrfs_end_transaction(trans);
+8 -8
fs/btrfs/ioctl.c
··· 376 if (comp) { 377 ret = btrfs_set_prop(trans, inode, "btrfs.compression", 378 comp, strlen(comp), 0); 379 - if (ret) { 380 btrfs_abort_transaction(trans, ret); 381 goto out_end_trans; 382 } 383 } else { 384 ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL, 0, 0); 385 - if (ret && ret != -ENODATA) { 386 btrfs_abort_transaction(trans, ret); 387 goto out_end_trans; 388 } ··· 633 btrfs_clear_buffer_dirty(trans, leaf); 634 btrfs_tree_unlock(leaf); 635 ret2 = btrfs_free_tree_block(trans, objectid, leaf, 0, 1); 636 - if (ret2 < 0) 637 btrfs_abort_transaction(trans, ret2); 638 free_extent_buffer(leaf); 639 goto out; ··· 654 /* ... and new_root is owned by new_inode_args.inode now. */ 655 656 ret = btrfs_record_root_in_trans(trans, new_root); 657 - if (ret) { 658 btrfs_abort_transaction(trans, ret); 659 goto out; 660 } 661 662 ret = btrfs_uuid_tree_add(trans, root_item->uuid, 663 BTRFS_UUID_KEY_SUBVOL, objectid); 664 - if (ret) { 665 btrfs_abort_transaction(trans, ret); 666 goto out; 667 } ··· 669 btrfs_record_new_subvolume(trans, BTRFS_I(dir)); 670 671 ret = btrfs_create_new_inode(trans, &new_inode_args); 672 - if (ret) { 673 btrfs_abort_transaction(trans, ret); 674 goto out; 675 } ··· 4008 ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid, 4009 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4010 btrfs_root_id(root)); 4011 - if (ret && ret != -ENOENT) { 4012 btrfs_abort_transaction(trans, ret); 4013 btrfs_end_transaction(trans); 4014 goto out; ··· 4032 ret = btrfs_uuid_tree_add(trans, sa->uuid, 4033 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4034 btrfs_root_id(root)); 4035 - if (ret < 0 && ret != -EEXIST) { 4036 btrfs_abort_transaction(trans, ret); 4037 btrfs_end_transaction(trans); 4038 goto out;
··· 376 if (comp) { 377 ret = btrfs_set_prop(trans, inode, "btrfs.compression", 378 comp, strlen(comp), 0); 379 + if (unlikely(ret)) { 380 btrfs_abort_transaction(trans, ret); 381 goto out_end_trans; 382 } 383 } else { 384 ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL, 0, 0); 385 + if (unlikely(ret && ret != -ENODATA)) { 386 btrfs_abort_transaction(trans, ret); 387 goto out_end_trans; 388 } ··· 633 btrfs_clear_buffer_dirty(trans, leaf); 634 btrfs_tree_unlock(leaf); 635 ret2 = btrfs_free_tree_block(trans, objectid, leaf, 0, 1); 636 + if (unlikely(ret2 < 0)) 637 btrfs_abort_transaction(trans, ret2); 638 free_extent_buffer(leaf); 639 goto out; ··· 654 /* ... and new_root is owned by new_inode_args.inode now. */ 655 656 ret = btrfs_record_root_in_trans(trans, new_root); 657 + if (unlikely(ret)) { 658 btrfs_abort_transaction(trans, ret); 659 goto out; 660 } 661 662 ret = btrfs_uuid_tree_add(trans, root_item->uuid, 663 BTRFS_UUID_KEY_SUBVOL, objectid); 664 + if (unlikely(ret)) { 665 btrfs_abort_transaction(trans, ret); 666 goto out; 667 } ··· 669 btrfs_record_new_subvolume(trans, BTRFS_I(dir)); 670 671 ret = btrfs_create_new_inode(trans, &new_inode_args); 672 + if (unlikely(ret)) { 673 btrfs_abort_transaction(trans, ret); 674 goto out; 675 } ··· 4008 ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid, 4009 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4010 btrfs_root_id(root)); 4011 + if (unlikely(ret && ret != -ENOENT)) { 4012 btrfs_abort_transaction(trans, ret); 4013 btrfs_end_transaction(trans); 4014 goto out; ··· 4032 ret = btrfs_uuid_tree_add(trans, sa->uuid, 4033 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4034 btrfs_root_id(root)); 4035 + if (unlikely(ret < 0 && ret != -EEXIST)) { 4036 btrfs_abort_transaction(trans, ret); 4037 btrfs_end_transaction(trans); 4038 goto out;
+12 -12
fs/btrfs/qgroup.c
··· 1069 } 1070 1071 path = btrfs_alloc_path(); 1072 - if (!path) { 1073 ret = -ENOMEM; 1074 btrfs_abort_transaction(trans, ret); 1075 goto out_free_root; ··· 1081 1082 ret = btrfs_insert_empty_item(trans, quota_root, path, &key, 1083 sizeof(*ptr)); 1084 - if (ret) { 1085 btrfs_abort_transaction(trans, ret); 1086 goto out_free_path; 1087 } ··· 1111 ret = btrfs_search_slot_for_read(tree_root, &key, path, 1, 0); 1112 if (ret > 0) 1113 goto out_add_root; 1114 - if (ret < 0) { 1115 btrfs_abort_transaction(trans, ret); 1116 goto out_free_path; 1117 } ··· 1129 /* We should not have a stray @prealloc pointer. */ 1130 ASSERT(prealloc == NULL); 1131 prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS); 1132 - if (!prealloc) { 1133 ret = -ENOMEM; 1134 btrfs_abort_transaction(trans, ret); 1135 goto out_free_path; ··· 1137 1138 ret = add_qgroup_item(trans, quota_root, 1139 found_key.offset); 1140 - if (ret) { 1141 btrfs_abort_transaction(trans, ret); 1142 goto out_free_path; 1143 } ··· 1145 qgroup = add_qgroup_rb(fs_info, prealloc, found_key.offset); 1146 prealloc = NULL; 1147 ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup); 1148 - if (ret < 0) { 1149 btrfs_abort_transaction(trans, ret); 1150 goto out_free_path; 1151 } 1152 ret = btrfs_search_slot_for_read(tree_root, &found_key, 1153 path, 1, 0); 1154 - if (ret < 0) { 1155 btrfs_abort_transaction(trans, ret); 1156 goto out_free_path; 1157 } ··· 1165 } 1166 } 1167 ret = btrfs_next_item(tree_root, path); 1168 - if (ret < 0) { 1169 btrfs_abort_transaction(trans, ret); 1170 goto out_free_path; 1171 } ··· 1176 out_add_root: 1177 btrfs_release_path(path); 1178 ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID); 1179 - if (ret) { 1180 btrfs_abort_transaction(trans, ret); 1181 goto out_free_path; 1182 } ··· 1190 qgroup = add_qgroup_rb(fs_info, prealloc, BTRFS_FS_TREE_OBJECTID); 1191 prealloc = NULL; 1192 ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup); 1193 - if (ret < 0) { 1194 btrfs_abort_transaction(trans, ret); 1195 goto out_free_path; 1196 } ··· 1376 btrfs_free_qgroup_config(fs_info); 1377 1378 ret = btrfs_clean_quota_tree(trans, quota_root); 1379 - if (ret) { 1380 btrfs_abort_transaction(trans, ret); 1381 goto out; 1382 } 1383 1384 ret = btrfs_del_root(trans, &quota_root->root_key); 1385 - if (ret) { 1386 btrfs_abort_transaction(trans, ret); 1387 goto out; 1388 }
··· 1069 } 1070 1071 path = btrfs_alloc_path(); 1072 + if (unlikely(!path)) { 1073 ret = -ENOMEM; 1074 btrfs_abort_transaction(trans, ret); 1075 goto out_free_root; ··· 1081 1082 ret = btrfs_insert_empty_item(trans, quota_root, path, &key, 1083 sizeof(*ptr)); 1084 + if (unlikely(ret)) { 1085 btrfs_abort_transaction(trans, ret); 1086 goto out_free_path; 1087 } ··· 1111 ret = btrfs_search_slot_for_read(tree_root, &key, path, 1, 0); 1112 if (ret > 0) 1113 goto out_add_root; 1114 + if (unlikely(ret < 0)) { 1115 btrfs_abort_transaction(trans, ret); 1116 goto out_free_path; 1117 } ··· 1129 /* We should not have a stray @prealloc pointer. */ 1130 ASSERT(prealloc == NULL); 1131 prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS); 1132 + if (unlikely(!prealloc)) { 1133 ret = -ENOMEM; 1134 btrfs_abort_transaction(trans, ret); 1135 goto out_free_path; ··· 1137 1138 ret = add_qgroup_item(trans, quota_root, 1139 found_key.offset); 1140 + if (unlikely(ret)) { 1141 btrfs_abort_transaction(trans, ret); 1142 goto out_free_path; 1143 } ··· 1145 qgroup = add_qgroup_rb(fs_info, prealloc, found_key.offset); 1146 prealloc = NULL; 1147 ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup); 1148 + if (unlikely(ret < 0)) { 1149 btrfs_abort_transaction(trans, ret); 1150 goto out_free_path; 1151 } 1152 ret = btrfs_search_slot_for_read(tree_root, &found_key, 1153 path, 1, 0); 1154 + if (unlikely(ret < 0)) { 1155 btrfs_abort_transaction(trans, ret); 1156 goto out_free_path; 1157 } ··· 1165 } 1166 } 1167 ret = btrfs_next_item(tree_root, path); 1168 + if (unlikely(ret < 0)) { 1169 btrfs_abort_transaction(trans, ret); 1170 goto out_free_path; 1171 } ··· 1176 out_add_root: 1177 btrfs_release_path(path); 1178 ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID); 1179 + if (unlikely(ret)) { 1180 btrfs_abort_transaction(trans, ret); 1181 goto out_free_path; 1182 } ··· 1190 qgroup = add_qgroup_rb(fs_info, prealloc, BTRFS_FS_TREE_OBJECTID); 1191 prealloc = NULL; 1192 ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup); 1193 + if (unlikely(ret < 0)) { 1194 btrfs_abort_transaction(trans, ret); 1195 goto out_free_path; 1196 } ··· 1376 btrfs_free_qgroup_config(fs_info); 1377 1378 ret = btrfs_clean_quota_tree(trans, quota_root); 1379 + if (unlikely(ret)) { 1380 btrfs_abort_transaction(trans, ret); 1381 goto out; 1382 } 1383 1384 ret = btrfs_del_root(trans, &quota_root->root_key); 1385 + if (unlikely(ret)) { 1386 btrfs_abort_transaction(trans, ret); 1387 goto out; 1388 }
+1 -1
fs/btrfs/raid-stripe-tree.c
··· 304 int ret; 305 306 stripe_extent = kzalloc(item_size, GFP_NOFS); 307 - if (!stripe_extent) { 308 btrfs_abort_transaction(trans, -ENOMEM); 309 btrfs_end_transaction(trans); 310 return -ENOMEM;
··· 304 int ret; 305 306 stripe_extent = kzalloc(item_size, GFP_NOFS); 307 + if (!unlikely(stripe_extent)) { 308 btrfs_abort_transaction(trans, -ENOMEM); 309 btrfs_end_transaction(trans); 310 return -ENOMEM;
+4 -4
fs/btrfs/reflink.c
··· 43 } 44 45 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 46 - if (ret) { 47 btrfs_abort_transaction(trans, ret); 48 btrfs_end_transaction(trans); 49 return ret; ··· 268 drop_args.end = aligned_end; 269 drop_args.drop_cache = true; 270 ret = btrfs_drop_extents(trans, root, inode, &drop_args); 271 - if (ret) { 272 btrfs_abort_transaction(trans, ret); 273 goto out; 274 } 275 ret = btrfs_insert_empty_item(trans, root, path, new_key, size); 276 - if (ret) { 277 btrfs_abort_transaction(trans, ret); 278 goto out; 279 } ··· 285 btrfs_update_inode_bytes(inode, datal, drop_args.bytes_found); 286 btrfs_set_inode_full_sync(inode); 287 ret = btrfs_inode_set_file_extent_range(inode, 0, aligned_end); 288 - if (ret) 289 btrfs_abort_transaction(trans, ret); 290 out: 291 if (!ret && !trans) {
··· 43 } 44 45 ret = btrfs_update_inode(trans, BTRFS_I(inode)); 46 + if (unlikely(ret)) { 47 btrfs_abort_transaction(trans, ret); 48 btrfs_end_transaction(trans); 49 return ret; ··· 268 drop_args.end = aligned_end; 269 drop_args.drop_cache = true; 270 ret = btrfs_drop_extents(trans, root, inode, &drop_args); 271 + if (unlikely(ret)) { 272 btrfs_abort_transaction(trans, ret); 273 goto out; 274 } 275 ret = btrfs_insert_empty_item(trans, root, path, new_key, size); 276 + if (unlikely(ret)) { 277 btrfs_abort_transaction(trans, ret); 278 goto out; 279 } ··· 285 btrfs_update_inode_bytes(inode, datal, drop_args.bytes_found); 286 btrfs_set_inode_full_sync(inode); 287 ret = btrfs_inode_set_file_extent_range(inode, 0, aligned_end); 288 + if (unlikely(ret)) 289 btrfs_abort_transaction(trans, ret); 290 out: 291 if (!ret && !trans) {
+8 -8
fs/btrfs/relocation.c
··· 967 btrfs_init_data_ref(&ref, key.objectid, key.offset, 968 btrfs_root_id(root), false); 969 ret = btrfs_inc_extent_ref(trans, &ref); 970 - if (ret) { 971 btrfs_abort_transaction(trans, ret); 972 break; 973 } ··· 981 btrfs_init_data_ref(&ref, key.objectid, key.offset, 982 btrfs_root_id(root), false); 983 ret = btrfs_free_extent(trans, &ref); 984 - if (ret) { 985 btrfs_abort_transaction(trans, ret); 986 break; 987 } ··· 1192 ref.ref_root = btrfs_root_id(src); 1193 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1194 ret = btrfs_inc_extent_ref(trans, &ref); 1195 - if (ret) { 1196 btrfs_abort_transaction(trans, ret); 1197 break; 1198 } ··· 1205 ref.ref_root = btrfs_root_id(dest); 1206 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1207 ret = btrfs_inc_extent_ref(trans, &ref); 1208 - if (ret) { 1209 btrfs_abort_transaction(trans, ret); 1210 break; 1211 } ··· 1219 ref.ref_root = btrfs_root_id(src); 1220 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1221 ret = btrfs_free_extent(trans, &ref); 1222 - if (ret) { 1223 btrfs_abort_transaction(trans, ret); 1224 break; 1225 } ··· 1233 ref.ref_root = btrfs_root_id(dest); 1234 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1235 ret = btrfs_free_extent(trans, &ref); 1236 - if (ret) { 1237 btrfs_abort_transaction(trans, ret); 1238 break; 1239 } ··· 1784 list_add(&reloc_root->root_list, &reloc_roots); 1785 btrfs_put_root(root); 1786 1787 - if (ret) { 1788 btrfs_abort_transaction(trans, ret); 1789 if (!err) 1790 err = ret; ··· 2325 if (!ret) 2326 ret = btrfs_drop_subtree(trans, root, eb, 2327 upper->eb); 2328 - if (ret) 2329 btrfs_abort_transaction(trans, ret); 2330 } 2331 next:
··· 967 btrfs_init_data_ref(&ref, key.objectid, key.offset, 968 btrfs_root_id(root), false); 969 ret = btrfs_inc_extent_ref(trans, &ref); 970 + if (unlikely(ret)) { 971 btrfs_abort_transaction(trans, ret); 972 break; 973 } ··· 981 btrfs_init_data_ref(&ref, key.objectid, key.offset, 982 btrfs_root_id(root), false); 983 ret = btrfs_free_extent(trans, &ref); 984 + if (unlikely(ret)) { 985 btrfs_abort_transaction(trans, ret); 986 break; 987 } ··· 1192 ref.ref_root = btrfs_root_id(src); 1193 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1194 ret = btrfs_inc_extent_ref(trans, &ref); 1195 + if (unlikely(ret)) { 1196 btrfs_abort_transaction(trans, ret); 1197 break; 1198 } ··· 1205 ref.ref_root = btrfs_root_id(dest); 1206 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1207 ret = btrfs_inc_extent_ref(trans, &ref); 1208 + if (unlikely(ret)) { 1209 btrfs_abort_transaction(trans, ret); 1210 break; 1211 } ··· 1219 ref.ref_root = btrfs_root_id(src); 1220 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1221 ret = btrfs_free_extent(trans, &ref); 1222 + if (unlikely(ret)) { 1223 btrfs_abort_transaction(trans, ret); 1224 break; 1225 } ··· 1233 ref.ref_root = btrfs_root_id(dest); 1234 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1235 ret = btrfs_free_extent(trans, &ref); 1236 + if (unlikely(ret)) { 1237 btrfs_abort_transaction(trans, ret); 1238 break; 1239 } ··· 1784 list_add(&reloc_root->root_list, &reloc_roots); 1785 btrfs_put_root(root); 1786 1787 + if (unlikely(ret)) { 1788 btrfs_abort_transaction(trans, ret); 1789 if (!err) 1790 err = ret; ··· 2325 if (!ret) 2326 ret = btrfs_drop_subtree(trans, root, eb, 2327 upper->eb); 2328 + if (unlikely(ret)) 2329 btrfs_abort_transaction(trans, ret); 2330 } 2331 next:
+4 -4
fs/btrfs/root-tree.c
··· 168 btrfs_release_path(path); 169 ret = btrfs_search_slot(trans, root, key, path, 170 -1, 1); 171 - if (ret < 0) { 172 btrfs_abort_transaction(trans, ret); 173 return ret; 174 } 175 176 ret = btrfs_del_item(trans, root, path); 177 - if (ret < 0) { 178 btrfs_abort_transaction(trans, ret); 179 return ret; 180 } 181 btrfs_release_path(path); 182 ret = btrfs_insert_empty_item(trans, root, path, 183 key, sizeof(*item)); 184 - if (ret < 0) { 185 btrfs_abort_transaction(trans, ret); 186 return ret; 187 } ··· 421 again: 422 ret = btrfs_insert_empty_item(trans, tree_root, path, &key, 423 sizeof(*ref) + name->len); 424 - if (ret) { 425 btrfs_abort_transaction(trans, ret); 426 return ret; 427 }
··· 168 btrfs_release_path(path); 169 ret = btrfs_search_slot(trans, root, key, path, 170 -1, 1); 171 + if (unlikely(ret < 0)) { 172 btrfs_abort_transaction(trans, ret); 173 return ret; 174 } 175 176 ret = btrfs_del_item(trans, root, path); 177 + if (unlikely(ret < 0)) { 178 btrfs_abort_transaction(trans, ret); 179 return ret; 180 } 181 btrfs_release_path(path); 182 ret = btrfs_insert_empty_item(trans, root, path, 183 key, sizeof(*item)); 184 + if (unlikely(ret < 0)) { 185 btrfs_abort_transaction(trans, ret); 186 return ret; 187 } ··· 421 again: 422 ret = btrfs_insert_empty_item(trans, tree_root, path, &key, 423 sizeof(*ref) + name->len); 424 + if (unlikely(ret)) { 425 btrfs_abort_transaction(trans, ret); 426 return ret; 427 }
+14 -14
fs/btrfs/transaction.c
··· 1569 * qgroup counters could end up wrong. 1570 */ 1571 ret = btrfs_run_delayed_refs(trans, U64_MAX); 1572 - if (ret) { 1573 btrfs_abort_transaction(trans, ret); 1574 return ret; 1575 } ··· 1710 * insert the directory item 1711 */ 1712 ret = btrfs_set_inode_index(parent_inode, &index); 1713 - if (ret) { 1714 btrfs_abort_transaction(trans, ret); 1715 goto fail; 1716 } ··· 1731 1732 ret = btrfs_create_qgroup(trans, objectid); 1733 if (ret && ret != -EEXIST) { 1734 - if (ret != -ENOTCONN || btrfs_qgroup_enabled(fs_info)) { 1735 btrfs_abort_transaction(trans, ret); 1736 goto fail; 1737 } ··· 1744 * snapshot 1745 */ 1746 ret = btrfs_run_delayed_items(trans); 1747 - if (ret) { /* Transaction aborted */ 1748 btrfs_abort_transaction(trans, ret); 1749 goto fail; 1750 } 1751 1752 ret = record_root_in_trans(trans, root, 0); 1753 - if (ret) { 1754 btrfs_abort_transaction(trans, ret); 1755 goto fail; 1756 } ··· 1785 old = btrfs_lock_root_node(root); 1786 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, 1787 BTRFS_NESTING_COW); 1788 - if (ret) { 1789 btrfs_tree_unlock(old); 1790 free_extent_buffer(old); 1791 btrfs_abort_transaction(trans, ret); ··· 1796 /* clean up in any case */ 1797 btrfs_tree_unlock(old); 1798 free_extent_buffer(old); 1799 - if (ret) { 1800 btrfs_abort_transaction(trans, ret); 1801 goto fail; 1802 } ··· 1812 ret = btrfs_insert_root(trans, tree_root, &key, new_root_item); 1813 btrfs_tree_unlock(tmp); 1814 free_extent_buffer(tmp); 1815 - if (ret) { 1816 btrfs_abort_transaction(trans, ret); 1817 goto fail; 1818 } ··· 1824 btrfs_root_id(parent_root), 1825 btrfs_ino(parent_inode), index, 1826 &fname.disk_name); 1827 - if (ret) { 1828 btrfs_abort_transaction(trans, ret); 1829 goto fail; 1830 } ··· 1839 } 1840 1841 ret = btrfs_reloc_post_snapshot(trans, pending); 1842 - if (ret) { 1843 btrfs_abort_transaction(trans, ret); 1844 goto fail; 1845 } ··· 1862 ret = btrfs_insert_dir_item(trans, &fname.disk_name, 1863 parent_inode, &key, BTRFS_FT_DIR, 1864 index); 1865 - if (ret) { 1866 btrfs_abort_transaction(trans, ret); 1867 goto fail; 1868 } ··· 1872 inode_set_mtime_to_ts(&parent_inode->vfs_inode, 1873 inode_set_ctime_current(&parent_inode->vfs_inode)); 1874 ret = btrfs_update_inode_fallback(trans, parent_inode); 1875 - if (ret) { 1876 btrfs_abort_transaction(trans, ret); 1877 goto fail; 1878 } 1879 ret = btrfs_uuid_tree_add(trans, new_root_item->uuid, 1880 BTRFS_UUID_KEY_SUBVOL, 1881 objectid); 1882 - if (ret) { 1883 btrfs_abort_transaction(trans, ret); 1884 goto fail; 1885 } ··· 1887 ret = btrfs_uuid_tree_add(trans, new_root_item->received_uuid, 1888 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 1889 objectid); 1890 - if (ret && ret != -EEXIST) { 1891 btrfs_abort_transaction(trans, ret); 1892 goto fail; 1893 }
··· 1569 * qgroup counters could end up wrong. 1570 */ 1571 ret = btrfs_run_delayed_refs(trans, U64_MAX); 1572 + if (unlikely(ret)) { 1573 btrfs_abort_transaction(trans, ret); 1574 return ret; 1575 } ··· 1710 * insert the directory item 1711 */ 1712 ret = btrfs_set_inode_index(parent_inode, &index); 1713 + if (unlikely(ret)) { 1714 btrfs_abort_transaction(trans, ret); 1715 goto fail; 1716 } ··· 1731 1732 ret = btrfs_create_qgroup(trans, objectid); 1733 if (ret && ret != -EEXIST) { 1734 + if (unlikely(ret != -ENOTCONN || btrfs_qgroup_enabled(fs_info))) { 1735 btrfs_abort_transaction(trans, ret); 1736 goto fail; 1737 } ··· 1744 * snapshot 1745 */ 1746 ret = btrfs_run_delayed_items(trans); 1747 + if (unlikely(ret)) { 1748 btrfs_abort_transaction(trans, ret); 1749 goto fail; 1750 } 1751 1752 ret = record_root_in_trans(trans, root, 0); 1753 + if (unlikely(ret)) { 1754 btrfs_abort_transaction(trans, ret); 1755 goto fail; 1756 } ··· 1785 old = btrfs_lock_root_node(root); 1786 ret = btrfs_cow_block(trans, root, old, NULL, 0, &old, 1787 BTRFS_NESTING_COW); 1788 + if (unlikely(ret)) { 1789 btrfs_tree_unlock(old); 1790 free_extent_buffer(old); 1791 btrfs_abort_transaction(trans, ret); ··· 1796 /* clean up in any case */ 1797 btrfs_tree_unlock(old); 1798 free_extent_buffer(old); 1799 + if (unlikely(ret)) { 1800 btrfs_abort_transaction(trans, ret); 1801 goto fail; 1802 } ··· 1812 ret = btrfs_insert_root(trans, tree_root, &key, new_root_item); 1813 btrfs_tree_unlock(tmp); 1814 free_extent_buffer(tmp); 1815 + if (unlikely(ret)) { 1816 btrfs_abort_transaction(trans, ret); 1817 goto fail; 1818 } ··· 1824 btrfs_root_id(parent_root), 1825 btrfs_ino(parent_inode), index, 1826 &fname.disk_name); 1827 + if (unlikely(ret)) { 1828 btrfs_abort_transaction(trans, ret); 1829 goto fail; 1830 } ··· 1839 } 1840 1841 ret = btrfs_reloc_post_snapshot(trans, pending); 1842 + if (unlikely(ret)) { 1843 btrfs_abort_transaction(trans, ret); 1844 goto fail; 1845 } ··· 1862 ret = btrfs_insert_dir_item(trans, &fname.disk_name, 1863 parent_inode, &key, BTRFS_FT_DIR, 1864 index); 1865 + if (unlikely(ret)) { 1866 btrfs_abort_transaction(trans, ret); 1867 goto fail; 1868 } ··· 1872 inode_set_mtime_to_ts(&parent_inode->vfs_inode, 1873 inode_set_ctime_current(&parent_inode->vfs_inode)); 1874 ret = btrfs_update_inode_fallback(trans, parent_inode); 1875 + if (unlikely(ret)) { 1876 btrfs_abort_transaction(trans, ret); 1877 goto fail; 1878 } 1879 ret = btrfs_uuid_tree_add(trans, new_root_item->uuid, 1880 BTRFS_UUID_KEY_SUBVOL, 1881 objectid); 1882 + if (unlikely(ret)) { 1883 btrfs_abort_transaction(trans, ret); 1884 goto fail; 1885 } ··· 1887 ret = btrfs_uuid_tree_add(trans, new_root_item->received_uuid, 1888 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 1889 objectid); 1890 + if (unlikely(ret && ret != -EEXIST)) { 1891 btrfs_abort_transaction(trans, ret); 1892 goto fail; 1893 }
+11 -11
fs/btrfs/tree-log.c
··· 439 }; 440 441 ret = btrfs_read_extent_buffer(eb, &check); 442 - if (ret) { 443 if (trans) 444 btrfs_abort_transaction(trans, ret); 445 else ··· 451 if (wc->pin) { 452 ASSERT(trans != NULL); 453 ret = btrfs_pin_extent_for_log_replay(trans, eb); 454 - if (ret) { 455 btrfs_abort_transaction(trans, ret); 456 return ret; 457 } ··· 3570 btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level); 3571 ret = write_all_supers(fs_info, 1); 3572 mutex_unlock(&fs_info->tree_log_mutex); 3573 - if (ret) { 3574 btrfs_set_log_full_commit(trans); 3575 btrfs_abort_transaction(trans, ret); 3576 goto out_wake_log_root; ··· 7630 7631 ret = walk_log_tree(&wc); 7632 wc.log = NULL; 7633 - if (ret) { 7634 btrfs_abort_transaction(trans, ret); 7635 goto error; 7636 } ··· 7645 7646 ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); 7647 7648 - if (ret < 0) { 7649 btrfs_abort_transaction(trans, ret); 7650 goto error; 7651 } ··· 7672 if (IS_ERR(wc.root)) { 7673 ret = PTR_ERR(wc.root); 7674 wc.root = NULL; 7675 - if (ret != -ENOENT) { 7676 btrfs_abort_transaction(trans, ret); 7677 goto error; 7678 } ··· 7689 * each subsequent pass. 7690 */ 7691 ret = btrfs_pin_extent_for_log_replay(trans, wc.log->node); 7692 - if (ret) { 7693 btrfs_abort_transaction(trans, ret); 7694 goto error; 7695 } ··· 7698 7699 wc.root->log_root = wc.log; 7700 ret = btrfs_record_root_in_trans(trans, wc.root); 7701 - if (ret) { 7702 btrfs_abort_transaction(trans, ret); 7703 goto next; 7704 } 7705 7706 ret = walk_log_tree(&wc); 7707 - if (ret) { 7708 btrfs_abort_transaction(trans, ret); 7709 goto next; 7710 } ··· 7715 wc.subvol_path = path; 7716 ret = fixup_inode_link_counts(&wc); 7717 wc.subvol_path = NULL; 7718 - if (ret) { 7719 btrfs_abort_transaction(trans, ret); 7720 goto next; 7721 } ··· 7728 * could only happen during mount. 7729 */ 7730 ret = btrfs_init_root_free_objectid(root); 7731 - if (ret) { 7732 btrfs_abort_transaction(trans, ret); 7733 goto next; 7734 }
··· 439 }; 440 441 ret = btrfs_read_extent_buffer(eb, &check); 442 + if (unlikely(ret)) { 443 if (trans) 444 btrfs_abort_transaction(trans, ret); 445 else ··· 451 if (wc->pin) { 452 ASSERT(trans != NULL); 453 ret = btrfs_pin_extent_for_log_replay(trans, eb); 454 + if (unlikely(ret)) { 455 btrfs_abort_transaction(trans, ret); 456 return ret; 457 } ··· 3570 btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level); 3571 ret = write_all_supers(fs_info, 1); 3572 mutex_unlock(&fs_info->tree_log_mutex); 3573 + if (unlikely(ret)) { 3574 btrfs_set_log_full_commit(trans); 3575 btrfs_abort_transaction(trans, ret); 3576 goto out_wake_log_root; ··· 7630 7631 ret = walk_log_tree(&wc); 7632 wc.log = NULL; 7633 + if (unlikely(ret)) { 7634 btrfs_abort_transaction(trans, ret); 7635 goto error; 7636 } ··· 7645 7646 ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); 7647 7648 + if (unlikely(ret < 0)) { 7649 btrfs_abort_transaction(trans, ret); 7650 goto error; 7651 } ··· 7672 if (IS_ERR(wc.root)) { 7673 ret = PTR_ERR(wc.root); 7674 wc.root = NULL; 7675 + if (unlikely(ret != -ENOENT)) { 7676 btrfs_abort_transaction(trans, ret); 7677 goto error; 7678 } ··· 7689 * each subsequent pass. 7690 */ 7691 ret = btrfs_pin_extent_for_log_replay(trans, wc.log->node); 7692 + if (unlikely(ret)) { 7693 btrfs_abort_transaction(trans, ret); 7694 goto error; 7695 } ··· 7698 7699 wc.root->log_root = wc.log; 7700 ret = btrfs_record_root_in_trans(trans, wc.root); 7701 + if (unlikely(ret)) { 7702 btrfs_abort_transaction(trans, ret); 7703 goto next; 7704 } 7705 7706 ret = walk_log_tree(&wc); 7707 + if (unlikely(ret)) { 7708 btrfs_abort_transaction(trans, ret); 7709 goto next; 7710 } ··· 7715 wc.subvol_path = path; 7716 ret = fixup_inode_link_counts(&wc); 7717 wc.subvol_path = NULL; 7718 + if (unlikely(ret)) { 7719 btrfs_abort_transaction(trans, ret); 7720 goto next; 7721 } ··· 7728 * could only happen during mount. 7729 */ 7730 ret = btrfs_init_root_free_objectid(root); 7731 + if (unlikely(ret)) { 7732 btrfs_abort_transaction(trans, ret); 7733 goto next; 7734 }
+2 -2
fs/btrfs/verity.c
··· 487 inode->ro_flags &= ~BTRFS_INODE_RO_VERITY; 488 btrfs_sync_inode_flags_to_i_flags(inode); 489 ret = btrfs_update_inode(trans, inode); 490 - if (ret) { 491 btrfs_abort_transaction(trans, ret); 492 goto out; 493 } 494 ret = del_orphan(trans, inode); 495 - if (ret) { 496 btrfs_abort_transaction(trans, ret); 497 goto out; 498 }
··· 487 inode->ro_flags &= ~BTRFS_INODE_RO_VERITY; 488 btrfs_sync_inode_flags_to_i_flags(inode); 489 ret = btrfs_update_inode(trans, inode); 490 + if (unlikely(ret)) { 491 btrfs_abort_transaction(trans, ret); 492 goto out; 493 } 494 ret = del_orphan(trans, inode); 495 + if (unlikely(ret)) { 496 btrfs_abort_transaction(trans, ret); 497 goto out; 498 }
+14 -14
fs/btrfs/volumes.c
··· 2243 } 2244 2245 ret = btrfs_rm_dev_item(trans, device); 2246 - if (ret) { 2247 /* Any error in dev item removal is critical */ 2248 btrfs_crit(fs_info, 2249 "failed to remove device item for devid %llu: %d", ··· 2843 mutex_lock(&fs_info->chunk_mutex); 2844 ret = init_first_rw_device(trans); 2845 mutex_unlock(&fs_info->chunk_mutex); 2846 - if (ret) { 2847 btrfs_abort_transaction(trans, ret); 2848 goto error_sysfs; 2849 } 2850 } 2851 2852 ret = btrfs_add_dev_item(trans, device); 2853 - if (ret) { 2854 btrfs_abort_transaction(trans, ret); 2855 goto error_sysfs; 2856 } 2857 2858 if (seeding_dev) { 2859 ret = btrfs_finish_sprout(trans); 2860 - if (ret) { 2861 btrfs_abort_transaction(trans, ret); 2862 goto error_sysfs; 2863 } ··· 3058 } 3059 3060 ret = btrfs_del_item(trans, root, path); 3061 - if (ret < 0) { 3062 btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset); 3063 btrfs_abort_transaction(trans, ret); 3064 goto out; ··· 3283 ret = btrfs_free_dev_extent(trans, device, 3284 map->stripes[i].physical, 3285 &dev_extent_len); 3286 - if (ret) { 3287 mutex_unlock(&fs_devices->device_list_mutex); 3288 btrfs_abort_transaction(trans, ret); 3289 goto out; ··· 3353 struct btrfs_space_info *space_info; 3354 3355 space_info = btrfs_find_space_info(fs_info, sys_flags); 3356 - if (!space_info) { 3357 ret = -EINVAL; 3358 btrfs_abort_transaction(trans, ret); 3359 goto out; ··· 3367 } 3368 3369 ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg); 3370 - if (ret) { 3371 btrfs_abort_transaction(trans, ret); 3372 goto out; 3373 } 3374 3375 ret = remove_chunk_item(trans, map, chunk_offset); 3376 - if (ret) { 3377 btrfs_abort_transaction(trans, ret); 3378 goto out; 3379 } 3380 - } else if (ret) { 3381 btrfs_abort_transaction(trans, ret); 3382 goto out; 3383 } ··· 3386 3387 if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { 3388 ret = btrfs_del_sys_chunk(fs_info, chunk_offset); 3389 - if (ret) { 3390 btrfs_abort_transaction(trans, ret); 3391 goto out; 3392 } ··· 3402 btrfs_trans_release_chunk_metadata(trans); 3403 3404 ret = btrfs_remove_block_group(trans, map); 3405 - if (ret) { 3406 btrfs_abort_transaction(trans, ret); 3407 goto out; 3408 } ··· 5041 /* Now btrfs_update_device() will change the on-disk size. */ 5042 ret = btrfs_update_device(trans, device); 5043 btrfs_trans_release_chunk_metadata(trans); 5044 - if (ret < 0) { 5045 btrfs_abort_transaction(trans, ret); 5046 btrfs_end_transaction(trans); 5047 } else { ··· 5701 item_size = btrfs_chunk_item_size(map->num_stripes); 5702 5703 chunk = kzalloc(item_size, GFP_NOFS); 5704 - if (!chunk) { 5705 ret = -ENOMEM; 5706 btrfs_abort_transaction(trans, ret); 5707 goto out;
··· 2243 } 2244 2245 ret = btrfs_rm_dev_item(trans, device); 2246 + if (unlikely(ret)) { 2247 /* Any error in dev item removal is critical */ 2248 btrfs_crit(fs_info, 2249 "failed to remove device item for devid %llu: %d", ··· 2843 mutex_lock(&fs_info->chunk_mutex); 2844 ret = init_first_rw_device(trans); 2845 mutex_unlock(&fs_info->chunk_mutex); 2846 + if (unlikely(ret)) { 2847 btrfs_abort_transaction(trans, ret); 2848 goto error_sysfs; 2849 } 2850 } 2851 2852 ret = btrfs_add_dev_item(trans, device); 2853 + if (unlikely(ret)) { 2854 btrfs_abort_transaction(trans, ret); 2855 goto error_sysfs; 2856 } 2857 2858 if (seeding_dev) { 2859 ret = btrfs_finish_sprout(trans); 2860 + if (unlikely(ret)) { 2861 btrfs_abort_transaction(trans, ret); 2862 goto error_sysfs; 2863 } ··· 3058 } 3059 3060 ret = btrfs_del_item(trans, root, path); 3061 + if (unlikely(ret < 0)) { 3062 btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset); 3063 btrfs_abort_transaction(trans, ret); 3064 goto out; ··· 3283 ret = btrfs_free_dev_extent(trans, device, 3284 map->stripes[i].physical, 3285 &dev_extent_len); 3286 + if (unlikely(ret)) { 3287 mutex_unlock(&fs_devices->device_list_mutex); 3288 btrfs_abort_transaction(trans, ret); 3289 goto out; ··· 3353 struct btrfs_space_info *space_info; 3354 3355 space_info = btrfs_find_space_info(fs_info, sys_flags); 3356 + if (unlikely(!space_info)) { 3357 ret = -EINVAL; 3358 btrfs_abort_transaction(trans, ret); 3359 goto out; ··· 3367 } 3368 3369 ret = btrfs_chunk_alloc_add_chunk_item(trans, sys_bg); 3370 + if (unlikely(ret)) { 3371 btrfs_abort_transaction(trans, ret); 3372 goto out; 3373 } 3374 3375 ret = remove_chunk_item(trans, map, chunk_offset); 3376 + if (unlikely(ret)) { 3377 btrfs_abort_transaction(trans, ret); 3378 goto out; 3379 } 3380 + } else if (unlikely(ret)) { 3381 btrfs_abort_transaction(trans, ret); 3382 goto out; 3383 } ··· 3386 3387 if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { 3388 ret = btrfs_del_sys_chunk(fs_info, chunk_offset); 3389 + if (unlikely(ret)) { 3390 btrfs_abort_transaction(trans, ret); 3391 goto out; 3392 } ··· 3402 btrfs_trans_release_chunk_metadata(trans); 3403 3404 ret = btrfs_remove_block_group(trans, map); 3405 + if (unlikely(ret)) { 3406 btrfs_abort_transaction(trans, ret); 3407 goto out; 3408 } ··· 5041 /* Now btrfs_update_device() will change the on-disk size. */ 5042 ret = btrfs_update_device(trans, device); 5043 btrfs_trans_release_chunk_metadata(trans); 5044 + if (unlikely(ret < 0)) { 5045 btrfs_abort_transaction(trans, ret); 5046 btrfs_end_transaction(trans); 5047 } else { ··· 5701 item_size = btrfs_chunk_item_size(map->num_stripes); 5702 5703 chunk = kzalloc(item_size, GFP_NOFS); 5704 + if (unlikely(!chunk)) { 5705 ret = -ENOMEM; 5706 btrfs_abort_transaction(trans, ret); 5707 goto out;