Skip to contentSkip to conversation

Free the temporary vfsmount created in bdev_cache_init()

PATCH In review Catalin Marinas 2 participants 3 messages Apr 1, 2009 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Free the temporary vfsmount created in bdev_cache_init()

The vfsmount structure allocated in this function (the bd_mnt local variable) is only used to obtain the blockdev_superblock and there are no other references to it. This structure can be safely freed (and prevent kmemleak from reporting it).

---

This patch was submitted and acked some time ago but I don't think it made it into the kernel. Here it is again. Thanks.

 fs/block_dev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/block_dev.c +1 -0
index 8c3c689..e7a332f 100644
@@ -492,6 +492,7 @@ void __init bdev_cache_init(void)
 	if (IS_ERR(bd_mnt))
 		panic("Cannot create bdev pseudo-fs");
 	blockdev_superblock = bd_mnt->mnt_sb;	/* For writeback */
+	free_vfsmnt(bd_mnt);
 }
 
 /*
maintainer
#1 lore raw
Quoted 4 lines · Catalin Marinas

The vfsmount structure allocated in this function (the bd_mnt local variable) is only used to obtain the blockdev_superblock and there are no other references to it. This structure can be safely freed (and prevent kmemleak from reporting it).

NAK. This kind of kludges is simply not worth doing. Store the pointer to vfsmount into a static-in-file variable if you want to get kmemleak to STFU.

Savings on a vfsmount are not worth neurons needed to remember that in this particular case we are OK to do something that is utterly wrong in general (free_vfsmnt() is a very low-level stuff that shouldn't be used outside of namespace.c and super.c).

#2 lore raw
Quoted 9 lines · Al Viro
Quoted 4 lines · Catalin Marinas

The vfsmount structure allocated in this function (the bd_mnt local variable) is only used to obtain the blockdev_superblock and there are no other references to it. This structure can be safely freed (and prevent kmemleak from reporting it).

NAK. This kind of kludges is simply not worth doing. Store the pointer to vfsmount into a static-in-file variable if you want to get kmemleak to STFU.

That's how it used to be until commit c2acf7b9 made bd_mnt a local variable. Rather than reverting part of this commit, I can add a kmemleak_ignore() call to shut it up.

Signature · 1 line
Catalin