mirror of
https://github.com/torvalds/linux.git
synced 2026-05-21 05:18:45 +02:00
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: 020010fbfa ("eventfs: Delete eventfs_inode when the last dentry is freed")
Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
parent
98b1cc82c4
commit
88903daeca
|
|
@ -27,16 +27,16 @@
|
|||
/*
|
||||
* eventfs_mutex protects the eventfs_inode (ei) dentry. Any access
|
||||
* 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
|
||||
* mutex at the same time ei->is_freed is set. If ei->is_freed is set
|
||||
* then the ei->dentry is invalid.
|
||||
* if ei->is_freed is not set. When ei->is_freed is set, the dentry
|
||||
* is on its way to being freed after the last dput() is made on it.
|
||||
*/
|
||||
static DEFINE_MUTEX(eventfs_mutex);
|
||||
|
||||
/*
|
||||
* 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).
|
||||
* 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);
|
||||
|
||||
|
|
@ -365,12 +365,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx,
|
|||
* created the dentry for this e_dentry. In which case
|
||||
* use that one.
|
||||
*
|
||||
* Note, with the mutex held, the e_dentry cannot have content
|
||||
* and the ei->is_freed be true at the same time.
|
||||
* If ei->is_freed is set, the e_dentry is currently on its
|
||||
* way to being freed, don't return it. If e_dentry is NULL
|
||||
* it means it was already freed.
|
||||
*/
|
||||
dentry = *e_dentry;
|
||||
if (WARN_ON_ONCE(dentry && ei->is_freed))
|
||||
if (ei->is_freed)
|
||||
dentry = NULL;
|
||||
else
|
||||
dentry = *e_dentry;
|
||||
/* The lookup does not need to up the dentry refcount */
|
||||
if (dentry && !lookup)
|
||||
dget(dentry);
|
||||
|
|
@ -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
|
||||
* use that one.
|
||||
*
|
||||
* Note, with the mutex held, the e_dentry cannot have content
|
||||
* and the ei->is_freed be true at the same time.
|
||||
* If ei->is_freed is set, the e_dentry is currently on its
|
||||
* way to being freed.
|
||||
*/
|
||||
dentry = ei->dentry;
|
||||
if (dentry && !lookup)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user