]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: mark as unlikely not uptodate extent buffer checks when navigating btrees
authorFilipe Manana <fdmanana@suse.com>
Tue, 16 Sep 2025 15:09:50 +0000 (16:09 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:23 +0000 (08:49 +0200)
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>
fs/btrfs/ctree.c

index 6f9465d4ce54ce7cbf24424ba6d8fe681943ab94..f6d2a4a4b9eb825462c04f7f9ae9e6fd4fc21eb6 100644 (file)
@@ -844,7 +844,7 @@ struct extent_buffer *btrfs_read_node_slot(struct extent_buffer *parent,
                             &check);
        if (IS_ERR(eb))
                return eb;
-       if (!extent_buffer_uptodate(eb)) {
+       if (unlikely(!extent_buffer_uptodate(eb))) {
                free_extent_buffer(eb);
                return ERR_PTR(-EIO);
        }
@@ -1571,7 +1571,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
         * and give up so that our caller doesn't loop forever
         * on our EAGAINs.
         */
-       if (!extent_buffer_uptodate(tmp)) {
+       if (unlikely(!extent_buffer_uptodate(tmp))) {
                ret = -EIO;
                goto out;
        }
@@ -1752,7 +1752,7 @@ out:
         * The root may have failed to write out at some point, and thus is no
         * longer valid, return an error in this case.
         */
-       if (!extent_buffer_uptodate(b)) {
+       if (unlikely(!extent_buffer_uptodate(b))) {
                if (root_lock)
                        btrfs_tree_unlock_rw(b, root_lock);
                free_extent_buffer(b);
@@ -2260,7 +2260,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
 
 again:
        b = btrfs_get_old_root(root, time_seq);
-       if (!b) {
+       if (unlikely(!b)) {
                ret = -EIO;
                goto done;
        }