From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
To: Mark Fasheh <mfasheh@suse.de>
Cc: linux-btrfs@vger.kernel.org, chris.mason@oracle.com
Subject: Re: [PATCH] btrfs: Handle NULL inode return from btrfs_lookup_dentry()
Date: Tue, 09 Aug 2011 13:45:39 +0900 [thread overview]
Message-ID: <4E40BB73.3010809@jp.fujitsu.com> (raw)
In-Reply-To: <20110805164828.GB8482@wotan.suse.de>
Hi, Mark,
(2011/08/06 1:48), Mark Fasheh wrote:
> Right now in create_snapshot(), we'll BUG() if btrfs_lookup_dentry() returns
> a NULL inode (negative dentry). Getting a negative dentry here probably
> isn't ever expected to happen however two things lead me to believe that we
> should trap this anyway:
>
> - I don't see any possiblity of serious fs corruption from handling the
> error. I do wonder though if we could have an "orphaned" snapshot? Even
> if we did that doesn't strike me as needing to crash the machine. (Q:
> Perhaps going read-only is the eventual solution here?)
>
> - It's very trivial to pass an -ENOENT back to userspace as we're pretty
> high up the call path at this point.
I have already posted the same purpose patch. Please look at the following.
http://marc.info/?l=linux-btrfs&m=130932339824237&w=2
Thanks,
Tsutomu
>
> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
> ---
> fs/btrfs/ioctl.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 7cf0133..fc9525f 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -498,14 +498,16 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
> if (ret)
> goto fail;
>
> + ret = 0;
> inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry);
> if (IS_ERR(inode)) {
> ret = PTR_ERR(inode);
> goto fail;
> - }
> - BUG_ON(!inode);
> + } else if (inode == NULL)
> + ret = -ENOENT;
> +
> d_instantiate(dentry, inode);
> - ret = 0;
> +
> fail:
> kfree(pending_snapshot);
> return ret;
prev parent reply other threads:[~2011-08-09 4:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 16:48 [PATCH] btrfs: Handle NULL inode return from btrfs_lookup_dentry() Mark Fasheh
2011-08-09 4:45 ` Tsutomu Itoh [this message]
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=4E40BB73.3010809@jp.fujitsu.com \
--to=t-itoh@jp.fujitsu.com \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=mfasheh@suse.de \
/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.