1 // SPDX-License-Identifier: GPL-2.0-only
3 * event_inode.c - part of tracefs, a pseudo file system for activating tracing
9 * eventfs is used to dynamically create inodes and dentries based on the
10 * meta data provided by the tracing system.
12 * eventfs stores the meta-data of files/dirs and holds off on creating
13 * inodes/dentries of the files. When accessed, the eventfs will create the
14 * inodes/dentries in a just-in-time (JIT) manner. The eventfs will clean up
15 * and delete the inodes/dentries when they are no longer referenced.
17 #include <linux/fsnotify.h>
19 #include <linux/namei.h>
20 #include <linux/workqueue.h>
21 #include <linux/security.h>
22 #include <linux/tracefs.h>
23 #include <linux/kref.h>
24 #include <linux/delay.h>
28 * eventfs_mutex protects the eventfs_inode (ei) dentry. Any access
29 * to the ei->dentry must be done under this mutex and after checking
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 static DEFINE_MUTEX(eventfs_mutex);
35 /* Choose something "unique" ;-) */
36 #define EVENTFS_FILE_INODE_INO 0x12c4e37
38 struct eventfs_root_inode {
39 struct eventfs_inode ei;
40 struct dentry *events_dir;
43 static struct eventfs_root_inode *get_root_inode(struct eventfs_inode *ei)
45 WARN_ON_ONCE(!ei->is_events);
46 return container_of(ei, struct eventfs_root_inode, ei);
49 /* Just try to make something consistent and unique */
50 static int eventfs_dir_ino(struct eventfs_inode *ei)
53 ei->ino = get_next_ino();
59 * The eventfs_inode (ei) itself is protected by SRCU. It is released from
60 * its parent's list and will have is_freed set (under eventfs_mutex).
61 * After the SRCU grace period is over and the last dput() is called
64 DEFINE_STATIC_SRCU(eventfs_srcu);
66 /* Mode is unsigned short, use the upper bits for flags */
68 EVENTFS_SAVE_MODE = BIT(16),
69 EVENTFS_SAVE_UID = BIT(17),
70 EVENTFS_SAVE_GID = BIT(18),
71 EVENTFS_TOPLEVEL = BIT(19),
74 #define EVENTFS_MODE_MASK (EVENTFS_SAVE_MODE - 1)
76 static void free_ei_rcu(struct rcu_head *rcu)
78 struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu);
79 struct eventfs_root_inode *rei;
81 kfree(ei->entry_attrs);
82 kfree_const(ei->name);
84 rei = get_root_inode(ei);
92 * eventfs_inode reference count management.
94 * NOTE! We count only references from dentries, in the
95 * form 'dentry->d_fsdata'. There are also references from
96 * directory inodes ('ti->private'), but the dentry reference
97 * count is always a superset of the inode reference count.
99 static void release_ei(struct kref *ref)
101 struct eventfs_inode *ei = container_of(ref, struct eventfs_inode, kref);
102 const struct eventfs_entry *entry;
104 WARN_ON_ONCE(!ei->is_freed);
106 for (int i = 0; i < ei->nr_entries; i++) {
107 entry = &ei->entries[i];
109 entry->release(entry->name, ei->data);
112 call_rcu(&ei->rcu, free_ei_rcu);
115 static inline void put_ei(struct eventfs_inode *ei)
118 kref_put(&ei->kref, release_ei);
121 static inline void free_ei(struct eventfs_inode *ei)
130 * Called when creation of an ei fails, do not call release() functions.
132 static inline void cleanup_ei(struct eventfs_inode *ei)
135 /* Set nr_entries to 0 to prevent release() function being called */
141 static inline struct eventfs_inode *get_ei(struct eventfs_inode *ei)
148 static struct dentry *eventfs_root_lookup(struct inode *dir,
149 struct dentry *dentry,
151 static int eventfs_iterate(struct file *file, struct dir_context *ctx);
153 static void update_attr(struct eventfs_attr *attr, struct iattr *iattr)
155 unsigned int ia_valid = iattr->ia_valid;
157 if (ia_valid & ATTR_MODE) {
158 attr->mode = (attr->mode & ~EVENTFS_MODE_MASK) |
159 (iattr->ia_mode & EVENTFS_MODE_MASK) |
162 if (ia_valid & ATTR_UID) {
163 attr->mode |= EVENTFS_SAVE_UID;
164 attr->uid = iattr->ia_uid;
166 if (ia_valid & ATTR_GID) {
167 attr->mode |= EVENTFS_SAVE_GID;
168 attr->gid = iattr->ia_gid;
172 static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
175 const struct eventfs_entry *entry;
176 struct eventfs_inode *ei;
180 mutex_lock(&eventfs_mutex);
181 ei = dentry->d_fsdata;
183 /* Do not allow changes if the event is about to be removed. */
184 mutex_unlock(&eventfs_mutex);
188 /* Preallocate the children mode array if necessary */
189 if (!(dentry->d_inode->i_mode & S_IFDIR)) {
190 if (!ei->entry_attrs) {
191 ei->entry_attrs = kcalloc(ei->nr_entries, sizeof(*ei->entry_attrs),
193 if (!ei->entry_attrs) {
200 ret = simple_setattr(idmap, dentry, iattr);
205 * If this is a dir, then update the ei cache, only the file
206 * mode is saved in the ei->m_children, and the ownership is
207 * determined by the parent directory.
209 if (dentry->d_inode->i_mode & S_IFDIR) {
211 * The events directory dentry is never freed, unless its
212 * part of an instance that is deleted. It's attr is the
213 * default for its child files and directories.
214 * Do not update it. It's not used for its own mode or ownership.
217 /* But it still needs to know if it was modified */
218 if (iattr->ia_valid & ATTR_UID)
219 ei->attr.mode |= EVENTFS_SAVE_UID;
220 if (iattr->ia_valid & ATTR_GID)
221 ei->attr.mode |= EVENTFS_SAVE_GID;
223 update_attr(&ei->attr, iattr);
227 name = dentry->d_name.name;
229 for (int i = 0; i < ei->nr_entries; i++) {
230 entry = &ei->entries[i];
231 if (strcmp(name, entry->name) == 0) {
232 update_attr(&ei->entry_attrs[i], iattr);
238 mutex_unlock(&eventfs_mutex);
242 static void update_top_events_attr(struct eventfs_inode *ei, struct super_block *sb)
246 /* Only update if the "events" was on the top level */
247 if (!ei || !(ei->attr.mode & EVENTFS_TOPLEVEL))
250 /* Get the tracefs root inode. */
251 root = d_inode(sb->s_root);
252 ei->attr.uid = root->i_uid;
253 ei->attr.gid = root->i_gid;
256 static void set_top_events_ownership(struct inode *inode)
258 struct tracefs_inode *ti = get_tracefs(inode);
259 struct eventfs_inode *ei = ti->private;
261 /* The top events directory doesn't get automatically updated */
262 if (!ei || !ei->is_events || !(ei->attr.mode & EVENTFS_TOPLEVEL))
265 update_top_events_attr(ei, inode->i_sb);
267 if (!(ei->attr.mode & EVENTFS_SAVE_UID))
268 inode->i_uid = ei->attr.uid;
270 if (!(ei->attr.mode & EVENTFS_SAVE_GID))
271 inode->i_gid = ei->attr.gid;
274 static int eventfs_get_attr(struct mnt_idmap *idmap,
275 const struct path *path, struct kstat *stat,
276 u32 request_mask, unsigned int flags)
278 struct dentry *dentry = path->dentry;
279 struct inode *inode = d_backing_inode(dentry);
281 set_top_events_ownership(inode);
283 generic_fillattr(idmap, request_mask, inode, stat);
287 static int eventfs_permission(struct mnt_idmap *idmap,
288 struct inode *inode, int mask)
290 set_top_events_ownership(inode);
291 return generic_permission(idmap, inode, mask);
294 static const struct inode_operations eventfs_root_dir_inode_operations = {
295 .lookup = eventfs_root_lookup,
296 .setattr = eventfs_set_attr,
297 .getattr = eventfs_get_attr,
298 .permission = eventfs_permission,
301 static const struct inode_operations eventfs_file_inode_operations = {
302 .setattr = eventfs_set_attr,
305 static const struct file_operations eventfs_file_operations = {
306 .read = generic_read_dir,
307 .iterate_shared = eventfs_iterate,
308 .llseek = generic_file_llseek,
311 /* Return the evenfs_inode of the "events" directory */
312 static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
314 struct eventfs_inode *ei;
317 // The parent is stable because we do not do renames
318 dentry = dentry->d_parent;
319 // ... and directories always have d_fsdata
320 ei = dentry->d_fsdata;
323 * If the ei is being freed, the ownership of the children
330 // Walk upwards until you find the events inode
331 } while (!ei->is_events);
333 update_top_events_attr(ei, dentry->d_sb);
338 static void update_inode_attr(struct dentry *dentry, struct inode *inode,
339 struct eventfs_attr *attr, umode_t mode)
341 struct eventfs_inode *events_ei = eventfs_find_events(dentry);
346 inode->i_mode = mode;
347 inode->i_uid = events_ei->attr.uid;
348 inode->i_gid = events_ei->attr.gid;
353 if (attr->mode & EVENTFS_SAVE_MODE)
354 inode->i_mode = attr->mode & EVENTFS_MODE_MASK;
356 if (attr->mode & EVENTFS_SAVE_UID)
357 inode->i_uid = attr->uid;
359 if (attr->mode & EVENTFS_SAVE_GID)
360 inode->i_gid = attr->gid;
364 * lookup_file - look up a file in the tracefs filesystem
365 * @parent_ei: Pointer to the eventfs_inode that represents parent of the file
366 * @dentry: the dentry to look up
367 * @mode: the permission that the file should have.
368 * @attr: saved attributes changed by user
369 * @data: something that the caller will want to get to later on.
370 * @fop: struct file_operations that should be used for this file.
372 * This function creates a dentry that represents a file in the eventsfs_inode
373 * directory. The inode.i_private pointer will point to @data in the open()
376 static struct dentry *lookup_file(struct eventfs_inode *parent_ei,
377 struct dentry *dentry,
379 struct eventfs_attr *attr,
381 const struct file_operations *fop)
383 struct tracefs_inode *ti;
386 if (!(mode & S_IFMT))
389 if (WARN_ON_ONCE(!S_ISREG(mode)))
390 return ERR_PTR(-EIO);
392 inode = tracefs_get_inode(dentry->d_sb);
393 if (unlikely(!inode))
394 return ERR_PTR(-ENOMEM);
396 /* If the user updated the directory's attributes, use them */
397 update_inode_attr(dentry, inode, attr, mode);
399 inode->i_op = &eventfs_file_inode_operations;
401 inode->i_private = data;
403 /* All files will have the same inode number */
404 inode->i_ino = EVENTFS_FILE_INODE_INO;
406 ti = get_tracefs(inode);
407 ti->flags |= TRACEFS_EVENT_INODE;
409 // Files have their parent's ei as their fsdata
410 dentry->d_fsdata = get_ei(parent_ei);
412 d_add(dentry, inode);
417 * lookup_dir_entry - look up a dir in the tracefs filesystem
418 * @dentry: the directory to look up
419 * @pei: Pointer to the parent eventfs_inode if available
420 * @ei: the eventfs_inode that represents the directory to create
422 * This function will look up a dentry for a directory represented by
425 static struct dentry *lookup_dir_entry(struct dentry *dentry,
426 struct eventfs_inode *pei, struct eventfs_inode *ei)
428 struct tracefs_inode *ti;
431 inode = tracefs_get_inode(dentry->d_sb);
432 if (unlikely(!inode))
433 return ERR_PTR(-ENOMEM);
435 /* If the user updated the directory's attributes, use them */
436 update_inode_attr(dentry, inode, &ei->attr,
437 S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO);
439 inode->i_op = &eventfs_root_dir_inode_operations;
440 inode->i_fop = &eventfs_file_operations;
442 /* All directories will have the same inode number */
443 inode->i_ino = eventfs_dir_ino(ei);
445 ti = get_tracefs(inode);
446 ti->flags |= TRACEFS_EVENT_INODE;
447 /* Only directories have ti->private set to an ei, not files */
450 dentry->d_fsdata = get_ei(ei);
452 d_add(dentry, inode);
456 static inline struct eventfs_inode *init_ei(struct eventfs_inode *ei, const char *name)
458 ei->name = kstrdup_const(name, GFP_KERNEL);
461 kref_init(&ei->kref);
465 static inline struct eventfs_inode *alloc_ei(const char *name)
467 struct eventfs_inode *ei = kzalloc(sizeof(*ei), GFP_KERNEL);
468 struct eventfs_inode *result;
473 result = init_ei(ei, name);
480 static inline struct eventfs_inode *alloc_root_ei(const char *name)
482 struct eventfs_root_inode *rei = kzalloc(sizeof(*rei), GFP_KERNEL);
483 struct eventfs_inode *ei;
488 rei->ei.is_events = 1;
489 ei = init_ei(&rei->ei, name);
497 * eventfs_d_release - dentry is going away
498 * @dentry: dentry which has the reference to remove.
500 * Remove the association between a dentry from an eventfs_inode.
502 void eventfs_d_release(struct dentry *dentry)
504 put_ei(dentry->d_fsdata);
508 * lookup_file_dentry - create a dentry for a file of an eventfs_inode
509 * @dentry: The parent dentry under which the new file's dentry will be created
510 * @ei: the eventfs_inode that the file will be created under
511 * @idx: the index into the entry_attrs[] of the @ei
512 * @mode: The mode of the file.
513 * @data: The data to use to set the inode of the file with on open()
514 * @fops: The fops of the file to be created.
516 * This function creates a dentry for a file associated with an
517 * eventfs_inode @ei. It uses the entry attributes specified by @idx,
518 * if available. The file will have the specified @mode and its inode will be
519 * set up with @data upon open. The file operations will be set to @fops.
521 * Return: Returns a pointer to the newly created file's dentry or an error
524 static struct dentry *
525 lookup_file_dentry(struct dentry *dentry,
526 struct eventfs_inode *ei, int idx,
527 umode_t mode, void *data,
528 const struct file_operations *fops)
530 struct eventfs_attr *attr = NULL;
533 attr = &ei->entry_attrs[idx];
535 return lookup_file(ei, dentry, mode, attr, data, fops);
539 * eventfs_root_lookup - lookup routine to create file/dir
540 * @dir: in which a lookup is being done
541 * @dentry: file/dir dentry
542 * @flags: Just passed to simple_lookup()
544 * Used to create dynamic file/dir with-in @dir, search with-in @ei
545 * list, if @dentry found go ahead and create the file/dir
548 static struct dentry *eventfs_root_lookup(struct inode *dir,
549 struct dentry *dentry,
552 struct eventfs_inode *ei_child;
553 struct tracefs_inode *ti;
554 struct eventfs_inode *ei;
555 const char *name = dentry->d_name.name;
556 struct dentry *result = NULL;
558 ti = get_tracefs(dir);
559 if (WARN_ON_ONCE(!(ti->flags & TRACEFS_EVENT_INODE)))
560 return ERR_PTR(-EIO);
562 mutex_lock(&eventfs_mutex);
565 if (!ei || ei->is_freed)
568 list_for_each_entry(ei_child, &ei->children, list) {
569 if (strcmp(ei_child->name, name) != 0)
571 /* A child is freed and removed from the list at the same time */
572 if (WARN_ON_ONCE(ei_child->is_freed))
574 result = lookup_dir_entry(dentry, ei, ei_child);
578 for (int i = 0; i < ei->nr_entries; i++) {
581 const struct file_operations *fops;
582 const struct eventfs_entry *entry = &ei->entries[i];
584 if (strcmp(name, entry->name) != 0)
588 if (entry->callback(name, &mode, &data, &fops) <= 0)
591 result = lookup_file_dentry(dentry, ei, i, mode, data, fops);
595 mutex_unlock(&eventfs_mutex);
600 * Walk the children of a eventfs_inode to fill in getdents().
602 static int eventfs_iterate(struct file *file, struct dir_context *ctx)
604 const struct file_operations *fops;
605 struct inode *f_inode = file_inode(file);
606 const struct eventfs_entry *entry;
607 struct eventfs_inode *ei_child;
608 struct tracefs_inode *ti;
609 struct eventfs_inode *ei;
617 if (!dir_emit_dots(file, ctx))
620 ti = get_tracefs(f_inode);
621 if (!(ti->flags & TRACEFS_EVENT_INODE))
626 idx = srcu_read_lock(&eventfs_srcu);
628 mutex_lock(&eventfs_mutex);
629 ei = READ_ONCE(ti->private);
630 if (ei && ei->is_freed)
632 mutex_unlock(&eventfs_mutex);
638 * Need to create the dentries and inodes to have a consistent
643 /* Start at 'c' to jump over already read entries */
644 for (i = c; i < ei->nr_entries; i++, ctx->pos++) {
645 void *cdata = ei->data;
647 entry = &ei->entries[i];
650 mutex_lock(&eventfs_mutex);
651 /* If ei->is_freed then just bail here, nothing more to do */
653 mutex_unlock(&eventfs_mutex);
656 r = entry->callback(name, &mode, &cdata, &fops);
657 mutex_unlock(&eventfs_mutex);
661 ino = EVENTFS_FILE_INODE_INO;
663 if (!dir_emit(ctx, name, strlen(name), ino, DT_REG))
667 /* Subtract the skipped entries above */
668 c -= min((unsigned int)c, (unsigned int)ei->nr_entries);
670 list_for_each_entry_srcu(ei_child, &ei->children, list,
671 srcu_read_lock_held(&eventfs_srcu)) {
680 if (ei_child->is_freed)
683 name = ei_child->name;
685 ino = eventfs_dir_ino(ei_child);
687 if (!dir_emit(ctx, name, strlen(name), ino, DT_DIR))
692 srcu_read_unlock(&eventfs_srcu, idx);
697 /* Incremented ctx->pos without adding something, reset it */
703 * eventfs_create_dir - Create the eventfs_inode for this directory
704 * @name: The name of the directory to create.
705 * @parent: The eventfs_inode of the parent directory.
706 * @entries: A list of entries that represent the files under this directory
707 * @size: The number of @entries
708 * @data: The default data to pass to the files (an entry may override it).
710 * This function creates the descriptor to represent a directory in the
711 * eventfs. This descriptor is an eventfs_inode, and it is returned to be
712 * used to create other children underneath.
714 * The @entries is an array of eventfs_entry structures which has:
716 * eventfs_callback callback;
718 * The name is the name of the file, and the callback is a pointer to a function
719 * that will be called when the file is reference (either by lookup or by
720 * reading a directory). The callback is of the prototype:
722 * int callback(const char *name, umode_t *mode, void **data,
723 * const struct file_operations **fops);
725 * When a file needs to be created, this callback will be called with
726 * name = the name of the file being created (so that the same callback
727 * may be used for multiple files).
728 * mode = a place to set the file's mode
729 * data = A pointer to @data, and the callback may replace it, which will
730 * cause the file created to pass the new data to the open() call.
731 * fops = the fops to use for the created file.
733 * NB. @callback is called while holding internal locks of the eventfs
734 * system. The callback must not call any code that might also call into
735 * the tracefs or eventfs system or it will risk creating a deadlock.
737 struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode *parent,
738 const struct eventfs_entry *entries,
739 int size, void *data)
741 struct eventfs_inode *ei;
744 return ERR_PTR(-EINVAL);
748 return ERR_PTR(-ENOMEM);
750 ei->entries = entries;
751 ei->nr_entries = size;
753 INIT_LIST_HEAD(&ei->children);
754 INIT_LIST_HEAD(&ei->list);
756 mutex_lock(&eventfs_mutex);
757 if (!parent->is_freed)
758 list_add_tail(&ei->list, &parent->children);
759 mutex_unlock(&eventfs_mutex);
761 /* Was the parent freed? */
762 if (list_empty(&ei->list)) {
770 * eventfs_create_events_dir - create the top level events directory
771 * @name: The name of the top level directory to create.
772 * @parent: Parent dentry for this file in the tracefs directory.
773 * @entries: A list of entries that represent the files under this directory
774 * @size: The number of @entries
775 * @data: The default data to pass to the files (an entry may override it).
777 * This function creates the top of the trace event directory.
779 * See eventfs_create_dir() for use of @entries.
781 struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry *parent,
782 const struct eventfs_entry *entries,
783 int size, void *data)
785 struct dentry *dentry = tracefs_start_creating(name, parent);
786 struct eventfs_root_inode *rei;
787 struct eventfs_inode *ei;
788 struct tracefs_inode *ti;
793 if (security_locked_down(LOCKDOWN_TRACEFS))
797 return ERR_CAST(dentry);
799 ei = alloc_root_ei(name);
803 inode = tracefs_get_inode(dentry->d_sb);
804 if (unlikely(!inode))
807 // Note: we have a ref to the dentry from tracefs_start_creating()
808 rei = get_root_inode(ei);
809 rei->events_dir = dentry;
811 ei->entries = entries;
812 ei->nr_entries = size;
815 /* Save the ownership of this directory */
816 uid = d_inode(dentry->d_parent)->i_uid;
817 gid = d_inode(dentry->d_parent)->i_gid;
820 * If the events directory is of the top instance, then parent
821 * is NULL. Set the attr.mode to reflect this and its permissions will
822 * default to the tracefs root dentry.
825 ei->attr.mode = EVENTFS_TOPLEVEL;
827 /* This is used as the default ownership of the files and directories */
831 INIT_LIST_HEAD(&ei->children);
832 INIT_LIST_HEAD(&ei->list);
834 ti = get_tracefs(inode);
835 ti->flags |= TRACEFS_EVENT_INODE | TRACEFS_EVENT_TOP_INODE;
838 inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
841 inode->i_op = &eventfs_root_dir_inode_operations;
842 inode->i_fop = &eventfs_file_operations;
844 dentry->d_fsdata = get_ei(ei);
847 * Keep all eventfs directories with i_nlink == 1.
848 * Due to the dynamic nature of the dentry creations and not
849 * wanting to add a pointer to the parent eventfs_inode in the
850 * eventfs_inode structure, keeping the i_nlink in sync with the
851 * number of directories would cause too much complexity for
852 * something not worth much. Keeping directory links at 1
853 * tells userspace not to trust the link number.
855 d_instantiate(dentry, inode);
856 /* The dentry of the "events" parent does keep track though */
857 inc_nlink(dentry->d_parent->d_inode);
858 fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
859 tracefs_end_creating(dentry);
865 tracefs_failed_creating(dentry);
866 return ERR_PTR(-ENOMEM);
870 * eventfs_remove_rec - remove eventfs dir or file from list
871 * @ei: eventfs_inode to be removed.
872 * @level: prevent recursion from going more than 3 levels deep.
874 * This function recursively removes eventfs_inodes which
875 * contains info of files and/or directories.
877 static void eventfs_remove_rec(struct eventfs_inode *ei, int level)
879 struct eventfs_inode *ei_child;
882 * Check recursion depth. It should never be greater than 3:
885 * 2 - events/group/event/
886 * 3 - events/group/event/file
888 if (WARN_ON_ONCE(level > 3))
891 /* search for nested folders or files */
892 list_for_each_entry(ei_child, &ei->children, list)
893 eventfs_remove_rec(ei_child, level + 1);
900 * eventfs_remove_dir - remove eventfs dir or file from list
901 * @ei: eventfs_inode to be removed.
903 * This function acquire the eventfs_mutex lock and call eventfs_remove_rec()
905 void eventfs_remove_dir(struct eventfs_inode *ei)
910 mutex_lock(&eventfs_mutex);
911 eventfs_remove_rec(ei, 0);
912 mutex_unlock(&eventfs_mutex);
916 * eventfs_remove_events_dir - remove the top level eventfs directory
917 * @ei: the event_inode returned by eventfs_create_events_dir().
919 * This function removes the events main directory
921 void eventfs_remove_events_dir(struct eventfs_inode *ei)
923 struct eventfs_root_inode *rei;
924 struct dentry *dentry;
926 rei = get_root_inode(ei);
927 dentry = rei->events_dir;
931 rei->events_dir = NULL;
932 eventfs_remove_dir(ei);
935 * Matches the dget() done by tracefs_start_creating()
936 * in eventfs_create_events_dir() when it the dentry was
937 * created. In other words, it's a normal dentry that
938 * sticks around while the other ei->dentry are created
939 * and destroyed dynamically.
941 d_invalidate(dentry);