From: Jeff Layton <jlayton@kernel.org>
To: xiubli@redhat.com, ceph-devel@vger.kernel.org
Subject: Re: [PATCH] ceph: fail the open_by_handle_at() if the dentry is being unlinked
Date: Thu, 04 Aug 2022 12:25:32 -0400 [thread overview]
Message-ID: <afbd8615b4bb651c505c933576350a8afa082e41.camel@kernel.org> (raw)
In-Reply-To: <20220804080624.14768-1-xiubli@redhat.com>
On Thu, 2022-08-04 at 16:06 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
>
> When unlinking a file the kclient will send a unlink request to MDS
> by holding the dentry reference, and then the MDS will return 2 replies,
> which are unsafe reply and a deferred safe reply.
>
> After the unsafe reply received the kernel will return and succeed
> the unlink request to user space apps.
>
> Only when the safe reply received the dentry's reference will be
> released. Or the dentry will only be unhashed from dcache. But when
> the open_by_handle_at() begins to open the unlinked files it will
> succeed.
>
> URL: https://tracker.ceph.com/issues/56524
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
> fs/ceph/export.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ceph/export.c b/fs/ceph/export.c
> index 0ebf2bd93055..7d2ae977b8c9 100644
> --- a/fs/ceph/export.c
> +++ b/fs/ceph/export.c
> @@ -182,6 +182,7 @@ struct inode *ceph_lookup_inode(struct super_block *sb, u64 ino)
> static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
> {
> struct inode *inode = __lookup_inode(sb, ino);
> + struct dentry *dentry;
> int err;
>
> if (IS_ERR(inode))
> @@ -197,7 +198,15 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
> iput(inode);
> return ERR_PTR(-ESTALE);
> }
> - return d_obtain_alias(inode);
> +
> + /* -ESTALE if the dentry is unhashed, which should being released */
> + dentry = d_obtain_alias(inode);
> + if (d_unhashed(dentry)) {
> + dput(dentry);
> + return ERR_PTR(-ESTALE);
> + }
> +
> + return dentry;
> }
>
> static struct dentry *__snapfh_to_dentry(struct super_block *sb,
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2022-08-04 16:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 8:06 [PATCH] ceph: fail the open_by_handle_at() if the dentry is being unlinked xiubli
2022-08-04 16:25 ` Jeff Layton [this message]
2023-09-06 16:58 ` Sebastian Hasler
2023-09-07 2:05 ` Xiubo Li
2023-09-07 11:57 ` Sebastian Hasler
2023-09-11 3:21 ` Xiubo Li
2023-09-11 10:07 ` Sebastian Hasler
2023-09-12 12:51 ` Xiubo Li
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=afbd8615b4bb651c505c933576350a8afa082e41.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=xiubli@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox