mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: Do not mntput() the root device parent
@ 2026-04-15 13:08 Sascha Hauer
  2026-04-15 13:21 ` Ahmad Fatoum
  2026-04-17  8:03 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-04-15 13:08 UTC (permalink / raw)
  To: Barebox List

The vfs rootfs ("/") parent points to itself, so do not call mntput() on
the parent when it's the root device as the reference counter would
become negative.

This doesn't happen in normal configurations as we normally have a ramfs
mounted at / and we leave fs_remove() early in that case. Some xload
configurations have a FAT from SD/eMMC mounted at / though which leads
to a "refcount for mount \"%s\" becomes negative\n" warning.

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

diff --git a/fs/fs.c b/fs/fs.c
index f1f69a501f..a562fe0fc6 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -874,7 +874,8 @@ static void fs_remove(struct device *dev)
 	list_for_each_entry_safe(inode, tmp, &sb->s_inodes, i_sb_list)
 		destroy_inode(inode);
 
-	mntput(fsdev->vfsmount.parent);
+	if (&fsdev->vfsmount != fsdev->vfsmount.parent)
+		mntput(fsdev->vfsmount.parent);
 
 	free(fsdev->backingstore);
 }
-- 
2.47.3




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: Do not mntput() the root device parent
  2026-04-15 13:08 [PATCH] fs: Do not mntput() the root device parent Sascha Hauer
@ 2026-04-15 13:21 ` Ahmad Fatoum
  2026-04-17  8:03 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-04-15 13:21 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List



On 4/15/26 3:08 PM, Sascha Hauer wrote:
> The vfs rootfs ("/") parent points to itself, so do not call mntput() on
> the parent when it's the root device as the reference counter would
> become negative.
> 
> This doesn't happen in normal configurations as we normally have a ramfs
> mounted at / and we leave fs_remove() early in that case. Some xload
> configurations have a FAT from SD/eMMC mounted at / though which leads
> to a "refcount for mount \"%s\" becomes negative\n" warning.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  fs/fs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index f1f69a501f..a562fe0fc6 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -874,7 +874,8 @@ static void fs_remove(struct device *dev)
>  	list_for_each_entry_safe(inode, tmp, &sb->s_inodes, i_sb_list)
>  		destroy_inode(inode);
>  
> -	mntput(fsdev->vfsmount.parent);
> +	if (&fsdev->vfsmount != fsdev->vfsmount.parent)

Nitpick: having the rvalue at the left-hand side is a bit unusual for
barebox, e.g. if (1 == x)..

> +		mntput(fsdev->vfsmount.parent);
>  
>  	free(fsdev->backingstore);
>  }

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: Do not mntput() the root device parent
  2026-04-15 13:08 [PATCH] fs: Do not mntput() the root device parent Sascha Hauer
  2026-04-15 13:21 ` Ahmad Fatoum
@ 2026-04-17  8:03 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-04-17  8:03 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Wed, 15 Apr 2026 15:08:54 +0200, Sascha Hauer wrote:
> The vfs rootfs ("/") parent points to itself, so do not call mntput() on
> the parent when it's the root device as the reference counter would
> become negative.
> 
> This doesn't happen in normal configurations as we normally have a ramfs
> mounted at / and we leave fs_remove() early in that case. Some xload
> configurations have a FAT from SD/eMMC mounted at / though which leads
> to a "refcount for mount \"%s\" becomes negative\n" warning.
> 
> [...]

Applied, thanks!

[1/1] fs: Do not mntput() the root device parent
      https://git.pengutronix.de/cgit/barebox/commit/?id=e0bf33757b78 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-17  8:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-15 13:08 [PATCH] fs: Do not mntput() the root device parent Sascha Hauer
2026-04-15 13:21 ` Ahmad Fatoum
2026-04-17  8:03 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox