mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 4/4] fs: free unused dentries
Date: Mon, 14 Sep 2020 15:06:40 +0200	[thread overview]
Message-ID: <20200914130640.21416-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200914130640.21416-1-s.hauer@pengutronix.de>

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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-09-14 13:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 13:06 [PATCH 1/4] fs: don't free device in remove callback Sascha Hauer
2020-09-14 13:06 ` [PATCH 2/4] fs: Drop unnecessary dput() Sascha Hauer
2020-09-14 13:06 ` [PATCH 3/4] fs: Fix use after free Sascha Hauer
2020-09-14 13:06 ` Sascha Hauer [this message]
2020-09-15  5:25   ` [PATCH 4/4] fs: free unused dentries Ahmad Fatoum
2020-09-15  7:12     ` Sascha Hauer
2020-09-15  8:01       ` Ahmad Fatoum
2020-09-15 13:12         ` Sascha Hauer
2020-09-15 13:28           ` Ahmad Fatoum
2020-09-16 10:43             ` Ahmad Fatoum

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=20200914130640.21416-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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