blob: c346919254a907eff9b862057d606a13c259f1dd [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;
Qu Wenruo52483bc2014-03-06 04:19:50 +000024struct btrfs_work;
liubo1abe9b82011-03-24 11:18:59 +000025
26#define show_ref_type(type) \
27 __print_symbolic(type, \
28 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
29 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
30 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
31 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
32 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
33
34#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080035 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000036 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
37 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
38 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
39 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
40 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
41 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
42 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
43 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000044 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000045 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
David Sterba13fd8da2013-09-03 18:28:57 +020046 { BTRFS_UUID_TREE_OBJECTID, "UUID_RELOC" }, \
liubo1abe9b82011-03-24 11:18:59 +000047 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
48
49#define show_root_type(obj) \
50 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000051 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000052 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000053
Josef Bacik3f7de032011-11-10 08:29:20 -050054#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000055 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
56 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
57 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
58 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
59 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
60 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
61 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
62 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
63 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050064
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050065#define BTRFS_UUID_SIZE 16
66
liubo1abe9b82011-03-24 11:18:59 +000067TRACE_EVENT(btrfs_transaction_commit,
68
69 TP_PROTO(struct btrfs_root *root),
70
71 TP_ARGS(root),
72
73 TP_STRUCT__entry(
74 __field( u64, generation )
75 __field( u64, root_objectid )
76 ),
77
78 TP_fast_assign(
79 __entry->generation = root->fs_info->generation;
80 __entry->root_objectid = root->root_key.objectid;
81 ),
82
83 TP_printk("root = %llu(%s), gen = %llu",
84 show_root_type(__entry->root_objectid),
85 (unsigned long long)__entry->generation)
86);
87
88DECLARE_EVENT_CLASS(btrfs__inode,
89
90 TP_PROTO(struct inode *inode),
91
92 TP_ARGS(inode),
93
94 TP_STRUCT__entry(
95 __field( ino_t, ino )
96 __field( blkcnt_t, blocks )
97 __field( u64, disk_i_size )
98 __field( u64, generation )
99 __field( u64, last_trans )
100 __field( u64, logged_trans )
101 __field( u64, root_objectid )
102 ),
103
104 TP_fast_assign(
105 __entry->ino = inode->i_ino;
106 __entry->blocks = inode->i_blocks;
107 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
108 __entry->generation = BTRFS_I(inode)->generation;
109 __entry->last_trans = BTRFS_I(inode)->last_trans;
110 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
111 __entry->root_objectid =
112 BTRFS_I(inode)->root->root_key.objectid;
113 ),
114
115 TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
116 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
117 show_root_type(__entry->root_objectid),
118 (unsigned long long)__entry->generation,
119 (unsigned long)__entry->ino,
120 (unsigned long long)__entry->blocks,
121 (unsigned long long)__entry->disk_i_size,
122 (unsigned long long)__entry->last_trans,
123 (unsigned long long)__entry->logged_trans)
124);
125
126DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
127
128 TP_PROTO(struct inode *inode),
129
130 TP_ARGS(inode)
131);
132
133DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
134
135 TP_PROTO(struct inode *inode),
136
137 TP_ARGS(inode)
138);
139
140DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
141
142 TP_PROTO(struct inode *inode),
143
144 TP_ARGS(inode)
145);
146
147#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800148 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000149 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
150 { EXTENT_MAP_HOLE, "HOLE" }, \
151 { EXTENT_MAP_INLINE, "INLINE" }, \
152 { EXTENT_MAP_DELALLOC, "DELALLOC" })
153
154#define show_map_type(type) \
155 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
156
157#define show_map_flags(flag) \
158 __print_flags(flag, "|", \
159 { EXTENT_FLAG_PINNED, "PINNED" }, \
160 { EXTENT_FLAG_COMPRESSED, "COMPRESSED" }, \
161 { EXTENT_FLAG_VACANCY, "VACANCY" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000162 { EXTENT_FLAG_PREALLOC, "PREALLOC" }, \
163 { EXTENT_FLAG_LOGGING, "LOGGING" }, \
164 { EXTENT_FLAG_FILLING, "FILLING" })
liubo1abe9b82011-03-24 11:18:59 +0000165
Steven Rostedt4cd8587c2013-11-14 22:57:29 -0500166TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000167
168 TP_PROTO(struct btrfs_root *root, struct extent_map *map),
169
170 TP_ARGS(root, map),
171
Steven Rostedt4cd8587c2013-11-14 22:57:29 -0500172 TP_CONDITION(map),
173
liubo1abe9b82011-03-24 11:18:59 +0000174 TP_STRUCT__entry(
175 __field( u64, root_objectid )
176 __field( u64, start )
177 __field( u64, len )
178 __field( u64, orig_start )
179 __field( u64, block_start )
180 __field( u64, block_len )
181 __field( unsigned long, flags )
182 __field( int, refs )
183 __field( unsigned int, compress_type )
184 ),
185
186 TP_fast_assign(
187 __entry->root_objectid = root->root_key.objectid;
188 __entry->start = map->start;
189 __entry->len = map->len;
190 __entry->orig_start = map->orig_start;
191 __entry->block_start = map->block_start;
192 __entry->block_len = map->block_len;
193 __entry->flags = map->flags;
194 __entry->refs = atomic_read(&map->refs);
195 __entry->compress_type = map->compress_type;
196 ),
197
198 TP_printk("root = %llu(%s), start = %llu, len = %llu, "
199 "orig_start = %llu, block_start = %llu(%s), "
200 "block_len = %llu, flags = %s, refs = %u, "
201 "compress_type = %u",
202 show_root_type(__entry->root_objectid),
203 (unsigned long long)__entry->start,
204 (unsigned long long)__entry->len,
205 (unsigned long long)__entry->orig_start,
206 show_map_type(__entry->block_start),
207 (unsigned long long)__entry->block_len,
208 show_map_flags(__entry->flags),
209 __entry->refs, __entry->compress_type)
210);
211
Liu Bo9d04a8c2013-11-06 12:04:13 +0800212#define show_ordered_flags(flags) \
213 __print_flags(flags, "|", \
214 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
215 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
216 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
217 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
218 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
219 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
220 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
221 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800222 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
223 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000224
liubo1abe9b82011-03-24 11:18:59 +0000225
226DECLARE_EVENT_CLASS(btrfs__ordered_extent,
227
228 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
229
230 TP_ARGS(inode, ordered),
231
232 TP_STRUCT__entry(
233 __field( ino_t, ino )
234 __field( u64, file_offset )
235 __field( u64, start )
236 __field( u64, len )
237 __field( u64, disk_len )
238 __field( u64, bytes_left )
239 __field( unsigned long, flags )
240 __field( int, compress_type )
241 __field( int, refs )
242 __field( u64, root_objectid )
243 ),
244
245 TP_fast_assign(
246 __entry->ino = inode->i_ino;
247 __entry->file_offset = ordered->file_offset;
248 __entry->start = ordered->start;
249 __entry->len = ordered->len;
250 __entry->disk_len = ordered->disk_len;
251 __entry->bytes_left = ordered->bytes_left;
252 __entry->flags = ordered->flags;
253 __entry->compress_type = ordered->compress_type;
254 __entry->refs = atomic_read(&ordered->refs);
255 __entry->root_objectid =
256 BTRFS_I(inode)->root->root_key.objectid;
257 ),
258
259 TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
260 "start = %llu, len = %llu, disk_len = %llu, "
261 "bytes_left = %llu, flags = %s, compress_type = %d, "
262 "refs = %d",
263 show_root_type(__entry->root_objectid),
264 (unsigned long long)__entry->ino,
265 (unsigned long long)__entry->file_offset,
266 (unsigned long long)__entry->start,
267 (unsigned long long)__entry->len,
268 (unsigned long long)__entry->disk_len,
269 (unsigned long long)__entry->bytes_left,
270 show_ordered_flags(__entry->flags),
271 __entry->compress_type, __entry->refs)
272);
273
274DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
275
276 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
277
278 TP_ARGS(inode, ordered)
279);
280
281DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
282
283 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
284
285 TP_ARGS(inode, ordered)
286);
287
288DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
289
290 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
291
292 TP_ARGS(inode, ordered)
293);
294
295DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
296
297 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
298
299 TP_ARGS(inode, ordered)
300);
301
302DECLARE_EVENT_CLASS(btrfs__writepage,
303
304 TP_PROTO(struct page *page, struct inode *inode,
305 struct writeback_control *wbc),
306
307 TP_ARGS(page, inode, wbc),
308
309 TP_STRUCT__entry(
310 __field( ino_t, ino )
311 __field( pgoff_t, index )
312 __field( long, nr_to_write )
313 __field( long, pages_skipped )
314 __field( loff_t, range_start )
315 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000316 __field( char, for_kupdate )
317 __field( char, for_reclaim )
318 __field( char, range_cyclic )
319 __field( pgoff_t, writeback_index )
320 __field( u64, root_objectid )
321 ),
322
323 TP_fast_assign(
324 __entry->ino = inode->i_ino;
325 __entry->index = page->index;
326 __entry->nr_to_write = wbc->nr_to_write;
327 __entry->pages_skipped = wbc->pages_skipped;
328 __entry->range_start = wbc->range_start;
329 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000330 __entry->for_kupdate = wbc->for_kupdate;
331 __entry->for_reclaim = wbc->for_reclaim;
332 __entry->range_cyclic = wbc->range_cyclic;
333 __entry->writeback_index = inode->i_mapping->writeback_index;
334 __entry->root_objectid =
335 BTRFS_I(inode)->root->root_key.objectid;
336 ),
337
338 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
339 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
Wu Fengguang846d5a02011-05-05 21:10:38 -0600340 "range_end = %llu, for_kupdate = %d, "
liubo1abe9b82011-03-24 11:18:59 +0000341 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
342 show_root_type(__entry->root_objectid),
343 (unsigned long)__entry->ino, __entry->index,
344 __entry->nr_to_write, __entry->pages_skipped,
345 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600346 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000347 __entry->for_reclaim, __entry->range_cyclic,
348 (unsigned long)__entry->writeback_index)
349);
350
351DEFINE_EVENT(btrfs__writepage, __extent_writepage,
352
353 TP_PROTO(struct page *page, struct inode *inode,
354 struct writeback_control *wbc),
355
356 TP_ARGS(page, inode, wbc)
357);
358
359TRACE_EVENT(btrfs_writepage_end_io_hook,
360
361 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
362
363 TP_ARGS(page, start, end, uptodate),
364
365 TP_STRUCT__entry(
366 __field( ino_t, ino )
367 __field( pgoff_t, index )
368 __field( u64, start )
369 __field( u64, end )
370 __field( int, uptodate )
371 __field( u64, root_objectid )
372 ),
373
374 TP_fast_assign(
375 __entry->ino = page->mapping->host->i_ino;
376 __entry->index = page->index;
377 __entry->start = start;
378 __entry->end = end;
379 __entry->uptodate = uptodate;
380 __entry->root_objectid =
381 BTRFS_I(page->mapping->host)->root->root_key.objectid;
382 ),
383
384 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
385 "end = %llu, uptodate = %d",
386 show_root_type(__entry->root_objectid),
387 (unsigned long)__entry->ino, (unsigned long)__entry->index,
388 (unsigned long long)__entry->start,
389 (unsigned long long)__entry->end, __entry->uptodate)
390);
391
392TRACE_EVENT(btrfs_sync_file,
393
394 TP_PROTO(struct file *file, int datasync),
395
396 TP_ARGS(file, datasync),
397
398 TP_STRUCT__entry(
399 __field( ino_t, ino )
400 __field( ino_t, parent )
401 __field( int, datasync )
402 __field( u64, root_objectid )
403 ),
404
405 TP_fast_assign(
406 struct dentry *dentry = file->f_path.dentry;
407 struct inode *inode = dentry->d_inode;
408
409 __entry->ino = inode->i_ino;
410 __entry->parent = dentry->d_parent->d_inode->i_ino;
411 __entry->datasync = datasync;
412 __entry->root_objectid =
413 BTRFS_I(inode)->root->root_key.objectid;
414 ),
415
416 TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
417 show_root_type(__entry->root_objectid),
418 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
419 __entry->datasync)
420);
421
422TRACE_EVENT(btrfs_sync_fs,
423
424 TP_PROTO(int wait),
425
426 TP_ARGS(wait),
427
428 TP_STRUCT__entry(
429 __field( int, wait )
430 ),
431
432 TP_fast_assign(
433 __entry->wait = wait;
434 ),
435
436 TP_printk("wait = %d", __entry->wait)
437);
438
439#define show_ref_action(action) \
440 __print_symbolic(action, \
441 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
442 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
443 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
444 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
445
446
Liu Bo599c75e2013-07-16 19:03:36 +0800447DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000448
449 TP_PROTO(struct btrfs_delayed_ref_node *ref,
450 struct btrfs_delayed_tree_ref *full_ref,
451 int action),
452
453 TP_ARGS(ref, full_ref, action),
454
455 TP_STRUCT__entry(
456 __field( u64, bytenr )
457 __field( u64, num_bytes )
458 __field( int, action )
459 __field( u64, parent )
460 __field( u64, ref_root )
461 __field( int, level )
462 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600463 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000464 ),
465
466 TP_fast_assign(
467 __entry->bytenr = ref->bytenr;
468 __entry->num_bytes = ref->num_bytes;
469 __entry->action = action;
470 __entry->parent = full_ref->parent;
471 __entry->ref_root = full_ref->root;
472 __entry->level = full_ref->level;
473 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600474 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000475 ),
476
477 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
478 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
Liu Bodea7d762012-09-07 20:01:27 -0600479 "type = %s, seq = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000480 (unsigned long long)__entry->bytenr,
481 (unsigned long long)__entry->num_bytes,
482 show_ref_action(__entry->action),
483 show_root_type(__entry->parent),
484 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600485 __entry->level, show_ref_type(__entry->type),
486 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000487);
488
Liu Bo599c75e2013-07-16 19:03:36 +0800489DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
490
491 TP_PROTO(struct btrfs_delayed_ref_node *ref,
492 struct btrfs_delayed_tree_ref *full_ref,
493 int action),
494
495 TP_ARGS(ref, full_ref, action)
496);
497
498DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
499
500 TP_PROTO(struct btrfs_delayed_ref_node *ref,
501 struct btrfs_delayed_tree_ref *full_ref,
502 int action),
503
504 TP_ARGS(ref, full_ref, action)
505);
506
507DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000508
509 TP_PROTO(struct btrfs_delayed_ref_node *ref,
510 struct btrfs_delayed_data_ref *full_ref,
511 int action),
512
513 TP_ARGS(ref, full_ref, action),
514
515 TP_STRUCT__entry(
516 __field( u64, bytenr )
517 __field( u64, num_bytes )
518 __field( int, action )
519 __field( u64, parent )
520 __field( u64, ref_root )
521 __field( u64, owner )
522 __field( u64, offset )
523 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600524 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000525 ),
526
527 TP_fast_assign(
528 __entry->bytenr = ref->bytenr;
529 __entry->num_bytes = ref->num_bytes;
530 __entry->action = action;
531 __entry->parent = full_ref->parent;
532 __entry->ref_root = full_ref->root;
533 __entry->owner = full_ref->objectid;
534 __entry->offset = full_ref->offset;
535 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600536 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000537 ),
538
539 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
540 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
Liu Bodea7d762012-09-07 20:01:27 -0600541 "offset = %llu, type = %s, seq = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000542 (unsigned long long)__entry->bytenr,
543 (unsigned long long)__entry->num_bytes,
544 show_ref_action(__entry->action),
545 show_root_type(__entry->parent),
546 show_root_type(__entry->ref_root),
547 (unsigned long long)__entry->owner,
548 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600549 show_ref_type(__entry->type),
550 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000551);
552
Liu Bo599c75e2013-07-16 19:03:36 +0800553DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
554
555 TP_PROTO(struct btrfs_delayed_ref_node *ref,
556 struct btrfs_delayed_data_ref *full_ref,
557 int action),
558
559 TP_ARGS(ref, full_ref, action)
560);
561
562DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
563
564 TP_PROTO(struct btrfs_delayed_ref_node *ref,
565 struct btrfs_delayed_data_ref *full_ref,
566 int action),
567
568 TP_ARGS(ref, full_ref, action)
569);
570
571DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000572
573 TP_PROTO(struct btrfs_delayed_ref_node *ref,
574 struct btrfs_delayed_ref_head *head_ref,
575 int action),
576
577 TP_ARGS(ref, head_ref, action),
578
579 TP_STRUCT__entry(
580 __field( u64, bytenr )
581 __field( u64, num_bytes )
582 __field( int, action )
583 __field( int, is_data )
584 ),
585
586 TP_fast_assign(
587 __entry->bytenr = ref->bytenr;
588 __entry->num_bytes = ref->num_bytes;
589 __entry->action = action;
590 __entry->is_data = head_ref->is_data;
591 ),
592
593 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
594 (unsigned long long)__entry->bytenr,
595 (unsigned long long)__entry->num_bytes,
596 show_ref_action(__entry->action),
597 __entry->is_data)
598);
599
Liu Bo599c75e2013-07-16 19:03:36 +0800600DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
601
602 TP_PROTO(struct btrfs_delayed_ref_node *ref,
603 struct btrfs_delayed_ref_head *head_ref,
604 int action),
605
606 TP_ARGS(ref, head_ref, action)
607);
608
609DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
610
611 TP_PROTO(struct btrfs_delayed_ref_node *ref,
612 struct btrfs_delayed_ref_head *head_ref,
613 int action),
614
615 TP_ARGS(ref, head_ref, action)
616);
617
liubo1abe9b82011-03-24 11:18:59 +0000618#define show_chunk_type(type) \
619 __print_flags(type, "|", \
620 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
621 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
622 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
623 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
624 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
625 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000626 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
627 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
628 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000629
630DECLARE_EVENT_CLASS(btrfs__chunk,
631
632 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
633 u64 offset, u64 size),
634
635 TP_ARGS(root, map, offset, size),
636
637 TP_STRUCT__entry(
638 __field( int, num_stripes )
639 __field( u64, type )
640 __field( int, sub_stripes )
641 __field( u64, offset )
642 __field( u64, size )
643 __field( u64, root_objectid )
644 ),
645
646 TP_fast_assign(
647 __entry->num_stripes = map->num_stripes;
648 __entry->type = map->type;
649 __entry->sub_stripes = map->sub_stripes;
650 __entry->offset = offset;
651 __entry->size = size;
652 __entry->root_objectid = root->root_key.objectid;
653 ),
654
655 TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
656 "num_stripes = %d, sub_stripes = %d, type = %s",
657 show_root_type(__entry->root_objectid),
658 (unsigned long long)__entry->offset,
659 (unsigned long long)__entry->size,
660 __entry->num_stripes, __entry->sub_stripes,
661 show_chunk_type(__entry->type))
662);
663
664DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
665
666 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
667 u64 offset, u64 size),
668
669 TP_ARGS(root, map, offset, size)
670);
671
672DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
673
674 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
675 u64 offset, u64 size),
676
677 TP_ARGS(root, map, offset, size)
678);
679
680TRACE_EVENT(btrfs_cow_block,
681
682 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
683 struct extent_buffer *cow),
684
685 TP_ARGS(root, buf, cow),
686
687 TP_STRUCT__entry(
688 __field( u64, root_objectid )
689 __field( u64, buf_start )
690 __field( int, refs )
691 __field( u64, cow_start )
692 __field( int, buf_level )
693 __field( int, cow_level )
694 ),
695
696 TP_fast_assign(
697 __entry->root_objectid = root->root_key.objectid;
698 __entry->buf_start = buf->start;
699 __entry->refs = atomic_read(&buf->refs);
700 __entry->cow_start = cow->start;
701 __entry->buf_level = btrfs_header_level(buf);
702 __entry->cow_level = btrfs_header_level(cow);
703 ),
704
705 TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
706 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
707 show_root_type(__entry->root_objectid),
708 __entry->refs,
709 (unsigned long long)__entry->buf_start,
710 __entry->buf_level,
711 (unsigned long long)__entry->cow_start,
712 __entry->cow_level)
713);
714
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500715TRACE_EVENT(btrfs_space_reservation,
716
717 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
718 u64 bytes, int reserve),
719
720 TP_ARGS(fs_info, type, val, bytes, reserve),
721
722 TP_STRUCT__entry(
723 __array( u8, fsid, BTRFS_UUID_SIZE )
724 __string( type, type )
725 __field( u64, val )
726 __field( u64, bytes )
727 __field( int, reserve )
728 ),
729
730 TP_fast_assign(
731 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
732 __assign_str(type, type);
733 __entry->val = val;
734 __entry->bytes = bytes;
735 __entry->reserve = reserve;
736 ),
737
738 TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
739 __entry->val, __entry->reserve ? "reserve" : "release",
740 __entry->bytes)
741);
742
liubo1abe9b82011-03-24 11:18:59 +0000743DECLARE_EVENT_CLASS(btrfs__reserved_extent,
744
745 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
746
747 TP_ARGS(root, start, len),
748
749 TP_STRUCT__entry(
750 __field( u64, root_objectid )
751 __field( u64, start )
752 __field( u64, len )
753 ),
754
755 TP_fast_assign(
756 __entry->root_objectid = root->root_key.objectid;
757 __entry->start = start;
758 __entry->len = len;
759 ),
760
761 TP_printk("root = %llu(%s), start = %llu, len = %llu",
762 show_root_type(__entry->root_objectid),
763 (unsigned long long)__entry->start,
764 (unsigned long long)__entry->len)
765);
766
767DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
768
769 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
770
771 TP_ARGS(root, start, len)
772);
773
774DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
775
776 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
777
778 TP_ARGS(root, start, len)
779);
780
Josef Bacik3f7de032011-11-10 08:29:20 -0500781TRACE_EVENT(find_free_extent,
782
783 TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
784 u64 data),
785
786 TP_ARGS(root, num_bytes, empty_size, data),
787
788 TP_STRUCT__entry(
789 __field( u64, root_objectid )
790 __field( u64, num_bytes )
791 __field( u64, empty_size )
792 __field( u64, data )
793 ),
794
795 TP_fast_assign(
796 __entry->root_objectid = root->root_key.objectid;
797 __entry->num_bytes = num_bytes;
798 __entry->empty_size = empty_size;
799 __entry->data = data;
800 ),
801
802 TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
803 "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
804 __entry->num_bytes, __entry->empty_size, __entry->data,
805 __print_flags((unsigned long)__entry->data, "|",
806 BTRFS_GROUP_FLAGS))
807);
808
809DECLARE_EVENT_CLASS(btrfs__reserve_extent,
810
811 TP_PROTO(struct btrfs_root *root,
812 struct btrfs_block_group_cache *block_group, u64 start,
813 u64 len),
814
815 TP_ARGS(root, block_group, start, len),
816
817 TP_STRUCT__entry(
818 __field( u64, root_objectid )
819 __field( u64, bg_objectid )
820 __field( u64, flags )
821 __field( u64, start )
822 __field( u64, len )
823 ),
824
825 TP_fast_assign(
826 __entry->root_objectid = root->root_key.objectid;
827 __entry->bg_objectid = block_group->key.objectid;
828 __entry->flags = block_group->flags;
829 __entry->start = start;
830 __entry->len = len;
831 ),
832
833 TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
834 "start = %Lu, len = %Lu",
835 show_root_type(__entry->root_objectid), __entry->bg_objectid,
836 __entry->flags, __print_flags((unsigned long)__entry->flags,
837 "|", BTRFS_GROUP_FLAGS),
838 __entry->start, __entry->len)
839);
840
841DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
842
843 TP_PROTO(struct btrfs_root *root,
844 struct btrfs_block_group_cache *block_group, u64 start,
845 u64 len),
846
847 TP_ARGS(root, block_group, start, len)
848);
849
850DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
851
852 TP_PROTO(struct btrfs_root *root,
853 struct btrfs_block_group_cache *block_group, u64 start,
854 u64 len),
855
856 TP_ARGS(root, block_group, start, len)
857);
858
859TRACE_EVENT(btrfs_find_cluster,
860
861 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
862 u64 bytes, u64 empty_size, u64 min_bytes),
863
864 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
865
866 TP_STRUCT__entry(
867 __field( u64, bg_objectid )
868 __field( u64, flags )
869 __field( u64, start )
870 __field( u64, bytes )
871 __field( u64, empty_size )
872 __field( u64, min_bytes )
873 ),
874
875 TP_fast_assign(
876 __entry->bg_objectid = block_group->key.objectid;
877 __entry->flags = block_group->flags;
878 __entry->start = start;
879 __entry->bytes = bytes;
880 __entry->empty_size = empty_size;
881 __entry->min_bytes = min_bytes;
882 ),
883
884 TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
885 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
886 __entry->flags,
887 __print_flags((unsigned long)__entry->flags, "|",
888 BTRFS_GROUP_FLAGS), __entry->start,
889 __entry->bytes, __entry->empty_size, __entry->min_bytes)
890);
891
892TRACE_EVENT(btrfs_failed_cluster_setup,
893
894 TP_PROTO(struct btrfs_block_group_cache *block_group),
895
896 TP_ARGS(block_group),
897
898 TP_STRUCT__entry(
899 __field( u64, bg_objectid )
900 ),
901
902 TP_fast_assign(
903 __entry->bg_objectid = block_group->key.objectid;
904 ),
905
906 TP_printk("block_group = %Lu", __entry->bg_objectid)
907);
908
909TRACE_EVENT(btrfs_setup_cluster,
910
911 TP_PROTO(struct btrfs_block_group_cache *block_group,
912 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
913
914 TP_ARGS(block_group, cluster, size, bitmap),
915
916 TP_STRUCT__entry(
917 __field( u64, bg_objectid )
918 __field( u64, flags )
919 __field( u64, start )
920 __field( u64, max_size )
921 __field( u64, size )
922 __field( int, bitmap )
923 ),
924
925 TP_fast_assign(
926 __entry->bg_objectid = block_group->key.objectid;
927 __entry->flags = block_group->flags;
928 __entry->start = cluster->window_start;
929 __entry->max_size = cluster->max_size;
930 __entry->size = size;
931 __entry->bitmap = bitmap;
932 ),
933
934 TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
935 "size = %Lu, max_size = %Lu, bitmap = %d",
936 __entry->bg_objectid,
937 __entry->flags,
938 __print_flags((unsigned long)__entry->flags, "|",
939 BTRFS_GROUP_FLAGS), __entry->start,
940 __entry->size, __entry->max_size, __entry->bitmap)
941);
942
Jeff Mahoney143bede2012-03-01 14:56:26 +0100943struct extent_state;
944TRACE_EVENT(alloc_extent_state,
945
946 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
947
948 TP_ARGS(state, mask, IP),
949
950 TP_STRUCT__entry(
951 __field(struct extent_state *, state)
952 __field(gfp_t, mask)
953 __field(unsigned long, ip)
954 ),
955
956 TP_fast_assign(
957 __entry->state = state,
958 __entry->mask = mask,
959 __entry->ip = IP
960 ),
961
962 TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
963 show_gfp_flags(__entry->mask), (void *)__entry->ip)
964);
965
966TRACE_EVENT(free_extent_state,
967
968 TP_PROTO(struct extent_state *state, unsigned long IP),
969
970 TP_ARGS(state, IP),
971
972 TP_STRUCT__entry(
973 __field(struct extent_state *, state)
974 __field(unsigned long, ip)
975 ),
976
977 TP_fast_assign(
978 __entry->state = state,
979 __entry->ip = IP
980 ),
981
982 TP_printk(" state=%p; caller = %pF", __entry->state,
983 (void *)__entry->ip)
984);
985
Qu Wenruo52483bc2014-03-06 04:19:50 +0000986DECLARE_EVENT_CLASS(btrfs__work,
987
988 TP_PROTO(struct btrfs_work *work),
989
990 TP_ARGS(work),
991
992 TP_STRUCT__entry(
993 __field( void *, work )
994 __field( void *, wq )
995 __field( void *, func )
996 __field( void *, ordered_func )
997 __field( void *, ordered_free )
998 ),
999
1000 TP_fast_assign(
1001 __entry->work = work;
1002 __entry->wq = work->wq;
1003 __entry->func = work->func;
1004 __entry->ordered_func = work->ordered_func;
1005 __entry->ordered_free = work->ordered_free;
1006 ),
1007
1008 TP_printk("work=%p, wq=%p, func=%p, ordered_func=%p, ordered_free=%p",
1009 __entry->work, __entry->wq, __entry->func,
1010 __entry->ordered_func, __entry->ordered_free)
1011);
1012
1013/* For situiations that the work is freed */
1014DECLARE_EVENT_CLASS(btrfs__work__done,
1015
1016 TP_PROTO(struct btrfs_work *work),
1017
1018 TP_ARGS(work),
1019
1020 TP_STRUCT__entry(
1021 __field( void *, work )
1022 ),
1023
1024 TP_fast_assign(
1025 __entry->work = work;
1026 ),
1027
1028 TP_printk("work->%p", __entry->work)
1029);
1030
1031DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1032
1033 TP_PROTO(struct btrfs_work *work),
1034
1035 TP_ARGS(work)
1036);
1037
1038DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1039
1040 TP_PROTO(struct btrfs_work *work),
1041
1042 TP_ARGS(work)
1043);
1044
1045DEFINE_EVENT(btrfs__work, btrfs_normal_work_done,
1046
1047 TP_PROTO(struct btrfs_work *work),
1048
1049 TP_ARGS(work)
1050);
1051
1052DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1053
1054 TP_PROTO(struct btrfs_work *work),
1055
1056 TP_ARGS(work)
1057);
1058
1059DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1060
1061 TP_PROTO(struct btrfs_work *work),
1062
1063 TP_ARGS(work)
1064);
1065
1066
liubo1abe9b82011-03-24 11:18:59 +00001067#endif /* _TRACE_BTRFS_H */
1068
1069/* This part must be outside protection */
1070#include <trace/define_trace.h>