Lines Matching refs:ei
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
39 static int eventfs_dir_ino(struct eventfs_inode *ei)
41 if (!ei->ino)
42 ei->ino = get_next_ino();
44 return ei->ino;
48 * The eventfs_inode (ei) itself is protected by SRCU. It is released from
51 * the ei is freed.
75 struct eventfs_inode *ei = container_of(ref, struct eventfs_inode, kref);
77 WARN_ON_ONCE(!ei->is_freed);
79 kfree(ei->entry_attrs);
80 kfree_const(ei->name);
81 kfree_rcu(ei, rcu);
84 static inline void put_ei(struct eventfs_inode *ei)
86 if (ei)
87 kref_put(&ei->kref, release_ei);
90 static inline void free_ei(struct eventfs_inode *ei)
92 if (ei) {
93 ei->is_freed = 1;
94 put_ei(ei);
98 static inline struct eventfs_inode *get_ei(struct eventfs_inode *ei)
100 if (ei)
101 kref_get(&ei->kref);
102 return ei;
133 struct eventfs_inode *ei;
138 ei = dentry->d_fsdata;
139 if (ei->is_freed) {
147 if (!ei->entry_attrs) {
148 ei->entry_attrs = kcalloc(ei->nr_entries, sizeof(*ei->entry_attrs),
150 if (!ei->entry_attrs) {
162 * If this is a dir, then update the ei cache, only the file
163 * mode is saved in the ei->m_children, and the ownership is
173 if (ei->is_events) {
176 ei->attr.mode |= EVENTFS_SAVE_UID;
178 ei->attr.mode |= EVENTFS_SAVE_GID;
180 update_attr(&ei->attr, iattr);
186 for (int i = 0; i < ei->nr_entries; i++) {
187 entry = &ei->entries[i];
189 update_attr(&ei->entry_attrs[i], iattr);
199 static void update_top_events_attr(struct eventfs_inode *ei, struct super_block *sb)
204 if (!ei || !(ei->attr.mode & EVENTFS_TOPLEVEL))
209 ei->attr.uid = root->i_uid;
210 ei->attr.gid = root->i_gid;
216 struct eventfs_inode *ei = ti->private;
219 if (!ei || !ei->is_events || !(ei->attr.mode & EVENTFS_TOPLEVEL))
222 update_top_events_attr(ei, inode->i_sb);
224 if (!(ei->attr.mode & EVENTFS_SAVE_UID))
225 inode->i_uid = ei->attr.uid;
227 if (!(ei->attr.mode & EVENTFS_SAVE_GID))
228 inode->i_gid = ei->attr.gid;
271 struct eventfs_inode *ei;
277 ei = dentry->d_fsdata;
280 * If the ei is being freed, the ownership of the children
283 if (ei->is_freed) {
284 ei = NULL;
288 } while (!ei->is_events);
290 update_top_events_attr(ei, dentry->d_sb);
292 return ei;
365 // Files have their parent's ei as their fsdata
375 * @ei: the eventfs_inode that represents the directory to create
381 struct eventfs_inode *pei, struct eventfs_inode *ei)
391 update_inode_attr(dentry, inode, &ei->attr,
398 inode->i_ino = eventfs_dir_ino(ei);
402 /* Only directories have ti->private set to an ei, not files */
403 ti->private = ei;
405 dentry->d_fsdata = get_ei(ei);
413 struct eventfs_inode *ei = kzalloc(sizeof(*ei), GFP_KERNEL);
415 if (!ei)
418 ei->name = kstrdup_const(name, GFP_KERNEL);
419 if (!ei->name) {
420 kfree(ei);
423 kref_init(&ei->kref);
424 return ei;
440 * @ei: the eventfs_inode that the file will be created under
441 * @idx: the index into the entry_attrs[] of the @ei
448 * Create a dentry for a file of an eventfs_inode @ei and place it into the
453 struct eventfs_inode *ei, int idx,
459 if (ei->entry_attrs)
460 attr = &ei->entry_attrs[idx];
462 return lookup_file(ei, dentry, mode, attr, data, fops);
471 * Used to create dynamic file/dir with-in @dir, search with-in @ei
481 struct eventfs_inode *ei;
491 ei = ti->private;
492 if (!ei || ei->is_freed)
495 list_for_each_entry(ei_child, &ei->children, list) {
500 result = lookup_dir_entry(dentry, ei, ei_child);
504 for (int i = 0; i < ei->nr_entries; i++) {
508 const struct eventfs_entry *entry = &ei->entries[i];
513 data = ei->data;
517 result = lookup_file_dentry(dentry, ei, i, mode, data, fops);
535 struct eventfs_inode *ei;
555 ei = READ_ONCE(ti->private);
556 if (ei && ei->is_freed)
557 ei = NULL;
560 if (!ei)
570 for (i = c; i < ei->nr_entries; i++, ctx->pos++) {
571 void *cdata = ei->data;
573 entry = &ei->entries[i];
577 /* If ei->is_freed then just bail here, nothing more to do */
578 if (ei->is_freed) {
594 c -= min((unsigned int)c, (unsigned int)ei->nr_entries);
596 list_for_each_entry_srcu(ei_child, &ei->children, list,
667 struct eventfs_inode *ei;
672 ei = alloc_ei(name);
673 if (!ei)
676 ei->entries = entries;
677 ei->nr_entries = size;
678 ei->data = data;
679 INIT_LIST_HEAD(&ei->children);
680 INIT_LIST_HEAD(&ei->list);
684 list_add_tail(&ei->list, &parent->children);
688 if (list_empty(&ei->list)) {
689 free_ei(ei);
690 ei = NULL;
692 return ei;
712 struct eventfs_inode *ei;
724 ei = alloc_ei(name);
725 if (!ei)
733 ei->events_dir = dentry;
734 ei->entries = entries;
735 ei->nr_entries = size;
736 ei->is_events = 1;
737 ei->data = data;
749 ei->attr.mode = EVENTFS_TOPLEVEL;
752 ei->attr.uid = uid;
753 ei->attr.gid = gid;
755 INIT_LIST_HEAD(&ei->children);
756 INIT_LIST_HEAD(&ei->list);
760 ti->private = ei;
768 dentry->d_fsdata = get_ei(ei);
785 return ei;
788 free_ei(ei);
795 * @ei: eventfs_inode to be removed.
801 static void eventfs_remove_rec(struct eventfs_inode *ei, int level)
816 list_for_each_entry(ei_child, &ei->children, list)
819 list_del(&ei->list);
820 free_ei(ei);
825 * @ei: eventfs_inode to be removed.
829 void eventfs_remove_dir(struct eventfs_inode *ei)
831 if (!ei)
835 eventfs_remove_rec(ei, 0);
841 * @ei: the event_inode returned by eventfs_create_events_dir().
845 void eventfs_remove_events_dir(struct eventfs_inode *ei)
849 dentry = ei->events_dir;
853 ei->events_dir = NULL;
854 eventfs_remove_dir(ei);
860 * sticks around while the other ei->dentry are created