mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 2/3] fs: warn when mount reference count becomes negative
Date: Wed, 10 Dec 2025 11:16:00 +0100	[thread overview]
Message-ID: <20251210-devfs-prep-v1-2-3a2a3aa27eab@pengutronix.de> (raw)
In-Reply-To: <20251210-devfs-prep-v1-0-3a2a3aa27eab@pengutronix.de>

Warn when the reference count of a mount would become negative.
With this we warn when it happens. Previously, only unmounting
a mountpoint failed with -EBUSY which was misleading because
mnt->ref was only true because it was negative.

Do not actually allow it to become negative anymore.

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

diff --git a/fs/fs.c b/fs/fs.c
index f7859304a7b5f4158db83298b586c633668301d5..e063dc48d9d53a64932564c4b983d5ca1b026a1a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -260,6 +260,12 @@ static void mntput(struct vfsmount *mnt)
 	if (!mnt)
 		return;
 
+	if (!mnt->ref) {
+		WARN_ONCE(1, "refcount for mount \"%s\" becomes negative\n",
+			  mnt->mountpoint->name);
+		return;
+	}
+
 	mnt->ref--;
 }
 

-- 
2.47.3




  parent reply	other threads:[~2025-12-10 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10 10:15 [PATCH 0/3] selftest: preparations for devfs changes Sascha Hauer
2025-12-10 10:15 ` [PATCH 1/3] fs: get path in path_init() Sascha Hauer
2025-12-10 10:16 ` Sascha Hauer [this message]
2025-12-10 10:16 ` [PATCH 3/3] test: dirfs: use ramfs rather than devfs Sascha Hauer
2025-12-15  9:30 ` [PATCH 0/3] selftest: preparations for devfs changes Sascha Hauer

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=20251210-devfs-prep-v1-2-3a2a3aa27eab@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