[PATCH 4/4] fs: free unused dentries

Sascha Hauer s.hauer at pengutronix.de
Mon Sep 14 09:06:40 EDT 2020


So far we only ever freed dentries when the filesystem they are on is
unmounted. With this patch we actually trust reference counting and free
the dentries once the reference count hits zero.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/fs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index 5784e9c1f3..824c4e2806 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1129,6 +1129,9 @@ void dput(struct dentry *dentry)
 		return;
 
 	dentry->d_count--;
+
+	if (!dentry->d_count)
+		dentry_kill(dentry);
 }
 
 struct dentry *dget(struct dentry *dentry)
@@ -2837,7 +2840,6 @@ int mount(const char *device, const char *fsname, const char *pathname,
 		fsdev->vfsmount.mountpoint->d_flags |= DCACHE_MOUNTED;
 	} else {
 		d_root = fsdev->sb.s_root;
-		path.dentry = d_root;
 		mnt_root = &fsdev->vfsmount;
 		fsdev->vfsmount.mountpoint = d_root;
 		fsdev->vfsmount.parent = &fsdev->vfsmount;
-- 
2.28.0




More information about the barebox mailing list