From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>,
Gautham Ananthakrishna <gautham.ananthakrishna@oracle.com>,
Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] dcache: stop walking siblings if remaining dentries all negative
Date: Mon, 13 Dec 2021 16:53:37 -0800 [thread overview]
Message-ID: <20211214005337.161885-5-stephen.s.brennan@oracle.com> (raw)
In-Reply-To: <20211214005337.161885-1-stephen.s.brennan@oracle.com>
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Most walkers are interested only in positive dentries.
Changes in simple_* libfs helpers are mostly cosmetic: it shouldn't cache
negative dentries unless uses d_delete other than always_delete_dentry().
Co-authored-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Co-authored-by: Gautham Ananthakrishna <gautham.ananthakrishna@oracle.com>
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
fs/dcache.c | 9 +++++++++
fs/libfs.c | 3 +++
2 files changed, 12 insertions(+)
diff --git a/fs/dcache.c b/fs/dcache.c
index 9083436f5dcb..85f33563936b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1505,6 +1505,8 @@ static enum d_walk_ret path_check_mount(void *data, struct dentry *dentry)
struct check_mount *info = data;
struct path path = { .mnt = info->mnt, .dentry = dentry };
+ if (d_is_tail_negative(dentry))
+ return D_WALK_SKIP_SIBLINGS;
if (likely(!d_mountpoint(dentry)))
return D_WALK_CONTINUE;
if (__path_is_mountpoint(&path)) {
@@ -1751,6 +1753,10 @@ void shrink_dcache_for_umount(struct super_block *sb)
static enum d_walk_ret find_submount(void *_data, struct dentry *dentry)
{
struct dentry **victim = _data;
+
+ if (d_is_tail_negative(dentry))
+ return D_WALK_SKIP_SIBLINGS;
+
if (d_mountpoint(dentry)) {
__dget_dlock(dentry);
*victim = dentry;
@@ -3231,6 +3237,9 @@ static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry)
{
struct dentry *root = data;
if (dentry != root) {
+ if (d_is_tail_negative(dentry))
+ return D_WALK_SKIP_SIBLINGS;
+
if (d_unhashed(dentry) || !dentry->d_inode)
return D_WALK_SKIP;
diff --git a/fs/libfs.c b/fs/libfs.c
index ba7438ab9371..13cb44cf158e 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -411,6 +411,9 @@ int simple_empty(struct dentry *dentry)
spin_lock(&dentry->d_lock);
list_for_each_entry(child, &dentry->d_subdirs, d_child) {
+ if (d_is_tail_negative(child))
+ break;
+
spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED);
if (simple_positive(child)) {
spin_unlock(&child->d_lock);
--
2.30.2
prev parent reply other threads:[~2021-12-14 0:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 0:53 [PATCH 0/4] Fix softlockup when adding inotify watch Stephen Brennan
2021-12-14 0:53 ` [PATCH 1/4] dcache: sweep cached negative dentries to the end of list of siblings Stephen Brennan
2021-12-18 8:17 ` [dcache] 5384bd38a8: WARNING:at_fs/nfsd/nfsctl.c:#nfsdfs_remove_files[nfsd] kernel test robot
2021-12-14 0:53 ` [PATCH 2/4] fsnotify: stop walking child dentries if remaining tail is negative Stephen Brennan
2021-12-14 0:53 ` [PATCH 3/4] dcache: add action D_WALK_SKIP_SIBLINGS to d_walk() Stephen Brennan
2021-12-14 0:53 ` Stephen Brennan [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=20211214005337.161885-5-stephen.s.brennan@oracle.com \
--to=stephen.s.brennan@oracle.com \
--cc=gautham.ananthakrishna@oracle.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).