xref: /openbmc/linux/include/trace/events/btrfs.h (revision 37185b33)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM btrfs
3 
4 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BTRFS_H
6 
7 #include <linux/writeback.h>
8 #include <linux/tracepoint.h>
9 #include <trace/events/gfpflags.h>
10 
11 struct btrfs_root;
12 struct btrfs_fs_info;
13 struct btrfs_inode;
14 struct extent_map;
15 struct btrfs_ordered_extent;
16 struct btrfs_delayed_ref_node;
17 struct btrfs_delayed_tree_ref;
18 struct btrfs_delayed_data_ref;
19 struct btrfs_delayed_ref_head;
20 struct btrfs_block_group_cache;
21 struct btrfs_free_cluster;
22 struct map_lookup;
23 struct extent_buffer;
24 
25 #define show_ref_type(type)						\
26 	__print_symbolic(type,						\
27 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
28 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
29 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
30 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
31 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
32 
33 #define __show_root_type(obj)						\
34 	__print_symbolic_u64(obj,					\
35 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
36 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
37 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
38 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
39 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
40 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
41 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
42 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
43 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
44 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
45 
46 #define show_root_type(obj)						\
47 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
48 	      (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-"
49 
50 #define BTRFS_GROUP_FLAGS	\
51 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"}, \
52 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"}, \
53 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"}, \
54 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, \
55 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, \
56 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, \
57 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}
58 
59 #define BTRFS_UUID_SIZE 16
60 
61 TRACE_EVENT(btrfs_transaction_commit,
62 
63 	TP_PROTO(struct btrfs_root *root),
64 
65 	TP_ARGS(root),
66 
67 	TP_STRUCT__entry(
68 		__field(	u64,  generation		)
69 		__field(	u64,  root_objectid		)
70 	),
71 
72 	TP_fast_assign(
73 		__entry->generation	= root->fs_info->generation;
74 		__entry->root_objectid	= root->root_key.objectid;
75 	),
76 
77 	TP_printk("root = %llu(%s), gen = %llu",
78 		  show_root_type(__entry->root_objectid),
79 		  (unsigned long long)__entry->generation)
80 );
81 
82 DECLARE_EVENT_CLASS(btrfs__inode,
83 
84 	TP_PROTO(struct inode *inode),
85 
86 	TP_ARGS(inode),
87 
88 	TP_STRUCT__entry(
89 		__field(	ino_t,  ino			)
90 		__field(	blkcnt_t,  blocks		)
91 		__field(	u64,  disk_i_size		)
92 		__field(	u64,  generation		)
93 		__field(	u64,  last_trans		)
94 		__field(	u64,  logged_trans		)
95 		__field(	u64,  root_objectid		)
96 	),
97 
98 	TP_fast_assign(
99 		__entry->ino	= inode->i_ino;
100 		__entry->blocks	= inode->i_blocks;
101 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
102 		__entry->generation = BTRFS_I(inode)->generation;
103 		__entry->last_trans = BTRFS_I(inode)->last_trans;
104 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
105 		__entry->root_objectid =
106 				BTRFS_I(inode)->root->root_key.objectid;
107 	),
108 
109 	TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
110 		  "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
111 		  show_root_type(__entry->root_objectid),
112 		  (unsigned long long)__entry->generation,
113 		  (unsigned long)__entry->ino,
114 		  (unsigned long long)__entry->blocks,
115 		  (unsigned long long)__entry->disk_i_size,
116 		  (unsigned long long)__entry->last_trans,
117 		  (unsigned long long)__entry->logged_trans)
118 );
119 
120 DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
121 
122 	TP_PROTO(struct inode *inode),
123 
124 	TP_ARGS(inode)
125 );
126 
127 DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
128 
129 	TP_PROTO(struct inode *inode),
130 
131 	TP_ARGS(inode)
132 );
133 
134 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
135 
136 	TP_PROTO(struct inode *inode),
137 
138 	TP_ARGS(inode)
139 );
140 
141 #define __show_map_type(type)						\
142 	__print_symbolic_u64(type,					\
143 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
144 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
145 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
146 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
147 
148 #define show_map_type(type)			\
149 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
150 
151 #define show_map_flags(flag)						\
152 	__print_flags(flag, "|",					\
153 		{ EXTENT_FLAG_PINNED, 		"PINNED" 	},	\
154 		{ EXTENT_FLAG_COMPRESSED, 	"COMPRESSED" 	},	\
155 		{ EXTENT_FLAG_VACANCY, 		"VACANCY" 	},	\
156 		{ EXTENT_FLAG_PREALLOC, 	"PREALLOC" 	})
157 
158 TRACE_EVENT(btrfs_get_extent,
159 
160 	TP_PROTO(struct btrfs_root *root, struct extent_map *map),
161 
162 	TP_ARGS(root, map),
163 
164 	TP_STRUCT__entry(
165 		__field(	u64,  root_objectid	)
166 		__field(	u64,  start		)
167 		__field(	u64,  len		)
168 		__field(	u64,  orig_start	)
169 		__field(	u64,  block_start	)
170 		__field(	u64,  block_len		)
171 		__field(	unsigned long,  flags	)
172 		__field(	int,  refs		)
173 		__field(	unsigned int,  compress_type	)
174 	),
175 
176 	TP_fast_assign(
177 		__entry->root_objectid	= root->root_key.objectid;
178 		__entry->start 		= map->start;
179 		__entry->len		= map->len;
180 		__entry->orig_start	= map->orig_start;
181 		__entry->block_start	= map->block_start;
182 		__entry->block_len	= map->block_len;
183 		__entry->flags		= map->flags;
184 		__entry->refs		= atomic_read(&map->refs);
185 		__entry->compress_type	= map->compress_type;
186 	),
187 
188 	TP_printk("root = %llu(%s), start = %llu, len = %llu, "
189 		  "orig_start = %llu, block_start = %llu(%s), "
190 		  "block_len = %llu, flags = %s, refs = %u, "
191 		  "compress_type = %u",
192 		  show_root_type(__entry->root_objectid),
193 		  (unsigned long long)__entry->start,
194 		  (unsigned long long)__entry->len,
195 		  (unsigned long long)__entry->orig_start,
196 		  show_map_type(__entry->block_start),
197 		  (unsigned long long)__entry->block_len,
198 		  show_map_flags(__entry->flags),
199 		  __entry->refs, __entry->compress_type)
200 );
201 
202 #define show_ordered_flags(flags)					\
203 	__print_symbolic(flags,					\
204 		{ BTRFS_ORDERED_IO_DONE, 	"IO_DONE" 	},	\
205 		{ BTRFS_ORDERED_COMPLETE, 	"COMPLETE" 	},	\
206 		{ BTRFS_ORDERED_NOCOW, 		"NOCOW" 	},	\
207 		{ BTRFS_ORDERED_COMPRESSED, 	"COMPRESSED" 	},	\
208 		{ BTRFS_ORDERED_PREALLOC, 	"PREALLOC" 	},	\
209 		{ BTRFS_ORDERED_DIRECT, 	"DIRECT" 	})
210 
211 DECLARE_EVENT_CLASS(btrfs__ordered_extent,
212 
213 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
214 
215 	TP_ARGS(inode, ordered),
216 
217 	TP_STRUCT__entry(
218 		__field(	ino_t,  ino		)
219 		__field(	u64,  file_offset	)
220 		__field(	u64,  start		)
221 		__field(	u64,  len		)
222 		__field(	u64,  disk_len		)
223 		__field(	u64,  bytes_left	)
224 		__field(	unsigned long,  flags	)
225 		__field(	int,  compress_type	)
226 		__field(	int,  refs		)
227 		__field(	u64,  root_objectid	)
228 	),
229 
230 	TP_fast_assign(
231 		__entry->ino 		= inode->i_ino;
232 		__entry->file_offset	= ordered->file_offset;
233 		__entry->start		= ordered->start;
234 		__entry->len		= ordered->len;
235 		__entry->disk_len	= ordered->disk_len;
236 		__entry->bytes_left	= ordered->bytes_left;
237 		__entry->flags		= ordered->flags;
238 		__entry->compress_type	= ordered->compress_type;
239 		__entry->refs		= atomic_read(&ordered->refs);
240 		__entry->root_objectid	=
241 				BTRFS_I(inode)->root->root_key.objectid;
242 	),
243 
244 	TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
245 		  "start = %llu, len = %llu, disk_len = %llu, "
246 		  "bytes_left = %llu, flags = %s, compress_type = %d, "
247 		  "refs = %d",
248 		  show_root_type(__entry->root_objectid),
249 		  (unsigned long long)__entry->ino,
250 		  (unsigned long long)__entry->file_offset,
251 		  (unsigned long long)__entry->start,
252 		  (unsigned long long)__entry->len,
253 		  (unsigned long long)__entry->disk_len,
254 		  (unsigned long long)__entry->bytes_left,
255 		  show_ordered_flags(__entry->flags),
256 		  __entry->compress_type, __entry->refs)
257 );
258 
259 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
260 
261 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
262 
263 	TP_ARGS(inode, ordered)
264 );
265 
266 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
267 
268 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
269 
270 	TP_ARGS(inode, ordered)
271 );
272 
273 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
274 
275 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
276 
277 	TP_ARGS(inode, ordered)
278 );
279 
280 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
281 
282 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
283 
284 	TP_ARGS(inode, ordered)
285 );
286 
287 DECLARE_EVENT_CLASS(btrfs__writepage,
288 
289 	TP_PROTO(struct page *page, struct inode *inode,
290 		 struct writeback_control *wbc),
291 
292 	TP_ARGS(page, inode, wbc),
293 
294 	TP_STRUCT__entry(
295 		__field(	ino_t,  ino			)
296 		__field(	pgoff_t,  index			)
297 		__field(	long,   nr_to_write		)
298 		__field(	long,   pages_skipped		)
299 		__field(	loff_t, range_start		)
300 		__field(	loff_t, range_end		)
301 		__field(	char,   for_kupdate		)
302 		__field(	char,   for_reclaim		)
303 		__field(	char,   range_cyclic		)
304 		__field(	pgoff_t,  writeback_index	)
305 		__field(	u64,    root_objectid		)
306 	),
307 
308 	TP_fast_assign(
309 		__entry->ino		= inode->i_ino;
310 		__entry->index		= page->index;
311 		__entry->nr_to_write	= wbc->nr_to_write;
312 		__entry->pages_skipped	= wbc->pages_skipped;
313 		__entry->range_start	= wbc->range_start;
314 		__entry->range_end	= wbc->range_end;
315 		__entry->for_kupdate	= wbc->for_kupdate;
316 		__entry->for_reclaim	= wbc->for_reclaim;
317 		__entry->range_cyclic	= wbc->range_cyclic;
318 		__entry->writeback_index = inode->i_mapping->writeback_index;
319 		__entry->root_objectid	=
320 				 BTRFS_I(inode)->root->root_key.objectid;
321 	),
322 
323 	TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
324 		  "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
325 		  "range_end = %llu, for_kupdate = %d, "
326 		  "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
327 		  show_root_type(__entry->root_objectid),
328 		  (unsigned long)__entry->ino, __entry->index,
329 		  __entry->nr_to_write, __entry->pages_skipped,
330 		  __entry->range_start, __entry->range_end,
331 		  __entry->for_kupdate,
332 		  __entry->for_reclaim, __entry->range_cyclic,
333 		  (unsigned long)__entry->writeback_index)
334 );
335 
336 DEFINE_EVENT(btrfs__writepage, __extent_writepage,
337 
338 	TP_PROTO(struct page *page, struct inode *inode,
339 		 struct writeback_control *wbc),
340 
341 	TP_ARGS(page, inode, wbc)
342 );
343 
344 TRACE_EVENT(btrfs_writepage_end_io_hook,
345 
346 	TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
347 
348 	TP_ARGS(page, start, end, uptodate),
349 
350 	TP_STRUCT__entry(
351 		__field(	ino_t,	 ino		)
352 		__field(	pgoff_t, index		)
353 		__field(	u64,	 start		)
354 		__field(	u64,	 end		)
355 		__field(	int,	 uptodate	)
356 		__field(	u64,    root_objectid	)
357 	),
358 
359 	TP_fast_assign(
360 		__entry->ino	= page->mapping->host->i_ino;
361 		__entry->index	= page->index;
362 		__entry->start	= start;
363 		__entry->end	= end;
364 		__entry->uptodate = uptodate;
365 		__entry->root_objectid	=
366 			 BTRFS_I(page->mapping->host)->root->root_key.objectid;
367 	),
368 
369 	TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
370 		  "end = %llu, uptodate = %d",
371 		  show_root_type(__entry->root_objectid),
372 		  (unsigned long)__entry->ino, (unsigned long)__entry->index,
373 		  (unsigned long long)__entry->start,
374 		  (unsigned long long)__entry->end, __entry->uptodate)
375 );
376 
377 TRACE_EVENT(btrfs_sync_file,
378 
379 	TP_PROTO(struct file *file, int datasync),
380 
381 	TP_ARGS(file, datasync),
382 
383 	TP_STRUCT__entry(
384 		__field(	ino_t,  ino		)
385 		__field(	ino_t,  parent		)
386 		__field(	int,    datasync	)
387 		__field(	u64,    root_objectid	)
388 	),
389 
390 	TP_fast_assign(
391 		struct dentry *dentry = file->f_path.dentry;
392 		struct inode *inode = dentry->d_inode;
393 
394 		__entry->ino		= inode->i_ino;
395 		__entry->parent		= dentry->d_parent->d_inode->i_ino;
396 		__entry->datasync	= datasync;
397 		__entry->root_objectid	=
398 				 BTRFS_I(inode)->root->root_key.objectid;
399 	),
400 
401 	TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
402 		  show_root_type(__entry->root_objectid),
403 		  (unsigned long)__entry->ino, (unsigned long)__entry->parent,
404 		  __entry->datasync)
405 );
406 
407 TRACE_EVENT(btrfs_sync_fs,
408 
409 	TP_PROTO(int wait),
410 
411 	TP_ARGS(wait),
412 
413 	TP_STRUCT__entry(
414 		__field(	int,  wait		)
415 	),
416 
417 	TP_fast_assign(
418 		__entry->wait	= wait;
419 	),
420 
421 	TP_printk("wait = %d", __entry->wait)
422 );
423 
424 #define show_ref_action(action)						\
425 	__print_symbolic(action,					\
426 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
427 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
428 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
429 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
430 
431 
432 TRACE_EVENT(btrfs_delayed_tree_ref,
433 
434 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
435 		 struct btrfs_delayed_tree_ref *full_ref,
436 		 int action),
437 
438 	TP_ARGS(ref, full_ref, action),
439 
440 	TP_STRUCT__entry(
441 		__field(	u64,  bytenr		)
442 		__field(	u64,  num_bytes		)
443 		__field(	int,  action		)
444 		__field(	u64,  parent		)
445 		__field(	u64,  ref_root		)
446 		__field(	int,  level		)
447 		__field(	int,  type		)
448 	),
449 
450 	TP_fast_assign(
451 		__entry->bytenr		= ref->bytenr;
452 		__entry->num_bytes	= ref->num_bytes;
453 		__entry->action		= action;
454 		__entry->parent		= full_ref->parent;
455 		__entry->ref_root	= full_ref->root;
456 		__entry->level		= full_ref->level;
457 		__entry->type		= ref->type;
458 	),
459 
460 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
461 		  "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
462 		  "type = %s",
463 		  (unsigned long long)__entry->bytenr,
464 		  (unsigned long long)__entry->num_bytes,
465 		  show_ref_action(__entry->action),
466 		  show_root_type(__entry->parent),
467 		  show_root_type(__entry->ref_root),
468 		  __entry->level, show_ref_type(__entry->type))
469 );
470 
471 TRACE_EVENT(btrfs_delayed_data_ref,
472 
473 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
474 		 struct btrfs_delayed_data_ref *full_ref,
475 		 int action),
476 
477 	TP_ARGS(ref, full_ref, action),
478 
479 	TP_STRUCT__entry(
480 		__field(	u64,  bytenr		)
481 		__field(	u64,  num_bytes		)
482 		__field(	int,  action		)
483 		__field(	u64,  parent		)
484 		__field(	u64,  ref_root		)
485 		__field(	u64,  owner		)
486 		__field(	u64,  offset		)
487 		__field(	int,  type		)
488 	),
489 
490 	TP_fast_assign(
491 		__entry->bytenr		= ref->bytenr;
492 		__entry->num_bytes	= ref->num_bytes;
493 		__entry->action		= action;
494 		__entry->parent		= full_ref->parent;
495 		__entry->ref_root	= full_ref->root;
496 		__entry->owner		= full_ref->objectid;
497 		__entry->offset		= full_ref->offset;
498 		__entry->type		= ref->type;
499 	),
500 
501 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
502 		  "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
503 		  "offset = %llu, type = %s",
504 		  (unsigned long long)__entry->bytenr,
505 		  (unsigned long long)__entry->num_bytes,
506 		  show_ref_action(__entry->action),
507 		  show_root_type(__entry->parent),
508 		  show_root_type(__entry->ref_root),
509 		  (unsigned long long)__entry->owner,
510 		  (unsigned long long)__entry->offset,
511 		  show_ref_type(__entry->type))
512 );
513 
514 TRACE_EVENT(btrfs_delayed_ref_head,
515 
516 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
517 		 struct btrfs_delayed_ref_head *head_ref,
518 		 int action),
519 
520 	TP_ARGS(ref, head_ref, action),
521 
522 	TP_STRUCT__entry(
523 		__field(	u64,  bytenr		)
524 		__field(	u64,  num_bytes		)
525 		__field(	int,  action		)
526 		__field(	int,  is_data		)
527 	),
528 
529 	TP_fast_assign(
530 		__entry->bytenr		= ref->bytenr;
531 		__entry->num_bytes	= ref->num_bytes;
532 		__entry->action		= action;
533 		__entry->is_data	= head_ref->is_data;
534 	),
535 
536 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
537 		  (unsigned long long)__entry->bytenr,
538 		  (unsigned long long)__entry->num_bytes,
539 		  show_ref_action(__entry->action),
540 		  __entry->is_data)
541 );
542 
543 #define show_chunk_type(type)					\
544 	__print_flags(type, "|",				\
545 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
546 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
547 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
548 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
549 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
550 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
551 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"})
552 
553 DECLARE_EVENT_CLASS(btrfs__chunk,
554 
555 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
556 		 u64 offset, u64 size),
557 
558 	TP_ARGS(root, map, offset, size),
559 
560 	TP_STRUCT__entry(
561 		__field(	int,  num_stripes		)
562 		__field(	u64,  type			)
563 		__field(	int,  sub_stripes		)
564 		__field(	u64,  offset			)
565 		__field(	u64,  size			)
566 		__field(	u64,  root_objectid		)
567 	),
568 
569 	TP_fast_assign(
570 		__entry->num_stripes	= map->num_stripes;
571 		__entry->type		= map->type;
572 		__entry->sub_stripes	= map->sub_stripes;
573 		__entry->offset		= offset;
574 		__entry->size		= size;
575 		__entry->root_objectid	= root->root_key.objectid;
576 	),
577 
578 	TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
579 		  "num_stripes = %d, sub_stripes = %d, type = %s",
580 		  show_root_type(__entry->root_objectid),
581 		  (unsigned long long)__entry->offset,
582 		  (unsigned long long)__entry->size,
583 		  __entry->num_stripes, __entry->sub_stripes,
584 		  show_chunk_type(__entry->type))
585 );
586 
587 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
588 
589 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
590 		 u64 offset, u64 size),
591 
592 	TP_ARGS(root, map, offset, size)
593 );
594 
595 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
596 
597 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
598 		 u64 offset, u64 size),
599 
600 	TP_ARGS(root, map, offset, size)
601 );
602 
603 TRACE_EVENT(btrfs_cow_block,
604 
605 	TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
606 		 struct extent_buffer *cow),
607 
608 	TP_ARGS(root, buf, cow),
609 
610 	TP_STRUCT__entry(
611 		__field(	u64,  root_objectid		)
612 		__field(	u64,  buf_start			)
613 		__field(	int,  refs			)
614 		__field(	u64,  cow_start			)
615 		__field(	int,  buf_level			)
616 		__field(	int,  cow_level			)
617 	),
618 
619 	TP_fast_assign(
620 		__entry->root_objectid	= root->root_key.objectid;
621 		__entry->buf_start	= buf->start;
622 		__entry->refs		= atomic_read(&buf->refs);
623 		__entry->cow_start	= cow->start;
624 		__entry->buf_level	= btrfs_header_level(buf);
625 		__entry->cow_level	= btrfs_header_level(cow);
626 	),
627 
628 	TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
629 		  "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
630 		  show_root_type(__entry->root_objectid),
631 		  __entry->refs,
632 		  (unsigned long long)__entry->buf_start,
633 		  __entry->buf_level,
634 		  (unsigned long long)__entry->cow_start,
635 		  __entry->cow_level)
636 );
637 
638 TRACE_EVENT(btrfs_space_reservation,
639 
640 	TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
641 		 u64 bytes, int reserve),
642 
643 	TP_ARGS(fs_info, type, val, bytes, reserve),
644 
645 	TP_STRUCT__entry(
646 		__array(	u8,	fsid,	BTRFS_UUID_SIZE	)
647 		__string(	type,	type			)
648 		__field(	u64,	val			)
649 		__field(	u64,	bytes			)
650 		__field(	int,	reserve			)
651 	),
652 
653 	TP_fast_assign(
654 		memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
655 		__assign_str(type, type);
656 		__entry->val		= val;
657 		__entry->bytes		= bytes;
658 		__entry->reserve	= reserve;
659 	),
660 
661 	TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
662 		  __entry->val, __entry->reserve ? "reserve" : "release",
663 		  __entry->bytes)
664 );
665 
666 DECLARE_EVENT_CLASS(btrfs__reserved_extent,
667 
668 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
669 
670 	TP_ARGS(root, start, len),
671 
672 	TP_STRUCT__entry(
673 		__field(	u64,  root_objectid		)
674 		__field(	u64,  start			)
675 		__field(	u64,  len			)
676 	),
677 
678 	TP_fast_assign(
679 		__entry->root_objectid	= root->root_key.objectid;
680 		__entry->start		= start;
681 		__entry->len		= len;
682 	),
683 
684 	TP_printk("root = %llu(%s), start = %llu, len = %llu",
685 		  show_root_type(__entry->root_objectid),
686 		  (unsigned long long)__entry->start,
687 		  (unsigned long long)__entry->len)
688 );
689 
690 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
691 
692 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
693 
694 	TP_ARGS(root, start, len)
695 );
696 
697 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
698 
699 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
700 
701 	TP_ARGS(root, start, len)
702 );
703 
704 TRACE_EVENT(find_free_extent,
705 
706 	TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
707 		 u64 data),
708 
709 	TP_ARGS(root, num_bytes, empty_size, data),
710 
711 	TP_STRUCT__entry(
712 		__field(	u64,	root_objectid		)
713 		__field(	u64,	num_bytes		)
714 		__field(	u64,	empty_size		)
715 		__field(	u64,	data			)
716 	),
717 
718 	TP_fast_assign(
719 		__entry->root_objectid	= root->root_key.objectid;
720 		__entry->num_bytes	= num_bytes;
721 		__entry->empty_size	= empty_size;
722 		__entry->data		= data;
723 	),
724 
725 	TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
726 		  "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
727 		  __entry->num_bytes, __entry->empty_size, __entry->data,
728 		  __print_flags((unsigned long)__entry->data, "|",
729 				 BTRFS_GROUP_FLAGS))
730 );
731 
732 DECLARE_EVENT_CLASS(btrfs__reserve_extent,
733 
734 	TP_PROTO(struct btrfs_root *root,
735 		 struct btrfs_block_group_cache *block_group, u64 start,
736 		 u64 len),
737 
738 	TP_ARGS(root, block_group, start, len),
739 
740 	TP_STRUCT__entry(
741 		__field(	u64,	root_objectid		)
742 		__field(	u64,	bg_objectid		)
743 		__field(	u64,	flags			)
744 		__field(	u64,	start			)
745 		__field(	u64,	len			)
746 	),
747 
748 	TP_fast_assign(
749 		__entry->root_objectid	= root->root_key.objectid;
750 		__entry->bg_objectid	= block_group->key.objectid;
751 		__entry->flags		= block_group->flags;
752 		__entry->start		= start;
753 		__entry->len		= len;
754 	),
755 
756 	TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
757 		  "start = %Lu, len = %Lu",
758 		  show_root_type(__entry->root_objectid), __entry->bg_objectid,
759 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
760 						"|", BTRFS_GROUP_FLAGS),
761 		  __entry->start, __entry->len)
762 );
763 
764 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
765 
766 	TP_PROTO(struct btrfs_root *root,
767 		 struct btrfs_block_group_cache *block_group, u64 start,
768 		 u64 len),
769 
770 	TP_ARGS(root, block_group, start, len)
771 );
772 
773 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
774 
775 	TP_PROTO(struct btrfs_root *root,
776 		 struct btrfs_block_group_cache *block_group, u64 start,
777 		 u64 len),
778 
779 	TP_ARGS(root, block_group, start, len)
780 );
781 
782 TRACE_EVENT(btrfs_find_cluster,
783 
784 	TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
785 		 u64 bytes, u64 empty_size, u64 min_bytes),
786 
787 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
788 
789 	TP_STRUCT__entry(
790 		__field(	u64,	bg_objectid		)
791 		__field(	u64,	flags			)
792 		__field(	u64,	start			)
793 		__field(	u64,	bytes			)
794 		__field(	u64,	empty_size		)
795 		__field(	u64,	min_bytes		)
796 	),
797 
798 	TP_fast_assign(
799 		__entry->bg_objectid	= block_group->key.objectid;
800 		__entry->flags		= block_group->flags;
801 		__entry->start		= start;
802 		__entry->bytes		= bytes;
803 		__entry->empty_size	= empty_size;
804 		__entry->min_bytes	= min_bytes;
805 	),
806 
807 	TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
808 		  " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
809 		  __entry->flags,
810 		  __print_flags((unsigned long)__entry->flags, "|",
811 				BTRFS_GROUP_FLAGS), __entry->start,
812 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
813 );
814 
815 TRACE_EVENT(btrfs_failed_cluster_setup,
816 
817 	TP_PROTO(struct btrfs_block_group_cache *block_group),
818 
819 	TP_ARGS(block_group),
820 
821 	TP_STRUCT__entry(
822 		__field(	u64,	bg_objectid		)
823 	),
824 
825 	TP_fast_assign(
826 		__entry->bg_objectid	= block_group->key.objectid;
827 	),
828 
829 	TP_printk("block_group = %Lu", __entry->bg_objectid)
830 );
831 
832 TRACE_EVENT(btrfs_setup_cluster,
833 
834 	TP_PROTO(struct btrfs_block_group_cache *block_group,
835 		 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
836 
837 	TP_ARGS(block_group, cluster, size, bitmap),
838 
839 	TP_STRUCT__entry(
840 		__field(	u64,	bg_objectid		)
841 		__field(	u64,	flags			)
842 		__field(	u64,	start			)
843 		__field(	u64,	max_size		)
844 		__field(	u64,	size			)
845 		__field(	int,	bitmap			)
846 	),
847 
848 	TP_fast_assign(
849 		__entry->bg_objectid	= block_group->key.objectid;
850 		__entry->flags		= block_group->flags;
851 		__entry->start		= cluster->window_start;
852 		__entry->max_size	= cluster->max_size;
853 		__entry->size		= size;
854 		__entry->bitmap		= bitmap;
855 	),
856 
857 	TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
858 		  "size = %Lu, max_size = %Lu, bitmap = %d",
859 		  __entry->bg_objectid,
860 		  __entry->flags,
861 		  __print_flags((unsigned long)__entry->flags, "|",
862 				BTRFS_GROUP_FLAGS), __entry->start,
863 		  __entry->size, __entry->max_size, __entry->bitmap)
864 );
865 
866 struct extent_state;
867 TRACE_EVENT(alloc_extent_state,
868 
869 	TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
870 
871 	TP_ARGS(state, mask, IP),
872 
873 	TP_STRUCT__entry(
874 		__field(struct extent_state *, state)
875 		__field(gfp_t, mask)
876 		__field(unsigned long, ip)
877 	),
878 
879 	TP_fast_assign(
880 		__entry->state	= state,
881 		__entry->mask	= mask,
882 		__entry->ip	= IP
883 	),
884 
885 	TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
886 		  show_gfp_flags(__entry->mask), (void *)__entry->ip)
887 );
888 
889 TRACE_EVENT(free_extent_state,
890 
891 	TP_PROTO(struct extent_state *state, unsigned long IP),
892 
893 	TP_ARGS(state, IP),
894 
895 	TP_STRUCT__entry(
896 		__field(struct extent_state *, state)
897 		__field(unsigned long, ip)
898 	),
899 
900 	TP_fast_assign(
901 		__entry->state	= state,
902 		__entry->ip = IP
903 	),
904 
905 	TP_printk(" state=%p; caller = %pF", __entry->state,
906 		  (void *)__entry->ip)
907 );
908 
909 #endif /* _TRACE_BTRFS_H */
910 
911 /* This part must be outside protection */
912 #include <trace/define_trace.h>
913