All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rohit Singh <rh0@fb.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: simplify error handling in btrfs_lookup_dentry
Date: Tue, 12 Jul 2022 12:54:30 -0700	[thread overview]
Message-ID: <Ys3Rdl7HrV+bbtmB@fb.com> (raw)
In-Reply-To: <20220711151618.2518485-1-nborisov@suse.com>

On Mon, Jul 11, 2022 at 06:16:18PM +0300, Nikolay Borisov wrote:
> In btrfs_lookup_dentry releasing the reference of the sub_root and the
> running orphan cleanup should only happen if the dentry found actually
> represents a subvolume. This can only be true in the 'else' branch as
> otherwise either fixup_tree_root_location returned an ENOENT error, in
> which case sub_root wouldn't have been changed or if we got a different
> errno this means btrfs_get_fs_root couldn't have executed successfully
> again meaning sub_root will equal to root. So simplify all the branches
> by moving the code into the 'else'.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/inode.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 0b17335555e0..1dd073e96696 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -5821,11 +5821,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
>  			inode = new_simple_dir(dir->i_sb, &location, sub_root);
>  	} else {
>  		inode = btrfs_iget(dir->i_sb, location.objectid, sub_root);
> -	}
> -	if (root != sub_root)
>  		btrfs_put_root(sub_root);
> -
> -	if (!IS_ERR(inode) && root != sub_root) {

It looks like the root != sub_root stuff looks correct.

Can't the btrfs inode have an error state on it though?

  reply	other threads:[~2022-07-12 19:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 15:16 [PATCH] btrfs: simplify error handling in btrfs_lookup_dentry Nikolay Borisov
2022-07-12 19:54 ` Rohit Singh [this message]
2022-07-12 20:36   ` Nikolay Borisov
2022-07-12 21:13     ` Rohit Singh
2022-07-12 21:26     ` Sweet Tea Dorminy
2022-07-13 14:03 ` 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=Ys3Rdl7HrV+bbtmB@fb.com \
    --to=rh0@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@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.