Merge tag 'drm-misc-next-fixes-2024-01-19' of git://anongit.freedesktop.org/drm/drm...
[linux-block.git] / fs / tracefs / internal.h
CommitLineData
ba37ff75
AK
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _TRACEFS_INTERNAL_H
3#define _TRACEFS_INTERNAL_H
4
c1504e51 5enum {
9879e5e1
SRG
6 TRACEFS_EVENT_INODE = BIT(1),
7 TRACEFS_EVENT_TOP_INODE = BIT(2),
8186fff7
SRG
8 TRACEFS_GID_PERM_SET = BIT(3),
9 TRACEFS_UID_PERM_SET = BIT(4),
10 TRACEFS_INSTANCE_INODE = BIT(5),
c1504e51
AK
11};
12
ba37ff75
AK
13struct tracefs_inode {
14 unsigned long flags;
15 void *private;
16 struct inode vfs_inode;
17};
18
28e12c09
SRG
19/*
20 * struct eventfs_attr - cache the mode and ownership of a eventfs entry
21 * @mode: saved mode plus flags of what is saved
22 * @uid: saved uid if changed
23 * @gid: saved gid if changed
24 */
25struct eventfs_attr {
26 int mode;
27 kuid_t uid;
28 kgid_t gid;
29};
30
5790b1fb
SRG
31/*
32 * struct eventfs_inode - hold the properties of the eventfs directories.
33 * @list: link list into the parent directory
34 * @entries: the array of entries representing the files in the directory
35 * @name: the name of the directory to create
36 * @children: link list into the child eventfs_inode
37 * @dentry: the dentry of the directory
38 * @d_parent: pointer to the parent's dentry
39 * @d_children: The array of dentries to represent the files when created
28e12c09
SRG
40 * @entry_attrs: Saved mode and ownership of the @d_children
41 * @attr: Saved mode and ownership of eventfs_inode itself
5790b1fb 42 * @data: The private data to pass to the callbacks
f2f49637 43 * @is_freed: Flag set if the eventfs is on its way to be freed
77a06c33 44 * Note if is_freed is set, then dentry is corrupted.
5790b1fb
SRG
45 * @nr_entries: The number of items in @entries
46 */
47struct eventfs_inode {
48 struct list_head list;
49 const struct eventfs_entry *entries;
50 const char *name;
51 struct list_head children;
77a06c33 52 struct dentry *dentry; /* Check is_freed to access */
5790b1fb
SRG
53 struct dentry *d_parent;
54 struct dentry **d_children;
28e12c09
SRG
55 struct eventfs_attr *entry_attrs;
56 struct eventfs_attr attr;
5790b1fb
SRG
57 void *data;
58 /*
59 * Union - used for deletion
020010fb 60 * @llist: for calling dput() if needed after RCU
29e06c10 61 * @rcu: eventfs_inode to delete in RCU
5790b1fb
SRG
62 */
63 union {
020010fb 64 struct llist_node llist;
5790b1fb 65 struct rcu_head rcu;
5790b1fb 66 };
f2f49637 67 unsigned int is_freed:1;
7e8358ed 68 unsigned int is_events:1;
fd56cd5f 69 unsigned int nr_entries:30;
5790b1fb
SRG
70};
71
ba37ff75
AK
72static inline struct tracefs_inode *get_tracefs(const struct inode *inode)
73{
74 return container_of(inode, struct tracefs_inode, vfs_inode);
75}
2c6b6b10
AK
76
77struct dentry *tracefs_start_creating(const char *name, struct dentry *parent);
78struct dentry *tracefs_end_creating(struct dentry *dentry);
79struct dentry *tracefs_failed_creating(struct dentry *dentry);
80struct inode *tracefs_get_inode(struct super_block *sb);
a3760079
AK
81struct dentry *eventfs_start_creating(const char *name, struct dentry *parent);
82struct dentry *eventfs_failed_creating(struct dentry *dentry);
83struct dentry *eventfs_end_creating(struct dentry *dentry);
7e8358ed 84void eventfs_update_gid(struct dentry *dentry, kgid_t gid);
5790b1fb 85void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry);
63940449 86
ba37ff75 87#endif /* _TRACEFS_INTERNAL_H */