xref: /openbmc/linux/include/trace/events/erofs.h (revision 52beb1fc)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM erofs
4 
5 #if !defined(_TRACE_EROFS_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_EROFS_H
7 
8 #include <linux/tracepoint.h>
9 #include <linux/fs.h>
10 
11 struct erofs_map_blocks;
12 
13 #define show_dev(dev)		MAJOR(dev), MINOR(dev)
14 #define show_dev_nid(entry)	show_dev(entry->dev), entry->nid
15 
16 #define show_file_type(type)						\
17 	__print_symbolic(type,						\
18 		{ 0,		"FILE" },				\
19 		{ 1,		"DIR" })
20 
21 #define show_map_flags(flags) __print_flags(flags, "|",	\
22 	{ EROFS_GET_BLOCKS_RAW,	"RAW" })
23 
24 #define show_mflags(flags) __print_flags(flags, "",	\
25 	{ EROFS_MAP_MAPPED,	"M" },			\
26 	{ EROFS_MAP_META,	"I" },			\
27 	{ EROFS_MAP_ENCODED,	"E" })
28 
29 TRACE_EVENT(erofs_lookup,
30 
31 	TP_PROTO(struct inode *dir, struct dentry *dentry, unsigned int flags),
32 
33 	TP_ARGS(dir, dentry, flags),
34 
35 	TP_STRUCT__entry(
36 		__field(dev_t,		dev	)
37 		__field(erofs_nid_t,	nid	)
38 		__string(name,		dentry->d_name.name	)
39 		__field(unsigned int,	flags	)
40 	),
41 
42 	TP_fast_assign(
43 		__entry->dev	= dir->i_sb->s_dev;
44 		__entry->nid	= EROFS_I(dir)->nid;
45 		__assign_str(name, dentry->d_name.name);
46 		__entry->flags	= flags;
47 	),
48 
49 	TP_printk("dev = (%d,%d), pnid = %llu, name:%s, flags:%x",
50 		show_dev_nid(__entry),
51 		__get_str(name),
52 		__entry->flags)
53 );
54 
55 TRACE_EVENT(erofs_fill_inode,
56 	TP_PROTO(struct inode *inode, int isdir),
57 	TP_ARGS(inode, isdir),
58 
59 	TP_STRUCT__entry(
60 		__field(dev_t,		dev	)
61 		__field(erofs_nid_t,	nid	)
62 		__field(erofs_blk_t,	blkaddr )
63 		__field(unsigned int,	ofs	)
64 		__field(int,		isdir	)
65 	),
66 
67 	TP_fast_assign(
68 		__entry->dev		= inode->i_sb->s_dev;
69 		__entry->nid		= EROFS_I(inode)->nid;
70 		__entry->blkaddr	= erofs_blknr(iloc(EROFS_I_SB(inode), __entry->nid));
71 		__entry->ofs		= erofs_blkoff(iloc(EROFS_I_SB(inode), __entry->nid));
72 		__entry->isdir		= isdir;
73 	),
74 
75 	TP_printk("dev = (%d,%d), nid = %llu, blkaddr %u ofs %u, isdir %d",
76 		  show_dev_nid(__entry),
77 		  __entry->blkaddr, __entry->ofs,
78 		  __entry->isdir)
79 );
80 
81 TRACE_EVENT(erofs_readpage,
82 
83 	TP_PROTO(struct page *page, bool raw),
84 
85 	TP_ARGS(page, raw),
86 
87 	TP_STRUCT__entry(
88 		__field(dev_t,		dev	)
89 		__field(erofs_nid_t,    nid     )
90 		__field(int,		dir	)
91 		__field(pgoff_t,	index	)
92 		__field(int,		uptodate)
93 		__field(bool,		raw	)
94 	),
95 
96 	TP_fast_assign(
97 		__entry->dev	= page->mapping->host->i_sb->s_dev;
98 		__entry->nid	= EROFS_I(page->mapping->host)->nid;
99 		__entry->dir	= S_ISDIR(page->mapping->host->i_mode);
100 		__entry->index	= page->index;
101 		__entry->uptodate = PageUptodate(page);
102 		__entry->raw = raw;
103 	),
104 
105 	TP_printk("dev = (%d,%d), nid = %llu, %s, index = %lu, uptodate = %d "
106 		"raw = %d",
107 		show_dev_nid(__entry),
108 		show_file_type(__entry->dir),
109 		(unsigned long)__entry->index,
110 		__entry->uptodate,
111 		__entry->raw)
112 );
113 
114 TRACE_EVENT(erofs_readpages,
115 
116 	TP_PROTO(struct inode *inode, pgoff_t start, unsigned int nrpage,
117 		bool raw),
118 
119 	TP_ARGS(inode, start, nrpage, raw),
120 
121 	TP_STRUCT__entry(
122 		__field(dev_t,		dev	)
123 		__field(erofs_nid_t,	nid	)
124 		__field(pgoff_t,	start	)
125 		__field(unsigned int,	nrpage	)
126 		__field(bool,		raw	)
127 	),
128 
129 	TP_fast_assign(
130 		__entry->dev	= inode->i_sb->s_dev;
131 		__entry->nid	= EROFS_I(inode)->nid;
132 		__entry->start	= start;
133 		__entry->nrpage	= nrpage;
134 		__entry->raw	= raw;
135 	),
136 
137 	TP_printk("dev = (%d,%d), nid = %llu, start = %lu nrpage = %u raw = %d",
138 		show_dev_nid(__entry),
139 		(unsigned long)__entry->start,
140 		__entry->nrpage,
141 		__entry->raw)
142 );
143 
144 DECLARE_EVENT_CLASS(erofs__map_blocks_enter,
145 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
146 		 unsigned int flags),
147 
148 	TP_ARGS(inode, map, flags),
149 
150 	TP_STRUCT__entry(
151 		__field(	dev_t,		dev		)
152 		__field(	erofs_nid_t,	nid		)
153 		__field(	erofs_off_t,	la		)
154 		__field(	u64,		llen		)
155 		__field(	unsigned int,	flags		)
156 	),
157 
158 	TP_fast_assign(
159 		__entry->dev    = inode->i_sb->s_dev;
160 		__entry->nid    = EROFS_I(inode)->nid;
161 		__entry->la	= map->m_la;
162 		__entry->llen	= map->m_llen;
163 		__entry->flags	= flags;
164 	),
165 
166 	TP_printk("dev = (%d,%d), nid = %llu, la %llu llen %llu flags %s",
167 		  show_dev_nid(__entry),
168 		  __entry->la, __entry->llen,
169 		  __entry->flags ? show_map_flags(__entry->flags) : "NULL")
170 );
171 
172 DEFINE_EVENT(erofs__map_blocks_enter, erofs_map_blocks_enter,
173 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
174 		 unsigned flags),
175 
176 	TP_ARGS(inode, map, flags)
177 );
178 
179 DEFINE_EVENT(erofs__map_blocks_enter, z_erofs_map_blocks_iter_enter,
180 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
181 		 unsigned int flags),
182 
183 	TP_ARGS(inode, map, flags)
184 );
185 
186 DECLARE_EVENT_CLASS(erofs__map_blocks_exit,
187 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
188 		 unsigned int flags, int ret),
189 
190 	TP_ARGS(inode, map, flags, ret),
191 
192 	TP_STRUCT__entry(
193 		__field(	dev_t,		dev		)
194 		__field(	erofs_nid_t,	nid		)
195 		__field(        unsigned int,   flags           )
196 		__field(	erofs_off_t,	la		)
197 		__field(	erofs_off_t,	pa		)
198 		__field(	u64,		llen		)
199 		__field(	u64,		plen		)
200 		__field(        unsigned int,	mflags		)
201 		__field(	int,		ret		)
202 	),
203 
204 	TP_fast_assign(
205 		__entry->dev    = inode->i_sb->s_dev;
206 		__entry->nid    = EROFS_I(inode)->nid;
207 		__entry->flags	= flags;
208 		__entry->la	= map->m_la;
209 		__entry->pa	= map->m_pa;
210 		__entry->llen	= map->m_llen;
211 		__entry->plen	= map->m_plen;
212 		__entry->mflags	= map->m_flags;
213 		__entry->ret	= ret;
214 	),
215 
216 	TP_printk("dev = (%d,%d), nid = %llu, flags %s "
217 		  "la %llu pa %llu llen %llu plen %llu mflags %s ret %d",
218 		  show_dev_nid(__entry),
219 		  __entry->flags ? show_map_flags(__entry->flags) : "NULL",
220 		  __entry->la, __entry->pa, __entry->llen, __entry->plen,
221 		  show_mflags(__entry->mflags), __entry->ret)
222 );
223 
224 DEFINE_EVENT(erofs__map_blocks_exit, erofs_map_blocks_exit,
225 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
226 		 unsigned flags, int ret),
227 
228 	TP_ARGS(inode, map, flags, ret)
229 );
230 
231 DEFINE_EVENT(erofs__map_blocks_exit, z_erofs_map_blocks_iter_exit,
232 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
233 		 unsigned int flags, int ret),
234 
235 	TP_ARGS(inode, map, flags, ret)
236 );
237 
238 TRACE_EVENT(erofs_destroy_inode,
239 	TP_PROTO(struct inode *inode),
240 
241 	TP_ARGS(inode),
242 
243 	TP_STRUCT__entry(
244 		__field(	dev_t,		dev		)
245 		__field(	erofs_nid_t,	nid		)
246 	),
247 
248 	TP_fast_assign(
249 		__entry->dev	= inode->i_sb->s_dev;
250 		__entry->nid	= EROFS_I(inode)->nid;
251 	),
252 
253 	TP_printk("dev = (%d,%d), nid = %llu", show_dev_nid(__entry))
254 );
255 
256 #endif /* _TRACE_EROFS_H */
257 
258  /* This part must be outside protection */
259 #include <trace/define_trace.h>
260