From: Jeff Layton <jlayton@redhat.com>
To: "Yan, Zheng" <zyan@redhat.com>, ceph-devel@vger.kernel.org
Subject: Re: [PATCH] ceph: drop negtive child dentries before try pruning inode's alias
Date: Thu, 30 Nov 2017 09:37:41 -0500 [thread overview]
Message-ID: <1512052661.4132.4.camel@redhat.com> (raw)
In-Reply-To: <20171130141259.8577-1-zyan@redhat.com>
On Thu, 2017-11-30 at 22:12 +0800, Yan, Zheng wrote:
> negtive child dentry holds reference on inode's alias, it makes
> d_prune_aliases() do nothing.
>
> Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
> ---
> fs/ceph/mds_client.c | 43 ++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 36 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index da181acd4a61..9e7bb5fa9295 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -1440,6 +1440,30 @@ static int __close_session(struct ceph_mds_client *mdsc,
> return request_close_session(mdsc, session);
> }
>
> +static bool drop_negative_children(struct dentry *dentry)
> +{
> + struct dentry *child;
> + bool all_negtive = true;
> +
> + if (!d_is_dir(dentry))
> + goto out;
> +
> + spin_lock(&dentry->d_lock);
> + list_for_each_entry(child, &dentry->d_subdirs, d_child) {
> + if (d_really_is_positive(child)) {
> + all_negtive = false;
> + break;
> + }
> + }
> + spin_unlock(&dentry->d_lock);
> +
> + if (all_negtive)
> + shrink_dcache_parent(dentry);
> +out:
> + dput(dentry);
> + return all_negtive;
> +}
> +
> /*
> * Trim old(er) caps.
> *
> @@ -1495,15 +1519,20 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
> __ceph_remove_cap(cap, true);
> session->s_trim_caps--;
> } else {
> - int refs;
> + struct dentry *dentry;
> /* try dropping referring dentries */
> spin_unlock(&ci->i_ceph_lock);
> - d_prune_aliases(inode);
> - refs = atomic_read(&inode->i_count);
> - if (refs == 1)
> - session->s_trim_caps--;
> - dout("trim_caps_cb %p cap %p pruned, count now %d\n",
> - inode, cap, refs);
> + dentry = d_find_any_alias(inode);
> + /* drop_negative_children() calls dput() */
> + if (dentry && drop_negative_children(dentry)) {
> + int refs;
> + d_prune_aliases(inode);
> + refs = atomic_read(&inode->i_count);
> + if (refs == 1)
> + session->s_trim_caps--;
> + dout("trim_caps_cb %p cap %p pruned, count now %d\n",
> + inode, cap, refs);
> + }
> return 0;
> }
>
Would it be better to do this at the VFS layer? Dropping negative
children when we're going to prune dentries for an inode seems like it
ought to be done as a matter of course in d_prune_aliases.
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2017-11-30 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 14:12 [PATCH] ceph: drop negtive child dentries before try pruning inode's alias Yan, Zheng
2017-11-30 14:37 ` Jeff Layton [this message]
2017-12-01 1:07 ` Yan, Zheng
2017-12-04 15:25 ` Jeff Layton
2017-12-07 13:21 ` Ilya Dryomov
2017-12-07 20:42 ` Jeff Layton
2017-12-08 7:32 ` Yan, Zheng
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=1512052661.4132.4.camel@redhat.com \
--to=jlayton@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=zyan@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 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.