linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Jonathan Corbet <corbet@lwn.net>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-doc@vger.kernel.org,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries
Date: Thu, 20 Jul 2017 10:21:35 -0400	[thread overview]
Message-ID: <b3e7ef2a-7c8a-41ee-a197-bbb09690c0a5@redhat.com> (raw)
In-Reply-To: <CAOssrKc5MG1JNy0ffQ5y3=HKLpJTcBiqANx7KSfpZU3itfQ3mw@mail.gmail.com>

On 07/20/2017 03:20 AM, Miklos Szeredi wrote:
> On Wed, Jul 19, 2017 at 10:42 PM, Waiman Long <longman@redhat.com> wrote:
>>
>>>> @@ -603,7 +698,13 @@ static struct dentry *dentry_kill(struct dentry *dentry)
>>>>
>>>>         if (!IS_ROOT(dentry)) {
>>>>                 parent = dentry->d_parent;
>>>> -               if (unlikely(!spin_trylock(&parent->d_lock))) {
>>>> +               /*
>>>> +                * Force the killing of this negative dentry when
>>>> +                * DCACHE_KILL_NEGATIVE flag is set.
>>>> +                */
>>>> +               if (unlikely(dentry->d_flags & DCACHE_KILL_NEGATIVE)) {
>>>> +                       spin_lock(&parent->d_lock);
>>> This looks like d_lock ordering problem (should be parent first, child
>>> second).  Why is this needed, anyway?
>>>
>> Yes, that is a bug. I should have used lock_parent() instead.
> lock_parent() can release dentry->d_lock, which means it's perfectly
> useless for this.

As the reference count is kept at 1 in dentry_kill(), the dentry won't
go away even if the dentry lock is temporarily released.

> I still feel forcing  free is wrong here.  Why not just block until
> the number of negatives goes below the limit (start reclaim if not
> already doing so, etc...)?

Force freeing is the simplest. Any other ways will require adding more
code and increasing code complexity.

One reason why I prefer this is to avoid adding unpredictable latency to
the regular directory lookup and other dentry related operations. We can
always change the code later on if there is a better way of doing it.

Cheers,
Longman

  reply	other threads:[~2017-07-20 14:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 13:39 [PATCH 0/4] fs/dcache: Limit # of negative dentries Waiman Long
2017-07-17 13:39 ` [PATCH 1/4] fs/dcache: Limit numbers " Waiman Long
2017-07-17 17:49   ` Matthew Wilcox
2017-07-17 18:31     ` Waiman Long
2017-07-19 14:39   ` Miklos Szeredi
2017-07-19 15:02     ` Waiman Long
2017-07-19 20:24   ` Miklos Szeredi
2017-07-19 20:42     ` Waiman Long
2017-07-20  7:20       ` Miklos Szeredi
2017-07-20 14:21         ` Waiman Long [this message]
2017-07-20 15:08           ` Miklos Szeredi
2017-07-20 15:46             ` Waiman Long
2017-07-17 13:39 ` [PATCH 2/4] fs/dcache: Report negative dentry number in dentry-state Waiman Long
2017-07-17 14:09   ` Matthew Wilcox
2017-07-17 14:39     ` Waiman Long
2017-07-17 13:39 ` [PATCH 3/4] fs/dcache: Enable automatic pruning of negative dentries Waiman Long
2017-07-17 13:39 ` [PATCH 4/4] fs/dcache: Protect negative dentry pruning from racing with umount Waiman Long

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=b3e7ef2a-7c8a-41ee-a197-bbb09690c0a5@redhat.com \
    --to=longman@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).