All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@linux.ibm.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	David Sterba <dsterba@suse.com>, Qu Wenruo <wqu@suse.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] btrfs: Fix btrfs_find_create_tree_block() testing
Date: Tue, 03 Dec 2019 11:04:08 +0000	[thread overview]
Message-ID: <20191203110408.GA30629@linux.ibm.com> (raw)
In-Reply-To: <20191203093036.fp4rbgm56yzbw6ku@kili.mountain>

Hi,

On Tue, Dec 03, 2019 at 12:33:04PM +0300, Dan Carpenter wrote:
> The btrfs_find_create_tree_block() uses alloc_dummy_extent_buffer() for
> testing and alloc_extent_buffer() for production.  The problem is that
> the test code returns NULL and the production code returns error
> pointers.  The callers only check for error pointers.
> 
> I have changed alloc_dummy_extent_buffer() to return error pointers and

nit:		alloc_test_extent_buffer()

> updated the two callers which use it directly.
> 
> Fixes: faa2dbf004e8 ("Btrfs: add sanity tests for new qgroup accounting code")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/btrfs/extent_io.c                   | 6 ++++--
>  fs/btrfs/tests/free-space-tree-tests.c | 4 ++--
>  fs/btrfs/tests/qgroup-tests.c          | 4 ++--
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index eb8bd0258360..2f4802f405a2 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -5074,12 +5074,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
>  		return eb;
>  	eb = alloc_dummy_extent_buffer(fs_info, start);
>  	if (!eb)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);
>  	eb->fs_info = fs_info;
>  again:
>  	ret = radix_tree_preload(GFP_NOFS);
> -	if (ret)
> +	if (ret) {
> +		exists = ERR_PTR(ret);
>  		goto free_eb;
> +	}
>  	spin_lock(&fs_info->buffer_lock);
>  	ret = radix_tree_insert(&fs_info->buffer_radix,
>  				start >> PAGE_SHIFT, eb);
> diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
> index 1a846bf6e197..914eea5ba6a7 100644
> --- a/fs/btrfs/tests/free-space-tree-tests.c
> +++ b/fs/btrfs/tests/free-space-tree-tests.c
> @@ -452,9 +452,9 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
>  	root->fs_info->tree_root = root;
>  
>  	root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
> -	if (!root->node) {
> +	if (IS_ERR(root->node)) {
>  		test_std_err(TEST_ALLOC_EXTENT_BUFFER);
> -		ret = -ENOMEM;
> +		ret = PTR_ERR(root->node);
>  		goto out;
>  	}
>  	btrfs_set_header_level(root->node, 0);
> diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
> index 09aaca1efd62..ac035a6fa003 100644
> --- a/fs/btrfs/tests/qgroup-tests.c
> +++ b/fs/btrfs/tests/qgroup-tests.c
> @@ -484,9 +484,9 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
>  	 * *cough*backref walking code*cough*
>  	 */
>  	root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
> -	if (!root->node) {
> +	if (IS_ERR(root->node)) {
>  		test_err("couldn't allocate dummy buffer");
> -		ret = -ENOMEM;
> +		ret = PTR_ERR(root->node);
>  		goto out;
>  	}
>  	btrfs_set_header_level(root->node, 0);
> -- 
> 2.11.0
> 

-- 
Sincerely yours,
Mike.

WARNING: multiple messages have this Message-ID (diff)
From: Mike Rapoport <rppt@linux.ibm.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	David Sterba <dsterba@suse.com>, Qu Wenruo <wqu@suse.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] btrfs: Fix btrfs_find_create_tree_block() testing
Date: Tue, 3 Dec 2019 13:04:08 +0200	[thread overview]
Message-ID: <20191203110408.GA30629@linux.ibm.com> (raw)
In-Reply-To: <20191203093036.fp4rbgm56yzbw6ku@kili.mountain>

Hi,

On Tue, Dec 03, 2019 at 12:33:04PM +0300, Dan Carpenter wrote:
> The btrfs_find_create_tree_block() uses alloc_dummy_extent_buffer() for
> testing and alloc_extent_buffer() for production.  The problem is that
> the test code returns NULL and the production code returns error
> pointers.  The callers only check for error pointers.
> 
> I have changed alloc_dummy_extent_buffer() to return error pointers and

nit:		alloc_test_extent_buffer()

> updated the two callers which use it directly.
> 
> Fixes: faa2dbf004e8 ("Btrfs: add sanity tests for new qgroup accounting code")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/btrfs/extent_io.c                   | 6 ++++--
>  fs/btrfs/tests/free-space-tree-tests.c | 4 ++--
>  fs/btrfs/tests/qgroup-tests.c          | 4 ++--
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index eb8bd0258360..2f4802f405a2 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -5074,12 +5074,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
>  		return eb;
>  	eb = alloc_dummy_extent_buffer(fs_info, start);
>  	if (!eb)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);
>  	eb->fs_info = fs_info;
>  again:
>  	ret = radix_tree_preload(GFP_NOFS);
> -	if (ret)
> +	if (ret) {
> +		exists = ERR_PTR(ret);
>  		goto free_eb;
> +	}
>  	spin_lock(&fs_info->buffer_lock);
>  	ret = radix_tree_insert(&fs_info->buffer_radix,
>  				start >> PAGE_SHIFT, eb);
> diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
> index 1a846bf6e197..914eea5ba6a7 100644
> --- a/fs/btrfs/tests/free-space-tree-tests.c
> +++ b/fs/btrfs/tests/free-space-tree-tests.c
> @@ -452,9 +452,9 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
>  	root->fs_info->tree_root = root;
>  
>  	root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
> -	if (!root->node) {
> +	if (IS_ERR(root->node)) {
>  		test_std_err(TEST_ALLOC_EXTENT_BUFFER);
> -		ret = -ENOMEM;
> +		ret = PTR_ERR(root->node);
>  		goto out;
>  	}
>  	btrfs_set_header_level(root->node, 0);
> diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
> index 09aaca1efd62..ac035a6fa003 100644
> --- a/fs/btrfs/tests/qgroup-tests.c
> +++ b/fs/btrfs/tests/qgroup-tests.c
> @@ -484,9 +484,9 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
>  	 * *cough*backref walking code*cough*
>  	 */
>  	root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
> -	if (!root->node) {
> +	if (IS_ERR(root->node)) {
>  		test_err("couldn't allocate dummy buffer");
> -		ret = -ENOMEM;
> +		ret = PTR_ERR(root->node);
>  		goto out;
>  	}
>  	btrfs_set_header_level(root->node, 0);
> -- 
> 2.11.0
> 

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2019-12-03 11:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03  9:33 [PATCH] btrfs: Fix btrfs_find_create_tree_block() testing Dan Carpenter
2019-12-03  9:33 ` Dan Carpenter
2019-12-03 11:04 ` Mike Rapoport [this message]
2019-12-03 11:04   ` Mike Rapoport
2019-12-03 11:24   ` [PATCH v2] " Dan Carpenter
2019-12-03 11:24     ` Dan Carpenter
2019-12-03 18:40     ` David Sterba
2019-12-03 18:40       ` David Sterba
2019-12-03 18:46       ` Dan Carpenter
2019-12-03 18:46         ` Dan Carpenter
2019-12-03 19:06         ` David Sterba
2019-12-03 19:06           ` 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=20191203110408.GA30629@linux.ibm.com \
    --to=rppt@linux.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=clm@fb.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=wqu@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.