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