Re: [PATCH] eventfs: Have inodes have unique inode numbers

From: Steven Rostedt
Date: Sat Jan 27 2024 - 09:47:30 EST


On Fri, 26 Jan 2024 14:26:08 -0800
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> nother thing that worries me is that odd locking that releases the
> lock in the middle. I don't understand why you release the
> tracefs_mutex() over create_file(), for example. There's a lot of
> "take, drop, re-take, re-drop" of that mutex that seems strange.

This was because the create_file/dir() would call into the VFS which
would grab locks, and on a final dput() on a ei dentry that is to be
freed, calls back into eventfs_set_ei_status_free() which also grabs
the eventfs_mutex. But it gets called with the same VFS locks that are
taken by create_file/dir() VFS calls. This was caught by lockdep. Hence
the dropping of those locks.

The eventfs_mutex is just protecting the ei list and also assigning and
clearing the ei->dentry. Now that dentry is used to synchronize the last
close, and also to know if the ei was ever referenced. If ei->dentry is
NULL it can be freed immediately (after SRCU) when the directory is
deleted. But if ei->dentry is set, it means that something may still
have a reference to it and must be freed after the last dput() and SRCU.

Now some of this was needed due to the way the dir wrapper worked so I
may be able to revisit this and possibly just use an ei->ref counter.
But I wasted enough time on this and I'm way behind in my other
responsibilities, so this is not something I can work on now.

-- Steve