From: Filipe Manana Date: Fri, 5 Jun 2026 16:25:50 +0000 (+0100) Subject: btrfs: move WARN_ON on unexpected error in __add_tree_block() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50c134f2a9eac39373d937785d18e4386f48532b;p=thirdparty%2Fkernel%2Flinux.git btrfs: move WARN_ON on unexpected error in __add_tree_block() 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 Signed-off-by: Filipe Manana Signed-off-by: David Sterba --- diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index e7771c4c4f388..5f1200e696925 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -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; }