From: Matthew Wilcox <willy@infradead.org>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Amir Goldstein <amir73il@gmail.com>, Jan Kara <jack@suse.cz>,
Ian Kent <raven@themaw.net>
Subject: Re: bad things when too many negative dentries in a directory
Date: Mon, 14 Apr 2025 15:30:37 +0100 [thread overview]
Message-ID: <Z_0cDYDi4unWYveL@casper.infradead.org> (raw)
In-Reply-To: <2334928cfdb750fd71f04c884eeb9ae29a382500.camel@HansenPartnership.com>
On Mon, Apr 14, 2025 at 10:07:09AM -0400, James Bottomley wrote:
> On Fri, 2025-04-11 at 17:01 +0100, Matthew Wilcox wrote:
> > On Fri, Apr 11, 2025 at 05:40:08PM +0200, Miklos Szeredi wrote:
> > > However, hundreds of millions of negative dentries can be created
> > > rather efficiently without unlink, though this one probably doesn't
> > > happen under normal circumstances.
> >
> > Depends on your userspace. Since we don't have union directories,
> > consider the not uncommon case of having a search path A:B:C.
> > Application looks for D in directory A, doesn't find it, creates a
> > negative dentry. Application looks for D in directory B, creates a
> > negative dentry. Application looks for D in directory C, doesn't find
> > it, so it creates it. Now we have two negative dentries and one
> > positive dentry.
>
> If an application does an A:B:C directory search pattern it's usually
> because it doesn't directly own the file location and hence suggests
> that other applications would also be looking for it, which would seem
> to indicate, if the search pattern gets repeated, that the two negative
> dentries do serve a purpose.
Not in this case. It's doing something like looking in /etc/app.d
/usr/share/app/defaults/ and then /var/run/app/ . Don't quote me on the
exact paths, or suggest alternatives based on these names; it's been a
few years since I last looked. But I can assure you no other app is
looking at these dentries; they're looked up exactly once.
> > And for some applications, the name "D" is going to be unique, so the
> > negative dentries have _no_ further use. The application isn't even
> > going to open C/D again. If there's no memory pressure, we can build
> > up billions of dentries. I believe the customer is currently echoing
> > 2 to /proc/sys/vm/drop-caches every hour.
>
> So this is an application that's the sole owner of D (i.e. sole
> controller of the entire path) yet it still does a search for it, why
> is that (if it's something like to update the location, it would be
> better served by first looking in the default location before searching
> others)? The problem is the pattern exactly matches the shared file
> one above so there doesn't seem to be a heuristic way to distinguish
> them.
Everything works fine when there's memory pressure. The problem is that
negative dentry growth is only constrained by available memory; there's
no reclaim of negative dentries which haven't been looked at in seconds
or minutes.
next prev parent reply other threads:[~2025-04-14 14:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 9:40 bad things when too many negative dentries in a directory Miklos Szeredi
2025-04-11 14:47 ` Christian Brauner
2025-04-11 15:40 ` Miklos Szeredi
2025-04-11 16:01 ` Matthew Wilcox
2025-04-14 14:07 ` James Bottomley
2025-04-14 14:30 ` Matthew Wilcox [this message]
2025-04-14 15:40 ` James Bottomley
2025-04-14 16:14 ` Matthew Wilcox
2025-04-14 17:58 ` James Bottomley
2025-04-15 17:22 ` Andreas Dilger
2025-04-16 15:18 ` Miklos Szeredi
2025-04-16 15:37 ` Matthew Wilcox
2025-04-16 21:41 ` Dave Chinner
2025-04-16 15:26 ` James Bottomley
2025-04-22 6:57 ` Andreas Dilger
2025-04-14 6:28 ` Ian Kent
2025-04-14 7:17 ` Miklos Szeredi
2025-04-12 1:48 ` Ian Kent
2025-04-12 1:56 ` Ian Kent
2025-04-12 6:31 ` Ian Kent
2025-04-11 21:02 ` Mateusz Guzik
2025-04-20 4:49 ` Al Viro
2025-05-08 15:45 ` Miklos Szeredi
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=Z_0cDYDi4unWYveL@casper.infradead.org \
--to=willy@infradead.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=raven@themaw.net \
--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