|
27 | 27 | /*
|
28 | 28 | * eventfs_mutex protects the eventfs_inode (ei) dentry. Any access
|
29 | 29 | * to the ei->dentry must be done under this mutex and after checking
|
30 |
| - * if ei->is_freed is not set. The ei->dentry is released under the |
31 |
| - * mutex at the same time ei->is_freed is set. If ei->is_freed is set |
32 |
| - * then the ei->dentry is invalid. |
| 30 | + * if ei->is_freed is not set. When ei->is_freed is set, the dentry |
| 31 | + * is on its way to being freed after the last dput() is made on it. |
33 | 32 | */
|
34 | 33 | static DEFINE_MUTEX(eventfs_mutex);
|
35 | 34 |
|
36 | 35 | /*
|
37 | 36 | * The eventfs_inode (ei) itself is protected by SRCU. It is released from
|
38 | 37 | * its parent's list and will have is_freed set (under eventfs_mutex).
|
39 |
| - * After the SRCU grace period is over, the ei may be freed. |
| 38 | + * After the SRCU grace period is over and the last dput() is called |
| 39 | + * the ei is freed. |
40 | 40 | */
|
41 | 41 | DEFINE_STATIC_SRCU(eventfs_srcu);
|
42 | 42 |
|
@@ -365,12 +365,14 @@ create_file_dentry(struct eventfs_inode *ei, int idx,
|
365 | 365 | * created the dentry for this e_dentry. In which case
|
366 | 366 | * use that one.
|
367 | 367 | *
|
368 |
| - * Note, with the mutex held, the e_dentry cannot have content |
369 |
| - * and the ei->is_freed be true at the same time. |
| 368 | + * If ei->is_freed is set, the e_dentry is currently on its |
| 369 | + * way to being freed, don't return it. If e_dentry is NULL |
| 370 | + * it means it was already freed. |
370 | 371 | */
|
371 |
| - dentry = *e_dentry; |
372 |
| - if (WARN_ON_ONCE(dentry && ei->is_freed)) |
| 372 | + if (ei->is_freed) |
373 | 373 | dentry = NULL;
|
| 374 | + else |
| 375 | + dentry = *e_dentry; |
374 | 376 | /* The lookup does not need to up the dentry refcount */
|
375 | 377 | if (dentry && !lookup)
|
376 | 378 | dget(dentry);
|
@@ -473,8 +475,8 @@ create_dir_dentry(struct eventfs_inode *pei, struct eventfs_inode *ei,
|
473 | 475 | * created the dentry for this e_dentry. In which case
|
474 | 476 | * use that one.
|
475 | 477 | *
|
476 |
| - * Note, with the mutex held, the e_dentry cannot have content |
477 |
| - * and the ei->is_freed be true at the same time. |
| 478 | + * If ei->is_freed is set, the e_dentry is currently on its |
| 479 | + * way to being freed. |
478 | 480 | */
|
479 | 481 | dentry = ei->dentry;
|
480 | 482 | if (dentry && !lookup)
|
|
0 commit comments