Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] btrfs: fix silent failure when deleting root reference
Date: Tue, 23 Aug 2022 07:47:16 +0800	[thread overview]
Message-ID: <54b0975b-dd84-7ce1-07bd-4e2839735cbd@gmx.com> (raw)
In-Reply-To: <f070919ec910b3682dd22742151a60f9e4c95cbf.1661179270.git.fdmanana@suse.com>



On 2022/8/22 22:47, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> At btrfs_del_root_ref(), if btrfs_search_slot() returns an error, we end
> up returning from the function with a value of 0 (success). This happens
> because the function returns the value stored in the variable 'err', which
> is 0, while the error value we got from btrfs_search_slot() is stored in
> the 'ret' variable.
>
> So fix it by setting 'err' with the error value.
>
> Fixes: 8289ed9f93bef2 ("btrfs: replace the BUG_ON in btrfs_del_root_ref with proper error handling")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks for catching this,
Qu
> ---
>   fs/btrfs/root-tree.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
> index a64b26b16904..d647cb2938c0 100644
> --- a/fs/btrfs/root-tree.c
> +++ b/fs/btrfs/root-tree.c
> @@ -349,9 +349,10 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
>   	key.offset = ref_id;
>   again:
>   	ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		err = ret;
>   		goto out;
> -	if (ret == 0) {

Just a small nitpick here, since above if (ret < 0) branch will call
"goto out", we don't need the "else" branch.
The old "if (ret == 0) {" should be good enough.

Thanks,
Qu

> +	} else if (ret == 0) {
>   		leaf = path->nodes[0];
>   		ref = btrfs_item_ptr(leaf, path->slots[0],
>   				     struct btrfs_root_ref);

  reply	other threads:[~2022-08-22 23:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22 11:53 [PATCH 0/2] btrfs: fix lost error value deleting root reference fdmanana
2022-08-22 11:53 ` [PATCH 1/2] btrfs: fix silent failure when " fdmanana
2022-08-22 11:53 ` [PATCH 2/2] btrfs: simplify error handling at btrfs_del_root_ref() fdmanana
2022-08-22 14:47 ` [PATCH v2 0/2] btrfs: fix lost error value deleting root reference fdmanana
2022-08-22 14:47   ` [PATCH v2 1/2] btrfs: fix silent failure when " fdmanana
2022-08-22 23:47     ` Qu Wenruo [this message]
2022-08-23  8:11       ` Filipe Manana
2022-08-23 17:15         ` David Sterba
2022-08-22 14:47   ` [PATCH v2 2/2] btrfs: simplify error handling at btrfs_del_root_ref() fdmanana
2022-08-22 23:54     ` Qu Wenruo
2022-08-23  8:09       ` Filipe Manana
2022-08-22 18:30   ` [PATCH v2 0/2] btrfs: fix lost error value deleting root reference 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=54b0975b-dd84-7ce1-07bd-4e2839735cbd@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=fdmanana@kernel.org \
    --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