btrfs: tag as unlikely branches that call extent_io_tree_panic()

It's unexpected to ever call extent_io_tree_panic() so surround with
'unlikely' every if statement condition that leads to it, making it
explicit to a reader and to hint the compiler to potentially generate
better code.

On x86_64, using gcc 14.2.0-19 from Debian, this resulted in a slightly
decrease of the btrfs module's text size.

Before:

  $ size fs/btrfs/btrfs.ko
     text	   data	    bss	    dec	    hex	filename
  1999832	 174320	  15592	2189744	 2169b0	fs/btrfs/btrfs.ko

After:

  $ size fs/btrfs/btrfs.ko
     text	   data	    bss	    dec	    hex	filename
  1999768	 174320	  15592	2189680	 216970	fs/btrfs/btrfs.ko

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2026-03-11 12:07:03 +00:00 committed by David Sterba
parent 598c10a9e9
commit 0f7c10d662

View File

@ -696,7 +696,7 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
goto search_again;
ret = split_state(tree, state, prealloc, start);
prealloc = NULL;
if (ret) {
if (unlikely(ret)) {
extent_io_tree_panic(tree, state, "split", ret);
goto out;
}
@ -762,7 +762,7 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
if (!prealloc)
goto search_again;
ret = split_state(tree, state, prealloc, end + 1);
if (ret) {
if (unlikely(ret)) {
extent_io_tree_panic(tree, state, "split", ret);
prealloc = NULL;
goto out;
@ -1203,7 +1203,7 @@ static int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
if (!prealloc)
goto search_again;
ret = split_state(tree, state, prealloc, start);
if (ret)
if (unlikely(ret))
extent_io_tree_panic(tree, state, "split", ret);
prealloc = NULL;
@ -1293,7 +1293,7 @@ static int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
if (!prealloc)
goto search_again;
ret = split_state(tree, state, prealloc, end + 1);
if (ret) {
if (unlikely(ret)) {
extent_io_tree_panic(tree, state, "split", ret);
prealloc = NULL;
goto out;
@ -1448,7 +1448,7 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
}
ret = split_state(tree, state, prealloc, start);
prealloc = NULL;
if (ret) {
if (unlikely(ret)) {
extent_io_tree_panic(tree, state, "split", ret);
goto out;
}
@ -1532,7 +1532,7 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
}
ret = split_state(tree, state, prealloc, end + 1);
if (ret) {
if (unlikely(ret)) {
extent_io_tree_panic(tree, state, "split", ret);
prealloc = NULL;
goto out;