xref: /openbmc/linux/include/trace/events/btrfs.h (revision f3956ebb)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM btrfs
4 
5 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_BTRFS_H
7 
8 #include <linux/writeback.h>
9 #include <linux/tracepoint.h>
10 #include <trace/events/mmflags.h>
11 
12 struct btrfs_root;
13 struct btrfs_fs_info;
14 struct btrfs_inode;
15 struct extent_map;
16 struct btrfs_file_extent_item;
17 struct btrfs_ordered_extent;
18 struct btrfs_delayed_ref_node;
19 struct btrfs_delayed_tree_ref;
20 struct btrfs_delayed_data_ref;
21 struct btrfs_delayed_ref_head;
22 struct btrfs_block_group;
23 struct btrfs_free_cluster;
24 struct map_lookup;
25 struct extent_buffer;
26 struct btrfs_work;
27 struct __btrfs_workqueue;
28 struct btrfs_qgroup_extent_record;
29 struct btrfs_qgroup;
30 struct extent_io_tree;
31 struct prelim_ref;
32 struct btrfs_space_info;
33 
34 #define show_ref_type(type)						\
35 	__print_symbolic(type,						\
36 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
37 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
38 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
39 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
40 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
41 
42 #define __show_root_type(obj)						\
43 	__print_symbolic_u64(obj,					\
44 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
45 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
46 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
47 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
48 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
49 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
50 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
51 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
52 		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
53 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
54 		{ BTRFS_UUID_TREE_OBJECTID,	"UUID_TREE"	},	\
55 		{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },	\
56 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
57 
58 #define show_root_type(obj)						\
59 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
60 	      (obj >= BTRFS_ROOT_TREE_OBJECTID &&			\
61 	       obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
62 
63 #define FLUSH_ACTIONS								\
64 	EM( BTRFS_RESERVE_NO_FLUSH,		"BTRFS_RESERVE_NO_FLUSH")	\
65 	EM( BTRFS_RESERVE_FLUSH_LIMIT,		"BTRFS_RESERVE_FLUSH_LIMIT")	\
66 	EM( BTRFS_RESERVE_FLUSH_ALL,		"BTRFS_RESERVE_FLUSH_ALL")	\
67 	EMe(BTRFS_RESERVE_FLUSH_ALL_STEAL,	"BTRFS_RESERVE_FLUSH_ALL_STEAL")
68 
69 #define FI_TYPES							\
70 	EM( BTRFS_FILE_EXTENT_INLINE,		"INLINE")		\
71 	EM( BTRFS_FILE_EXTENT_REG,		"REG")			\
72 	EMe(BTRFS_FILE_EXTENT_PREALLOC,		"PREALLOC")
73 
74 #define QGROUP_RSV_TYPES						\
75 	EM( BTRFS_QGROUP_RSV_DATA,		"DATA")			\
76 	EM( BTRFS_QGROUP_RSV_META_PERTRANS,	"META_PERTRANS")	\
77 	EMe(BTRFS_QGROUP_RSV_META_PREALLOC,	"META_PREALLOC")
78 
79 #define IO_TREE_OWNER						    \
80 	EM( IO_TREE_FS_PINNED_EXTENTS, 	  "PINNED_EXTENTS")	    \
81 	EM( IO_TREE_FS_EXCLUDED_EXTENTS,  "EXCLUDED_EXTENTS")	    \
82 	EM( IO_TREE_BTREE_INODE_IO,	  "BTREE_INODE_IO")	    \
83 	EM( IO_TREE_INODE_IO,		  "INODE_IO")		    \
84 	EM( IO_TREE_INODE_IO_FAILURE,	  "INODE_IO_FAILURE")	    \
85 	EM( IO_TREE_RELOC_BLOCKS,	  "RELOC_BLOCKS")	    \
86 	EM( IO_TREE_TRANS_DIRTY_PAGES,	  "TRANS_DIRTY_PAGES")      \
87 	EM( IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES")   \
88 	EM( IO_TREE_INODE_FILE_EXTENT,	  "INODE_FILE_EXTENT")      \
89 	EM( IO_TREE_LOG_CSUM_RANGE,	  "LOG_CSUM_RANGE")         \
90 	EMe(IO_TREE_SELFTEST,		  "SELFTEST")
91 
92 #define FLUSH_STATES							\
93 	EM( FLUSH_DELAYED_ITEMS_NR,	"FLUSH_DELAYED_ITEMS_NR")	\
94 	EM( FLUSH_DELAYED_ITEMS,	"FLUSH_DELAYED_ITEMS")		\
95 	EM( FLUSH_DELALLOC,		"FLUSH_DELALLOC")		\
96 	EM( FLUSH_DELALLOC_WAIT,	"FLUSH_DELALLOC_WAIT")		\
97 	EM( FLUSH_DELALLOC_FULL,	"FLUSH_DELALLOC_FULL")		\
98 	EM( FLUSH_DELAYED_REFS_NR,	"FLUSH_DELAYED_REFS_NR")	\
99 	EM( FLUSH_DELAYED_REFS,		"FLUSH_ELAYED_REFS")		\
100 	EM( ALLOC_CHUNK,		"ALLOC_CHUNK")			\
101 	EM( ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE")		\
102 	EM( RUN_DELAYED_IPUTS,		"RUN_DELAYED_IPUTS")		\
103 	EMe(COMMIT_TRANS,		"COMMIT_TRANS")
104 
105 /*
106  * First define the enums in the above macros to be exported to userspace via
107  * TRACE_DEFINE_ENUM().
108  */
109 
110 #undef EM
111 #undef EMe
112 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
113 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
114 
115 FLUSH_ACTIONS
116 FI_TYPES
117 QGROUP_RSV_TYPES
118 IO_TREE_OWNER
119 FLUSH_STATES
120 
121 /*
122  * Now redefine the EM and EMe macros to map the enums to the strings that will
123  * be printed in the output
124  */
125 
126 #undef EM
127 #undef EMe
128 #define EM(a, b)        {a, b},
129 #define EMe(a, b)       {a, b}
130 
131 
132 #define BTRFS_GROUP_FLAGS	\
133 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
134 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
135 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
136 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
137 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
138 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
139 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
140 	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
141 	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
142 
143 #define EXTENT_FLAGS						\
144 	{ EXTENT_DIRTY,			"DIRTY"},		\
145 	{ EXTENT_UPTODATE,		"UPTODATE"},		\
146 	{ EXTENT_LOCKED,		"LOCKED"},		\
147 	{ EXTENT_NEW,			"NEW"},			\
148 	{ EXTENT_DELALLOC,		"DELALLOC"},		\
149 	{ EXTENT_DEFRAG,		"DEFRAG"},		\
150 	{ EXTENT_BOUNDARY,		"BOUNDARY"},		\
151 	{ EXTENT_NODATASUM,		"NODATASUM"},		\
152 	{ EXTENT_CLEAR_META_RESV,	"CLEAR_META_RESV"},	\
153 	{ EXTENT_NEED_WAIT,		"NEED_WAIT"},		\
154 	{ EXTENT_DAMAGED,		"DAMAGED"},		\
155 	{ EXTENT_NORESERVE,		"NORESERVE"},		\
156 	{ EXTENT_QGROUP_RESERVED,	"QGROUP_RESERVED"},	\
157 	{ EXTENT_CLEAR_DATA_RESV,	"CLEAR_DATA_RESV"},	\
158 	{ EXTENT_DELALLOC_NEW,		"DELALLOC_NEW"}
159 
160 #define BTRFS_FSID_SIZE 16
161 #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
162 
163 #define TP_fast_assign_fsid(fs_info)					\
164 ({									\
165 	if (fs_info)							\
166 		memcpy(__entry->fsid, fs_info->fs_devices->fsid,	\
167 		       BTRFS_FSID_SIZE);				\
168 	else								\
169 		memset(__entry->fsid, 0, BTRFS_FSID_SIZE);		\
170 })
171 
172 #define TP_STRUCT__entry_btrfs(args...)					\
173 	TP_STRUCT__entry(						\
174 		TP_STRUCT__entry_fsid					\
175 		args)
176 #define TP_fast_assign_btrfs(fs_info, args...)				\
177 	TP_fast_assign(							\
178 		TP_fast_assign_fsid(fs_info);				\
179 		args)
180 #define TP_printk_btrfs(fmt, args...) \
181 	TP_printk("%pU: " fmt, __entry->fsid, args)
182 
183 TRACE_EVENT(btrfs_transaction_commit,
184 
185 	TP_PROTO(const struct btrfs_root *root),
186 
187 	TP_ARGS(root),
188 
189 	TP_STRUCT__entry_btrfs(
190 		__field(	u64,  generation		)
191 		__field(	u64,  root_objectid		)
192 	),
193 
194 	TP_fast_assign_btrfs(root->fs_info,
195 		__entry->generation	= root->fs_info->generation;
196 		__entry->root_objectid	= root->root_key.objectid;
197 	),
198 
199 	TP_printk_btrfs("root=%llu(%s) gen=%llu",
200 		  show_root_type(__entry->root_objectid),
201 		  __entry->generation)
202 );
203 
204 DECLARE_EVENT_CLASS(btrfs__inode,
205 
206 	TP_PROTO(const struct inode *inode),
207 
208 	TP_ARGS(inode),
209 
210 	TP_STRUCT__entry_btrfs(
211 		__field(	u64,  ino			)
212 		__field(	u64,  blocks			)
213 		__field(	u64,  disk_i_size		)
214 		__field(	u64,  generation		)
215 		__field(	u64,  last_trans		)
216 		__field(	u64,  logged_trans		)
217 		__field(	u64,  root_objectid		)
218 	),
219 
220 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
221 		__entry->ino	= btrfs_ino(BTRFS_I(inode));
222 		__entry->blocks	= inode->i_blocks;
223 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
224 		__entry->generation = BTRFS_I(inode)->generation;
225 		__entry->last_trans = BTRFS_I(inode)->last_trans;
226 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
227 		__entry->root_objectid =
228 				BTRFS_I(inode)->root->root_key.objectid;
229 	),
230 
231 	TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
232 		  "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
233 		  show_root_type(__entry->root_objectid),
234 		  __entry->generation,
235 		  __entry->ino,
236 		  __entry->blocks,
237 		  __entry->disk_i_size,
238 		  __entry->last_trans,
239 		  __entry->logged_trans)
240 );
241 
242 DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
243 
244 	TP_PROTO(const struct inode *inode),
245 
246 	TP_ARGS(inode)
247 );
248 
249 DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
250 
251 	TP_PROTO(const struct inode *inode),
252 
253 	TP_ARGS(inode)
254 );
255 
256 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
257 
258 	TP_PROTO(const struct inode *inode),
259 
260 	TP_ARGS(inode)
261 );
262 
263 #define __show_map_type(type)						\
264 	__print_symbolic_u64(type,					\
265 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
266 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
267 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
268 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
269 
270 #define show_map_type(type)			\
271 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
272 
273 #define show_map_flags(flag)						\
274 	__print_flags(flag, "|",					\
275 		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
276 		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
277 		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
278 		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
279 		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
280 		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
281 
282 TRACE_EVENT_CONDITION(btrfs_get_extent,
283 
284 	TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
285 		 const struct extent_map *map),
286 
287 	TP_ARGS(root, inode, map),
288 
289 	TP_CONDITION(map),
290 
291 	TP_STRUCT__entry_btrfs(
292 		__field(	u64,  root_objectid	)
293 		__field(	u64,  ino		)
294 		__field(	u64,  start		)
295 		__field(	u64,  len		)
296 		__field(	u64,  orig_start	)
297 		__field(	u64,  block_start	)
298 		__field(	u64,  block_len		)
299 		__field(	unsigned long,  flags	)
300 		__field(	int,  refs		)
301 		__field(	unsigned int,  compress_type	)
302 	),
303 
304 	TP_fast_assign_btrfs(root->fs_info,
305 		__entry->root_objectid	= root->root_key.objectid;
306 		__entry->ino		= btrfs_ino(inode);
307 		__entry->start		= map->start;
308 		__entry->len		= map->len;
309 		__entry->orig_start	= map->orig_start;
310 		__entry->block_start	= map->block_start;
311 		__entry->block_len	= map->block_len;
312 		__entry->flags		= map->flags;
313 		__entry->refs		= refcount_read(&map->refs);
314 		__entry->compress_type	= map->compress_type;
315 	),
316 
317 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
318 		  "orig_start=%llu block_start=%llu(%s) "
319 		  "block_len=%llu flags=%s refs=%u "
320 		  "compress_type=%u",
321 		  show_root_type(__entry->root_objectid),
322 		  __entry->ino,
323 		  __entry->start,
324 		  __entry->len,
325 		  __entry->orig_start,
326 		  show_map_type(__entry->block_start),
327 		  __entry->block_len,
328 		  show_map_flags(__entry->flags),
329 		  __entry->refs, __entry->compress_type)
330 );
331 
332 TRACE_EVENT(btrfs_handle_em_exist,
333 
334 	TP_PROTO(const struct btrfs_fs_info *fs_info,
335 		const struct extent_map *existing, const struct extent_map *map,
336 		u64 start, u64 len),
337 
338 	TP_ARGS(fs_info, existing, map, start, len),
339 
340 	TP_STRUCT__entry_btrfs(
341 		__field(	u64,  e_start		)
342 		__field(	u64,  e_len		)
343 		__field(	u64,  map_start		)
344 		__field(	u64,  map_len		)
345 		__field(	u64,  start		)
346 		__field(	u64,  len		)
347 	),
348 
349 	TP_fast_assign_btrfs(fs_info,
350 		__entry->e_start	= existing->start;
351 		__entry->e_len		= existing->len;
352 		__entry->map_start	= map->start;
353 		__entry->map_len	= map->len;
354 		__entry->start		= start;
355 		__entry->len		= len;
356 	),
357 
358 	TP_printk_btrfs("start=%llu len=%llu "
359 		  "existing(start=%llu len=%llu) "
360 		  "em(start=%llu len=%llu)",
361 		  __entry->start,
362 		  __entry->len,
363 		  __entry->e_start,
364 		  __entry->e_len,
365 		  __entry->map_start,
366 		  __entry->map_len)
367 );
368 
369 /* file extent item */
370 DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
371 
372 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
373 		 const struct btrfs_file_extent_item *fi, u64 start),
374 
375 	TP_ARGS(bi, l, fi, start),
376 
377 	TP_STRUCT__entry_btrfs(
378 		__field(	u64,	root_obj	)
379 		__field(	u64,	ino		)
380 		__field(	loff_t,	isize		)
381 		__field(	u64,	disk_isize	)
382 		__field(	u64,	num_bytes	)
383 		__field(	u64,	ram_bytes	)
384 		__field(	u64,	disk_bytenr	)
385 		__field(	u64,	disk_num_bytes	)
386 		__field(	u64,	extent_offset	)
387 		__field(	u8,	extent_type	)
388 		__field(	u8,	compression	)
389 		__field(	u64,	extent_start	)
390 		__field(	u64,	extent_end	)
391 	),
392 
393 	TP_fast_assign_btrfs(bi->root->fs_info,
394 		__entry->root_obj	= bi->root->root_key.objectid;
395 		__entry->ino		= btrfs_ino(bi);
396 		__entry->isize		= bi->vfs_inode.i_size;
397 		__entry->disk_isize	= bi->disk_i_size;
398 		__entry->num_bytes	= btrfs_file_extent_num_bytes(l, fi);
399 		__entry->ram_bytes	= btrfs_file_extent_ram_bytes(l, fi);
400 		__entry->disk_bytenr	= btrfs_file_extent_disk_bytenr(l, fi);
401 		__entry->disk_num_bytes	= btrfs_file_extent_disk_num_bytes(l, fi);
402 		__entry->extent_offset	= btrfs_file_extent_offset(l, fi);
403 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
404 		__entry->compression	= btrfs_file_extent_compression(l, fi);
405 		__entry->extent_start	= start;
406 		__entry->extent_end	= (start + __entry->num_bytes);
407 	),
408 
409 	TP_printk_btrfs(
410 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
411 		"file extent range=[%llu %llu] "
412 		"(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
413 		"disk_num_bytes=%llu extent_offset=%llu type=%s "
414 		"compression=%u",
415 		show_root_type(__entry->root_obj), __entry->ino,
416 		__entry->isize,
417 		__entry->disk_isize, __entry->extent_start,
418 		__entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
419 		__entry->disk_bytenr, __entry->disk_num_bytes,
420 		__entry->extent_offset, __print_symbolic(__entry->extent_type, FI_TYPES),
421 		__entry->compression)
422 );
423 
424 DECLARE_EVENT_CLASS(
425 	btrfs__file_extent_item_inline,
426 
427 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
428 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
429 
430 	TP_ARGS(bi, l, fi, slot,  start),
431 
432 	TP_STRUCT__entry_btrfs(
433 		__field(	u64,	root_obj	)
434 		__field(	u64,	ino		)
435 		__field(	loff_t,	isize		)
436 		__field(	u64,	disk_isize	)
437 		__field(	u8,	extent_type	)
438 		__field(	u8,	compression	)
439 		__field(	u64,	extent_start	)
440 		__field(	u64,	extent_end	)
441 	),
442 
443 	TP_fast_assign_btrfs(
444 		bi->root->fs_info,
445 		__entry->root_obj	= bi->root->root_key.objectid;
446 		__entry->ino		= btrfs_ino(bi);
447 		__entry->isize		= bi->vfs_inode.i_size;
448 		__entry->disk_isize	= bi->disk_i_size;
449 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
450 		__entry->compression	= btrfs_file_extent_compression(l, fi);
451 		__entry->extent_start	= start;
452 		__entry->extent_end	= (start + btrfs_file_extent_ram_bytes(l, fi));
453 	),
454 
455 	TP_printk_btrfs(
456 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
457 		"file extent range=[%llu %llu] "
458 		"extent_type=%s compression=%u",
459 		show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
460 		__entry->disk_isize, __entry->extent_start,
461 		__entry->extent_end, __print_symbolic(__entry->extent_type, FI_TYPES),
462 		__entry->compression)
463 );
464 
465 DEFINE_EVENT(
466 	btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
467 
468 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
469 		 const struct btrfs_file_extent_item *fi, u64 start),
470 
471 	TP_ARGS(bi, l, fi, start)
472 );
473 
474 DEFINE_EVENT(
475 	btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
476 
477 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
478 		 const struct btrfs_file_extent_item *fi, u64 start),
479 
480 	TP_ARGS(bi, l, fi, start)
481 );
482 
483 DEFINE_EVENT(
484 	btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
485 
486 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
487 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
488 
489 	TP_ARGS(bi, l, fi, slot, start)
490 );
491 
492 DEFINE_EVENT(
493 	btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
494 
495 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
496 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
497 
498 	TP_ARGS(bi, l, fi, slot, start)
499 );
500 
501 #define show_ordered_flags(flags)					   \
502 	__print_flags(flags, "|",					   \
503 		{ (1 << BTRFS_ORDERED_REGULAR), 	"REGULAR" 	}, \
504 		{ (1 << BTRFS_ORDERED_NOCOW), 		"NOCOW" 	}, \
505 		{ (1 << BTRFS_ORDERED_PREALLOC), 	"PREALLOC" 	}, \
506 		{ (1 << BTRFS_ORDERED_COMPRESSED), 	"COMPRESSED" 	}, \
507 		{ (1 << BTRFS_ORDERED_DIRECT),	 	"DIRECT" 	}, \
508 		{ (1 << BTRFS_ORDERED_IO_DONE), 	"IO_DONE" 	}, \
509 		{ (1 << BTRFS_ORDERED_COMPLETE), 	"COMPLETE" 	}, \
510 		{ (1 << BTRFS_ORDERED_IOERR), 		"IOERR" 	}, \
511 		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
512 
513 
514 DECLARE_EVENT_CLASS(btrfs__ordered_extent,
515 
516 	TP_PROTO(const struct btrfs_inode *inode,
517 		 const struct btrfs_ordered_extent *ordered),
518 
519 	TP_ARGS(inode, ordered),
520 
521 	TP_STRUCT__entry_btrfs(
522 		__field(	u64,  ino		)
523 		__field(	u64,  file_offset	)
524 		__field(	u64,  start		)
525 		__field(	u64,  len		)
526 		__field(	u64,  disk_len		)
527 		__field(	u64,  bytes_left	)
528 		__field(	unsigned long,  flags	)
529 		__field(	int,  compress_type	)
530 		__field(	int,  refs		)
531 		__field(	u64,  root_objectid	)
532 		__field(	u64,  truncated_len	)
533 	),
534 
535 	TP_fast_assign_btrfs(inode->root->fs_info,
536 		__entry->ino 		= btrfs_ino(inode);
537 		__entry->file_offset	= ordered->file_offset;
538 		__entry->start		= ordered->disk_bytenr;
539 		__entry->len		= ordered->num_bytes;
540 		__entry->disk_len	= ordered->disk_num_bytes;
541 		__entry->bytes_left	= ordered->bytes_left;
542 		__entry->flags		= ordered->flags;
543 		__entry->compress_type	= ordered->compress_type;
544 		__entry->refs		= refcount_read(&ordered->refs);
545 		__entry->root_objectid	= inode->root->root_key.objectid;
546 		__entry->truncated_len	= ordered->truncated_len;
547 	),
548 
549 	TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
550 		  "start=%llu len=%llu disk_len=%llu "
551 		  "truncated_len=%llu "
552 		  "bytes_left=%llu flags=%s compress_type=%d "
553 		  "refs=%d",
554 		  show_root_type(__entry->root_objectid),
555 		  __entry->ino,
556 		  __entry->file_offset,
557 		  __entry->start,
558 		  __entry->len,
559 		  __entry->disk_len,
560 		  __entry->truncated_len,
561 		  __entry->bytes_left,
562 		  show_ordered_flags(__entry->flags),
563 		  __entry->compress_type, __entry->refs)
564 );
565 
566 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
567 
568 	TP_PROTO(const struct btrfs_inode *inode,
569 		 const struct btrfs_ordered_extent *ordered),
570 
571 	TP_ARGS(inode, ordered)
572 );
573 
574 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
575 
576 	TP_PROTO(const struct btrfs_inode *inode,
577 		 const struct btrfs_ordered_extent *ordered),
578 
579 	TP_ARGS(inode, ordered)
580 );
581 
582 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
583 
584 	TP_PROTO(const struct btrfs_inode *inode,
585 		 const struct btrfs_ordered_extent *ordered),
586 
587 	TP_ARGS(inode, ordered)
588 );
589 
590 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
591 
592 	TP_PROTO(const struct btrfs_inode *inode,
593 		 const struct btrfs_ordered_extent *ordered),
594 
595 	TP_ARGS(inode, ordered)
596 );
597 
598 DECLARE_EVENT_CLASS(btrfs__writepage,
599 
600 	TP_PROTO(const struct page *page, const struct inode *inode,
601 		 const struct writeback_control *wbc),
602 
603 	TP_ARGS(page, inode, wbc),
604 
605 	TP_STRUCT__entry_btrfs(
606 		__field(	u64,	ino			)
607 		__field(	pgoff_t,  index			)
608 		__field(	long,   nr_to_write		)
609 		__field(	long,   pages_skipped		)
610 		__field(	loff_t, range_start		)
611 		__field(	loff_t, range_end		)
612 		__field(	char,   for_kupdate		)
613 		__field(	char,   for_reclaim		)
614 		__field(	char,   range_cyclic		)
615 		__field(	unsigned long,  writeback_index	)
616 		__field(	u64,    root_objectid		)
617 	),
618 
619 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
620 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
621 		__entry->index		= page->index;
622 		__entry->nr_to_write	= wbc->nr_to_write;
623 		__entry->pages_skipped	= wbc->pages_skipped;
624 		__entry->range_start	= wbc->range_start;
625 		__entry->range_end	= wbc->range_end;
626 		__entry->for_kupdate	= wbc->for_kupdate;
627 		__entry->for_reclaim	= wbc->for_reclaim;
628 		__entry->range_cyclic	= wbc->range_cyclic;
629 		__entry->writeback_index = inode->i_mapping->writeback_index;
630 		__entry->root_objectid	=
631 				 BTRFS_I(inode)->root->root_key.objectid;
632 	),
633 
634 	TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
635 		  "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
636 		  "range_end=%llu for_kupdate=%d "
637 		  "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
638 		  show_root_type(__entry->root_objectid),
639 		  __entry->ino, __entry->index,
640 		  __entry->nr_to_write, __entry->pages_skipped,
641 		  __entry->range_start, __entry->range_end,
642 		  __entry->for_kupdate,
643 		  __entry->for_reclaim, __entry->range_cyclic,
644 		  __entry->writeback_index)
645 );
646 
647 DEFINE_EVENT(btrfs__writepage, __extent_writepage,
648 
649 	TP_PROTO(const struct page *page, const struct inode *inode,
650 		 const struct writeback_control *wbc),
651 
652 	TP_ARGS(page, inode, wbc)
653 );
654 
655 TRACE_EVENT(btrfs_writepage_end_io_hook,
656 
657 	TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 end,
658 		 int uptodate),
659 
660 	TP_ARGS(inode, start, end, uptodate),
661 
662 	TP_STRUCT__entry_btrfs(
663 		__field(	u64,	 ino		)
664 		__field(	u64,	 start		)
665 		__field(	u64,	 end		)
666 		__field(	int,	 uptodate	)
667 		__field(	u64,    root_objectid	)
668 	),
669 
670 	TP_fast_assign_btrfs(inode->root->fs_info,
671 		__entry->ino	= btrfs_ino(inode);
672 		__entry->start	= start;
673 		__entry->end	= end;
674 		__entry->uptodate = uptodate;
675 		__entry->root_objectid = inode->root->root_key.objectid;
676 	),
677 
678 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu end=%llu uptodate=%d",
679 		  show_root_type(__entry->root_objectid),
680 		  __entry->ino, __entry->start,
681 		  __entry->end, __entry->uptodate)
682 );
683 
684 TRACE_EVENT(btrfs_sync_file,
685 
686 	TP_PROTO(const struct file *file, int datasync),
687 
688 	TP_ARGS(file, datasync),
689 
690 	TP_STRUCT__entry_btrfs(
691 		__field(	u64,	ino		)
692 		__field(	u64,	parent		)
693 		__field(	int,    datasync	)
694 		__field(	u64,    root_objectid	)
695 	),
696 
697 	TP_fast_assign(
698 		const struct dentry *dentry = file->f_path.dentry;
699 		const struct inode *inode = d_inode(dentry);
700 
701 		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
702 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
703 		__entry->parent		= btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
704 		__entry->datasync	= datasync;
705 		__entry->root_objectid	=
706 				 BTRFS_I(inode)->root->root_key.objectid;
707 	),
708 
709 	TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
710 		  show_root_type(__entry->root_objectid),
711 		  __entry->ino,
712 		  __entry->parent,
713 		  __entry->datasync)
714 );
715 
716 TRACE_EVENT(btrfs_sync_fs,
717 
718 	TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
719 
720 	TP_ARGS(fs_info, wait),
721 
722 	TP_STRUCT__entry_btrfs(
723 		__field(	int,  wait		)
724 	),
725 
726 	TP_fast_assign_btrfs(fs_info,
727 		__entry->wait	= wait;
728 	),
729 
730 	TP_printk_btrfs("wait=%d", __entry->wait)
731 );
732 
733 TRACE_EVENT(btrfs_add_block_group,
734 
735 	TP_PROTO(const struct btrfs_fs_info *fs_info,
736 		 const struct btrfs_block_group *block_group, int create),
737 
738 	TP_ARGS(fs_info, block_group, create),
739 
740 	TP_STRUCT__entry_btrfs(
741 		__field(	u64,	offset			)
742 		__field(	u64,	size			)
743 		__field(	u64,	flags			)
744 		__field(	u64,	bytes_used		)
745 		__field(	u64,	bytes_super		)
746 		__field(	int,	create			)
747 	),
748 
749 	TP_fast_assign_btrfs(fs_info,
750 		__entry->offset		= block_group->start;
751 		__entry->size		= block_group->length;
752 		__entry->flags		= block_group->flags;
753 		__entry->bytes_used	= block_group->used;
754 		__entry->bytes_super	= block_group->bytes_super;
755 		__entry->create		= create;
756 	),
757 
758 	TP_printk_btrfs("block_group offset=%llu size=%llu "
759 		  "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
760 		  "create=%d",
761 		  __entry->offset,
762 		  __entry->size,
763 		  __entry->flags,
764 		  __print_flags((unsigned long)__entry->flags, "|",
765 				BTRFS_GROUP_FLAGS),
766 		  __entry->bytes_used,
767 		  __entry->bytes_super, __entry->create)
768 );
769 
770 #define show_ref_action(action)						\
771 	__print_symbolic(action,					\
772 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
773 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
774 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
775 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
776 
777 
778 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
779 
780 	TP_PROTO(const struct btrfs_fs_info *fs_info,
781 		 const struct btrfs_delayed_ref_node *ref,
782 		 const struct btrfs_delayed_tree_ref *full_ref,
783 		 int action),
784 
785 	TP_ARGS(fs_info, ref, full_ref, action),
786 
787 	TP_STRUCT__entry_btrfs(
788 		__field(	u64,  bytenr		)
789 		__field(	u64,  num_bytes		)
790 		__field(	int,  action		)
791 		__field(	u64,  parent		)
792 		__field(	u64,  ref_root		)
793 		__field(	int,  level		)
794 		__field(	int,  type		)
795 		__field(	u64,  seq		)
796 	),
797 
798 	TP_fast_assign_btrfs(fs_info,
799 		__entry->bytenr		= ref->bytenr;
800 		__entry->num_bytes	= ref->num_bytes;
801 		__entry->action		= action;
802 		__entry->parent		= full_ref->parent;
803 		__entry->ref_root	= full_ref->root;
804 		__entry->level		= full_ref->level;
805 		__entry->type		= ref->type;
806 		__entry->seq		= ref->seq;
807 	),
808 
809 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
810 		  "parent=%llu(%s) ref_root=%llu(%s) level=%d "
811 		  "type=%s seq=%llu",
812 		  __entry->bytenr,
813 		  __entry->num_bytes,
814 		  show_ref_action(__entry->action),
815 		  show_root_type(__entry->parent),
816 		  show_root_type(__entry->ref_root),
817 		  __entry->level, show_ref_type(__entry->type),
818 		  __entry->seq)
819 );
820 
821 DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
822 
823 	TP_PROTO(const struct btrfs_fs_info *fs_info,
824 		 const struct btrfs_delayed_ref_node *ref,
825 		 const struct btrfs_delayed_tree_ref *full_ref,
826 		 int action),
827 
828 	TP_ARGS(fs_info, ref, full_ref, action)
829 );
830 
831 DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
832 
833 	TP_PROTO(const struct btrfs_fs_info *fs_info,
834 		 const struct btrfs_delayed_ref_node *ref,
835 		 const struct btrfs_delayed_tree_ref *full_ref,
836 		 int action),
837 
838 	TP_ARGS(fs_info, ref, full_ref, action)
839 );
840 
841 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
842 
843 	TP_PROTO(const struct btrfs_fs_info *fs_info,
844 		 const struct btrfs_delayed_ref_node *ref,
845 		 const struct btrfs_delayed_data_ref *full_ref,
846 		 int action),
847 
848 	TP_ARGS(fs_info, ref, full_ref, action),
849 
850 	TP_STRUCT__entry_btrfs(
851 		__field(	u64,  bytenr		)
852 		__field(	u64,  num_bytes		)
853 		__field(	int,  action		)
854 		__field(	u64,  parent		)
855 		__field(	u64,  ref_root		)
856 		__field(	u64,  owner		)
857 		__field(	u64,  offset		)
858 		__field(	int,  type		)
859 		__field(	u64,  seq		)
860 	),
861 
862 	TP_fast_assign_btrfs(fs_info,
863 		__entry->bytenr		= ref->bytenr;
864 		__entry->num_bytes	= ref->num_bytes;
865 		__entry->action		= action;
866 		__entry->parent		= full_ref->parent;
867 		__entry->ref_root	= full_ref->root;
868 		__entry->owner		= full_ref->objectid;
869 		__entry->offset		= full_ref->offset;
870 		__entry->type		= ref->type;
871 		__entry->seq		= ref->seq;
872 	),
873 
874 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
875 		  "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
876 		  "offset=%llu type=%s seq=%llu",
877 		  __entry->bytenr,
878 		  __entry->num_bytes,
879 		  show_ref_action(__entry->action),
880 		  show_root_type(__entry->parent),
881 		  show_root_type(__entry->ref_root),
882 		  __entry->owner,
883 		  __entry->offset,
884 		  show_ref_type(__entry->type),
885 		  __entry->seq)
886 );
887 
888 DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
889 
890 	TP_PROTO(const struct btrfs_fs_info *fs_info,
891 		 const struct btrfs_delayed_ref_node *ref,
892 		 const struct btrfs_delayed_data_ref *full_ref,
893 		 int action),
894 
895 	TP_ARGS(fs_info, ref, full_ref, action)
896 );
897 
898 DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
899 
900 	TP_PROTO(const struct btrfs_fs_info *fs_info,
901 		 const struct btrfs_delayed_ref_node *ref,
902 		 const struct btrfs_delayed_data_ref *full_ref,
903 		 int action),
904 
905 	TP_ARGS(fs_info, ref, full_ref, action)
906 );
907 
908 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
909 
910 	TP_PROTO(const struct btrfs_fs_info *fs_info,
911 		 const struct btrfs_delayed_ref_head *head_ref,
912 		 int action),
913 
914 	TP_ARGS(fs_info, head_ref, action),
915 
916 	TP_STRUCT__entry_btrfs(
917 		__field(	u64,  bytenr		)
918 		__field(	u64,  num_bytes		)
919 		__field(	int,  action		)
920 		__field(	int,  is_data		)
921 	),
922 
923 	TP_fast_assign_btrfs(fs_info,
924 		__entry->bytenr		= head_ref->bytenr;
925 		__entry->num_bytes	= head_ref->num_bytes;
926 		__entry->action		= action;
927 		__entry->is_data	= head_ref->is_data;
928 	),
929 
930 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
931 		  __entry->bytenr,
932 		  __entry->num_bytes,
933 		  show_ref_action(__entry->action),
934 		  __entry->is_data)
935 );
936 
937 DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
938 
939 	TP_PROTO(const struct btrfs_fs_info *fs_info,
940 		 const struct btrfs_delayed_ref_head *head_ref,
941 		 int action),
942 
943 	TP_ARGS(fs_info, head_ref, action)
944 );
945 
946 DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
947 
948 	TP_PROTO(const struct btrfs_fs_info *fs_info,
949 		 const struct btrfs_delayed_ref_head *head_ref,
950 		 int action),
951 
952 	TP_ARGS(fs_info, head_ref, action)
953 );
954 
955 #define show_chunk_type(type)					\
956 	__print_flags(type, "|",				\
957 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
958 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
959 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
960 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
961 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
962 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
963 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
964 		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
965 		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
966 
967 DECLARE_EVENT_CLASS(btrfs__chunk,
968 
969 	TP_PROTO(const struct btrfs_fs_info *fs_info,
970 		 const struct map_lookup *map, u64 offset, u64 size),
971 
972 	TP_ARGS(fs_info, map, offset, size),
973 
974 	TP_STRUCT__entry_btrfs(
975 		__field(	int,  num_stripes		)
976 		__field(	u64,  type			)
977 		__field(	int,  sub_stripes		)
978 		__field(	u64,  offset			)
979 		__field(	u64,  size			)
980 		__field(	u64,  root_objectid		)
981 	),
982 
983 	TP_fast_assign_btrfs(fs_info,
984 		__entry->num_stripes	= map->num_stripes;
985 		__entry->type		= map->type;
986 		__entry->sub_stripes	= map->sub_stripes;
987 		__entry->offset		= offset;
988 		__entry->size		= size;
989 		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
990 	),
991 
992 	TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
993 		  "num_stripes=%d sub_stripes=%d type=%s",
994 		  show_root_type(__entry->root_objectid),
995 		  __entry->offset,
996 		  __entry->size,
997 		  __entry->num_stripes, __entry->sub_stripes,
998 		  show_chunk_type(__entry->type))
999 );
1000 
1001 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
1002 
1003 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1004 		 const struct map_lookup *map, u64 offset, u64 size),
1005 
1006 	TP_ARGS(fs_info, map, offset, size)
1007 );
1008 
1009 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
1010 
1011 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1012 		 const struct map_lookup *map, u64 offset, u64 size),
1013 
1014 	TP_ARGS(fs_info, map, offset, size)
1015 );
1016 
1017 TRACE_EVENT(btrfs_cow_block,
1018 
1019 	TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
1020 		 const struct extent_buffer *cow),
1021 
1022 	TP_ARGS(root, buf, cow),
1023 
1024 	TP_STRUCT__entry_btrfs(
1025 		__field(	u64,  root_objectid		)
1026 		__field(	u64,  buf_start			)
1027 		__field(	int,  refs			)
1028 		__field(	u64,  cow_start			)
1029 		__field(	int,  buf_level			)
1030 		__field(	int,  cow_level			)
1031 	),
1032 
1033 	TP_fast_assign_btrfs(root->fs_info,
1034 		__entry->root_objectid	= root->root_key.objectid;
1035 		__entry->buf_start	= buf->start;
1036 		__entry->refs		= atomic_read(&buf->refs);
1037 		__entry->cow_start	= cow->start;
1038 		__entry->buf_level	= btrfs_header_level(buf);
1039 		__entry->cow_level	= btrfs_header_level(cow);
1040 	),
1041 
1042 	TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
1043 		  "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
1044 		  show_root_type(__entry->root_objectid),
1045 		  __entry->refs,
1046 		  __entry->buf_start,
1047 		  __entry->buf_level,
1048 		  __entry->cow_start,
1049 		  __entry->cow_level)
1050 );
1051 
1052 TRACE_EVENT(btrfs_space_reservation,
1053 
1054 	TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val,
1055 		 u64 bytes, int reserve),
1056 
1057 	TP_ARGS(fs_info, type, val, bytes, reserve),
1058 
1059 	TP_STRUCT__entry_btrfs(
1060 		__string(	type,	type			)
1061 		__field(	u64,	val			)
1062 		__field(	u64,	bytes			)
1063 		__field(	int,	reserve			)
1064 	),
1065 
1066 	TP_fast_assign_btrfs(fs_info,
1067 		__assign_str(type, type);
1068 		__entry->val		= val;
1069 		__entry->bytes		= bytes;
1070 		__entry->reserve	= reserve;
1071 	),
1072 
1073 	TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
1074 			__entry->reserve ? "reserve" : "release",
1075 			__entry->bytes)
1076 );
1077 
1078 TRACE_EVENT(btrfs_trigger_flush,
1079 
1080 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
1081 		 int flush, const char *reason),
1082 
1083 	TP_ARGS(fs_info, flags, bytes, flush, reason),
1084 
1085 	TP_STRUCT__entry_btrfs(
1086 		__field(	u64,	flags			)
1087 		__field(	u64,	bytes			)
1088 		__field(	int,	flush			)
1089 		__string(	reason,	reason			)
1090 	),
1091 
1092 	TP_fast_assign_btrfs(fs_info,
1093 		__entry->flags	= flags;
1094 		__entry->bytes	= bytes;
1095 		__entry->flush	= flush;
1096 		__assign_str(reason, reason);
1097 	),
1098 
1099 	TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
1100 		  __get_str(reason), __entry->flush,
1101 		  __print_symbolic(__entry->flush, FLUSH_ACTIONS),
1102 		  __entry->flags,
1103 		  __print_flags((unsigned long)__entry->flags, "|",
1104 				BTRFS_GROUP_FLAGS),
1105 		  __entry->bytes)
1106 );
1107 
1108 
1109 TRACE_EVENT(btrfs_flush_space,
1110 
1111 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
1112 		 int state, int ret, bool for_preempt),
1113 
1114 	TP_ARGS(fs_info, flags, num_bytes, state, ret, for_preempt),
1115 
1116 	TP_STRUCT__entry_btrfs(
1117 		__field(	u64,	flags			)
1118 		__field(	u64,	num_bytes		)
1119 		__field(	int,	state			)
1120 		__field(	int,	ret			)
1121 		__field(       bool,	for_preempt		)
1122 	),
1123 
1124 	TP_fast_assign_btrfs(fs_info,
1125 		__entry->flags		=	flags;
1126 		__entry->num_bytes	=	num_bytes;
1127 		__entry->state		=	state;
1128 		__entry->ret		=	ret;
1129 		__entry->for_preempt	=	for_preempt;
1130 	),
1131 
1132 	TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d for_preempt=%d",
1133 		  __entry->state,
1134 		  __print_symbolic(__entry->state, FLUSH_STATES),
1135 		  __entry->flags,
1136 		  __print_flags((unsigned long)__entry->flags, "|",
1137 				BTRFS_GROUP_FLAGS),
1138 		  __entry->num_bytes, __entry->ret, __entry->for_preempt)
1139 );
1140 
1141 DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1142 
1143 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1144 
1145 	TP_ARGS(fs_info, start, len),
1146 
1147 	TP_STRUCT__entry_btrfs(
1148 		__field(	u64,  start			)
1149 		__field(	u64,  len			)
1150 	),
1151 
1152 	TP_fast_assign_btrfs(fs_info,
1153 		__entry->start		= start;
1154 		__entry->len		= len;
1155 	),
1156 
1157 	TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
1158 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1159 		  __entry->start,
1160 		  __entry->len)
1161 );
1162 
1163 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
1164 
1165 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1166 
1167 	TP_ARGS(fs_info, start, len)
1168 );
1169 
1170 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
1171 
1172 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1173 
1174 	TP_ARGS(fs_info, start, len)
1175 );
1176 
1177 TRACE_EVENT(find_free_extent,
1178 
1179 	TP_PROTO(const struct btrfs_root *root, u64 num_bytes,
1180 		 u64 empty_size, u64 data),
1181 
1182 	TP_ARGS(root, num_bytes, empty_size, data),
1183 
1184 	TP_STRUCT__entry_btrfs(
1185 		__field(	u64,	root_objectid		)
1186 		__field(	u64,	num_bytes		)
1187 		__field(	u64,	empty_size		)
1188 		__field(	u64,	data			)
1189 	),
1190 
1191 	TP_fast_assign_btrfs(root->fs_info,
1192 		__entry->root_objectid	= root->root_key.objectid;
1193 		__entry->num_bytes	= num_bytes;
1194 		__entry->empty_size	= empty_size;
1195 		__entry->data		= data;
1196 	),
1197 
1198 	TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
1199 		  show_root_type(__entry->root_objectid),
1200 		  __entry->num_bytes, __entry->empty_size, __entry->data,
1201 		  __print_flags((unsigned long)__entry->data, "|",
1202 				 BTRFS_GROUP_FLAGS))
1203 );
1204 
1205 DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1206 
1207 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
1208 		 u64 len),
1209 
1210 	TP_ARGS(block_group, start, len),
1211 
1212 	TP_STRUCT__entry_btrfs(
1213 		__field(	u64,	bg_objectid		)
1214 		__field(	u64,	flags			)
1215 		__field(	u64,	start			)
1216 		__field(	u64,	len			)
1217 	),
1218 
1219 	TP_fast_assign_btrfs(block_group->fs_info,
1220 		__entry->bg_objectid	= block_group->start;
1221 		__entry->flags		= block_group->flags;
1222 		__entry->start		= start;
1223 		__entry->len		= len;
1224 	),
1225 
1226 	TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
1227 		  "start=%llu len=%llu",
1228 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1229 		  __entry->bg_objectid,
1230 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
1231 						"|", BTRFS_GROUP_FLAGS),
1232 		  __entry->start, __entry->len)
1233 );
1234 
1235 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1236 
1237 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
1238 		 u64 len),
1239 
1240 	TP_ARGS(block_group, start, len)
1241 );
1242 
1243 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1244 
1245 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
1246 		 u64 len),
1247 
1248 	TP_ARGS(block_group, start, len)
1249 );
1250 
1251 TRACE_EVENT(btrfs_find_cluster,
1252 
1253 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
1254 		 u64 bytes, u64 empty_size, u64 min_bytes),
1255 
1256 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1257 
1258 	TP_STRUCT__entry_btrfs(
1259 		__field(	u64,	bg_objectid		)
1260 		__field(	u64,	flags			)
1261 		__field(	u64,	start			)
1262 		__field(	u64,	bytes			)
1263 		__field(	u64,	empty_size		)
1264 		__field(	u64,	min_bytes		)
1265 	),
1266 
1267 	TP_fast_assign_btrfs(block_group->fs_info,
1268 		__entry->bg_objectid	= block_group->start;
1269 		__entry->flags		= block_group->flags;
1270 		__entry->start		= start;
1271 		__entry->bytes		= bytes;
1272 		__entry->empty_size	= empty_size;
1273 		__entry->min_bytes	= min_bytes;
1274 	),
1275 
1276 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
1277 		  "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
1278 		  __entry->flags,
1279 		  __print_flags((unsigned long)__entry->flags, "|",
1280 				BTRFS_GROUP_FLAGS), __entry->start,
1281 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
1282 );
1283 
1284 TRACE_EVENT(btrfs_failed_cluster_setup,
1285 
1286 	TP_PROTO(const struct btrfs_block_group *block_group),
1287 
1288 	TP_ARGS(block_group),
1289 
1290 	TP_STRUCT__entry_btrfs(
1291 		__field(	u64,	bg_objectid		)
1292 	),
1293 
1294 	TP_fast_assign_btrfs(block_group->fs_info,
1295 		__entry->bg_objectid	= block_group->start;
1296 	),
1297 
1298 	TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
1299 );
1300 
1301 TRACE_EVENT(btrfs_setup_cluster,
1302 
1303 	TP_PROTO(const struct btrfs_block_group *block_group,
1304 		 const struct btrfs_free_cluster *cluster,
1305 		 u64 size, int bitmap),
1306 
1307 	TP_ARGS(block_group, cluster, size, bitmap),
1308 
1309 	TP_STRUCT__entry_btrfs(
1310 		__field(	u64,	bg_objectid		)
1311 		__field(	u64,	flags			)
1312 		__field(	u64,	start			)
1313 		__field(	u64,	max_size		)
1314 		__field(	u64,	size			)
1315 		__field(	int,	bitmap			)
1316 	),
1317 
1318 	TP_fast_assign_btrfs(block_group->fs_info,
1319 		__entry->bg_objectid	= block_group->start;
1320 		__entry->flags		= block_group->flags;
1321 		__entry->start		= cluster->window_start;
1322 		__entry->max_size	= cluster->max_size;
1323 		__entry->size		= size;
1324 		__entry->bitmap		= bitmap;
1325 	),
1326 
1327 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
1328 		  "size=%llu max_size=%llu bitmap=%d",
1329 		  __entry->bg_objectid,
1330 		  __entry->flags,
1331 		  __print_flags((unsigned long)__entry->flags, "|",
1332 				BTRFS_GROUP_FLAGS), __entry->start,
1333 		  __entry->size, __entry->max_size, __entry->bitmap)
1334 );
1335 
1336 struct extent_state;
1337 TRACE_EVENT(alloc_extent_state,
1338 
1339 	TP_PROTO(const struct extent_state *state,
1340 		 gfp_t mask, unsigned long IP),
1341 
1342 	TP_ARGS(state, mask, IP),
1343 
1344 	TP_STRUCT__entry(
1345 		__field(const struct extent_state *, state)
1346 		__field(gfp_t, mask)
1347 		__field(const void*, ip)
1348 	),
1349 
1350 	TP_fast_assign(
1351 		__entry->state	= state,
1352 		__entry->mask	= mask,
1353 		__entry->ip	= (const void *)IP
1354 	),
1355 
1356 	TP_printk("state=%p mask=%s caller=%pS", __entry->state,
1357 		  show_gfp_flags(__entry->mask), __entry->ip)
1358 );
1359 
1360 TRACE_EVENT(free_extent_state,
1361 
1362 	TP_PROTO(const struct extent_state *state, unsigned long IP),
1363 
1364 	TP_ARGS(state, IP),
1365 
1366 	TP_STRUCT__entry(
1367 		__field(const struct extent_state *, state)
1368 		__field(const void*, ip)
1369 	),
1370 
1371 	TP_fast_assign(
1372 		__entry->state	= state,
1373 		__entry->ip = (const void *)IP
1374 	),
1375 
1376 	TP_printk("state=%p caller=%pS", __entry->state, __entry->ip)
1377 );
1378 
1379 DECLARE_EVENT_CLASS(btrfs__work,
1380 
1381 	TP_PROTO(const struct btrfs_work *work),
1382 
1383 	TP_ARGS(work),
1384 
1385 	TP_STRUCT__entry_btrfs(
1386 		__field(	const void *,	work			)
1387 		__field(	const void *,	wq			)
1388 		__field(	const void *,	func			)
1389 		__field(	const void *,	ordered_func		)
1390 		__field(	const void *,	ordered_free		)
1391 		__field(	const void *,	normal_work		)
1392 	),
1393 
1394 	TP_fast_assign_btrfs(btrfs_work_owner(work),
1395 		__entry->work		= work;
1396 		__entry->wq		= work->wq;
1397 		__entry->func		= work->func;
1398 		__entry->ordered_func	= work->ordered_func;
1399 		__entry->ordered_free	= work->ordered_free;
1400 		__entry->normal_work	= &work->normal_work;
1401 	),
1402 
1403 	TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
1404 		  "ordered_free=%p",
1405 		  __entry->work, __entry->normal_work, __entry->wq,
1406 		   __entry->func, __entry->ordered_func, __entry->ordered_free)
1407 );
1408 
1409 /*
1410  * For situations when the work is freed, we pass fs_info and a tag that matches
1411  * the address of the work structure so it can be paired with the scheduling
1412  * event. DO NOT add anything here that dereferences wtag.
1413  */
1414 DECLARE_EVENT_CLASS(btrfs__work__done,
1415 
1416 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
1417 
1418 	TP_ARGS(fs_info, wtag),
1419 
1420 	TP_STRUCT__entry_btrfs(
1421 		__field(	const void *,	wtag			)
1422 	),
1423 
1424 	TP_fast_assign_btrfs(fs_info,
1425 		__entry->wtag		= wtag;
1426 	),
1427 
1428 	TP_printk_btrfs("work->%p", __entry->wtag)
1429 );
1430 
1431 DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1432 
1433 	TP_PROTO(const struct btrfs_work *work),
1434 
1435 	TP_ARGS(work)
1436 );
1437 
1438 DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1439 
1440 	TP_PROTO(const struct btrfs_work *work),
1441 
1442 	TP_ARGS(work)
1443 );
1444 
1445 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1446 
1447 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
1448 
1449 	TP_ARGS(fs_info, wtag)
1450 );
1451 
1452 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1453 
1454 	TP_PROTO(const struct btrfs_work *work),
1455 
1456 	TP_ARGS(work)
1457 );
1458 
1459 DECLARE_EVENT_CLASS(btrfs__workqueue,
1460 
1461 	TP_PROTO(const struct __btrfs_workqueue *wq,
1462 		 const char *name, int high),
1463 
1464 	TP_ARGS(wq, name, high),
1465 
1466 	TP_STRUCT__entry_btrfs(
1467 		__field(	const void *,	wq			)
1468 		__string(	name,	name			)
1469 		__field(	int ,	high			)
1470 	),
1471 
1472 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1473 		__entry->wq		= wq;
1474 		__assign_str(name, name);
1475 		__entry->high		= high;
1476 	),
1477 
1478 	TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1479 		  __print_flags(__entry->high, "",
1480 				{(WQ_HIGHPRI),	"-high"}),
1481 		  __entry->wq)
1482 );
1483 
1484 DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1485 
1486 	TP_PROTO(const struct __btrfs_workqueue *wq,
1487 		 const char *name, int high),
1488 
1489 	TP_ARGS(wq, name, high)
1490 );
1491 
1492 DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1493 
1494 	TP_PROTO(const struct __btrfs_workqueue *wq),
1495 
1496 	TP_ARGS(wq),
1497 
1498 	TP_STRUCT__entry_btrfs(
1499 		__field(	const void *,	wq		)
1500 	),
1501 
1502 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1503 		__entry->wq		= wq;
1504 	),
1505 
1506 	TP_printk_btrfs("wq=%p", __entry->wq)
1507 );
1508 
1509 DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1510 
1511 	TP_PROTO(const struct __btrfs_workqueue *wq),
1512 
1513 	TP_ARGS(wq)
1514 );
1515 
1516 #define BTRFS_QGROUP_OPERATIONS				\
1517 	{ QGROUP_RESERVE,	"reserve"	},	\
1518 	{ QGROUP_RELEASE,	"release"	},	\
1519 	{ QGROUP_FREE,		"free"		}
1520 
1521 DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1522 
1523 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
1524 		 u64 reserved, int op),
1525 
1526 	TP_ARGS(inode, start, len, reserved, op),
1527 
1528 	TP_STRUCT__entry_btrfs(
1529 		__field(	u64,		rootid		)
1530 		__field(	u64,		ino		)
1531 		__field(	u64,		start		)
1532 		__field(	u64,		len		)
1533 		__field(	u64,		reserved	)
1534 		__field(	int,		op		)
1535 	),
1536 
1537 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
1538 		__entry->rootid		=
1539 			BTRFS_I(inode)->root->root_key.objectid;
1540 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
1541 		__entry->start		= start;
1542 		__entry->len		= len;
1543 		__entry->reserved	= reserved;
1544 		__entry->op		= op;
1545 	),
1546 
1547 	TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
1548 		  __entry->rootid, __entry->ino, __entry->start, __entry->len,
1549 		  __entry->reserved,
1550 		  __print_flags((unsigned long)__entry->op, "",
1551 				BTRFS_QGROUP_OPERATIONS)
1552 	)
1553 );
1554 
1555 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1556 
1557 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
1558 		 u64 reserved, int op),
1559 
1560 	TP_ARGS(inode, start, len, reserved, op)
1561 );
1562 
1563 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1564 
1565 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
1566 		 u64 reserved, int op),
1567 
1568 	TP_ARGS(inode, start, len, reserved, op)
1569 );
1570 
1571 DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1572 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1573 		 const struct btrfs_qgroup_extent_record *rec),
1574 
1575 	TP_ARGS(fs_info, rec),
1576 
1577 	TP_STRUCT__entry_btrfs(
1578 		__field(	u64,  bytenr		)
1579 		__field(	u64,  num_bytes		)
1580 	),
1581 
1582 	TP_fast_assign_btrfs(fs_info,
1583 		__entry->bytenr		= rec->bytenr,
1584 		__entry->num_bytes	= rec->num_bytes;
1585 	),
1586 
1587 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
1588 		  __entry->bytenr, __entry->num_bytes)
1589 );
1590 
1591 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1592 
1593 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1594 		 const struct btrfs_qgroup_extent_record *rec),
1595 
1596 	TP_ARGS(fs_info, rec)
1597 );
1598 
1599 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
1600 
1601 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1602 		 const struct btrfs_qgroup_extent_record *rec),
1603 
1604 	TP_ARGS(fs_info, rec)
1605 );
1606 
1607 TRACE_EVENT(qgroup_num_dirty_extents,
1608 
1609 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1610 		 u64 num_dirty_extents),
1611 
1612 	TP_ARGS(fs_info, transid, num_dirty_extents),
1613 
1614 	TP_STRUCT__entry_btrfs(
1615 		__field(	u64, transid			)
1616 		__field(	u64, num_dirty_extents		)
1617 	),
1618 
1619 	TP_fast_assign_btrfs(fs_info,
1620 		__entry->transid	   = transid;
1621 		__entry->num_dirty_extents = num_dirty_extents;
1622 	),
1623 
1624 	TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1625 		__entry->transid, __entry->num_dirty_extents)
1626 );
1627 
1628 TRACE_EVENT(btrfs_qgroup_account_extent,
1629 
1630 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
1631 		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
1632 
1633 	TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1634 		nr_new_roots),
1635 
1636 	TP_STRUCT__entry_btrfs(
1637 		__field(	u64,  transid			)
1638 		__field(	u64,  bytenr			)
1639 		__field(	u64,  num_bytes			)
1640 		__field(	u64,  nr_old_roots		)
1641 		__field(	u64,  nr_new_roots		)
1642 	),
1643 
1644 	TP_fast_assign_btrfs(fs_info,
1645 		__entry->transid	= transid;
1646 		__entry->bytenr		= bytenr;
1647 		__entry->num_bytes	= num_bytes;
1648 		__entry->nr_old_roots	= nr_old_roots;
1649 		__entry->nr_new_roots	= nr_new_roots;
1650 	),
1651 
1652 	TP_printk_btrfs(
1653 "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1654 		__entry->transid,
1655 		__entry->bytenr,
1656 		__entry->num_bytes,
1657 		__entry->nr_old_roots,
1658 		__entry->nr_new_roots)
1659 );
1660 
1661 TRACE_EVENT(qgroup_update_counters,
1662 
1663 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1664 		 const struct btrfs_qgroup *qgroup,
1665 		 u64 cur_old_count, u64 cur_new_count),
1666 
1667 	TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
1668 
1669 	TP_STRUCT__entry_btrfs(
1670 		__field(	u64,  qgid			)
1671 		__field(	u64,  old_rfer			)
1672 		__field(	u64,  old_excl			)
1673 		__field(	u64,  cur_old_count		)
1674 		__field(	u64,  cur_new_count		)
1675 	),
1676 
1677 	TP_fast_assign_btrfs(fs_info,
1678 		__entry->qgid		= qgroup->qgroupid;
1679 		__entry->old_rfer	= qgroup->rfer;
1680 		__entry->old_excl	= qgroup->excl;
1681 		__entry->cur_old_count	= cur_old_count;
1682 		__entry->cur_new_count	= cur_new_count;
1683 	),
1684 
1685 	TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
1686 		  __entry->qgid, __entry->old_rfer, __entry->old_excl,
1687 		  __entry->cur_old_count, __entry->cur_new_count)
1688 );
1689 
1690 TRACE_EVENT(qgroup_update_reserve,
1691 
1692 	TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
1693 		 s64 diff, int type),
1694 
1695 	TP_ARGS(fs_info, qgroup, diff, type),
1696 
1697 	TP_STRUCT__entry_btrfs(
1698 		__field(	u64,	qgid			)
1699 		__field(	u64,	cur_reserved		)
1700 		__field(	s64,	diff			)
1701 		__field(	int,	type			)
1702 	),
1703 
1704 	TP_fast_assign_btrfs(fs_info,
1705 		__entry->qgid		= qgroup->qgroupid;
1706 		__entry->cur_reserved	= qgroup->rsv.values[type];
1707 		__entry->diff		= diff;
1708 		__entry->type		= type;
1709 	),
1710 
1711 	TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
1712 		__entry->qgid, __print_symbolic(__entry->type, QGROUP_RSV_TYPES),
1713 		__entry->cur_reserved, __entry->diff)
1714 );
1715 
1716 TRACE_EVENT(qgroup_meta_reserve,
1717 
1718 	TP_PROTO(struct btrfs_root *root, s64 diff, int type),
1719 
1720 	TP_ARGS(root, diff, type),
1721 
1722 	TP_STRUCT__entry_btrfs(
1723 		__field(	u64,	refroot			)
1724 		__field(	s64,	diff			)
1725 		__field(	int,	type			)
1726 	),
1727 
1728 	TP_fast_assign_btrfs(root->fs_info,
1729 		__entry->refroot	= root->root_key.objectid;
1730 		__entry->diff		= diff;
1731 		__entry->type		= type;
1732 	),
1733 
1734 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1735 		show_root_type(__entry->refroot),
1736 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
1737 );
1738 
1739 TRACE_EVENT(qgroup_meta_convert,
1740 
1741 	TP_PROTO(struct btrfs_root *root, s64 diff),
1742 
1743 	TP_ARGS(root, diff),
1744 
1745 	TP_STRUCT__entry_btrfs(
1746 		__field(	u64,	refroot			)
1747 		__field(	s64,	diff			)
1748 	),
1749 
1750 	TP_fast_assign_btrfs(root->fs_info,
1751 		__entry->refroot	= root->root_key.objectid;
1752 		__entry->diff		= diff;
1753 	),
1754 
1755 	TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
1756 		show_root_type(__entry->refroot),
1757 		__print_symbolic(BTRFS_QGROUP_RSV_META_PREALLOC, QGROUP_RSV_TYPES),
1758 		__print_symbolic(BTRFS_QGROUP_RSV_META_PERTRANS, QGROUP_RSV_TYPES),
1759 		__entry->diff)
1760 );
1761 
1762 TRACE_EVENT(qgroup_meta_free_all_pertrans,
1763 
1764 	TP_PROTO(struct btrfs_root *root),
1765 
1766 	TP_ARGS(root),
1767 
1768 	TP_STRUCT__entry_btrfs(
1769 		__field(	u64,	refroot			)
1770 		__field(	s64,	diff			)
1771 		__field(	int,	type			)
1772 	),
1773 
1774 	TP_fast_assign_btrfs(root->fs_info,
1775 		__entry->refroot	= root->root_key.objectid;
1776 		spin_lock(&root->qgroup_meta_rsv_lock);
1777 		__entry->diff		= -(s64)root->qgroup_meta_rsv_pertrans;
1778 		spin_unlock(&root->qgroup_meta_rsv_lock);
1779 		__entry->type		= BTRFS_QGROUP_RSV_META_PERTRANS;
1780 	),
1781 
1782 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1783 		show_root_type(__entry->refroot),
1784 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
1785 );
1786 
1787 DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1788 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1789 		 const struct prelim_ref *oldref,
1790 		 const struct prelim_ref *newref, u64 tree_size),
1791 	TP_ARGS(fs_info, newref, oldref, tree_size),
1792 
1793 	TP_STRUCT__entry_btrfs(
1794 		__field(	u64,  root_id		)
1795 		__field(	u64,  objectid		)
1796 		__field(	 u8,  type		)
1797 		__field(	u64,  offset		)
1798 		__field(	int,  level		)
1799 		__field(	int,  old_count		)
1800 		__field(	u64,  parent		)
1801 		__field(	u64,  bytenr		)
1802 		__field(	int,  mod_count		)
1803 		__field(	u64,  tree_size		)
1804 	),
1805 
1806 	TP_fast_assign_btrfs(fs_info,
1807 		__entry->root_id	= oldref->root_id;
1808 		__entry->objectid	= oldref->key_for_search.objectid;
1809 		__entry->type		= oldref->key_for_search.type;
1810 		__entry->offset		= oldref->key_for_search.offset;
1811 		__entry->level		= oldref->level;
1812 		__entry->old_count	= oldref->count;
1813 		__entry->parent		= oldref->parent;
1814 		__entry->bytenr		= oldref->wanted_disk_byte;
1815 		__entry->mod_count	= newref ? newref->count : 0;
1816 		__entry->tree_size	= tree_size;
1817 	),
1818 
1819 	TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
1820 			__entry->root_id,
1821 			__entry->objectid, __entry->type,
1822 			__entry->offset, __entry->level,
1823 			__entry->old_count, __entry->mod_count,
1824 			__entry->old_count + __entry->mod_count,
1825 			__entry->parent,
1826 			__entry->bytenr,
1827 			__entry->tree_size)
1828 );
1829 
1830 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1831 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1832 		 const struct prelim_ref *oldref,
1833 		 const struct prelim_ref *newref, u64 tree_size),
1834 	TP_ARGS(fs_info, oldref, newref, tree_size)
1835 );
1836 
1837 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1838 	TP_PROTO(const struct btrfs_fs_info *fs_info,
1839 		 const struct prelim_ref *oldref,
1840 		 const struct prelim_ref *newref, u64 tree_size),
1841 	TP_ARGS(fs_info, oldref, newref, tree_size)
1842 );
1843 
1844 TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
1845 	TP_PROTO(const struct btrfs_root *root, u64 ino, int mod),
1846 
1847 	TP_ARGS(root, ino, mod),
1848 
1849 	TP_STRUCT__entry_btrfs(
1850 		__field(	u64, root_objectid	)
1851 		__field(	u64, ino		)
1852 		__field(	int, mod		)
1853 	),
1854 
1855 	TP_fast_assign_btrfs(root->fs_info,
1856 		__entry->root_objectid	= root->root_key.objectid;
1857 		__entry->ino		= ino;
1858 		__entry->mod		= mod;
1859 	),
1860 
1861 	TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1862 			show_root_type(__entry->root_objectid),
1863 			__entry->ino, __entry->mod)
1864 );
1865 
1866 DECLARE_EVENT_CLASS(btrfs__block_group,
1867 	TP_PROTO(const struct btrfs_block_group *bg_cache),
1868 
1869 	TP_ARGS(bg_cache),
1870 
1871 	TP_STRUCT__entry_btrfs(
1872 		__field(	u64,	bytenr		)
1873 		__field(	u64,	len		)
1874 		__field(	u64,	used		)
1875 		__field(	u64,	flags		)
1876 	),
1877 
1878 	TP_fast_assign_btrfs(bg_cache->fs_info,
1879 		__entry->bytenr = bg_cache->start,
1880 		__entry->len	= bg_cache->length,
1881 		__entry->used	= bg_cache->used;
1882 		__entry->flags	= bg_cache->flags;
1883 	),
1884 
1885 	TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
1886 		__entry->bytenr, __entry->len, __entry->used, __entry->flags,
1887 		__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
1888 );
1889 
1890 DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
1891 	TP_PROTO(const struct btrfs_block_group *bg_cache),
1892 
1893 	TP_ARGS(bg_cache)
1894 );
1895 
1896 DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
1897 	TP_PROTO(const struct btrfs_block_group *bg_cache),
1898 
1899 	TP_ARGS(bg_cache)
1900 );
1901 
1902 DEFINE_EVENT(btrfs__block_group, btrfs_add_reclaim_block_group,
1903 	TP_PROTO(const struct btrfs_block_group *bg_cache),
1904 
1905 	TP_ARGS(bg_cache)
1906 );
1907 
1908 DEFINE_EVENT(btrfs__block_group, btrfs_reclaim_block_group,
1909 	TP_PROTO(const struct btrfs_block_group *bg_cache),
1910 
1911 	TP_ARGS(bg_cache)
1912 );
1913 
1914 DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
1915 	TP_PROTO(const struct btrfs_block_group *bg_cache),
1916 
1917 	TP_ARGS(bg_cache)
1918 );
1919 
1920 TRACE_EVENT(btrfs_set_extent_bit,
1921 	TP_PROTO(const struct extent_io_tree *tree,
1922 		 u64 start, u64 len, unsigned set_bits),
1923 
1924 	TP_ARGS(tree, start, len, set_bits),
1925 
1926 	TP_STRUCT__entry_btrfs(
1927 		__field(	unsigned,	owner	)
1928 		__field(	u64,		ino	)
1929 		__field(	u64,		rootid	)
1930 		__field(	u64,		start	)
1931 		__field(	u64,		len	)
1932 		__field(	unsigned,	set_bits)
1933 	),
1934 
1935 	TP_fast_assign_btrfs(tree->fs_info,
1936 		__entry->owner = tree->owner;
1937 		if (tree->private_data) {
1938 			const struct inode *inode = tree->private_data;
1939 
1940 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
1941 			__entry->rootid	=
1942 				BTRFS_I(inode)->root->root_key.objectid;
1943 		} else {
1944 			__entry->ino	= 0;
1945 			__entry->rootid	= 0;
1946 		}
1947 		__entry->start		= start;
1948 		__entry->len		= len;
1949 		__entry->set_bits	= set_bits;
1950 	),
1951 
1952 	TP_printk_btrfs(
1953 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s",
1954 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
1955 		__entry->rootid, __entry->start, __entry->len,
1956 		__print_flags(__entry->set_bits, "|", EXTENT_FLAGS))
1957 );
1958 
1959 TRACE_EVENT(btrfs_clear_extent_bit,
1960 	TP_PROTO(const struct extent_io_tree *tree,
1961 		 u64 start, u64 len, unsigned clear_bits),
1962 
1963 	TP_ARGS(tree, start, len, clear_bits),
1964 
1965 	TP_STRUCT__entry_btrfs(
1966 		__field(	unsigned,	owner	)
1967 		__field(	u64,		ino	)
1968 		__field(	u64,		rootid	)
1969 		__field(	u64,		start	)
1970 		__field(	u64,		len	)
1971 		__field(	unsigned,	clear_bits)
1972 	),
1973 
1974 	TP_fast_assign_btrfs(tree->fs_info,
1975 		__entry->owner = tree->owner;
1976 		if (tree->private_data) {
1977 			const struct inode *inode = tree->private_data;
1978 
1979 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
1980 			__entry->rootid	=
1981 				BTRFS_I(inode)->root->root_key.objectid;
1982 		} else {
1983 			__entry->ino	= 0;
1984 			__entry->rootid	= 0;
1985 		}
1986 		__entry->start		= start;
1987 		__entry->len		= len;
1988 		__entry->clear_bits	= clear_bits;
1989 	),
1990 
1991 	TP_printk_btrfs(
1992 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s",
1993 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
1994 		__entry->rootid, __entry->start, __entry->len,
1995 		__print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
1996 );
1997 
1998 TRACE_EVENT(btrfs_convert_extent_bit,
1999 	TP_PROTO(const struct extent_io_tree *tree,
2000 		 u64 start, u64 len, unsigned set_bits, unsigned clear_bits),
2001 
2002 	TP_ARGS(tree, start, len, set_bits, clear_bits),
2003 
2004 	TP_STRUCT__entry_btrfs(
2005 		__field(	unsigned,	owner	)
2006 		__field(	u64,		ino	)
2007 		__field(	u64,		rootid	)
2008 		__field(	u64,		start	)
2009 		__field(	u64,		len	)
2010 		__field(	unsigned,	set_bits)
2011 		__field(	unsigned,	clear_bits)
2012 	),
2013 
2014 	TP_fast_assign_btrfs(tree->fs_info,
2015 		__entry->owner = tree->owner;
2016 		if (tree->private_data) {
2017 			const struct inode *inode = tree->private_data;
2018 
2019 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
2020 			__entry->rootid	=
2021 				BTRFS_I(inode)->root->root_key.objectid;
2022 		} else {
2023 			__entry->ino	= 0;
2024 			__entry->rootid	= 0;
2025 		}
2026 		__entry->start		= start;
2027 		__entry->len		= len;
2028 		__entry->set_bits	= set_bits;
2029 		__entry->clear_bits	= clear_bits;
2030 	),
2031 
2032 	TP_printk_btrfs(
2033 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s",
2034 		  __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2035 		  __entry->rootid, __entry->start, __entry->len,
2036 		  __print_flags(__entry->set_bits , "|", EXTENT_FLAGS),
2037 		  __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2038 );
2039 
2040 DECLARE_EVENT_CLASS(btrfs_dump_space_info,
2041 	TP_PROTO(struct btrfs_fs_info *fs_info,
2042 		 const struct btrfs_space_info *sinfo),
2043 
2044 	TP_ARGS(fs_info, sinfo),
2045 
2046 	TP_STRUCT__entry_btrfs(
2047 		__field(	u64,	flags			)
2048 		__field(	u64,	total_bytes		)
2049 		__field(	u64,	bytes_used		)
2050 		__field(	u64,	bytes_pinned		)
2051 		__field(	u64,	bytes_reserved		)
2052 		__field(	u64,	bytes_may_use		)
2053 		__field(	u64,	bytes_readonly		)
2054 		__field(	u64,	reclaim_size		)
2055 		__field(	int,	clamp			)
2056 		__field(	u64,	global_reserved		)
2057 		__field(	u64,	trans_reserved		)
2058 		__field(	u64,	delayed_refs_reserved	)
2059 		__field(	u64,	delayed_reserved	)
2060 		__field(	u64,	free_chunk_space	)
2061 		__field(	u64,	delalloc_bytes		)
2062 		__field(	u64,	ordered_bytes		)
2063 	),
2064 
2065 	TP_fast_assign_btrfs(fs_info,
2066 		__entry->flags			=	sinfo->flags;
2067 		__entry->total_bytes		=	sinfo->total_bytes;
2068 		__entry->bytes_used		=	sinfo->bytes_used;
2069 		__entry->bytes_pinned		=	sinfo->bytes_pinned;
2070 		__entry->bytes_reserved		=	sinfo->bytes_reserved;
2071 		__entry->bytes_may_use		=	sinfo->bytes_may_use;
2072 		__entry->bytes_readonly		=	sinfo->bytes_readonly;
2073 		__entry->reclaim_size		=	sinfo->reclaim_size;
2074 		__entry->clamp			=	sinfo->clamp;
2075 		__entry->global_reserved	=	fs_info->global_block_rsv.reserved;
2076 		__entry->trans_reserved		=	fs_info->trans_block_rsv.reserved;
2077 		__entry->delayed_refs_reserved	=	fs_info->delayed_refs_rsv.reserved;
2078 		__entry->delayed_reserved	=	fs_info->delayed_block_rsv.reserved;
2079 		__entry->free_chunk_space	=	atomic64_read(&fs_info->free_chunk_space);
2080 		__entry->delalloc_bytes		=	percpu_counter_sum_positive(&fs_info->delalloc_bytes);
2081 		__entry->ordered_bytes		=	percpu_counter_sum_positive(&fs_info->ordered_bytes);
2082 	),
2083 
2084 	TP_printk_btrfs("flags=%s total_bytes=%llu bytes_used=%llu "
2085 			"bytes_pinned=%llu bytes_reserved=%llu "
2086 			"bytes_may_use=%llu bytes_readonly=%llu "
2087 			"reclaim_size=%llu clamp=%d global_reserved=%llu "
2088 			"trans_reserved=%llu delayed_refs_reserved=%llu "
2089 			"delayed_reserved=%llu chunk_free_space=%llu "
2090 			"delalloc_bytes=%llu ordered_bytes=%llu",
2091 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2092 			__entry->total_bytes, __entry->bytes_used,
2093 			__entry->bytes_pinned, __entry->bytes_reserved,
2094 			__entry->bytes_may_use, __entry->bytes_readonly,
2095 			__entry->reclaim_size, __entry->clamp,
2096 			__entry->global_reserved, __entry->trans_reserved,
2097 			__entry->delayed_refs_reserved,
2098 			__entry->delayed_reserved, __entry->free_chunk_space,
2099 			__entry->delalloc_bytes, __entry->ordered_bytes)
2100 );
2101 
2102 DEFINE_EVENT(btrfs_dump_space_info, btrfs_done_preemptive_reclaim,
2103 	TP_PROTO(struct btrfs_fs_info *fs_info,
2104 		 const struct btrfs_space_info *sinfo),
2105 	TP_ARGS(fs_info, sinfo)
2106 );
2107 
2108 DEFINE_EVENT(btrfs_dump_space_info, btrfs_fail_all_tickets,
2109 	TP_PROTO(struct btrfs_fs_info *fs_info,
2110 		 const struct btrfs_space_info *sinfo),
2111 	TP_ARGS(fs_info, sinfo)
2112 );
2113 
2114 TRACE_EVENT(btrfs_reserve_ticket,
2115 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
2116 		 u64 start_ns, int flush, int error),
2117 
2118 	TP_ARGS(fs_info, flags, bytes, start_ns, flush, error),
2119 
2120 	TP_STRUCT__entry_btrfs(
2121 		__field(	u64,	flags		)
2122 		__field(	u64,	bytes		)
2123 		__field(	u64,	start_ns	)
2124 		__field(	int,	flush		)
2125 		__field(	int,	error		)
2126 	),
2127 
2128 	TP_fast_assign_btrfs(fs_info,
2129 		__entry->flags		= flags;
2130 		__entry->bytes		= bytes;
2131 		__entry->start_ns	= start_ns;
2132 		__entry->flush		= flush;
2133 		__entry->error		= error;
2134 	),
2135 
2136 	TP_printk_btrfs("flags=%s bytes=%llu start_ns=%llu flush=%s error=%d",
2137 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2138 			__entry->bytes, __entry->start_ns,
2139 			__print_symbolic(__entry->flush, FLUSH_ACTIONS),
2140 			__entry->error)
2141 );
2142 
2143 DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock,
2144 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2145 
2146 	TP_ARGS(eb, start_ns),
2147 
2148 	TP_STRUCT__entry_btrfs(
2149 		__field(	u64,	block		)
2150 		__field(	u64,	generation	)
2151 		__field(	u64,	start_ns	)
2152 		__field(	u64,	end_ns		)
2153 		__field(	u64,	diff_ns		)
2154 		__field(	u64,	owner		)
2155 		__field(	int,	is_log_tree	)
2156 	),
2157 
2158 	TP_fast_assign_btrfs(eb->fs_info,
2159 		__entry->block		= eb->start;
2160 		__entry->generation	= btrfs_header_generation(eb);
2161 		__entry->start_ns	= start_ns;
2162 		__entry->end_ns		= ktime_get_ns();
2163 		__entry->diff_ns	= __entry->end_ns - start_ns;
2164 		__entry->owner		= btrfs_header_owner(eb);
2165 		__entry->is_log_tree	= (eb->log_index >= 0);
2166 	),
2167 
2168 	TP_printk_btrfs(
2169 "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d",
2170 		__entry->block, __entry->generation,
2171 		__entry->start_ns, __entry->end_ns, __entry->diff_ns,
2172 		__entry->owner, __entry->is_log_tree)
2173 );
2174 
2175 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock,
2176 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2177 
2178 	TP_ARGS(eb, start_ns)
2179 );
2180 
2181 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock,
2182 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2183 
2184 	TP_ARGS(eb, start_ns)
2185 );
2186 
2187 DECLARE_EVENT_CLASS(btrfs_locking_events,
2188 	TP_PROTO(const struct extent_buffer *eb),
2189 
2190 	TP_ARGS(eb),
2191 
2192 	TP_STRUCT__entry_btrfs(
2193 		__field(	u64,	block		)
2194 		__field(	u64,	generation	)
2195 		__field(	u64,	owner		)
2196 		__field(	int,	is_log_tree	)
2197 	),
2198 
2199 	TP_fast_assign_btrfs(eb->fs_info,
2200 		__entry->block		= eb->start;
2201 		__entry->generation	= btrfs_header_generation(eb);
2202 		__entry->owner		= btrfs_header_owner(eb);
2203 		__entry->is_log_tree	= (eb->log_index >= 0);
2204 	),
2205 
2206 	TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d",
2207 		__entry->block, __entry->generation,
2208 		__entry->owner, __entry->is_log_tree)
2209 );
2210 
2211 #define DEFINE_BTRFS_LOCK_EVENT(name)				\
2212 DEFINE_EVENT(btrfs_locking_events, name,			\
2213 		TP_PROTO(const struct extent_buffer *eb),	\
2214 								\
2215 		TP_ARGS(eb)					\
2216 )
2217 
2218 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock);
2219 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock);
2220 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking);
2221 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read);
2222 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write);
2223 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock);
2224 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock);
2225 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic);
2226 
2227 DECLARE_EVENT_CLASS(btrfs__space_info_update,
2228 
2229 	TP_PROTO(const struct btrfs_fs_info *fs_info,
2230 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2231 
2232 	TP_ARGS(fs_info, sinfo, old, diff),
2233 
2234 	TP_STRUCT__entry_btrfs(
2235 		__field(	u64,	type		)
2236 		__field(	u64,	old		)
2237 		__field(	s64,	diff		)
2238 	),
2239 
2240 	TP_fast_assign_btrfs(fs_info,
2241 		__entry->type	= sinfo->flags;
2242 		__entry->old	= old;
2243 		__entry->diff	= diff;
2244 	),
2245 	TP_printk_btrfs("type=%s old=%llu diff=%lld",
2246 		__print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS),
2247 		__entry->old, __entry->diff)
2248 );
2249 
2250 DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use,
2251 
2252 	TP_PROTO(const struct btrfs_fs_info *fs_info,
2253 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2254 
2255 	TP_ARGS(fs_info, sinfo, old, diff)
2256 );
2257 
2258 DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned,
2259 
2260 	TP_PROTO(const struct btrfs_fs_info *fs_info,
2261 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2262 
2263 	TP_ARGS(fs_info, sinfo, old, diff)
2264 );
2265 
2266 #endif /* _TRACE_BTRFS_H */
2267 
2268 /* This part must be outside protection */
2269 #include <trace/define_trace.h>
2270