Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: use EXPORT_FOR_TESTS for conditionally exported functions

Several functions in BTRFS are only used inside the source file they are
declared if CONFIG_BTRFS_FS_RUN_SANITY_TESTS is not defined. However if
CONFIG_BTRFS_FS_RUN_SANITY_TESTS is defined these functions are shared
with the unit tests code.

Before the introduction of the EXPORT_FOR_TESTS macro, these functions
could not be declared as static and the compiler had a harder task when
optimizing and inlining them.

As we have EXPORT_FOR_TESTS now, use it where appropriate to support the
compiler.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Johannes Thumshirn and committed by
David Sterba
ce9f967f f8f591df

+20 -25
+2 -11
fs/btrfs/extent_io.c
··· 1556 1556 * 1557 1557 * 1 is returned if we find something, 0 if nothing was in the tree 1558 1558 */ 1559 - static noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode, 1559 + EXPORT_FOR_TESTS 1560 + noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode, 1560 1561 struct extent_io_tree *tree, 1561 1562 struct page *locked_page, u64 *start, 1562 1563 u64 *end) ··· 1637 1636 out_failed: 1638 1637 return found; 1639 1638 } 1640 - 1641 - #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 1642 - u64 btrfs_find_lock_delalloc_range(struct inode *inode, 1643 - struct extent_io_tree *tree, 1644 - struct page *locked_page, u64 *start, 1645 - u64 *end) 1646 - { 1647 - return find_lock_delalloc_range(inode, tree, locked_page, start, end); 1648 - } 1649 - #endif 1650 1639 1651 1640 static int __process_pages_contig(struct address_space *mapping, 1652 1641 struct page *locked_page,
+3 -4
fs/btrfs/extent_io.h
··· 522 522 struct extent_io_tree *io_tree, 523 523 struct io_failure_record *rec); 524 524 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 525 - u64 btrfs_find_lock_delalloc_range(struct inode *inode, 526 - struct extent_io_tree *tree, 527 - struct page *locked_page, u64 *start, 528 - u64 *end); 525 + u64 find_lock_delalloc_range(struct inode *inode, struct extent_io_tree *tree, 526 + struct page *locked_page, u64 *start, 527 + u64 *end); 529 528 #endif 530 529 struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, 531 530 u64 start);
+10 -5
fs/btrfs/free-space-tree.c
··· 74 74 return ret; 75 75 } 76 76 77 - struct btrfs_free_space_info * 78 - search_free_space_info(struct btrfs_trans_handle *trans, 79 - struct btrfs_fs_info *fs_info, 80 - struct btrfs_block_group_cache *block_group, 81 - struct btrfs_path *path, int cow) 77 + EXPORT_FOR_TESTS 78 + struct btrfs_free_space_info *search_free_space_info( 79 + struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info, 80 + struct btrfs_block_group_cache *block_group, 81 + struct btrfs_path *path, int cow) 82 82 { 83 83 struct btrfs_root *root = fs_info->free_space_root; 84 84 struct btrfs_key key; ··· 176 176 } 177 177 } 178 178 179 + EXPORT_FOR_TESTS 179 180 int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, 180 181 struct btrfs_block_group_cache *block_group, 181 182 struct btrfs_path *path) ··· 316 315 return ret; 317 316 } 318 317 318 + EXPORT_FOR_TESTS 319 319 int convert_free_space_to_extents(struct btrfs_trans_handle *trans, 320 320 struct btrfs_block_group_cache *block_group, 321 321 struct btrfs_path *path) ··· 489 487 return ret; 490 488 } 491 489 490 + EXPORT_FOR_TESTS 492 491 int free_space_test_bit(struct btrfs_block_group_cache *block_group, 493 492 struct btrfs_path *path, u64 offset) 494 493 { ··· 778 775 return ret; 779 776 } 780 777 778 + EXPORT_FOR_TESTS 781 779 int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, 782 780 struct btrfs_block_group_cache *block_group, 783 781 struct btrfs_path *path, u64 start, u64 size) ··· 972 968 return ret; 973 969 } 974 970 971 + EXPORT_FOR_TESTS 975 972 int __add_to_free_space_tree(struct btrfs_trans_handle *trans, 976 973 struct btrfs_block_group_cache *block_group, 977 974 struct btrfs_path *path, u64 start, u64 size)
+5 -5
fs/btrfs/tests/extent-io-tests.c
··· 107 107 set_extent_delalloc(&tmp, 0, sectorsize - 1, 0, NULL); 108 108 start = 0; 109 109 end = 0; 110 - found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, 110 + found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, 111 111 &end); 112 112 if (!found) { 113 113 test_err("should have found at least one delalloc"); ··· 138 138 set_extent_delalloc(&tmp, sectorsize, max_bytes - 1, 0, NULL); 139 139 start = test_start; 140 140 end = 0; 141 - found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, 141 + found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, 142 142 &end); 143 143 if (!found) { 144 144 test_err("couldn't find delalloc in our range"); ··· 172 172 } 173 173 start = test_start; 174 174 end = 0; 175 - found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, 175 + found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, 176 176 &end); 177 177 if (found) { 178 178 test_err("found range when we shouldn't have"); ··· 193 193 set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, 0, NULL); 194 194 start = test_start; 195 195 end = 0; 196 - found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, 196 + found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, 197 197 &end); 198 198 if (!found) { 199 199 test_err("didn't find our range"); ··· 234 234 * this changes at any point in the future we will need to fix this 235 235 * tests expected behavior. 236 236 */ 237 - found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, 237 + found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, 238 238 &end); 239 239 if (!found) { 240 240 test_err("didn't find our range");