]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: move WARN_ON on unexpected error in __add_tree_block()
authorFilipe Manana <fdmanana@suse.com>
Fri, 5 Jun 2026 16:25:50 +0000 (17:25 +0100)
committerJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 9 Jun 2026 16:22:47 +0000 (18:22 +0200)
There's no point in having the WARN_ON(1) inside the if statement for the
unexpected error. Move it into the if statement's condition, which brings
a couple benefits:

1) It marks the branch as unlikely, hinting the compiler to generate
   better code;

2) The WARN_ON() produces a stack trace after the dumped leaf and error
   message which can hide that more important information in case we get
   a truncated dmesg/syslog.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c

index e7771c4c4f38844deba4c916c07c5be52b179fc1..5f1200e69692545a064f7292f01813b6ea06e04d 100644 (file)
@@ -3200,13 +3200,12 @@ again:
                        goto again;
                }
        }
-       if (ret) {
+       if (WARN_ON(ret)) {
                ASSERT(ret == 1);
                btrfs_print_leaf(path->nodes[0]);
                btrfs_err(fs_info,
             "tree block extent item (%llu) is not found in extent tree",
                     bytenr);
-               WARN_ON(1);
                return -EINVAL;
        }