linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Johannes Thumshirn <jthumshirn@suse.de>, David Sterba <dsterba@suse.com>
Cc: Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2 5/5] btrfs: use EXPORT_FOR_TESTS for conditionally shared functions
Date: Mon, 19 Nov 2018 11:50:34 +0200	[thread overview]
Message-ID: <1c66cd0f-613e-bf80-bee7-a4e3b1a5d6f2@suse.com> (raw)
In-Reply-To: <20181119093817.9291-6-jthumshirn@suse.de>



On 19.11.18 г. 11:38 ч., Johannes Thumshirn wrote:
> 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.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/extent_io.c             | 14 ++------------
>  fs/btrfs/extent_io.h             |  7 +++----
>  fs/btrfs/free-space-tree.c       |  8 ++++++--
>  fs/btrfs/tests/extent-io-tests.c | 10 +++++-----
>  4 files changed, 16 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 926bf30c2f2e..16344d5b8d68 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -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
>   */
> -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 page *locked_page, u64 *start,
>  				    u64 *end, u64 max_bytes)
> @@ -1636,17 +1637,6 @@ static noinline_for_stack u64 find_lock_delalloc_range(struct inode *inode,
>  	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, u64 max_bytes)
> -{
> -	return find_lock_delalloc_range(inode, tree, locked_page, start, end,
> -			max_bytes);
> -}
> -#endif
> -
>  static int __process_pages_contig(struct address_space *mapping,
>  				  struct page *locked_page,
>  				  pgoff_t start_index, pgoff_t end_index,
> diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
> index d96fd534f144..a03204a81751 100644
> --- a/fs/btrfs/extent_io.h
> +++ b/fs/btrfs/extent_io.h
> @@ -522,10 +522,9 @@ int free_io_failure(struct extent_io_tree *failure_tree,
>  		    struct extent_io_tree *io_tree,
>  		    struct io_failure_record *rec);
>  #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, u64 max_bytes);
> +u64 find_lock_delalloc_range(struct inode *inode, struct extent_io_tree *tree,
> +			     struct page *locked_page, u64 *start,
> +			     u64 *end, u64 max_bytes);
>  #endif
>  struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
>  					       u64 start);
> diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
> index d6736595ec57..cacdebc26fa0 100644
> --- a/fs/btrfs/free-space-tree.c
> +++ b/fs/btrfs/free-space-tree.c
> @@ -74,7 +74,7 @@ static int add_new_free_space_info(struct btrfs_trans_handle *trans,
>  	return ret;
>  }
>  
> -struct btrfs_free_space_info *
> +EXPORT_FOR_TESTS struct btrfs_free_space_info *
>  search_free_space_info(struct btrfs_trans_handle *trans,
>  		       struct btrfs_fs_info *fs_info,
>  		       struct btrfs_block_group_cache *block_group,
> @@ -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,
>  				  struct btrfs_block_group_cache *block_group,
>  				  struct btrfs_path *path)
> @@ -315,6 +316,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
>  	return ret;
>  }
>  
> +EXPORT_FOR_TESTS
>  int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
>  				  struct btrfs_block_group_cache *block_group,
>  				  struct btrfs_path *path)
> @@ -487,6 +489,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
>  	return ret;
>  }
>  
> +EXPORT_FOR_TESTS
>  int free_space_test_bit(struct btrfs_block_group_cache *block_group,
>  			struct btrfs_path *path, u64 offset)
>  {
> @@ -775,6 +778,7 @@ static int remove_free_space_extent(struct btrfs_trans_handle *trans,
>  	return ret;
>  }
>  
> +EXPORT_FOR_TESTS
>  int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
>  				  struct btrfs_block_group_cache *block_group,
>  				  struct btrfs_path *path, u64 start, u64 size)
> @@ -968,7 +972,7 @@ static int add_free_space_extent(struct btrfs_trans_handle *trans,
>  	return ret;
>  }
>  
> -int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
> +EXPORT_FOR_TESTS int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
>  			     struct btrfs_block_group_cache *block_group,
>  			     struct btrfs_path *path, u64 start, u64 size)
>  {
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index a99dc04331b4..ab7771b2a5fb 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -107,7 +107,7 @@ static int test_find_delalloc(u32 sectorsize)
>  	set_extent_delalloc(&tmp, 0, sectorsize - 1, 0, NULL);
>  	start = 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, max_bytes);
>  	if (!found) {
>  		test_err("should have found at least one delalloc");
> @@ -138,7 +138,7 @@ static int test_find_delalloc(u32 sectorsize)
>  	set_extent_delalloc(&tmp, sectorsize, max_bytes - 1, 0, NULL);
>  	start = test_start;
>  	end = 0;
> -	found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start,
> +	found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
>  					 &end, max_bytes);
>  	if (!found) {
>  		test_err("couldn't find delalloc in our range");
> @@ -172,7 +172,7 @@ static int test_find_delalloc(u32 sectorsize)
>  	}
>  	start = test_start;
>  	end = 0;
> -	found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start,
> +	found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
>  					 &end, max_bytes);
>  	if (found) {
>  		test_err("found range when we shouldn't have");
> @@ -193,7 +193,7 @@ static int test_find_delalloc(u32 sectorsize)
>  	set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, 0, NULL);
>  	start = test_start;
>  	end = 0;
> -	found = btrfs_find_lock_delalloc_range(inode, &tmp, locked_page, &start,
> +	found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
>  					 &end, max_bytes);
>  	if (!found) {
>  		test_err("didn't find our range");
> @@ -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
>  	 * 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, max_bytes);
>  	if (!found) {
>  		test_err("didn't find our range");
> 

  reply	other threads:[~2018-11-19  9:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19  9:38 [PATCH v2 0/5] btrfs: fix compiler warning with make W=1 Johannes Thumshirn
2018-11-19  9:38 ` [PATCH v2 1/5] btrfs: remove unused drop_on_err in btrfs_mkdir() Johannes Thumshirn
2018-11-19  9:38 ` [PATCH v2 2/5] btrfs: remove set but not used variable err in btrfs_add_link Johannes Thumshirn
2018-11-19 14:13   ` David Sterba
2018-11-19  9:38 ` [PATCH v2 3/5] btrfs: remove unused function btrfs_sysfs_feature_update() Johannes Thumshirn
2018-11-19 14:21   ` David Sterba
2018-11-19  9:38 ` [PATCH v2 4/5] btrfs: introduce EXPORT_FOR_TESTS macro Johannes Thumshirn
2018-11-19  9:49   ` Nikolay Borisov
2018-11-19  9:38 ` [PATCH v2 5/5] btrfs: use EXPORT_FOR_TESTS for conditionally shared functions Johannes Thumshirn
2018-11-19  9:50   ` Nikolay Borisov [this message]
2018-11-19 14:40 ` [PATCH v2 0/5] btrfs: fix compiler warning with make W=1 David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c66cd0f-613e-bf80-bee7-a4e3b1a5d6f2@suse.com \
    --to=nborisov@suse.com \
    --cc=dsterba@suse.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).