Skip to content

Commit 6d8ff4e

Browse files
committed
btrfs: annotate unlikely branches after V0 extent type removal
The v0 extent type checks are the right case for the unlikely annotations as we don't expect to ever see them, so let's give the compiler some hint. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent ba3c2b1 commit 6d8ff4e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

fs/btrfs/extent-tree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
13041304
ref2 = btrfs_item_ptr(leaf, path->slots[0],
13051305
struct btrfs_shared_data_ref);
13061306
num_refs = btrfs_shared_data_ref_count(leaf, ref2);
1307-
} else if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
1307+
} else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
13081308
btrfs_print_v0_err(trans->fs_info);
13091309
btrfs_abort_transaction(trans, -EINVAL);
13101310
return -EINVAL;
@@ -1555,7 +1555,7 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
15551555

15561556
leaf = path->nodes[0];
15571557
item_size = btrfs_item_size_nr(leaf, path->slots[0]);
1558-
if (item_size < sizeof(*ei)) {
1558+
if (unlikely(item_size < sizeof(*ei))) {
15591559
err = -EINVAL;
15601560
btrfs_print_v0_err(fs_info);
15611561
btrfs_abort_transaction(trans, err);
@@ -2285,7 +2285,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
22852285
leaf = path->nodes[0];
22862286
item_size = btrfs_item_size_nr(leaf, path->slots[0]);
22872287

2288-
if (item_size < sizeof(*ei)) {
2288+
if (unlikely(item_size < sizeof(*ei))) {
22892289
err = -EINVAL;
22902290
btrfs_print_v0_err(fs_info);
22912291
btrfs_abort_transaction(trans, err);
@@ -6822,7 +6822,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
68226822

68236823
leaf = path->nodes[0];
68246824
item_size = btrfs_item_size_nr(leaf, extent_slot);
6825-
if (item_size < sizeof(*ei)) {
6825+
if (unlikely(item_size < sizeof(*ei))) {
68266826
ret = -EINVAL;
68276827
btrfs_print_v0_err(info);
68286828
btrfs_abort_transaction(trans, ret);

fs/btrfs/print-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
5252
u64 offset;
5353
int ref_index = 0;
5454

55-
if (item_size < sizeof(*ei)) {
55+
if (unlikely(item_size < sizeof(*ei))) {
5656
btrfs_print_v0_err(eb->fs_info);
5757
btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
5858
}

fs/btrfs/relocation.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
830830
edge->node[UPPER] = upper;
831831

832832
goto next;
833-
} else if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
833+
} else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
834834
err = -EINVAL;
835835
btrfs_print_v0_err(rc->extent_root->fs_info);
836836
btrfs_handle_fs_error(rc->extent_root->fs_info, err,
@@ -3325,7 +3325,7 @@ static int add_tree_block(struct reloc_control *rc,
33253325
level = (int)extent_key->offset;
33263326
}
33273327
generation = btrfs_extent_generation(eb, ei);
3328-
} else if (item_size == sizeof(struct btrfs_extent_item_v0)) {
3328+
} else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
33293329
btrfs_print_v0_err(eb->fs_info);
33303330
btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
33313331
return -EINVAL;
@@ -3742,7 +3742,7 @@ int add_data_references(struct reloc_control *rc,
37423742
struct btrfs_extent_data_ref);
37433743
ret = find_data_references(rc, extent_key,
37443744
eb, dref, blocks);
3745-
} else if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
3745+
} else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
37463746
btrfs_print_v0_err(eb->fs_info);
37473747
btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
37483748
ret = -EINVAL;
@@ -3984,7 +3984,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
39843984
flags = btrfs_extent_flags(path->nodes[0], ei);
39853985
ret = check_extent_flags(flags);
39863986
BUG_ON(ret);
3987-
} else if (item_size == sizeof(struct btrfs_extent_item_v0)) {
3987+
} else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
39883988
err = -EINVAL;
39893989
btrfs_print_v0_err(trans->fs_info);
39903990
btrfs_abort_transaction(trans, err);

0 commit comments

Comments
 (0)