eventfs: Remove expectation that ei->is_freed means ei->dentry == NULL

The logic to free the eventfs_inode (ei) use to set is_freed and clear the
"dentry" field under the eventfs_mutex. But that changed when a race was
found where the ei->dentry needed to be cleared when the last dput() was
called on it. But there was still logic that checked if ei->dentry was not
NULL and is_freed is set, and would warn if it was.

But since that situation was changed and the ei->dentry isn't cleared
until the last dput() is called on it while the ei->is_freed is set, do
not test for that condition anymore, and change the comments to reflect
that.

Link: https://lkml.kernel.org/r/20231120235154.265826243@goodmis.org

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Fixes: 020010fb ("eventfs: Delete eventfs_inode when the last dentry is freed")
Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 98b1cc82
...@@ -27,16 +27,16 @@ ...@@ -27,16 +27,16 @@
/* /*
* eventfs_mutex protects the eventfs_inode (ei) dentry. Any access * eventfs_mutex protects the eventfs_inode (ei) dentry. Any access
* to the ei->dentry must be done under this mutex and after checking * to the ei->dentry must be done under this mutex and after checking
* if ei->is_freed is not set. The ei->dentry is released under the * if ei->is_freed is not set. When ei->is_freed is set, the dentry
* mutex at the same time ei->is_freed is set. If ei->is_freed is set * is on its way to being freed after the last dput() is made on it.
* then the ei->dentry is invalid.
*/ */
static DEFINE_MUTEX(eventfs_mutex); static DEFINE_MUTEX(eventfs_mutex);
/* /*
* The eventfs_inode (ei) itself is protected by SRCU. It is released from * The eventfs_inode (ei) itself is protected by SRCU. It is released from
* its parent's list and will have is_freed set (under eventfs_mutex). * its parent's list and will have is_freed set (under eventfs_mutex).
* After the SRCU grace period is over, the ei may be freed. * After the SRCU grace period is over and the last dput() is called
* the ei is freed.
*/ */
DEFINE_STATIC_SRCU(eventfs_srcu); DEFINE_STATIC_SRCU(eventfs_srcu);
...@@ -365,12 +365,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx, ...@@ -365,12 +365,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx,
* created the dentry for this e_dentry. In which case * created the dentry for this e_dentry. In which case
* use that one. * use that one.
* *
* Note, with the mutex held, the e_dentry cannot have content * If ei->is_freed is set, the e_dentry is currently on its
* and the ei->is_freed be true at the same time. * way to being freed, don't return it. If e_dentry is NULL
* it means it was already freed.
*/ */
dentry = *e_dentry; if (ei->is_freed)
if (WARN_ON_ONCE(dentry && ei->is_freed))
dentry = NULL; dentry = NULL;
else
dentry = *e_dentry;
/* The lookup does not need to up the dentry refcount */ /* The lookup does not need to up the dentry refcount */
if (dentry && !lookup) if (dentry && !lookup)
dget(dentry); dget(dentry);
...@@ -473,8 +475,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei, ...@@ -473,8 +475,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
* created the dentry for this e_dentry. In which case * created the dentry for this e_dentry. In which case
* use that one. * use that one.
* *
* Note, with the mutex held, the e_dentry cannot have content * If ei->is_freed is set, the e_dentry is currently on its
* and the ei->is_freed be true at the same time. * way to being freed.
*/ */
dentry = ei->dentry; dentry = ei->dentry;
if (dentry && !lookup) if (dentry && !lookup)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment