From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix error check of btrfs_lookup_dentry()
Date: Tue, 17 Dec 2013 10:10:01 +0900 [thread overview]
Message-ID: <52AFA469.1070800@jp.fujitsu.com> (raw)
In-Reply-To: <20131216152730.GI6498@twin.jikos.cz>
Hi, David,
On 2013/12/17 0:27, David Sterba wrote:
> On Fri, Dec 13, 2013 at 09:51:42AM +0900, Tsutomu Itoh wrote:
>> --- a/fs/btrfs/inode.c
>> +++ b/fs/btrfs/inode.c
>> @@ -4974,10 +4974,17 @@ static void btrfs_dentry_release(struct dentry *dentry)
>> static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
>> unsigned int flags)
>> {
>> - struct dentry *ret;
>> + struct inode *inode;
>>
>> - ret = d_splice_alias(btrfs_lookup_dentry(dir, dentry), dentry);
>> - return ret;
>> + inode = btrfs_lookup_dentry(dir, dentry);
>> + if (IS_ERR(inode)) {
>> + if (PTR_ERR(inode) == -ENOENT)
>> + inode = NULL;
>> + else
>> + return ERR_CAST(inode);
>> + }
>> +
>> + return d_splice_alias(inode, dentry);
>
> btrfs_lookup used to be a simple d_splice_alias(btrfs_lookup_dentry ...)
> and the expanded back and forth with the DCACHE_NEED_LOOKUP flag.
>
> a66e7cc626f42de6c745963fe0d807518fa49d39 added
> 39e3c9553f34381a1b664c27b0c696a266a5735e removed
>
> d_splice_alias has been made robust in
> a9049376ee05bf966bfe2b081b5071326856890a
> "make d_splice_alias(ERR_PTR(err), dentry) = ERR_PTR(err)"
>
> you can drop the error handling from btrfs_lookup completely.
d_splice_alias() is called by the following formats if btrfs_lookup_dentry()
returns NULL before my patch is applied.
d_splice_alias(NULL, dentry);
However, d_splice_alias() is called by the following formats when
becoming the same situation after my patch is applied.
d_splice_alias(-ENOENT, dentry);
Therefore, I added the following error handling code.
+ if (IS_ERR(inode)) {
+ if (PTR_ERR(inode) == -ENOENT)
+ inode = NULL;
+ else
+ return ERR_CAST(inode);
+ }
Thanks,
Tsutomu
>
> The rest looks ok.
>
>
next prev parent reply other threads:[~2013-12-17 1:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 0:51 [PATCH] Btrfs: fix error check of btrfs_lookup_dentry() Tsutomu Itoh
2013-12-16 15:27 ` David Sterba
2013-12-17 1:10 ` Tsutomu Itoh [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-06-28 3:34 Tsutomu Itoh
2011-06-28 14:22 ` Josef Bacik
2011-06-29 0:15 ` Tsutomu Itoh
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=52AFA469.1070800@jp.fujitsu.com \
--to=t-itoh@jp.fujitsu.com \
--cc=dsterba@suse.cz \
--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 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.