Skip to content

Commit b0e30e3

Browse files
fdmananakdave
authored andcommitted
btrfs: mark as unlikely not uptodate extent buffer checks when navigating btrees
We expect that after attempting to read an extent buffer we had no errors therefore the extent buffer is up to date, so mark the checks for a not up to date extent buffer as unlikely and allow the compiler to pontentially generate better code. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 8f0534e commit b0e30e3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

fs/btrfs/ctree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ struct extent_buffer *btrfs_read_node_slot(struct extent_buffer *parent,
844844
&check);
845845
if (IS_ERR(eb))
846846
return eb;
847-
if (!extent_buffer_uptodate(eb)) {
847+
if (unlikely(!extent_buffer_uptodate(eb))) {
848848
free_extent_buffer(eb);
849849
return ERR_PTR(-EIO);
850850
}
@@ -1571,7 +1571,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
15711571
* and give up so that our caller doesn't loop forever
15721572
* on our EAGAINs.
15731573
*/
1574-
if (!extent_buffer_uptodate(tmp)) {
1574+
if (unlikely(!extent_buffer_uptodate(tmp))) {
15751575
ret = -EIO;
15761576
goto out;
15771577
}
@@ -1752,7 +1752,7 @@ static struct extent_buffer *btrfs_search_slot_get_root(struct btrfs_root *root,
17521752
* The root may have failed to write out at some point, and thus is no
17531753
* longer valid, return an error in this case.
17541754
*/
1755-
if (!extent_buffer_uptodate(b)) {
1755+
if (unlikely(!extent_buffer_uptodate(b))) {
17561756
if (root_lock)
17571757
btrfs_tree_unlock_rw(b, root_lock);
17581758
free_extent_buffer(b);
@@ -2260,7 +2260,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
22602260

22612261
again:
22622262
b = btrfs_get_old_root(root, time_seq);
2263-
if (!b) {
2263+
if (unlikely(!b)) {
22642264
ret = -EIO;
22652265
goto done;
22662266
}

0 commit comments

Comments
 (0)