Skip to content

Commit 71cade8

Browse files
committed
eventfs: Do not invalidate dentry in create_file/dir_dentry()
With the call to simple_recursive_removal() on the entire eventfs sub system when the directory is removed, it performs the d_invalidate on all the dentries when it is removed. There's no need to do clean ups when a dentry is being created while the directory is being deleted. As dentries are cleaned up by the simpler_recursive_removal(), trying to do d_invalidate() in these functions will cause the dentry to be invalidated twice, and crash the kernel. Link: https://lore.kernel.org/all/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Andrew Morton <[email protected]> Fixes: 407c672 ("eventfs: Use simple_recursive_removal() to clean up dentries") Reported-by: Mark Rutland <[email protected]> Reported-by: Naresh Kamboju <[email protected]> Reported-by: Linux Kernel Functional Testing <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 88903da commit 71cade8

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

fs/tracefs/event_inode.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ create_file_dentry(struct eventfs_inode *ei, int idx,
326326
struct eventfs_attr *attr = NULL;
327327
struct dentry **e_dentry = &ei->d_children[idx];
328328
struct dentry *dentry;
329-
bool invalidate = false;
330329

331330
mutex_lock(&eventfs_mutex);
332331
if (ei->is_freed) {
@@ -389,17 +388,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx,
389388
* Otherwise it means two dentries exist with the same name.
390389
*/
391390
WARN_ON_ONCE(!ei->is_freed);
392-
invalidate = true;
391+
dentry = NULL;
393392
}
394393
mutex_unlock(&eventfs_mutex);
395394

396-
if (invalidate)
397-
d_invalidate(dentry);
398-
399-
if (lookup || invalidate)
395+
if (lookup)
400396
dput(dentry);
401397

402-
return invalidate ? NULL : dentry;
398+
return dentry;
403399
}
404400

405401
/**
@@ -439,7 +435,6 @@ static struct dentry *
439435
create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
440436
struct dentry *parent, bool lookup)
441437
{
442-
bool invalidate = false;
443438
struct dentry *dentry = NULL;
444439

445440
mutex_lock(&eventfs_mutex);
@@ -495,16 +490,14 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
495490
* Otherwise it means two dentries exist with the same name.
496491
*/
497492
WARN_ON_ONCE(!ei->is_freed);
498-
invalidate = true;
493+
dentry = NULL;
499494
}
500495
mutex_unlock(&eventfs_mutex);
501-
if (invalidate)
502-
d_invalidate(dentry);
503496

504-
if (lookup || invalidate)
497+
if (lookup)
505498
dput(dentry);
506499

507-
return invalidate ? NULL : dentry;
500+
return dentry;
508501
}
509502

510503
/**

0 commit comments

Comments
 (0)