blob: 3176cdc32937f4b62cbcd11e878310f1b086f15e [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" }, \
David Sterba13fd8da2013-09-03 18:28:57 +020045 { BTRFS_UUID_TREE_OBJECTID, "UUID_RELOC" }, \
liubo1abe9b82011-03-24 11:18:59 +000046 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
47
48#define show_root_type(obj) \
49 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000050 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000051 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000052
Josef Bacik3f7de032011-11-10 08:29:20 -050053#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000054 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
55 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
56 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
57 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
58 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
59 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
60 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
61 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
62 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050063
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050064#define BTRFS_UUID_SIZE 16
65
liubo1abe9b82011-03-24 11:18:59 +000066TRACE_EVENT(btrfs_transaction_commit,
67
68 TP_PROTO(struct btrfs_root *root),
69
70 TP_ARGS(root),
71
72 TP_STRUCT__entry(
73 __field( u64, generation )
74 __field( u64, root_objectid )
75 ),
76
77 TP_fast_assign(
78 __entry->generation = root->fs_info->generation;
79 __entry->root_objectid = root->root_key.objectid;
80 ),
81
82 TP_printk("root = %llu(%s), gen = %llu",
83 show_root_type(__entry->root_objectid),
84 (unsigned long long)__entry->generation)
85);
86
87DECLARE_EVENT_CLASS(btrfs__inode,
88
89 TP_PROTO(struct inode *inode),
90
91 TP_ARGS(inode),
92
93 TP_STRUCT__entry(
94 __field( ino_t, ino )
95 __field( blkcnt_t, blocks )
96 __field( u64, disk_i_size )
97 __field( u64, generation )
98 __field( u64, last_trans )
99 __field( u64, logged_trans )
100 __field( u64, root_objectid )
101 ),
102
103 TP_fast_assign(
104 __entry->ino = inode->i_ino;
105 __entry->blocks = inode->i_blocks;
106 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
107 __entry->generation = BTRFS_I(inode)->generation;
108 __entry->last_trans = BTRFS_I(inode)->last_trans;
109 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
110 __entry->root_objectid =
111 BTRFS_I(inode)->root->root_key.objectid;
112 ),
113
114 TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
115 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
116 show_root_type(__entry->root_objectid),
117 (unsigned long long)__entry->generation,
118 (unsigned long)__entry->ino,
119 (unsigned long long)__entry->blocks,
120 (unsigned long long)__entry->disk_i_size,
121 (unsigned long long)__entry->last_trans,
122 (unsigned long long)__entry->logged_trans)
123);
124
125DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
126
127 TP_PROTO(struct inode *inode),
128
129 TP_ARGS(inode)
130);
131
132DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
133
134 TP_PROTO(struct inode *inode),
135
136 TP_ARGS(inode)
137);
138
139DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
140
141 TP_PROTO(struct inode *inode),
142
143 TP_ARGS(inode)
144);
145
146#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800147 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000148 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
149 { EXTENT_MAP_HOLE, "HOLE" }, \
150 { EXTENT_MAP_INLINE, "INLINE" }, \
151 { EXTENT_MAP_DELALLOC, "DELALLOC" })
152
153#define show_map_type(type) \
154 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
155
156#define show_map_flags(flag) \
157 __print_flags(flag, "|", \
158 { EXTENT_FLAG_PINNED, "PINNED" }, \
159 { EXTENT_FLAG_COMPRESSED, "COMPRESSED" }, \
160 { EXTENT_FLAG_VACANCY, "VACANCY" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000161 { EXTENT_FLAG_PREALLOC, "PREALLOC" }, \
162 { EXTENT_FLAG_LOGGING, "LOGGING" }, \
163 { EXTENT_FLAG_FILLING, "FILLING" })
liubo1abe9b82011-03-24 11:18:59 +0000164
Steven Rostedt4cd8587c2013-11-14 22:57:29 -0500165TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000166
167 TP_PROTO(struct btrfs_root *root, struct extent_map *map),
168
169 TP_ARGS(root, map),
170
Steven Rostedt4cd8587c2013-11-14 22:57:29 -0500171 TP_CONDITION(map),
172
liubo1abe9b82011-03-24 11:18:59 +0000173 TP_STRUCT__entry(
174 __field( u64, root_objectid )
175 __field( u64, start )
176 __field( u64, len )
177 __field( u64, orig_start )
178 __field( u64, block_start )
179 __field( u64, block_len )
180 __field( unsigned long, flags )
181 __field( int, refs )
182 __field( unsigned int, compress_type )
183 ),
184
185 TP_fast_assign(
186 __entry->root_objectid = root->root_key.objectid;
187 __entry->start = map->start;
188 __entry->len = map->len;
189 __entry->orig_start = map->orig_start;
190 __entry->block_start = map->block_start;
191 __entry->block_len = map->block_len;
192 __entry->flags = map->flags;
193 __entry->refs = atomic_read(&map->refs);
194 __entry->compress_type = map->compress_type;
195 ),
196
197 TP_printk("root = %llu(%s), start = %llu, len = %llu, "
198 "orig_start = %llu, block_start = %llu(%s), "
199 "block_len = %llu, flags = %s, refs = %u, "
200 "compress_type = %u",
201 show_root_type(__entry->root_objectid),
202 (unsigned long long)__entry->start,
203 (unsigned long long)__entry->len,
204 (unsigned long long)__entry->orig_start,
205 show_map_type(__entry->block_start),
206 (unsigned long long)__entry->block_len,
207 show_map_flags(__entry->flags),
208 __entry->refs, __entry->compress_type)
209);
210
Liu Bo9d04a8c2013-11-06 12:04:13 +0800211#define show_ordered_flags(flags) \
212 __print_flags(flags, "|", \
213 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
214 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
215 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
216 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
217 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
218 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
219 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
220 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800221 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
222 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000223
liubo1abe9b82011-03-24 11:18:59 +0000224
225DECLARE_EVENT_CLASS(btrfs__ordered_extent,
226
227 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
228
229 TP_ARGS(inode, ordered),
230
231 TP_STRUCT__entry(
232 __field( ino_t, ino )
233 __field( u64, file_offset )
234 __field( u64, start )
235 __field( u64, len )
236 __field( u64, disk_len )
237 __field( u64, bytes_left )
238 __field( unsigned long, flags )
239 __field( int, compress_type )
240 __field( int, refs )
241 __field( u64, root_objectid )
242 ),
243
244 TP_fast_assign(
245 __entry->ino = inode->i_ino;
246 __entry->file_offset = ordered->file_offset;
247 __entry->start = ordered->start;
248 __entry->len = ordered->len;
249 __entry->disk_len = ordered->disk_len;
250 __entry->bytes_left = ordered->bytes_left;
251 __entry->flags = ordered->flags;
252 __entry->compress_type = ordered->compress_type;
253 __entry->refs = atomic_read(&ordered->refs);
254 __entry->root_objectid =
255 BTRFS_I(inode)->root->root_key.objectid;
256 ),
257
258 TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
259 "start = %llu, len = %llu, disk_len = %llu, "
260 "bytes_left = %llu, flags = %s, compress_type = %d, "
261 "refs = %d",
262 show_root_type(__entry->root_objectid),
263 (unsigned long long)__entry->ino,
264 (unsigned long long)__entry->file_offset,
265 (unsigned long long)__entry->start,
266 (unsigned long long)__entry->len,
267 (unsigned long long)__entry->disk_len,
268 (unsigned long long)__entry->bytes_left,
269 show_ordered_flags(__entry->flags),
270 __entry->compress_type, __entry->refs)
271);
272
273DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
274
275 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
276
277 TP_ARGS(inode, ordered)
278);
279
280DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
281
282 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
283
284 TP_ARGS(inode, ordered)
285);
286
287DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
288
289 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
290
291 TP_ARGS(inode, ordered)
292);
293
294DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
295
296 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
297
298 TP_ARGS(inode, ordered)
299);
300
301DECLARE_EVENT_CLASS(btrfs__writepage,
302
303 TP_PROTO(struct page *page, struct inode *inode,
304 struct writeback_control *wbc),
305
306 TP_ARGS(page, inode, wbc),
307
308 TP_STRUCT__entry(
309 __field( ino_t, ino )
310 __field( pgoff_t, index )
311 __field( long, nr_to_write )
312 __field( long, pages_skipped )
313 __field( loff_t, range_start )
314 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000315 __field( char, for_kupdate )
316 __field( char, for_reclaim )
317 __field( char, range_cyclic )
318 __field( pgoff_t, writeback_index )
319 __field( u64, root_objectid )
320 ),
321
322 TP_fast_assign(
323 __entry->ino = inode->i_ino;
324 __entry->index = page->index;
325 __entry->nr_to_write = wbc->nr_to_write;
326 __entry->pages_skipped = wbc->pages_skipped;
327 __entry->range_start = wbc->range_start;
328 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000329 __entry->for_kupdate = wbc->for_kupdate;
330 __entry->for_reclaim = wbc->for_reclaim;
331 __entry->range_cyclic = wbc->range_cyclic;
332 __entry->writeback_index = inode->i_mapping->writeback_index;
333 __entry->root_objectid =
334 BTRFS_I(inode)->root->root_key.objectid;
335 ),
336
337 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
338 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
Wu Fengguang846d5a02011-05-05 21:10:38 -0600339 "range_end = %llu, for_kupdate = %d, "
liubo1abe9b82011-03-24 11:18:59 +0000340 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
341 show_root_type(__entry->root_objectid),
342 (unsigned long)__entry->ino, __entry->index,
343 __entry->nr_to_write, __entry->pages_skipped,
344 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600345 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000346 __entry->for_reclaim, __entry->range_cyclic,
347 (unsigned long)__entry->writeback_index)
348);
349
350DEFINE_EVENT(btrfs__writepage, __extent_writepage,
351
352 TP_PROTO(struct page *page, struct inode *inode,
353 struct writeback_control *wbc),
354
355 TP_ARGS(page, inode, wbc)
356);
357
358TRACE_EVENT(btrfs_writepage_end_io_hook,
359
360 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
361
362 TP_ARGS(page, start, end, uptodate),
363
364 TP_STRUCT__entry(
365 __field( ino_t, ino )
366 __field( pgoff_t, index )
367 __field( u64, start )
368 __field( u64, end )
369 __field( int, uptodate )
370 __field( u64, root_objectid )
371 ),
372
373 TP_fast_assign(
374 __entry->ino = page->mapping->host->i_ino;
375 __entry->index = page->index;
376 __entry->start = start;
377 __entry->end = end;
378 __entry->uptodate = uptodate;
379 __entry->root_objectid =
380 BTRFS_I(page->mapping->host)->root->root_key.objectid;
381 ),
382
383 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
384 "end = %llu, uptodate = %d",
385 show_root_type(__entry->root_objectid),
386 (unsigned long)__entry->ino, (unsigned long)__entry->index,
387 (unsigned long long)__entry->start,
388 (unsigned long long)__entry->end, __entry->uptodate)
389);
390
391TRACE_EVENT(btrfs_sync_file,
392
393 TP_PROTO(struct file *file, int datasync),
394
395 TP_ARGS(file, datasync),
396
397 TP_STRUCT__entry(
398 __field( ino_t, ino )
399 __field( ino_t, parent )
400 __field( int, datasync )
401 __field( u64, root_objectid )
402 ),
403
404 TP_fast_assign(
405 struct dentry *dentry = file->f_path.dentry;
406 struct inode *inode = dentry->d_inode;
407
408 __entry->ino = inode->i_ino;
409 __entry->parent = dentry->d_parent->d_inode->i_ino;
410 __entry->datasync = datasync;
411 __entry->root_objectid =
412 BTRFS_I(inode)->root->root_key.objectid;
413 ),
414
415 TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
416 show_root_type(__entry->root_objectid),
417 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
418 __entry->datasync)
419);
420
421TRACE_EVENT(btrfs_sync_fs,
422
423 TP_PROTO(int wait),
424
425 TP_ARGS(wait),
426
427 TP_STRUCT__entry(
428 __field( int, wait )
429 ),
430
431 TP_fast_assign(
432 __entry->wait = wait;
433 ),
434
435 TP_printk("wait = %d", __entry->wait)
436);
437
438#define show_ref_action(action) \
439 __print_symbolic(action, \
440 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
441 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
442 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
443 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
444
445
Liu Bo599c75e2013-07-16 19:03:36 +0800446DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000447
448 TP_PROTO(struct btrfs_delayed_ref_node *ref,
449 struct btrfs_delayed_tree_ref *full_ref,
450 int action),
451
452 TP_ARGS(ref, full_ref, action),
453
454 TP_STRUCT__entry(
455 __field( u64, bytenr )
456 __field( u64, num_bytes )
457 __field( int, action )
458 __field( u64, parent )
459 __field( u64, ref_root )
460 __field( int, level )
461 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600462 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000463 ),
464
465 TP_fast_assign(
466 __entry->bytenr = ref->bytenr;
467 __entry->num_bytes = ref->num_bytes;
468 __entry->action = action;
469 __entry->parent = full_ref->parent;
470 __entry->ref_root = full_ref->root;
471 __entry->level = full_ref->level;
472 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600473 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000474 ),
475
476 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
477 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
Liu Bodea7d762012-09-07 20:01:27 -0600478 "type = %s, seq = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000479 (unsigned long long)__entry->bytenr,
480 (unsigned long long)__entry->num_bytes,
481 show_ref_action(__entry->action),
482 show_root_type(__entry->parent),
483 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600484 __entry->level, show_ref_type(__entry->type),
485 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000486);
487
Liu Bo599c75e2013-07-16 19:03:36 +0800488DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
489
490 TP_PROTO(struct btrfs_delayed_ref_node *ref,
491 struct btrfs_delayed_tree_ref *full_ref,
492 int action),
493
494 TP_ARGS(ref, full_ref, action)
495);
496
497DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
498
499 TP_PROTO(struct btrfs_delayed_ref_node *ref,
500 struct btrfs_delayed_tree_ref *full_ref,
501 int action),
502
503 TP_ARGS(ref, full_ref, action)
504);
505
506DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000507
508 TP_PROTO(struct btrfs_delayed_ref_node *ref,
509 struct btrfs_delayed_data_ref *full_ref,
510 int action),
511
512 TP_ARGS(ref, full_ref, action),
513
514 TP_STRUCT__entry(
515 __field( u64, bytenr )
516 __field( u64, num_bytes )
517 __field( int, action )
518 __field( u64, parent )
519 __field( u64, ref_root )
520 __field( u64, owner )
521 __field( u64, offset )
522 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600523 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000524 ),
525
526 TP_fast_assign(
527 __entry->bytenr = ref->bytenr;
528 __entry->num_bytes = ref->num_bytes;
529 __entry->action = action;
530 __entry->parent = full_ref->parent;
531 __entry->ref_root = full_ref->root;
532 __entry->owner = full_ref->objectid;
533 __entry->offset = full_ref->offset;
534 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600535 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000536 ),
537
538 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
539 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
Liu Bodea7d762012-09-07 20:01:27 -0600540 "offset = %llu, type = %s, seq = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000541 (unsigned long long)__entry->bytenr,
542 (unsigned long long)__entry->num_bytes,
543 show_ref_action(__entry->action),
544 show_root_type(__entry->parent),
545 show_root_type(__entry->ref_root),
546 (unsigned long long)__entry->owner,
547 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600548 show_ref_type(__entry->type),
549 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000550);
551
Liu Bo599c75e2013-07-16 19:03:36 +0800552DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
553
554 TP_PROTO(struct btrfs_delayed_ref_node *ref,
555 struct btrfs_delayed_data_ref *full_ref,
556 int action),
557
558 TP_ARGS(ref, full_ref, action)
559);
560
561DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
562
563 TP_PROTO(struct btrfs_delayed_ref_node *ref,
564 struct btrfs_delayed_data_ref *full_ref,
565 int action),
566
567 TP_ARGS(ref, full_ref, action)
568);
569
570DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000571
572 TP_PROTO(struct btrfs_delayed_ref_node *ref,
573 struct btrfs_delayed_ref_head *head_ref,
574 int action),
575
576 TP_ARGS(ref, head_ref, action),
577
578 TP_STRUCT__entry(
579 __field( u64, bytenr )
580 __field( u64, num_bytes )
581 __field( int, action )
582 __field( int, is_data )
583 ),
584
585 TP_fast_assign(
586 __entry->bytenr = ref->bytenr;
587 __entry->num_bytes = ref->num_bytes;
588 __entry->action = action;
589 __entry->is_data = head_ref->is_data;
590 ),
591
592 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
593 (unsigned long long)__entry->bytenr,
594 (unsigned long long)__entry->num_bytes,
595 show_ref_action(__entry->action),
596 __entry->is_data)
597);
598
Liu Bo599c75e2013-07-16 19:03:36 +0800599DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
600
601 TP_PROTO(struct btrfs_delayed_ref_node *ref,
602 struct btrfs_delayed_ref_head *head_ref,
603 int action),
604
605 TP_ARGS(ref, head_ref, action)
606);
607
608DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
609
610 TP_PROTO(struct btrfs_delayed_ref_node *ref,
611 struct btrfs_delayed_ref_head *head_ref,
612 int action),
613
614 TP_ARGS(ref, head_ref, action)
615);
616
liubo1abe9b82011-03-24 11:18:59 +0000617#define show_chunk_type(type) \
618 __print_flags(type, "|", \
619 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
620 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
621 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
622 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
623 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
624 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000625 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
626 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
627 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000628
629DECLARE_EVENT_CLASS(btrfs__chunk,
630
631 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
632 u64 offset, u64 size),
633
634 TP_ARGS(root, map, offset, size),
635
636 TP_STRUCT__entry(
637 __field( int, num_stripes )
638 __field( u64, type )
639 __field( int, sub_stripes )
640 __field( u64, offset )
641 __field( u64, size )
642 __field( u64, root_objectid )
643 ),
644
645 TP_fast_assign(
646 __entry->num_stripes = map->num_stripes;
647 __entry->type = map->type;
648 __entry->sub_stripes = map->sub_stripes;
649 __entry->offset = offset;
650 __entry->size = size;
651 __entry->root_objectid = root->root_key.objectid;
652 ),
653
654 TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
655 "num_stripes = %d, sub_stripes = %d, type = %s",
656 show_root_type(__entry->root_objectid),
657 (unsigned long long)__entry->offset,
658 (unsigned long long)__entry->size,
659 __entry->num_stripes, __entry->sub_stripes,
660 show_chunk_type(__entry->type))
661);
662
663DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
664
665 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
666 u64 offset, u64 size),
667
668 TP_ARGS(root, map, offset, size)
669);
670
671DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
672
673 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
674 u64 offset, u64 size),
675
676 TP_ARGS(root, map, offset, size)
677);
678
679TRACE_EVENT(btrfs_cow_block,
680
681 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
682 struct extent_buffer *cow),
683
684 TP_ARGS(root, buf, cow),
685
686 TP_STRUCT__entry(
687 __field( u64, root_objectid )
688 __field( u64, buf_start )
689 __field( int, refs )
690 __field( u64, cow_start )
691 __field( int, buf_level )
692 __field( int, cow_level )
693 ),
694
695 TP_fast_assign(
696 __entry->root_objectid = root->root_key.objectid;
697 __entry->buf_start = buf->start;
698 __entry->refs = atomic_read(&buf->refs);
699 __entry->cow_start = cow->start;
700 __entry->buf_level = btrfs_header_level(buf);
701 __entry->cow_level = btrfs_header_level(cow);
702 ),
703
704 TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
705 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
706 show_root_type(__entry->root_objectid),
707 __entry->refs,
708 (unsigned long long)__entry->buf_start,
709 __entry->buf_level,
710 (unsigned long long)__entry->cow_start,
711 __entry->cow_level)
712);
713
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500714TRACE_EVENT(btrfs_space_reservation,
715
716 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
717 u64 bytes, int reserve),
718
719 TP_ARGS(fs_info, type, val, bytes, reserve),
720
721 TP_STRUCT__entry(
722 __array( u8, fsid, BTRFS_UUID_SIZE )
723 __string( type, type )
724 __field( u64, val )
725 __field( u64, bytes )
726 __field( int, reserve )
727 ),
728
729 TP_fast_assign(
730 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
731 __assign_str(type, type);
732 __entry->val = val;
733 __entry->bytes = bytes;
734 __entry->reserve = reserve;
735 ),
736
737 TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
738 __entry->val, __entry->reserve ? "reserve" : "release",
739 __entry->bytes)
740);
741
liubo1abe9b82011-03-24 11:18:59 +0000742DECLARE_EVENT_CLASS(btrfs__reserved_extent,
743
744 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
745
746 TP_ARGS(root, start, len),
747
748 TP_STRUCT__entry(
749 __field( u64, root_objectid )
750 __field( u64, start )
751 __field( u64, len )
752 ),
753
754 TP_fast_assign(
755 __entry->root_objectid = root->root_key.objectid;
756 __entry->start = start;
757 __entry->len = len;
758 ),
759
760 TP_printk("root = %llu(%s), start = %llu, len = %llu",
761 show_root_type(__entry->root_objectid),
762 (unsigned long long)__entry->start,
763 (unsigned long long)__entry->len)
764);
765
766DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
767
768 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
769
770 TP_ARGS(root, start, len)
771);
772
773DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
774
775 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
776
777 TP_ARGS(root, start, len)
778);
779
Josef Bacik3f7de032011-11-10 08:29:20 -0500780TRACE_EVENT(find_free_extent,
781
782 TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
783 u64 data),
784
785 TP_ARGS(root, num_bytes, empty_size, data),
786
787 TP_STRUCT__entry(
788 __field( u64, root_objectid )
789 __field( u64, num_bytes )
790 __field( u64, empty_size )
791 __field( u64, data )
792 ),
793
794 TP_fast_assign(
795 __entry->root_objectid = root->root_key.objectid;
796 __entry->num_bytes = num_bytes;
797 __entry->empty_size = empty_size;
798 __entry->data = data;
799 ),
800
801 TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
802 "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
803 __entry->num_bytes, __entry->empty_size, __entry->data,
804 __print_flags((unsigned long)__entry->data, "|",
805 BTRFS_GROUP_FLAGS))
806);
807
808DECLARE_EVENT_CLASS(btrfs__reserve_extent,
809
810 TP_PROTO(struct btrfs_root *root,
811 struct btrfs_block_group_cache *block_group, u64 start,
812 u64 len),
813
814 TP_ARGS(root, block_group, start, len),
815
816 TP_STRUCT__entry(
817 __field( u64, root_objectid )
818 __field( u64, bg_objectid )
819 __field( u64, flags )
820 __field( u64, start )
821 __field( u64, len )
822 ),
823
824 TP_fast_assign(
825 __entry->root_objectid = root->root_key.objectid;
826 __entry->bg_objectid = block_group->key.objectid;
827 __entry->flags = block_group->flags;
828 __entry->start = start;
829 __entry->len = len;
830 ),
831
832 TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
833 "start = %Lu, len = %Lu",
834 show_root_type(__entry->root_objectid), __entry->bg_objectid,
835 __entry->flags, __print_flags((unsigned long)__entry->flags,
836 "|", BTRFS_GROUP_FLAGS),
837 __entry->start, __entry->len)
838);
839
840DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
841
842 TP_PROTO(struct btrfs_root *root,
843 struct btrfs_block_group_cache *block_group, u64 start,
844 u64 len),
845
846 TP_ARGS(root, block_group, start, len)
847);
848
849DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
850
851 TP_PROTO(struct btrfs_root *root,
852 struct btrfs_block_group_cache *block_group, u64 start,
853 u64 len),
854
855 TP_ARGS(root, block_group, start, len)
856);
857
858TRACE_EVENT(btrfs_find_cluster,
859
860 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
861 u64 bytes, u64 empty_size, u64 min_bytes),
862
863 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
864
865 TP_STRUCT__entry(
866 __field( u64, bg_objectid )
867 __field( u64, flags )
868 __field( u64, start )
869 __field( u64, bytes )
870 __field( u64, empty_size )
871 __field( u64, min_bytes )
872 ),
873
874 TP_fast_assign(
875 __entry->bg_objectid = block_group->key.objectid;
876 __entry->flags = block_group->flags;
877 __entry->start = start;
878 __entry->bytes = bytes;
879 __entry->empty_size = empty_size;
880 __entry->min_bytes = min_bytes;
881 ),
882
883 TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
884 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
885 __entry->flags,
886 __print_flags((unsigned long)__entry->flags, "|",
887 BTRFS_GROUP_FLAGS), __entry->start,
888 __entry->bytes, __entry->empty_size, __entry->min_bytes)
889);
890
891TRACE_EVENT(btrfs_failed_cluster_setup,
892
893 TP_PROTO(struct btrfs_block_group_cache *block_group),
894
895 TP_ARGS(block_group),
896
897 TP_STRUCT__entry(
898 __field( u64, bg_objectid )
899 ),
900
901 TP_fast_assign(
902 __entry->bg_objectid = block_group->key.objectid;
903 ),
904
905 TP_printk("block_group = %Lu", __entry->bg_objectid)
906);
907
908TRACE_EVENT(btrfs_setup_cluster,
909
910 TP_PROTO(struct btrfs_block_group_cache *block_group,
911 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
912
913 TP_ARGS(block_group, cluster, size, bitmap),
914
915 TP_STRUCT__entry(
916 __field( u64, bg_objectid )
917 __field( u64, flags )
918 __field( u64, start )
919 __field( u64, max_size )
920 __field( u64, size )
921 __field( int, bitmap )
922 ),
923
924 TP_fast_assign(
925 __entry->bg_objectid = block_group->key.objectid;
926 __entry->flags = block_group->flags;
927 __entry->start = cluster->window_start;
928 __entry->max_size = cluster->max_size;
929 __entry->size = size;
930 __entry->bitmap = bitmap;
931 ),
932
933 TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
934 "size = %Lu, max_size = %Lu, bitmap = %d",
935 __entry->bg_objectid,
936 __entry->flags,
937 __print_flags((unsigned long)__entry->flags, "|",
938 BTRFS_GROUP_FLAGS), __entry->start,
939 __entry->size, __entry->max_size, __entry->bitmap)
940);
941
Jeff Mahoney143bede2012-03-01 14:56:26 +0100942struct extent_state;
943TRACE_EVENT(alloc_extent_state,
944
945 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
946
947 TP_ARGS(state, mask, IP),
948
949 TP_STRUCT__entry(
950 __field(struct extent_state *, state)
951 __field(gfp_t, mask)
952 __field(unsigned long, ip)
953 ),
954
955 TP_fast_assign(
956 __entry->state = state,
957 __entry->mask = mask,
958 __entry->ip = IP
959 ),
960
961 TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
962 show_gfp_flags(__entry->mask), (void *)__entry->ip)
963);
964
965TRACE_EVENT(free_extent_state,
966
967 TP_PROTO(struct extent_state *state, unsigned long IP),
968
969 TP_ARGS(state, IP),
970
971 TP_STRUCT__entry(
972 __field(struct extent_state *, state)
973 __field(unsigned long, ip)
974 ),
975
976 TP_fast_assign(
977 __entry->state = state,
978 __entry->ip = IP
979 ),
980
981 TP_printk(" state=%p; caller = %pF", __entry->state,
982 (void *)__entry->ip)
983);
984
liubo1abe9b82011-03-24 11:18:59 +0000985#endif /* _TRACE_BTRFS_H */
986
987/* This part must be outside protection */
988#include <trace/define_trace.h>