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