@@ -404,7 +404,7 @@ int btrfs_validate_extent_buffer(struct extent_buffer *eb,
404
404
CSUM_FMT_VALUE (csum_size , result ),
405
405
btrfs_header_level (eb ),
406
406
ignore_csum ? ", ignored" : "" );
407
- if (!ignore_csum ) {
407
+ if (unlikely ( !ignore_csum ) ) {
408
408
ret = - EUCLEAN ;
409
409
goto out ;
410
410
}
@@ -1055,10 +1055,10 @@ static struct btrfs_root *read_tree_root_path(struct btrfs_root *tree_root,
1055
1055
* For real fs, and not log/reloc trees, root owner must
1056
1056
* match its root node owner
1057
1057
*/
1058
- if (!btrfs_is_testing (fs_info ) &&
1059
- btrfs_root_id (root ) != BTRFS_TREE_LOG_OBJECTID &&
1060
- btrfs_root_id (root ) != BTRFS_TREE_RELOC_OBJECTID &&
1061
- btrfs_root_id (root ) != btrfs_header_owner (root -> node )) {
1058
+ if (unlikely ( !btrfs_is_testing (fs_info ) &&
1059
+ btrfs_root_id (root ) != BTRFS_TREE_LOG_OBJECTID &&
1060
+ btrfs_root_id (root ) != BTRFS_TREE_RELOC_OBJECTID &&
1061
+ btrfs_root_id (root ) != btrfs_header_owner (root -> node ) )) {
1062
1062
btrfs_crit (fs_info ,
1063
1063
"root=%llu block=%llu, tree root owner mismatch, have %llu expect %llu" ,
1064
1064
btrfs_root_id (root ), root -> node -> start ,
@@ -2324,7 +2324,7 @@ static int validate_sys_chunk_array(const struct btrfs_fs_info *fs_info,
2324
2324
const u32 sectorsize = btrfs_super_sectorsize (sb );
2325
2325
u32 sys_array_size = btrfs_super_sys_array_size (sb );
2326
2326
2327
- if (sys_array_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE ) {
2327
+ if (unlikely ( sys_array_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE ) ) {
2328
2328
btrfs_err (fs_info , "system chunk array too big %u > %u" ,
2329
2329
sys_array_size , BTRFS_SYSTEM_CHUNK_ARRAY_SIZE );
2330
2330
return - EUCLEAN ;
@@ -2342,23 +2342,23 @@ static int validate_sys_chunk_array(const struct btrfs_fs_info *fs_info,
2342
2342
disk_key = (struct btrfs_disk_key * )(sb -> sys_chunk_array + cur );
2343
2343
len = sizeof (* disk_key );
2344
2344
2345
- if (cur + len > sys_array_size )
2345
+ if (unlikely ( cur + len > sys_array_size ) )
2346
2346
goto short_read ;
2347
2347
cur += len ;
2348
2348
2349
2349
btrfs_disk_key_to_cpu (& key , disk_key );
2350
- if (key .type != BTRFS_CHUNK_ITEM_KEY ) {
2350
+ if (unlikely ( key .type != BTRFS_CHUNK_ITEM_KEY ) ) {
2351
2351
btrfs_err (fs_info ,
2352
2352
"unexpected item type %u in sys_array at offset %u" ,
2353
2353
key .type , cur );
2354
2354
return - EUCLEAN ;
2355
2355
}
2356
2356
chunk = (struct btrfs_chunk * )(sb -> sys_chunk_array + cur );
2357
2357
num_stripes = btrfs_stack_chunk_num_stripes (chunk );
2358
- if (cur + btrfs_chunk_item_size (num_stripes ) > sys_array_size )
2358
+ if (unlikely ( cur + btrfs_chunk_item_size (num_stripes ) > sys_array_size ) )
2359
2359
goto short_read ;
2360
2360
type = btrfs_stack_chunk_type (chunk );
2361
- if (!(type & BTRFS_BLOCK_GROUP_SYSTEM )) {
2361
+ if (unlikely ( !(type & BTRFS_BLOCK_GROUP_SYSTEM ) )) {
2362
2362
btrfs_err (fs_info ,
2363
2363
"invalid chunk type %llu in sys_array at offset %u" ,
2364
2364
type , cur );
@@ -2605,13 +2605,13 @@ static int btrfs_validate_write_super(struct btrfs_fs_info *fs_info,
2605
2605
ret = btrfs_validate_super (fs_info , sb , -1 );
2606
2606
if (ret < 0 )
2607
2607
goto out ;
2608
- if (!btrfs_supported_super_csum (btrfs_super_csum_type (sb ))) {
2608
+ if (unlikely ( !btrfs_supported_super_csum (btrfs_super_csum_type (sb ) ))) {
2609
2609
ret = - EUCLEAN ;
2610
2610
btrfs_err (fs_info , "invalid csum type, has %u want %u" ,
2611
2611
btrfs_super_csum_type (sb ), BTRFS_CSUM_TYPE_CRC32 );
2612
2612
goto out ;
2613
2613
}
2614
- if (btrfs_super_incompat_flags (sb ) & ~BTRFS_FEATURE_INCOMPAT_SUPP ) {
2614
+ if (unlikely ( btrfs_super_incompat_flags (sb ) & ~BTRFS_FEATURE_INCOMPAT_SUPP ) ) {
2615
2615
ret = - EUCLEAN ;
2616
2616
btrfs_err (fs_info ,
2617
2617
"invalid incompat flags, has 0x%llx valid mask 0x%llx" ,
@@ -4065,7 +4065,7 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
4065
4065
btrfs_set_super_flags (sb , flags | BTRFS_HEADER_FLAG_WRITTEN );
4066
4066
4067
4067
ret = btrfs_validate_write_super (fs_info , sb );
4068
- if (ret < 0 ) {
4068
+ if (unlikely ( ret < 0 ) ) {
4069
4069
mutex_unlock (& fs_info -> fs_devices -> device_list_mutex );
4070
4070
btrfs_handle_fs_error (fs_info , - EUCLEAN ,
4071
4071
"unexpected superblock corruption detected" );
@@ -4881,7 +4881,7 @@ int btrfs_init_root_free_objectid(struct btrfs_root *root)
4881
4881
ret = btrfs_search_slot (NULL , root , & search_key , path , 0 , 0 );
4882
4882
if (ret < 0 )
4883
4883
return ret ;
4884
- if (ret == 0 ) {
4884
+ if (unlikely ( ret == 0 ) ) {
4885
4885
/*
4886
4886
* Key with offset -1 found, there would have to exist a root
4887
4887
* with such id, but this is out of valid range.
0 commit comments