Commit ce9f967f authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba

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: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f8f591df
...@@ -1556,7 +1556,8 @@ static noinline int lock_delalloc_pages(struct inode *inode, ...@@ -1556,7 +1556,8 @@ static noinline int lock_delalloc_pages(struct inode *inode,
* *
* 1 is returned if we find something, 0 if nothing was in the tree * 1 is returned if we find something, 0 if nothing was in the tree
*/ */
static noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode, EXPORT_FOR_TESTS
noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
struct extent_io_tree *tree, struct extent_io_tree *tree,
struct page *locked_page, u64 *start, struct page *locked_page, u64 *start,
u64 *end) u64 *end)
...@@ -1637,16 +1638,6 @@ static noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode, ...@@ -1637,16 +1638,6 @@ static noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
return found; return found;
} }
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
u64 btrfs_find_lock_delalloc_range(struct inode *inode,
struct extent_io_tree *tree,
struct page *locked_page, u64 *start,
u64 *end)
{
return find_lock_delalloc_range(inode, tree, locked_page, start, end);
}
#endif
static int __process_pages_contig(struct address_space *mapping, static int __process_pages_contig(struct address_space *mapping,
struct page *locked_page, struct page *locked_page,
pgoff_t start_index, pgoff_t end_index, pgoff_t start_index, pgoff_t end_index,
......
...@@ -522,8 +522,7 @@ int free_io_failure(struct extent_io_tree *failure_tree, ...@@ -522,8 +522,7 @@ int free_io_failure(struct extent_io_tree *failure_tree,
struct extent_io_tree *io_tree, struct extent_io_tree *io_tree,
struct io_failure_record *rec); struct io_failure_record *rec);
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
u64 btrfs_find_lock_delalloc_range(struct inode *inode, u64 find_lock_delalloc_range(struct inode *inode, struct extent_io_tree *tree,
struct extent_io_tree *tree,
struct page *locked_page, u64 *start, struct page *locked_page, u64 *start,
u64 *end); u64 *end);
#endif #endif
......
...@@ -74,9 +74,9 @@ static int add_new_free_space_info(struct btrfs_trans_handle *trans, ...@@ -74,9 +74,9 @@ static int add_new_free_space_info(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
struct btrfs_free_space_info * EXPORT_FOR_TESTS
search_free_space_info(struct btrfs_trans_handle *trans, struct btrfs_free_space_info *search_free_space_info(
struct btrfs_fs_info *fs_info, struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, int cow) struct btrfs_path *path, int cow)
{ {
...@@ -176,6 +176,7 @@ static void le_bitmap_set(unsigned long *map, unsigned int start, int len) ...@@ -176,6 +176,7 @@ static void le_bitmap_set(unsigned long *map, unsigned int start, int len)
} }
} }
EXPORT_FOR_TESTS
int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path) struct btrfs_path *path)
...@@ -315,6 +316,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, ...@@ -315,6 +316,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
EXPORT_FOR_TESTS
int convert_free_space_to_extents(struct btrfs_trans_handle *trans, int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path) struct btrfs_path *path)
...@@ -487,6 +489,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans, ...@@ -487,6 +489,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
EXPORT_FOR_TESTS
int free_space_test_bit(struct btrfs_block_group_cache *block_group, int free_space_test_bit(struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 offset) struct btrfs_path *path, u64 offset)
{ {
...@@ -775,6 +778,7 @@ static int remove_free_space_extent(struct btrfs_trans_handle *trans, ...@@ -775,6 +778,7 @@ static int remove_free_space_extent(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
EXPORT_FOR_TESTS
int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size) struct btrfs_path *path, u64 start, u64 size)
...@@ -968,6 +972,7 @@ static int add_free_space_extent(struct btrfs_trans_handle *trans, ...@@ -968,6 +972,7 @@ static int add_free_space_extent(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
EXPORT_FOR_TESTS
int __add_to_free_space_tree(struct btrfs_trans_handle *trans, int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size) struct btrfs_path *path, u64 start, u64 size)
......
...@@ -107,7 +107,7 @@ static int test_find_delalloc(u32 sectorsize) ...@@ -107,7 +107,7 @@ static int test_find_delalloc(u32 sectorsize)
set_extent_delalloc(&tmp, 0, sectorsize - 1, 0, NULL); set_extent_delalloc(&tmp, 0, sectorsize - 1, 0, NULL);
start = 0; start = 0;
end = 0; end = 0;
found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end); &end);
if (!found) { if (!found) {
test_err("should have found at least one delalloc"); test_err("should have found at least one delalloc");
...@@ -138,7 +138,7 @@ static int test_find_delalloc(u32 sectorsize) ...@@ -138,7 +138,7 @@ static int test_find_delalloc(u32 sectorsize)
set_extent_delalloc(&tmp, sectorsize, max_bytes - 1, 0, NULL); set_extent_delalloc(&tmp, sectorsize, max_bytes - 1, 0, NULL);
start = test_start; start = test_start;
end = 0; end = 0;
found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end); &end);
if (!found) { if (!found) {
test_err("couldn't find delalloc in our range"); test_err("couldn't find delalloc in our range");
...@@ -172,7 +172,7 @@ static int test_find_delalloc(u32 sectorsize) ...@@ -172,7 +172,7 @@ static int test_find_delalloc(u32 sectorsize)
} }
start = test_start; start = test_start;
end = 0; end = 0;
found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end); &end);
if (found) { if (found) {
test_err("found range when we shouldn't have"); test_err("found range when we shouldn't have");
...@@ -193,7 +193,7 @@ static int test_find_delalloc(u32 sectorsize) ...@@ -193,7 +193,7 @@ static int test_find_delalloc(u32 sectorsize)
set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, 0, NULL); set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, 0, NULL);
start = test_start; start = test_start;
end = 0; end = 0;
found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end); &end);
if (!found) { if (!found) {
test_err("didn't find our range"); test_err("didn't find our range");
...@@ -234,7 +234,7 @@ static int test_find_delalloc(u32 sectorsize) ...@@ -234,7 +234,7 @@ static int test_find_delalloc(u32 sectorsize)
* this changes at any point in the future we will need to fix this * this changes at any point in the future we will need to fix this
* tests expected behavior. * tests expected behavior.
*/ */
found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start, found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end); &end);
if (!found) { if (!found) {
test_err("didn't find our range"); test_err("didn't find our range");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment