From: Amir Goldstein <amir73il@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org
Subject: [PATCH] dcache: rename d_genocide()
Date: Sat, 10 Feb 2024 12:06:43 +0200 [thread overview]
Message-ID: <20240210100643.2207350-1-amir73il@gmail.com> (raw)
Political context aside, using analogies from the real world in code
is supposed to help us human programmers understand the code better.
In the case of d_genocide(), not only is it a very dark analogy, but it's
also a bad one, because d_genocide() does not actually kill any dentries.
Rename it to dput_dcache_for_umount() and rename the DCACHE_GENOCIDE
flag to DCACHE_SB_DYING.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
Al,
I am not usually for PC culture and I know that you are on team
"freedom of speech" ;-), but IMO this one stood out for its high ratio
of bad taste vs. usefulness.
The patch is based on your revert of "get rid of DCACHE_GENOCIDE".
I was hoping that you could queue my patch along with the revert.
BTW, why was d_genocide() only dropping refcounts on the s_root tree
and not on the s_roots trees like shrink_dcache_for_umount()?
Is it because dentries on s_roots are not supposed to be hashed?
Thanks,
Amir.
fs/dcache.c | 13 ++++++++-----
fs/internal.h | 2 +-
fs/super.c | 3 +--
include/linux/dcache.h | 2 +-
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 6ebccba33336..61ecc98c49a8 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3054,24 +3054,27 @@ bool is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
}
EXPORT_SYMBOL(is_subdir);
-static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry)
+/* make umount_check() happy before killing sb */
+static enum d_walk_ret dput_for_umount(void *data, struct dentry *dentry)
{
struct dentry *root = data;
if (dentry != root) {
if (d_unhashed(dentry) || !dentry->d_inode)
return D_WALK_SKIP;
- if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
- dentry->d_flags |= DCACHE_GENOCIDE;
+ if (!(dentry->d_flags & DCACHE_SB_DYING)) {
+ dentry->d_flags |= DCACHE_SB_DYING;
dentry->d_lockref.count--;
}
}
return D_WALK_CONTINUE;
}
-void d_genocide(struct dentry *parent)
+/* drop last references before shrink_dcache_for_umount() */
+void dput_dcache_for_umount(struct super_block *sb)
{
- d_walk(parent, parent, d_genocide_kill);
+ if (sb->s_root)
+ d_walk(sb->s_root, sb->s_root, dput_for_umount);
}
void d_mark_tmpfile(struct file *file, struct inode *inode)
diff --git a/fs/internal.h b/fs/internal.h
index b67406435fc0..27bda8a3ff9d 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -215,10 +215,10 @@ extern char *simple_dname(struct dentry *, char *, int);
extern void dput_to_list(struct dentry *, struct list_head *);
extern void shrink_dentry_list(struct list_head *);
extern void shrink_dcache_for_umount(struct super_block *);
+extern void dput_dcache_for_umount(struct super_block *);
extern struct dentry *__d_lookup(const struct dentry *, const struct qstr *);
extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
const struct qstr *name, unsigned *seq);
-extern void d_genocide(struct dentry *);
/*
* pipe.c
diff --git a/fs/super.c b/fs/super.c
index d35e85295489..42b3189fbe06 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1235,8 +1235,7 @@ EXPORT_SYMBOL(kill_anon_super);
void kill_litter_super(struct super_block *sb)
{
- if (sb->s_root)
- d_genocide(sb->s_root);
+ dput_dcache_for_umount(sb);
kill_anon_super(sb);
}
EXPORT_SYMBOL(kill_litter_super);
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index d07cf2f1bb7d..0ce8543b64d7 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -173,7 +173,7 @@ struct dentry_operations {
#define DCACHE_DONTCACHE BIT(7) /* Purge from memory on final dput() */
#define DCACHE_CANT_MOUNT BIT(8)
-#define DCACHE_GENOCIDE BIT(9)
+#define DCACHE_SB_DYING BIT(9)
#define DCACHE_SHRINK_LIST BIT(10)
#define DCACHE_OP_WEAK_REVALIDATE BIT(11)
--
2.34.1
next reply other threads:[~2024-02-10 10:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-10 10:06 Amir Goldstein [this message]
2024-02-10 23:27 ` [PATCH] dcache: rename d_genocide() Al Viro
2024-02-11 8:00 ` Amir Goldstein
2024-02-11 18:44 ` Al Viro
2024-02-12 7:02 ` Amir Goldstein
2024-02-12 8:09 ` Al Viro
2024-02-13 4:42 ` Al Viro
2024-02-13 6:42 ` Amir Goldstein
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=20240210100643.2207350-1-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@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 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.