From: Mark Harmstone Date: Thu, 6 Mar 2025 10:58:46 +0000 (+0000) Subject: btrfs: avoid linker error in btrfs_find_create_tree_block() X-Git-Tag: v5.10.238~134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4012eb35e3b1cbcf460af24b49b49a94cfe85715;p=thirdparty%2Fkernel%2Fstable.git btrfs: avoid linker error in btrfs_find_create_tree_block() [ Upstream commit 7ef3cbf17d2734ca66c4ed8573be45f4e461e7ee ] The inline function btrfs_is_testing() is hardcoded to return 0 if CONFIG_BTRFS_FS_RUN_SANITY_TESTS is not set. Currently we're relying on the compiler optimizing out the call to alloc_test_extent_buffer() in btrfs_find_create_tree_block(), as it's not been defined (it's behind an #ifdef). Add a stub version of alloc_test_extent_buffer() to avoid linker errors on non-standard optimization levels. This problem was seen on GCC 14 with -O0 and is helps to see symbols that would be otherwise optimized out. Reviewed-by: Qu Wenruo Signed-off-by: Mark Harmstone Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9cef930c4ecfb..8498994ef5c6d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5134,10 +5134,10 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, return NULL; } -#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, u64 start) { +#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct extent_buffer *eb, *exists = NULL; int ret; @@ -5173,8 +5173,11 @@ again: free_eb: btrfs_release_extent_buffer(eb); return exists; -} +#else + /* Stub to avoid linker error when compiled with optimizations turned off. */ + return NULL; #endif +} struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start)