]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/trace/events/btrfs.h
Merge branch 'for-3.13' into for-next
[karo-tx-linux.git] / include / trace / events / btrfs.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM btrfs
3
4 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BTRFS_H
6
7 #include <linux/writeback.h>
8 #include <linux/tracepoint.h>
9 #include <trace/events/gfpflags.h>
10
11 struct btrfs_root;
12 struct btrfs_fs_info;
13 struct btrfs_inode;
14 struct extent_map;
15 struct btrfs_ordered_extent;
16 struct btrfs_delayed_ref_node;
17 struct btrfs_delayed_tree_ref;
18 struct btrfs_delayed_data_ref;
19 struct btrfs_delayed_ref_head;
20 struct btrfs_block_group_cache;
21 struct btrfs_free_cluster;
22 struct map_lookup;
23 struct extent_buffer;
24
25 #define show_ref_type(type)                                             \
26         __print_symbolic(type,                                          \
27                 { BTRFS_TREE_BLOCK_REF_KEY,     "TREE_BLOCK_REF" },     \
28                 { BTRFS_EXTENT_DATA_REF_KEY,    "EXTENT_DATA_REF" },    \
29                 { BTRFS_EXTENT_REF_V0_KEY,      "EXTENT_REF_V0" },      \
30                 { BTRFS_SHARED_BLOCK_REF_KEY,   "SHARED_BLOCK_REF" },   \
31                 { BTRFS_SHARED_DATA_REF_KEY,    "SHARED_DATA_REF" })
32
33 #define __show_root_type(obj)                                           \
34         __print_symbolic_u64(obj,                                       \
35                 { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
36                 { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
37                 { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
38                 { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
39                 { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
40                 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
41                 { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
42                 { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
43                 { BTRFS_QUOTA_TREE_OBJECTID,    "QUOTA_TREE"    },      \
44                 { 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) ||                \
49               (obj >= BTRFS_ROOT_TREE_OBJECTID &&                       \
50                obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
51
52 #define BTRFS_GROUP_FLAGS       \
53         { 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"}
62
63 #define BTRFS_UUID_SIZE 16
64
65 TRACE_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
86 DECLARE_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
124 DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
125
126         TP_PROTO(struct inode *inode),
127
128         TP_ARGS(inode)
129 );
130
131 DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
132
133         TP_PROTO(struct inode *inode),
134
135         TP_ARGS(inode)
136 );
137
138 DEFINE_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)                                           \
146         __print_symbolic_u64(type,                                      \
147                 { 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"       },      \
160                 { EXTENT_FLAG_PREALLOC,         "PREALLOC"      },      \
161                 { EXTENT_FLAG_LOGGING,          "LOGGING"       },      \
162                 { EXTENT_FLAG_FILLING,          "FILLING"       })
163
164 TRACE_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)                                       \
209         __print_symbolic(flags,                                         \
210                 { 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"      },      \
215                 { BTRFS_ORDERED_DIRECT,         "DIRECT"        },      \
216                 { BTRFS_ORDERED_IOERR,          "IOERR"         },      \
217                 { BTRFS_ORDERED_UPDATED_ISIZE,  "UPDATED_ISIZE" },      \
218                 { BTRFS_ORDERED_LOGGED_CSUM,    "LOGGED_CSUM"   })
219
220
221 DECLARE_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
269 DEFINE_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
276 DEFINE_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
283 DEFINE_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
290 DEFINE_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
297 DECLARE_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               )
311                 __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;
325                 __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, "
335                   "range_end = %llu, for_kupdate = %d, "
336                   "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,
341                   __entry->for_kupdate,
342                   __entry->for_reclaim, __entry->range_cyclic,
343                   (unsigned long)__entry->writeback_index)
344 );
345
346 DEFINE_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
354 TRACE_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
387 TRACE_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
417 TRACE_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
442 DECLARE_EVENT_CLASS(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              )
458                 __field(        u64,  seq               )
459         ),
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;
469                 __entry->seq            = ref->seq;
470         ),
471
472         TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
473                   "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
474                   "type = %s, seq = %llu",
475                   (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),
480                   __entry->level, show_ref_type(__entry->type),
481                   (unsigned long long)__entry->seq)
482 );
483
484 DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
485
486         TP_PROTO(struct btrfs_delayed_ref_node *ref,
487                  struct btrfs_delayed_tree_ref *full_ref,
488                  int action),
489
490         TP_ARGS(ref, full_ref, action)
491 );
492
493 DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
494
495         TP_PROTO(struct btrfs_delayed_ref_node *ref,
496                  struct btrfs_delayed_tree_ref *full_ref,
497                  int action),
498
499         TP_ARGS(ref, full_ref, action)
500 );
501
502 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
503
504         TP_PROTO(struct btrfs_delayed_ref_node *ref,
505                  struct btrfs_delayed_data_ref *full_ref,
506                  int action),
507
508         TP_ARGS(ref, full_ref, action),
509
510         TP_STRUCT__entry(
511                 __field(        u64,  bytenr            )
512                 __field(        u64,  num_bytes         )
513                 __field(        int,  action            ) 
514                 __field(        u64,  parent            )
515                 __field(        u64,  ref_root          )
516                 __field(        u64,  owner             )
517                 __field(        u64,  offset            )
518                 __field(        int,  type              )
519                 __field(        u64,  seq               )
520         ),
521
522         TP_fast_assign(
523                 __entry->bytenr         = ref->bytenr;
524                 __entry->num_bytes      = ref->num_bytes;
525                 __entry->action         = action;
526                 __entry->parent         = full_ref->parent;
527                 __entry->ref_root       = full_ref->root;
528                 __entry->owner          = full_ref->objectid;
529                 __entry->offset         = full_ref->offset;
530                 __entry->type           = ref->type;
531                 __entry->seq            = ref->seq;
532         ),
533
534         TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
535                   "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
536                   "offset = %llu, type = %s, seq = %llu",
537                   (unsigned long long)__entry->bytenr,
538                   (unsigned long long)__entry->num_bytes,
539                   show_ref_action(__entry->action),
540                   show_root_type(__entry->parent),
541                   show_root_type(__entry->ref_root),
542                   (unsigned long long)__entry->owner,
543                   (unsigned long long)__entry->offset,
544                   show_ref_type(__entry->type),
545                   (unsigned long long)__entry->seq)
546 );
547
548 DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
549
550         TP_PROTO(struct btrfs_delayed_ref_node *ref,
551                  struct btrfs_delayed_data_ref *full_ref,
552                  int action),
553
554         TP_ARGS(ref, full_ref, action)
555 );
556
557 DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
558
559         TP_PROTO(struct btrfs_delayed_ref_node *ref,
560                  struct btrfs_delayed_data_ref *full_ref,
561                  int action),
562
563         TP_ARGS(ref, full_ref, action)
564 );
565
566 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
567
568         TP_PROTO(struct btrfs_delayed_ref_node *ref,
569                  struct btrfs_delayed_ref_head *head_ref,
570                  int action),
571
572         TP_ARGS(ref, head_ref, action),
573
574         TP_STRUCT__entry(
575                 __field(        u64,  bytenr            )
576                 __field(        u64,  num_bytes         )
577                 __field(        int,  action            ) 
578                 __field(        int,  is_data           )
579         ),
580
581         TP_fast_assign(
582                 __entry->bytenr         = ref->bytenr;
583                 __entry->num_bytes      = ref->num_bytes;
584                 __entry->action         = action;
585                 __entry->is_data        = head_ref->is_data;
586         ),
587
588         TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
589                   (unsigned long long)__entry->bytenr,
590                   (unsigned long long)__entry->num_bytes,
591                   show_ref_action(__entry->action),
592                   __entry->is_data)
593 );
594
595 DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
596
597         TP_PROTO(struct btrfs_delayed_ref_node *ref,
598                  struct btrfs_delayed_ref_head *head_ref,
599                  int action),
600
601         TP_ARGS(ref, head_ref, action)
602 );
603
604 DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
605
606         TP_PROTO(struct btrfs_delayed_ref_node *ref,
607                  struct btrfs_delayed_ref_head *head_ref,
608                  int action),
609
610         TP_ARGS(ref, head_ref, action)
611 );
612
613 #define show_chunk_type(type)                                   \
614         __print_flags(type, "|",                                \
615                 { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
616                 { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
617                 { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
618                 { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
619                 { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
620                 { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
621                 { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
622                 { BTRFS_BLOCK_GROUP_RAID5,      "RAID5" },      \
623                 { BTRFS_BLOCK_GROUP_RAID6,      "RAID6" })
624
625 DECLARE_EVENT_CLASS(btrfs__chunk,
626
627         TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
628                  u64 offset, u64 size),
629
630         TP_ARGS(root, map, offset, size),
631
632         TP_STRUCT__entry(
633                 __field(        int,  num_stripes               )
634                 __field(        u64,  type                      )
635                 __field(        int,  sub_stripes               )
636                 __field(        u64,  offset                    )
637                 __field(        u64,  size                      )
638                 __field(        u64,  root_objectid             )
639         ),
640
641         TP_fast_assign(
642                 __entry->num_stripes    = map->num_stripes;
643                 __entry->type           = map->type;
644                 __entry->sub_stripes    = map->sub_stripes;
645                 __entry->offset         = offset;
646                 __entry->size           = size;
647                 __entry->root_objectid  = root->root_key.objectid;
648         ),
649
650         TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
651                   "num_stripes = %d, sub_stripes = %d, type = %s",
652                   show_root_type(__entry->root_objectid),
653                   (unsigned long long)__entry->offset,
654                   (unsigned long long)__entry->size,
655                   __entry->num_stripes, __entry->sub_stripes,
656                   show_chunk_type(__entry->type))
657 );
658
659 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
660
661         TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
662                  u64 offset, u64 size),
663
664         TP_ARGS(root, map, offset, size)
665 );
666
667 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
668
669         TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
670                  u64 offset, u64 size),
671
672         TP_ARGS(root, map, offset, size)
673 );
674
675 TRACE_EVENT(btrfs_cow_block,
676
677         TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
678                  struct extent_buffer *cow),
679
680         TP_ARGS(root, buf, cow),
681
682         TP_STRUCT__entry(
683                 __field(        u64,  root_objectid             )
684                 __field(        u64,  buf_start                 )
685                 __field(        int,  refs                      )
686                 __field(        u64,  cow_start                 )
687                 __field(        int,  buf_level                 )
688                 __field(        int,  cow_level                 )
689         ),
690
691         TP_fast_assign(
692                 __entry->root_objectid  = root->root_key.objectid;
693                 __entry->buf_start      = buf->start;
694                 __entry->refs           = atomic_read(&buf->refs);
695                 __entry->cow_start      = cow->start;
696                 __entry->buf_level      = btrfs_header_level(buf);
697                 __entry->cow_level      = btrfs_header_level(cow);
698         ),
699
700         TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
701                   "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
702                   show_root_type(__entry->root_objectid),
703                   __entry->refs,
704                   (unsigned long long)__entry->buf_start,
705                   __entry->buf_level,
706                   (unsigned long long)__entry->cow_start,
707                   __entry->cow_level)
708 );
709
710 TRACE_EVENT(btrfs_space_reservation,
711
712         TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
713                  u64 bytes, int reserve),
714
715         TP_ARGS(fs_info, type, val, bytes, reserve),
716
717         TP_STRUCT__entry(
718                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
719                 __string(       type,   type                    )
720                 __field(        u64,    val                     )
721                 __field(        u64,    bytes                   )
722                 __field(        int,    reserve                 )
723         ),
724
725         TP_fast_assign(
726                 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
727                 __assign_str(type, type);
728                 __entry->val            = val;
729                 __entry->bytes          = bytes;
730                 __entry->reserve        = reserve;
731         ),
732
733         TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
734                   __entry->val, __entry->reserve ? "reserve" : "release",
735                   __entry->bytes)
736 );
737
738 DECLARE_EVENT_CLASS(btrfs__reserved_extent,
739
740         TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
741
742         TP_ARGS(root, start, len),
743
744         TP_STRUCT__entry(
745                 __field(        u64,  root_objectid             )
746                 __field(        u64,  start                     )
747                 __field(        u64,  len                       )
748         ),
749
750         TP_fast_assign(
751                 __entry->root_objectid  = root->root_key.objectid;
752                 __entry->start          = start;
753                 __entry->len            = len;
754         ),
755
756         TP_printk("root = %llu(%s), start = %llu, len = %llu",
757                   show_root_type(__entry->root_objectid),
758                   (unsigned long long)__entry->start,
759                   (unsigned long long)__entry->len)
760 );
761
762 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
763
764         TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
765
766         TP_ARGS(root, start, len)
767 );
768
769 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
770
771         TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
772
773         TP_ARGS(root, start, len)
774 );
775
776 TRACE_EVENT(find_free_extent,
777
778         TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
779                  u64 data),
780
781         TP_ARGS(root, num_bytes, empty_size, data),
782
783         TP_STRUCT__entry(
784                 __field(        u64,    root_objectid           )
785                 __field(        u64,    num_bytes               )
786                 __field(        u64,    empty_size              )
787                 __field(        u64,    data                    )
788         ),
789
790         TP_fast_assign(
791                 __entry->root_objectid  = root->root_key.objectid;
792                 __entry->num_bytes      = num_bytes;
793                 __entry->empty_size     = empty_size;
794                 __entry->data           = data;
795         ),
796
797         TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
798                   "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
799                   __entry->num_bytes, __entry->empty_size, __entry->data,
800                   __print_flags((unsigned long)__entry->data, "|",
801                                  BTRFS_GROUP_FLAGS))
802 );
803
804 DECLARE_EVENT_CLASS(btrfs__reserve_extent,
805
806         TP_PROTO(struct btrfs_root *root,
807                  struct btrfs_block_group_cache *block_group, u64 start,
808                  u64 len),
809
810         TP_ARGS(root, block_group, start, len),
811
812         TP_STRUCT__entry(
813                 __field(        u64,    root_objectid           )
814                 __field(        u64,    bg_objectid             )
815                 __field(        u64,    flags                   )
816                 __field(        u64,    start                   )
817                 __field(        u64,    len                     )
818         ),
819
820         TP_fast_assign(
821                 __entry->root_objectid  = root->root_key.objectid;
822                 __entry->bg_objectid    = block_group->key.objectid;
823                 __entry->flags          = block_group->flags;
824                 __entry->start          = start;
825                 __entry->len            = len;
826         ),
827
828         TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
829                   "start = %Lu, len = %Lu",
830                   show_root_type(__entry->root_objectid), __entry->bg_objectid,
831                   __entry->flags, __print_flags((unsigned long)__entry->flags,
832                                                 "|", BTRFS_GROUP_FLAGS),
833                   __entry->start, __entry->len)
834 );
835
836 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
837
838         TP_PROTO(struct btrfs_root *root,
839                  struct btrfs_block_group_cache *block_group, u64 start,
840                  u64 len),
841
842         TP_ARGS(root, block_group, start, len)
843 );
844
845 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
846
847         TP_PROTO(struct btrfs_root *root,
848                  struct btrfs_block_group_cache *block_group, u64 start,
849                  u64 len),
850
851         TP_ARGS(root, block_group, start, len)
852 );
853
854 TRACE_EVENT(btrfs_find_cluster,
855
856         TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
857                  u64 bytes, u64 empty_size, u64 min_bytes),
858
859         TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
860
861         TP_STRUCT__entry(
862                 __field(        u64,    bg_objectid             )
863                 __field(        u64,    flags                   )
864                 __field(        u64,    start                   )
865                 __field(        u64,    bytes                   )
866                 __field(        u64,    empty_size              )
867                 __field(        u64,    min_bytes               )
868         ),
869
870         TP_fast_assign(
871                 __entry->bg_objectid    = block_group->key.objectid;
872                 __entry->flags          = block_group->flags;
873                 __entry->start          = start;
874                 __entry->bytes          = bytes;
875                 __entry->empty_size     = empty_size;
876                 __entry->min_bytes      = min_bytes;
877         ),
878
879         TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
880                   " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
881                   __entry->flags,
882                   __print_flags((unsigned long)__entry->flags, "|",
883                                 BTRFS_GROUP_FLAGS), __entry->start,
884                   __entry->bytes, __entry->empty_size,  __entry->min_bytes)
885 );
886
887 TRACE_EVENT(btrfs_failed_cluster_setup,
888
889         TP_PROTO(struct btrfs_block_group_cache *block_group),
890
891         TP_ARGS(block_group),
892
893         TP_STRUCT__entry(
894                 __field(        u64,    bg_objectid             )
895         ),
896
897         TP_fast_assign(
898                 __entry->bg_objectid    = block_group->key.objectid;
899         ),
900
901         TP_printk("block_group = %Lu", __entry->bg_objectid)
902 );
903
904 TRACE_EVENT(btrfs_setup_cluster,
905
906         TP_PROTO(struct btrfs_block_group_cache *block_group,
907                  struct btrfs_free_cluster *cluster, u64 size, int bitmap),
908
909         TP_ARGS(block_group, cluster, size, bitmap),
910
911         TP_STRUCT__entry(
912                 __field(        u64,    bg_objectid             )
913                 __field(        u64,    flags                   )
914                 __field(        u64,    start                   )
915                 __field(        u64,    max_size                )
916                 __field(        u64,    size                    )
917                 __field(        int,    bitmap                  )
918         ),
919
920         TP_fast_assign(
921                 __entry->bg_objectid    = block_group->key.objectid;
922                 __entry->flags          = block_group->flags;
923                 __entry->start          = cluster->window_start;
924                 __entry->max_size       = cluster->max_size;
925                 __entry->size           = size;
926                 __entry->bitmap         = bitmap;
927         ),
928
929         TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
930                   "size = %Lu, max_size = %Lu, bitmap = %d",
931                   __entry->bg_objectid,
932                   __entry->flags,
933                   __print_flags((unsigned long)__entry->flags, "|",
934                                 BTRFS_GROUP_FLAGS), __entry->start,
935                   __entry->size, __entry->max_size, __entry->bitmap)
936 );
937
938 struct extent_state;
939 TRACE_EVENT(alloc_extent_state,
940
941         TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
942
943         TP_ARGS(state, mask, IP),
944
945         TP_STRUCT__entry(
946                 __field(struct extent_state *, state)
947                 __field(gfp_t, mask)
948                 __field(unsigned long, ip)
949         ),
950
951         TP_fast_assign(
952                 __entry->state  = state,
953                 __entry->mask   = mask,
954                 __entry->ip     = IP
955         ),
956
957         TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
958                   show_gfp_flags(__entry->mask), (void *)__entry->ip)
959 );
960
961 TRACE_EVENT(free_extent_state,
962
963         TP_PROTO(struct extent_state *state, unsigned long IP),
964
965         TP_ARGS(state, IP),
966
967         TP_STRUCT__entry(
968                 __field(struct extent_state *, state)
969                 __field(unsigned long, ip)
970         ),
971
972         TP_fast_assign(
973                 __entry->state  = state,
974                 __entry->ip = IP
975         ),
976
977         TP_printk(" state=%p; caller = %pF", __entry->state,
978                   (void *)__entry->ip)
979 );
980
981 #endif /* _TRACE_BTRFS_H */
982
983 /* This part must be outside protection */
984 #include <trace/define_trace.h>