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