[PATCH] dcache: rename d_genocide()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---

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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux