Re: How to detect inode leaks?
From: Steven Rostedt
Date: Thu Nov 05 2026 - 11:46:14 EST
On Thu, 5 Nov 2026 16:58:28 +0100
Christian Brauner <brauner@xxxxxxxxxx> wrote:
> On Fri, Oct 30, 2026 at 04:12:20PM -0400, Steven Rostedt wrote:
> > This got me thinking. If for some reason any use case of alloc_inode() did
> > not free it, kmemleak will not catch it. I'm guessing because the inode is
> > referenced by something somewhere (where it requires the drop_caches or
> > memory pressure to free it).
> >
> > My question is, is there any mechanism that can catch leaked inodes?
>
> Yeah, but it won't fire for your case. generic_shutdown_super() calls
> evict_inodes() and then complains about inodes that are still on
> sb->s_inodes:
>
> if (CHECK_DATA_CORRUPTION(!list_empty(&sb->s_inodes), NULL,
> "VFS: Busy inodes after unmount of %s (%s)",
> sb->s_id, sb->s_type->name)) {
>
> That's all. That whole block sits under if (sb->s_root).
>
> Your fill_super() fails before that's set. So the superblock gets zapped
> without ever looking at sb->s_inodes.
Thanks for the update. So leaked inodes are caught as long as the
fill_super isn't buggy ;-)
-- Steve