Commit 6d8ff4e4 authored by David Sterba's avatar David Sterba

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: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ba3c2b19
...@@ -1304,7 +1304,7 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans, ...@@ -1304,7 +1304,7 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
ref2 = btrfs_item_ptr(leaf, path->slots[0], ref2 = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_shared_data_ref); struct btrfs_shared_data_ref);
num_refs = btrfs_shared_data_ref_count(leaf, ref2); num_refs = btrfs_shared_data_ref_count(leaf, ref2);
} else if (key.type == BTRFS_EXTENT_REF_V0_KEY) { } else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
btrfs_print_v0_err(trans->fs_info); btrfs_print_v0_err(trans->fs_info);
btrfs_abort_transaction(trans, -EINVAL); btrfs_abort_transaction(trans, -EINVAL);
return -EINVAL; return -EINVAL;
...@@ -1555,7 +1555,7 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, ...@@ -1555,7 +1555,7 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
leaf = path->nodes[0]; leaf = path->nodes[0];
item_size = btrfs_item_size_nr(leaf, path->slots[0]); item_size = btrfs_item_size_nr(leaf, path->slots[0]);
if (item_size < sizeof(*ei)) { if (unlikely(item_size < sizeof(*ei))) {
err = -EINVAL; err = -EINVAL;
btrfs_print_v0_err(fs_info); btrfs_print_v0_err(fs_info);
btrfs_abort_transaction(trans, err); btrfs_abort_transaction(trans, err);
...@@ -2285,7 +2285,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, ...@@ -2285,7 +2285,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
leaf = path->nodes[0]; leaf = path->nodes[0];
item_size = btrfs_item_size_nr(leaf, path->slots[0]); item_size = btrfs_item_size_nr(leaf, path->slots[0]);
if (item_size < sizeof(*ei)) { if (unlikely(item_size < sizeof(*ei))) {
err = -EINVAL; err = -EINVAL;
btrfs_print_v0_err(fs_info); btrfs_print_v0_err(fs_info);
btrfs_abort_transaction(trans, err); btrfs_abort_transaction(trans, err);
...@@ -6822,7 +6822,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, ...@@ -6822,7 +6822,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
leaf = path->nodes[0]; leaf = path->nodes[0];
item_size = btrfs_item_size_nr(leaf, extent_slot); item_size = btrfs_item_size_nr(leaf, extent_slot);
if (item_size < sizeof(*ei)) { if (unlikely(item_size < sizeof(*ei))) {
ret = -EINVAL; ret = -EINVAL;
btrfs_print_v0_err(info); btrfs_print_v0_err(info);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
......
...@@ -52,7 +52,7 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type) ...@@ -52,7 +52,7 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
u64 offset; u64 offset;
int ref_index = 0; int ref_index = 0;
if (item_size < sizeof(*ei)) { if (unlikely(item_size < sizeof(*ei))) {
btrfs_print_v0_err(eb->fs_info); btrfs_print_v0_err(eb->fs_info);
btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL); btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
} }
......
...@@ -830,7 +830,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc, ...@@ -830,7 +830,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
edge->node[UPPER] = upper; edge->node[UPPER] = upper;
goto next; goto next;
} else if (key.type == BTRFS_EXTENT_REF_V0_KEY) { } else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
err = -EINVAL; err = -EINVAL;
btrfs_print_v0_err(rc->extent_root->fs_info); btrfs_print_v0_err(rc->extent_root->fs_info);
btrfs_handle_fs_error(rc->extent_root->fs_info, err, btrfs_handle_fs_error(rc->extent_root->fs_info, err,
...@@ -3325,7 +3325,7 @@ static int add_tree_block(struct reloc_control *rc, ...@@ -3325,7 +3325,7 @@ static int add_tree_block(struct reloc_control *rc,
level = (int)extent_key->offset; level = (int)extent_key->offset;
} }
generation = btrfs_extent_generation(eb, ei); generation = btrfs_extent_generation(eb, ei);
} else if (item_size == sizeof(struct btrfs_extent_item_v0)) { } else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
btrfs_print_v0_err(eb->fs_info); btrfs_print_v0_err(eb->fs_info);
btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL); btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
return -EINVAL; return -EINVAL;
...@@ -3742,7 +3742,7 @@ int add_data_references(struct reloc_control *rc, ...@@ -3742,7 +3742,7 @@ int add_data_references(struct reloc_control *rc,
struct btrfs_extent_data_ref); struct btrfs_extent_data_ref);
ret = find_data_references(rc, extent_key, ret = find_data_references(rc, extent_key,
eb, dref, blocks); eb, dref, blocks);
} else if (key.type == BTRFS_EXTENT_REF_V0_KEY) { } else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
btrfs_print_v0_err(eb->fs_info); btrfs_print_v0_err(eb->fs_info);
btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL); btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
ret = -EINVAL; ret = -EINVAL;
...@@ -3984,7 +3984,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -3984,7 +3984,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
flags = btrfs_extent_flags(path->nodes[0], ei); flags = btrfs_extent_flags(path->nodes[0], ei);
ret = check_extent_flags(flags); ret = check_extent_flags(flags);
BUG_ON(ret); BUG_ON(ret);
} else if (item_size == sizeof(struct btrfs_extent_item_v0)) { } else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
err = -EINVAL; err = -EINVAL;
btrfs_print_v0_err(trans->fs_info); btrfs_print_v0_err(trans->fs_info);
btrfs_abort_transaction(trans, err); btrfs_abort_transaction(trans, err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment