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 <[email protected]>
---
 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


Reply via email to