xref: /linux/include/trace/events/erofs.h (revision 0d6ccfe6b319d56da63b7d7cfbcecd92780a680d)
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_FIEMAP,	"FIEMAP" },	\
23 	{ EROFS_GET_BLOCKS_READMORE,	"READMORE" },	\
24 	{ EROFS_GET_BLOCKS_FINDTAIL,	"FINDTAIL" })
25 
26 #define show_mflags(flags) __print_flags(flags, "",	\
27 	{ EROFS_MAP_MAPPED,		"M" },		\
28 	{ EROFS_MAP_META,		"I" },		\
29 	{ EROFS_MAP_ENCODED,		"E" },		\
30 	{ EROFS_MAP_FULL_MAPPED,	"F" },		\
31 	{ EROFS_MAP_FRAGMENT,		"R" },		\
32 	{ EROFS_MAP_PARTIAL_REF,	"P" })
33 
34 TRACE_EVENT(erofs_lookup,
35 
36 	TP_PROTO(struct inode *dir, struct dentry *dentry, unsigned int flags),
37 
38 	TP_ARGS(dir, dentry, flags),
39 
40 	TP_STRUCT__entry(
41 		__field(dev_t,		dev	)
42 		__field(erofs_nid_t,	nid	)
43 		__string(name,		dentry->d_name.name	)
44 		__field(unsigned int,	flags	)
45 	),
46 
47 	TP_fast_assign(
48 		__entry->dev	= dir->i_sb->s_dev;
49 		__entry->nid	= EROFS_I(dir)->nid;
50 		__assign_str(name);
51 		__entry->flags	= flags;
52 	),
53 
54 	TP_printk("dev = (%d,%d), pnid = %llu, name:%s, flags:%x",
55 		show_dev_nid(__entry),
56 		__get_str(name),
57 		__entry->flags)
58 );
59 
60 TRACE_EVENT(erofs_fill_inode,
61 	TP_PROTO(struct inode *inode),
62 	TP_ARGS(inode),
63 
64 	TP_STRUCT__entry(
65 		__field(dev_t,		dev	)
66 		__field(erofs_nid_t,	nid	)
67 		__field(erofs_blk_t,	blkaddr )
68 		__field(unsigned int,	ofs	)
69 	),
70 
71 	TP_fast_assign(
72 		__entry->dev		= inode->i_sb->s_dev;
73 		__entry->nid		= EROFS_I(inode)->nid;
74 		__entry->blkaddr	= erofs_blknr(inode->i_sb, erofs_iloc(inode));
75 		__entry->ofs		= erofs_blkoff(inode->i_sb, erofs_iloc(inode));
76 	),
77 
78 	TP_printk("dev = (%d,%d), nid = %llu, blkaddr %u ofs %u",
79 		  show_dev_nid(__entry),
80 		  __entry->blkaddr, __entry->ofs)
81 );
82 
83 TRACE_EVENT(erofs_read_folio,
84 
85 	TP_PROTO(struct folio *folio, bool raw),
86 
87 	TP_ARGS(folio, raw),
88 
89 	TP_STRUCT__entry(
90 		__field(dev_t,		dev	)
91 		__field(erofs_nid_t,    nid     )
92 		__field(int,		dir	)
93 		__field(pgoff_t,	index	)
94 		__field(int,		uptodate)
95 		__field(bool,		raw	)
96 	),
97 
98 	TP_fast_assign(
99 		__entry->dev	= folio->mapping->host->i_sb->s_dev;
100 		__entry->nid	= EROFS_I(folio->mapping->host)->nid;
101 		__entry->dir	= S_ISDIR(folio->mapping->host->i_mode);
102 		__entry->index	= folio->index;
103 		__entry->uptodate = folio_test_uptodate(folio);
104 		__entry->raw = raw;
105 	),
106 
107 	TP_printk("dev = (%d,%d), nid = %llu, %s, index = %lu, uptodate = %d "
108 		"raw = %d",
109 		show_dev_nid(__entry),
110 		show_file_type(__entry->dir),
111 		(unsigned long)__entry->index,
112 		__entry->uptodate,
113 		__entry->raw)
114 );
115 
116 TRACE_EVENT(erofs_readpages,
117 
118 	TP_PROTO(struct inode *inode, pgoff_t start, unsigned int nrpage,
119 		bool raw),
120 
121 	TP_ARGS(inode, start, nrpage, raw),
122 
123 	TP_STRUCT__entry(
124 		__field(dev_t,		dev	)
125 		__field(erofs_nid_t,	nid	)
126 		__field(pgoff_t,	start	)
127 		__field(unsigned int,	nrpage	)
128 		__field(bool,		raw	)
129 	),
130 
131 	TP_fast_assign(
132 		__entry->dev	= inode->i_sb->s_dev;
133 		__entry->nid	= EROFS_I(inode)->nid;
134 		__entry->start	= start;
135 		__entry->nrpage	= nrpage;
136 		__entry->raw	= raw;
137 	),
138 
139 	TP_printk("dev = (%d,%d), nid = %llu, start = %lu nrpage = %u raw = %d",
140 		show_dev_nid(__entry),
141 		(unsigned long)__entry->start,
142 		__entry->nrpage,
143 		__entry->raw)
144 );
145 
146 TRACE_EVENT(erofs_map_blocks_enter,
147 
148 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
149 		 unsigned int flags),
150 
151 	TP_ARGS(inode, map, flags),
152 
153 	TP_STRUCT__entry(
154 		__field(	dev_t,		dev		)
155 		__field(	erofs_nid_t,	nid		)
156 		__field(	erofs_off_t,	la		)
157 		__field(	u64,		llen		)
158 		__field(	unsigned int,	flags		)
159 	),
160 
161 	TP_fast_assign(
162 		__entry->dev    = inode->i_sb->s_dev;
163 		__entry->nid    = EROFS_I(inode)->nid;
164 		__entry->la	= map->m_la;
165 		__entry->llen	= map->m_llen;
166 		__entry->flags	= flags;
167 	),
168 
169 	TP_printk("dev = (%d,%d), nid = %llu, la %llu llen %llu flags %s",
170 		  show_dev_nid(__entry),
171 		  __entry->la, __entry->llen,
172 		  __entry->flags ? show_map_flags(__entry->flags) : "NULL")
173 );
174 
175 TRACE_EVENT(erofs_map_blocks_exit,
176 
177 	TP_PROTO(struct inode *inode, struct erofs_map_blocks *map,
178 		 unsigned int flags, int ret),
179 
180 	TP_ARGS(inode, map, flags, ret),
181 
182 	TP_STRUCT__entry(
183 		__field(	dev_t,		dev		)
184 		__field(	erofs_nid_t,	nid		)
185 		__field(        unsigned int,   flags           )
186 		__field(	erofs_off_t,	la		)
187 		__field(	erofs_off_t,	pa		)
188 		__field(	u64,		llen		)
189 		__field(	u64,		plen		)
190 		__field(        unsigned int,	mflags		)
191 		__field(	int,		ret		)
192 	),
193 
194 	TP_fast_assign(
195 		__entry->dev    = inode->i_sb->s_dev;
196 		__entry->nid    = EROFS_I(inode)->nid;
197 		__entry->flags	= flags;
198 		__entry->la	= map->m_la;
199 		__entry->pa	= map->m_pa;
200 		__entry->llen	= map->m_llen;
201 		__entry->plen	= map->m_plen;
202 		__entry->mflags	= map->m_flags;
203 		__entry->ret	= ret;
204 	),
205 
206 	TP_printk("dev = (%d,%d), nid = %llu, flags %s "
207 		  "la %llu pa %llu llen %llu plen %llu mflags %s ret %d",
208 		  show_dev_nid(__entry),
209 		  __entry->flags ? show_map_flags(__entry->flags) : "NULL",
210 		  __entry->la, __entry->pa, __entry->llen, __entry->plen,
211 		  show_mflags(__entry->mflags), __entry->ret)
212 );
213 
214 TRACE_EVENT(erofs_destroy_inode,
215 	TP_PROTO(struct inode *inode),
216 
217 	TP_ARGS(inode),
218 
219 	TP_STRUCT__entry(
220 		__field(	dev_t,		dev		)
221 		__field(	erofs_nid_t,	nid		)
222 	),
223 
224 	TP_fast_assign(
225 		__entry->dev	= inode->i_sb->s_dev;
226 		__entry->nid	= EROFS_I(inode)->nid;
227 	),
228 
229 	TP_printk("dev = (%d,%d), nid = %llu", show_dev_nid(__entry))
230 );
231 
232 #endif /* _TRACE_EROFS_H */
233 
234  /* This part must be outside protection */
235 #include <trace/define_trace.h>
236