Merge tag 'upstream-4.8-rc1' of git://git.infradead.org/linux-ubifs
[sfrench/cifs-2.6.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/mmflags.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 struct btrfs_work;
25 struct __btrfs_workqueue;
26 struct btrfs_qgroup_extent_record;
27
28 #define show_ref_type(type)                                             \
29         __print_symbolic(type,                                          \
30                 { BTRFS_TREE_BLOCK_REF_KEY,     "TREE_BLOCK_REF" },     \
31                 { BTRFS_EXTENT_DATA_REF_KEY,    "EXTENT_DATA_REF" },    \
32                 { BTRFS_EXTENT_REF_V0_KEY,      "EXTENT_REF_V0" },      \
33                 { BTRFS_SHARED_BLOCK_REF_KEY,   "SHARED_BLOCK_REF" },   \
34                 { BTRFS_SHARED_DATA_REF_KEY,    "SHARED_DATA_REF" })
35
36 #define __show_root_type(obj)                                           \
37         __print_symbolic_u64(obj,                                       \
38                 { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
39                 { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
40                 { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
41                 { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
42                 { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
43                 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
44                 { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
45                 { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
46                 { BTRFS_QUOTA_TREE_OBJECTID,    "QUOTA_TREE"    },      \
47                 { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
48                 { BTRFS_UUID_TREE_OBJECTID,     "UUID_TREE"     },      \
49                 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },  \
50                 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
51
52 #define show_root_type(obj)                                             \
53         obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
54               (obj >= BTRFS_ROOT_TREE_OBJECTID &&                       \
55                obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
56
57 #define BTRFS_GROUP_FLAGS       \
58         { BTRFS_BLOCK_GROUP_DATA,       "DATA"},        \
59         { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
60         { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
61         { BTRFS_BLOCK_GROUP_RAID0,      "RAID0"},       \
62         { BTRFS_BLOCK_GROUP_RAID1,      "RAID1"},       \
63         { BTRFS_BLOCK_GROUP_DUP,        "DUP"},         \
64         { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
65         { BTRFS_BLOCK_GROUP_RAID5,      "RAID5"},       \
66         { BTRFS_BLOCK_GROUP_RAID6,      "RAID6"}
67
68 #define BTRFS_UUID_SIZE 16
69
70 TRACE_EVENT(btrfs_transaction_commit,
71
72         TP_PROTO(struct btrfs_root *root),
73
74         TP_ARGS(root),
75
76         TP_STRUCT__entry(
77                 __field(        u64,  generation                )
78                 __field(        u64,  root_objectid             )
79         ),
80
81         TP_fast_assign(
82                 __entry->generation     = root->fs_info->generation;
83                 __entry->root_objectid  = root->root_key.objectid;
84         ),
85
86         TP_printk("root = %llu(%s), gen = %llu",
87                   show_root_type(__entry->root_objectid),
88                   (unsigned long long)__entry->generation)
89 );
90
91 DECLARE_EVENT_CLASS(btrfs__inode,
92
93         TP_PROTO(struct inode *inode),
94
95         TP_ARGS(inode),
96
97         TP_STRUCT__entry(
98                 __field(        ino_t,  ino                     )
99                 __field(        blkcnt_t,  blocks               )
100                 __field(        u64,  disk_i_size               )
101                 __field(        u64,  generation                )
102                 __field(        u64,  last_trans                )
103                 __field(        u64,  logged_trans              )
104                 __field(        u64,  root_objectid             )
105         ),
106
107         TP_fast_assign(
108                 __entry->ino    = inode->i_ino;
109                 __entry->blocks = inode->i_blocks;
110                 __entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
111                 __entry->generation = BTRFS_I(inode)->generation;
112                 __entry->last_trans = BTRFS_I(inode)->last_trans;
113                 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
114                 __entry->root_objectid =
115                                 BTRFS_I(inode)->root->root_key.objectid;
116         ),
117
118         TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
119                   "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
120                   show_root_type(__entry->root_objectid),
121                   (unsigned long long)__entry->generation,
122                   (unsigned long)__entry->ino,
123                   (unsigned long long)__entry->blocks,
124                   (unsigned long long)__entry->disk_i_size,
125                   (unsigned long long)__entry->last_trans,
126                   (unsigned long long)__entry->logged_trans)
127 );
128
129 DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
130
131         TP_PROTO(struct inode *inode),
132
133         TP_ARGS(inode)
134 );
135
136 DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
137
138         TP_PROTO(struct inode *inode),
139
140         TP_ARGS(inode)
141 );
142
143 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
144
145         TP_PROTO(struct inode *inode),
146
147         TP_ARGS(inode)
148 );
149
150 #define __show_map_type(type)                                           \
151         __print_symbolic_u64(type,                                      \
152                 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE"     },              \
153                 { EXTENT_MAP_HOLE,      "HOLE"          },              \
154                 { EXTENT_MAP_INLINE,    "INLINE"        },              \
155                 { EXTENT_MAP_DELALLOC,  "DELALLOC"      })
156
157 #define show_map_type(type)                     \
158         type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
159
160 #define show_map_flags(flag)                                            \
161         __print_flags(flag, "|",                                        \
162                 { (1 << EXTENT_FLAG_PINNED),            "PINNED"        },\
163                 { (1 << EXTENT_FLAG_COMPRESSED),        "COMPRESSED"    },\
164                 { (1 << EXTENT_FLAG_VACANCY),           "VACANCY"       },\
165                 { (1 << EXTENT_FLAG_PREALLOC),          "PREALLOC"      },\
166                 { (1 << EXTENT_FLAG_LOGGING),           "LOGGING"       },\
167                 { (1 << EXTENT_FLAG_FILLING),           "FILLING"       },\
168                 { (1 << EXTENT_FLAG_FS_MAPPING),        "FS_MAPPING"    })
169
170 TRACE_EVENT_CONDITION(btrfs_get_extent,
171
172         TP_PROTO(struct btrfs_root *root, struct extent_map *map),
173
174         TP_ARGS(root, map),
175
176         TP_CONDITION(map),
177
178         TP_STRUCT__entry(
179                 __field(        u64,  root_objectid     )
180                 __field(        u64,  start             )
181                 __field(        u64,  len               )
182                 __field(        u64,  orig_start        )
183                 __field(        u64,  block_start       )
184                 __field(        u64,  block_len         )
185                 __field(        unsigned long,  flags   )
186                 __field(        int,  refs              )
187                 __field(        unsigned int,  compress_type    )
188         ),
189
190         TP_fast_assign(
191                 __entry->root_objectid  = root->root_key.objectid;
192                 __entry->start          = map->start;
193                 __entry->len            = map->len;
194                 __entry->orig_start     = map->orig_start;
195                 __entry->block_start    = map->block_start;
196                 __entry->block_len      = map->block_len;
197                 __entry->flags          = map->flags;
198                 __entry->refs           = atomic_read(&map->refs);
199                 __entry->compress_type  = map->compress_type;
200         ),
201
202         TP_printk("root = %llu(%s), start = %llu, len = %llu, "
203                   "orig_start = %llu, block_start = %llu(%s), "
204                   "block_len = %llu, flags = %s, refs = %u, "
205                   "compress_type = %u",
206                   show_root_type(__entry->root_objectid),
207                   (unsigned long long)__entry->start,
208                   (unsigned long long)__entry->len,
209                   (unsigned long long)__entry->orig_start,
210                   show_map_type(__entry->block_start),
211                   (unsigned long long)__entry->block_len,
212                   show_map_flags(__entry->flags),
213                   __entry->refs, __entry->compress_type)
214 );
215
216 #define show_ordered_flags(flags)                                          \
217         __print_flags(flags, "|",                                          \
218                 { (1 << BTRFS_ORDERED_IO_DONE),         "IO_DONE"       }, \
219                 { (1 << BTRFS_ORDERED_COMPLETE),        "COMPLETE"      }, \
220                 { (1 << BTRFS_ORDERED_NOCOW),           "NOCOW"         }, \
221                 { (1 << BTRFS_ORDERED_COMPRESSED),      "COMPRESSED"    }, \
222                 { (1 << BTRFS_ORDERED_PREALLOC),        "PREALLOC"      }, \
223                 { (1 << BTRFS_ORDERED_DIRECT),          "DIRECT"        }, \
224                 { (1 << BTRFS_ORDERED_IOERR),           "IOERR"         }, \
225                 { (1 << BTRFS_ORDERED_UPDATED_ISIZE),   "UPDATED_ISIZE" }, \
226                 { (1 << BTRFS_ORDERED_LOGGED_CSUM),     "LOGGED_CSUM"   }, \
227                 { (1 << BTRFS_ORDERED_TRUNCATED),       "TRUNCATED"     })
228
229
230 DECLARE_EVENT_CLASS(btrfs__ordered_extent,
231
232         TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
233
234         TP_ARGS(inode, ordered),
235
236         TP_STRUCT__entry(
237                 __field(        ino_t,  ino             )
238                 __field(        u64,  file_offset       )
239                 __field(        u64,  start             )
240                 __field(        u64,  len               )
241                 __field(        u64,  disk_len          )
242                 __field(        u64,  bytes_left        )
243                 __field(        unsigned long,  flags   )
244                 __field(        int,  compress_type     )
245                 __field(        int,  refs              )
246                 __field(        u64,  root_objectid     )
247         ),
248
249         TP_fast_assign(
250                 __entry->ino            = inode->i_ino;
251                 __entry->file_offset    = ordered->file_offset;
252                 __entry->start          = ordered->start;
253                 __entry->len            = ordered->len;
254                 __entry->disk_len       = ordered->disk_len;
255                 __entry->bytes_left     = ordered->bytes_left;
256                 __entry->flags          = ordered->flags;
257                 __entry->compress_type  = ordered->compress_type;
258                 __entry->refs           = atomic_read(&ordered->refs);
259                 __entry->root_objectid  =
260                                 BTRFS_I(inode)->root->root_key.objectid;
261         ),
262
263         TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
264                   "start = %llu, len = %llu, disk_len = %llu, "
265                   "bytes_left = %llu, flags = %s, compress_type = %d, "
266                   "refs = %d",
267                   show_root_type(__entry->root_objectid),
268                   (unsigned long long)__entry->ino,
269                   (unsigned long long)__entry->file_offset,
270                   (unsigned long long)__entry->start,
271                   (unsigned long long)__entry->len,
272                   (unsigned long long)__entry->disk_len,
273                   (unsigned long long)__entry->bytes_left,
274                   show_ordered_flags(__entry->flags),
275                   __entry->compress_type, __entry->refs)
276 );
277
278 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
279
280         TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
281
282         TP_ARGS(inode, ordered)
283 );
284
285 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
286
287         TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
288
289         TP_ARGS(inode, ordered)
290 );
291
292 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
293
294         TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
295
296         TP_ARGS(inode, ordered)
297 );
298
299 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
300
301         TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
302
303         TP_ARGS(inode, ordered)
304 );
305
306 DECLARE_EVENT_CLASS(btrfs__writepage,
307
308         TP_PROTO(struct page *page, struct inode *inode,
309                  struct writeback_control *wbc),
310
311         TP_ARGS(page, inode, wbc),
312
313         TP_STRUCT__entry(
314                 __field(        ino_t,  ino                     )
315                 __field(        pgoff_t,  index                 )
316                 __field(        long,   nr_to_write             )
317                 __field(        long,   pages_skipped           )
318                 __field(        loff_t, range_start             )
319                 __field(        loff_t, range_end               )
320                 __field(        char,   for_kupdate             )
321                 __field(        char,   for_reclaim             )
322                 __field(        char,   range_cyclic            )
323                 __field(        pgoff_t,  writeback_index       )
324                 __field(        u64,    root_objectid           )
325         ),
326
327         TP_fast_assign(
328                 __entry->ino            = inode->i_ino;
329                 __entry->index          = page->index;
330                 __entry->nr_to_write    = wbc->nr_to_write;
331                 __entry->pages_skipped  = wbc->pages_skipped;
332                 __entry->range_start    = wbc->range_start;
333                 __entry->range_end      = wbc->range_end;
334                 __entry->for_kupdate    = wbc->for_kupdate;
335                 __entry->for_reclaim    = wbc->for_reclaim;
336                 __entry->range_cyclic   = wbc->range_cyclic;
337                 __entry->writeback_index = inode->i_mapping->writeback_index;
338                 __entry->root_objectid  =
339                                  BTRFS_I(inode)->root->root_key.objectid;
340         ),
341
342         TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
343                   "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
344                   "range_end = %llu, for_kupdate = %d, "
345                   "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
346                   show_root_type(__entry->root_objectid),
347                   (unsigned long)__entry->ino, __entry->index,
348                   __entry->nr_to_write, __entry->pages_skipped,
349                   __entry->range_start, __entry->range_end,
350                   __entry->for_kupdate,
351                   __entry->for_reclaim, __entry->range_cyclic,
352                   (unsigned long)__entry->writeback_index)
353 );
354
355 DEFINE_EVENT(btrfs__writepage, __extent_writepage,
356
357         TP_PROTO(struct page *page, struct inode *inode,
358                  struct writeback_control *wbc),
359
360         TP_ARGS(page, inode, wbc)
361 );
362
363 TRACE_EVENT(btrfs_writepage_end_io_hook,
364
365         TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
366
367         TP_ARGS(page, start, end, uptodate),
368
369         TP_STRUCT__entry(
370                 __field(        ino_t,   ino            )
371                 __field(        pgoff_t, index          )
372                 __field(        u64,     start          )
373                 __field(        u64,     end            )
374                 __field(        int,     uptodate       )
375                 __field(        u64,    root_objectid   )
376         ),
377
378         TP_fast_assign(
379                 __entry->ino    = page->mapping->host->i_ino;
380                 __entry->index  = page->index;
381                 __entry->start  = start;
382                 __entry->end    = end;
383                 __entry->uptodate = uptodate;
384                 __entry->root_objectid  =
385                          BTRFS_I(page->mapping->host)->root->root_key.objectid;
386         ),
387
388         TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
389                   "end = %llu, uptodate = %d",
390                   show_root_type(__entry->root_objectid),
391                   (unsigned long)__entry->ino, (unsigned long)__entry->index,
392                   (unsigned long long)__entry->start,
393                   (unsigned long long)__entry->end, __entry->uptodate)
394 );
395
396 TRACE_EVENT(btrfs_sync_file,
397
398         TP_PROTO(struct file *file, int datasync),
399
400         TP_ARGS(file, datasync),
401
402         TP_STRUCT__entry(
403                 __field(        ino_t,  ino             )
404                 __field(        ino_t,  parent          )
405                 __field(        int,    datasync        )
406                 __field(        u64,    root_objectid   )
407         ),
408
409         TP_fast_assign(
410                 struct dentry *dentry = file->f_path.dentry;
411                 struct inode *inode = d_inode(dentry);
412
413                 __entry->ino            = inode->i_ino;
414                 __entry->parent         = d_inode(dentry->d_parent)->i_ino;
415                 __entry->datasync       = datasync;
416                 __entry->root_objectid  =
417                                  BTRFS_I(inode)->root->root_key.objectid;
418         ),
419
420         TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
421                   show_root_type(__entry->root_objectid),
422                   (unsigned long)__entry->ino, (unsigned long)__entry->parent,
423                   __entry->datasync)
424 );
425
426 TRACE_EVENT(btrfs_sync_fs,
427
428         TP_PROTO(int wait),
429
430         TP_ARGS(wait),
431
432         TP_STRUCT__entry(
433                 __field(        int,  wait              )
434         ),
435
436         TP_fast_assign(
437                 __entry->wait   = wait;
438         ),
439
440         TP_printk("wait = %d", __entry->wait)
441 );
442
443 TRACE_EVENT(btrfs_add_block_group,
444
445         TP_PROTO(struct btrfs_fs_info *fs_info,
446                  struct btrfs_block_group_cache *block_group, int create),
447
448         TP_ARGS(fs_info, block_group, create),
449
450         TP_STRUCT__entry(
451                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
452                 __field(        u64,    offset                  )
453                 __field(        u64,    size                    )
454                 __field(        u64,    flags                   )
455                 __field(        u64,    bytes_used              )
456                 __field(        u64,    bytes_super             )
457                 __field(        int,    create                  )
458         ),
459
460         TP_fast_assign(
461                 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
462                 __entry->offset         = block_group->key.objectid;
463                 __entry->size           = block_group->key.offset;
464                 __entry->flags          = block_group->flags;
465                 __entry->bytes_used     =
466                         btrfs_block_group_used(&block_group->item);
467                 __entry->bytes_super    = block_group->bytes_super;
468                 __entry->create         = create;
469         ),
470
471         TP_printk("%pU: block_group offset = %llu, size = %llu, "
472                   "flags = %llu(%s), bytes_used = %llu, bytes_super = %llu, "
473                   "create = %d", __entry->fsid,
474                   (unsigned long long)__entry->offset,
475                   (unsigned long long)__entry->size,
476                   (unsigned long long)__entry->flags,
477                   __print_flags((unsigned long)__entry->flags, "|",
478                                 BTRFS_GROUP_FLAGS),
479                   (unsigned long long)__entry->bytes_used,
480                   (unsigned long long)__entry->bytes_super, __entry->create)
481 );
482
483 #define show_ref_action(action)                                         \
484         __print_symbolic(action,                                        \
485                 { BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },        \
486                 { BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },       \
487                 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" },     \
488                 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
489                         
490
491 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
492
493         TP_PROTO(struct btrfs_delayed_ref_node *ref,
494                  struct btrfs_delayed_tree_ref *full_ref,
495                  int action),
496
497         TP_ARGS(ref, full_ref, action),
498
499         TP_STRUCT__entry(
500                 __field(        u64,  bytenr            )
501                 __field(        u64,  num_bytes         )
502                 __field(        int,  action            ) 
503                 __field(        u64,  parent            )
504                 __field(        u64,  ref_root          )
505                 __field(        int,  level             )
506                 __field(        int,  type              )
507                 __field(        u64,  seq               )
508         ),
509
510         TP_fast_assign(
511                 __entry->bytenr         = ref->bytenr;
512                 __entry->num_bytes      = ref->num_bytes;
513                 __entry->action         = action;
514                 __entry->parent         = full_ref->parent;
515                 __entry->ref_root       = full_ref->root;
516                 __entry->level          = full_ref->level;
517                 __entry->type           = ref->type;
518                 __entry->seq            = ref->seq;
519         ),
520
521         TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
522                   "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
523                   "type = %s, seq = %llu",
524                   (unsigned long long)__entry->bytenr,
525                   (unsigned long long)__entry->num_bytes,
526                   show_ref_action(__entry->action),
527                   show_root_type(__entry->parent),
528                   show_root_type(__entry->ref_root),
529                   __entry->level, show_ref_type(__entry->type),
530                   (unsigned long long)__entry->seq)
531 );
532
533 DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
534
535         TP_PROTO(struct btrfs_delayed_ref_node *ref,
536                  struct btrfs_delayed_tree_ref *full_ref,
537                  int action),
538
539         TP_ARGS(ref, full_ref, action)
540 );
541
542 DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
543
544         TP_PROTO(struct btrfs_delayed_ref_node *ref,
545                  struct btrfs_delayed_tree_ref *full_ref,
546                  int action),
547
548         TP_ARGS(ref, full_ref, action)
549 );
550
551 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
552
553         TP_PROTO(struct btrfs_delayed_ref_node *ref,
554                  struct btrfs_delayed_data_ref *full_ref,
555                  int action),
556
557         TP_ARGS(ref, full_ref, action),
558
559         TP_STRUCT__entry(
560                 __field(        u64,  bytenr            )
561                 __field(        u64,  num_bytes         )
562                 __field(        int,  action            ) 
563                 __field(        u64,  parent            )
564                 __field(        u64,  ref_root          )
565                 __field(        u64,  owner             )
566                 __field(        u64,  offset            )
567                 __field(        int,  type              )
568                 __field(        u64,  seq               )
569         ),
570
571         TP_fast_assign(
572                 __entry->bytenr         = ref->bytenr;
573                 __entry->num_bytes      = ref->num_bytes;
574                 __entry->action         = action;
575                 __entry->parent         = full_ref->parent;
576                 __entry->ref_root       = full_ref->root;
577                 __entry->owner          = full_ref->objectid;
578                 __entry->offset         = full_ref->offset;
579                 __entry->type           = ref->type;
580                 __entry->seq            = ref->seq;
581         ),
582
583         TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
584                   "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
585                   "offset = %llu, type = %s, seq = %llu",
586                   (unsigned long long)__entry->bytenr,
587                   (unsigned long long)__entry->num_bytes,
588                   show_ref_action(__entry->action),
589                   show_root_type(__entry->parent),
590                   show_root_type(__entry->ref_root),
591                   (unsigned long long)__entry->owner,
592                   (unsigned long long)__entry->offset,
593                   show_ref_type(__entry->type),
594                   (unsigned long long)__entry->seq)
595 );
596
597 DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
598
599         TP_PROTO(struct btrfs_delayed_ref_node *ref,
600                  struct btrfs_delayed_data_ref *full_ref,
601                  int action),
602
603         TP_ARGS(ref, full_ref, action)
604 );
605
606 DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
607
608         TP_PROTO(struct btrfs_delayed_ref_node *ref,
609                  struct btrfs_delayed_data_ref *full_ref,
610                  int action),
611
612         TP_ARGS(ref, full_ref, action)
613 );
614
615 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
616
617         TP_PROTO(struct btrfs_delayed_ref_node *ref,
618                  struct btrfs_delayed_ref_head *head_ref,
619                  int action),
620
621         TP_ARGS(ref, head_ref, action),
622
623         TP_STRUCT__entry(
624                 __field(        u64,  bytenr            )
625                 __field(        u64,  num_bytes         )
626                 __field(        int,  action            ) 
627                 __field(        int,  is_data           )
628         ),
629
630         TP_fast_assign(
631                 __entry->bytenr         = ref->bytenr;
632                 __entry->num_bytes      = ref->num_bytes;
633                 __entry->action         = action;
634                 __entry->is_data        = head_ref->is_data;
635         ),
636
637         TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
638                   (unsigned long long)__entry->bytenr,
639                   (unsigned long long)__entry->num_bytes,
640                   show_ref_action(__entry->action),
641                   __entry->is_data)
642 );
643
644 DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
645
646         TP_PROTO(struct btrfs_delayed_ref_node *ref,
647                  struct btrfs_delayed_ref_head *head_ref,
648                  int action),
649
650         TP_ARGS(ref, head_ref, action)
651 );
652
653 DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
654
655         TP_PROTO(struct btrfs_delayed_ref_node *ref,
656                  struct btrfs_delayed_ref_head *head_ref,
657                  int action),
658
659         TP_ARGS(ref, head_ref, action)
660 );
661
662 #define show_chunk_type(type)                                   \
663         __print_flags(type, "|",                                \
664                 { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
665                 { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
666                 { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
667                 { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
668                 { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
669                 { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
670                 { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
671                 { BTRFS_BLOCK_GROUP_RAID5,      "RAID5" },      \
672                 { BTRFS_BLOCK_GROUP_RAID6,      "RAID6" })
673
674 DECLARE_EVENT_CLASS(btrfs__chunk,
675
676         TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
677                  u64 offset, u64 size),
678
679         TP_ARGS(root, map, offset, size),
680
681         TP_STRUCT__entry(
682                 __field(        int,  num_stripes               )
683                 __field(        u64,  type                      )
684                 __field(        int,  sub_stripes               )
685                 __field(        u64,  offset                    )
686                 __field(        u64,  size                      )
687                 __field(        u64,  root_objectid             )
688         ),
689
690         TP_fast_assign(
691                 __entry->num_stripes    = map->num_stripes;
692                 __entry->type           = map->type;
693                 __entry->sub_stripes    = map->sub_stripes;
694                 __entry->offset         = offset;
695                 __entry->size           = size;
696                 __entry->root_objectid  = root->root_key.objectid;
697         ),
698
699         TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
700                   "num_stripes = %d, sub_stripes = %d, type = %s",
701                   show_root_type(__entry->root_objectid),
702                   (unsigned long long)__entry->offset,
703                   (unsigned long long)__entry->size,
704                   __entry->num_stripes, __entry->sub_stripes,
705                   show_chunk_type(__entry->type))
706 );
707
708 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
709
710         TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
711                  u64 offset, u64 size),
712
713         TP_ARGS(root, map, offset, size)
714 );
715
716 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
717
718         TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
719                  u64 offset, u64 size),
720
721         TP_ARGS(root, map, offset, size)
722 );
723
724 TRACE_EVENT(btrfs_cow_block,
725
726         TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
727                  struct extent_buffer *cow),
728
729         TP_ARGS(root, buf, cow),
730
731         TP_STRUCT__entry(
732                 __field(        u64,  root_objectid             )
733                 __field(        u64,  buf_start                 )
734                 __field(        int,  refs                      )
735                 __field(        u64,  cow_start                 )
736                 __field(        int,  buf_level                 )
737                 __field(        int,  cow_level                 )
738         ),
739
740         TP_fast_assign(
741                 __entry->root_objectid  = root->root_key.objectid;
742                 __entry->buf_start      = buf->start;
743                 __entry->refs           = atomic_read(&buf->refs);
744                 __entry->cow_start      = cow->start;
745                 __entry->buf_level      = btrfs_header_level(buf);
746                 __entry->cow_level      = btrfs_header_level(cow);
747         ),
748
749         TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
750                   "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
751                   show_root_type(__entry->root_objectid),
752                   __entry->refs,
753                   (unsigned long long)__entry->buf_start,
754                   __entry->buf_level,
755                   (unsigned long long)__entry->cow_start,
756                   __entry->cow_level)
757 );
758
759 TRACE_EVENT(btrfs_space_reservation,
760
761         TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
762                  u64 bytes, int reserve),
763
764         TP_ARGS(fs_info, type, val, bytes, reserve),
765
766         TP_STRUCT__entry(
767                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
768                 __string(       type,   type                    )
769                 __field(        u64,    val                     )
770                 __field(        u64,    bytes                   )
771                 __field(        int,    reserve                 )
772         ),
773
774         TP_fast_assign(
775                 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
776                 __assign_str(type, type);
777                 __entry->val            = val;
778                 __entry->bytes          = bytes;
779                 __entry->reserve        = reserve;
780         ),
781
782         TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
783                   __entry->val, __entry->reserve ? "reserve" : "release",
784                   __entry->bytes)
785 );
786
787 #define show_flush_action(action)                                               \
788         __print_symbolic(action,                                                \
789                 { BTRFS_RESERVE_NO_FLUSH,       "BTRFS_RESERVE_NO_FLUSH"},      \
790                 { BTRFS_RESERVE_FLUSH_LIMIT,    "BTRFS_RESERVE_FLUSH_LIMIT"},   \
791                 { BTRFS_RESERVE_FLUSH_ALL,      "BTRFS_RESERVE_FLUSH_ALL"})
792
793 TRACE_EVENT(btrfs_trigger_flush,
794
795         TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
796                  int flush, char *reason),
797
798         TP_ARGS(fs_info, flags, bytes, flush, reason),
799
800         TP_STRUCT__entry(
801                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
802                 __field(        u64,    flags                   )
803                 __field(        u64,    bytes                   )
804                 __field(        int,    flush                   )
805                 __string(       reason, reason                  )
806         ),
807
808         TP_fast_assign(
809                 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
810                 __entry->flags  = flags;
811                 __entry->bytes  = bytes;
812                 __entry->flush  = flush;
813                 __assign_str(reason, reason)
814         ),
815
816         TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu",
817                   __entry->fsid, __get_str(reason), __entry->flush,
818                   show_flush_action(__entry->flush),
819                   (unsigned long long)__entry->flags,
820                   __print_flags((unsigned long)__entry->flags, "|",
821                                 BTRFS_GROUP_FLAGS),
822                   (unsigned long long)__entry->bytes)
823 );
824
825 #define show_flush_state(state)                                                 \
826         __print_symbolic(state,                                                 \
827                 { FLUSH_DELAYED_ITEMS_NR,       "FLUSH_DELAYED_ITEMS_NR"},      \
828                 { FLUSH_DELAYED_ITEMS,          "FLUSH_DELAYED_ITEMS"},         \
829                 { FLUSH_DELALLOC,               "FLUSH_DELALLOC"},              \
830                 { FLUSH_DELALLOC_WAIT,          "FLUSH_DELALLOC_WAIT"},         \
831                 { ALLOC_CHUNK,                  "ALLOC_CHUNK"},                 \
832                 { COMMIT_TRANS,                 "COMMIT_TRANS"})
833
834 TRACE_EVENT(btrfs_flush_space,
835
836         TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
837                  u64 orig_bytes, int state, int ret),
838
839         TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),
840
841         TP_STRUCT__entry(
842                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
843                 __field(        u64,    flags                   )
844                 __field(        u64,    num_bytes               )
845                 __field(        u64,    orig_bytes              )
846                 __field(        int,    state                   )
847                 __field(        int,    ret                     )
848         ),
849
850         TP_fast_assign(
851                 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
852                 __entry->flags          =       flags;
853                 __entry->num_bytes      =       num_bytes;
854                 __entry->orig_bytes     =       orig_bytes;
855                 __entry->state          =       state;
856                 __entry->ret            =       ret;
857         ),
858
859         TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, "
860                   "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state,
861                   show_flush_state(__entry->state),
862                   (unsigned long long)__entry->flags,
863                   __print_flags((unsigned long)__entry->flags, "|",
864                                 BTRFS_GROUP_FLAGS),
865                   (unsigned long long)__entry->num_bytes,
866                   (unsigned long long)__entry->orig_bytes, __entry->ret)
867 );
868
869 DECLARE_EVENT_CLASS(btrfs__reserved_extent,
870
871         TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
872
873         TP_ARGS(root, start, len),
874
875         TP_STRUCT__entry(
876                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
877                 __field(        u64,    root_objectid           )
878                 __field(        u64,    start                   )
879                 __field(        u64,    len                     )
880         ),
881
882         TP_fast_assign(
883                 memcpy(__entry->fsid, root->fs_info->fsid, BTRFS_UUID_SIZE);
884                 __entry->root_objectid  = root->root_key.objectid;
885                 __entry->start          = start;
886                 __entry->len            = len;
887         ),
888
889         TP_printk("%pU: root = %llu(%s), start = %llu, len = %llu",
890                   __entry->fsid,
891                   show_root_type(__entry->root_objectid),
892                   (unsigned long long)__entry->start,
893                   (unsigned long long)__entry->len)
894 );
895
896 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
897
898         TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
899
900         TP_ARGS(root, start, len)
901 );
902
903 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
904
905         TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
906
907         TP_ARGS(root, start, len)
908 );
909
910 TRACE_EVENT(find_free_extent,
911
912         TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
913                  u64 data),
914
915         TP_ARGS(root, num_bytes, empty_size, data),
916
917         TP_STRUCT__entry(
918                 __field(        u64,    root_objectid           )
919                 __field(        u64,    num_bytes               )
920                 __field(        u64,    empty_size              )
921                 __field(        u64,    data                    )
922         ),
923
924         TP_fast_assign(
925                 __entry->root_objectid  = root->root_key.objectid;
926                 __entry->num_bytes      = num_bytes;
927                 __entry->empty_size     = empty_size;
928                 __entry->data           = data;
929         ),
930
931         TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
932                   "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
933                   __entry->num_bytes, __entry->empty_size, __entry->data,
934                   __print_flags((unsigned long)__entry->data, "|",
935                                  BTRFS_GROUP_FLAGS))
936 );
937
938 DECLARE_EVENT_CLASS(btrfs__reserve_extent,
939
940         TP_PROTO(struct btrfs_root *root,
941                  struct btrfs_block_group_cache *block_group, u64 start,
942                  u64 len),
943
944         TP_ARGS(root, block_group, start, len),
945
946         TP_STRUCT__entry(
947                 __array(        u8,     fsid,   BTRFS_UUID_SIZE )
948                 __field(        u64,    root_objectid           )
949                 __field(        u64,    bg_objectid             )
950                 __field(        u64,    flags                   )
951                 __field(        u64,    start                   )
952                 __field(        u64,    len                     )
953         ),
954
955         TP_fast_assign(
956                 memcpy(__entry->fsid, root->fs_info->fsid, BTRFS_UUID_SIZE);
957                 __entry->root_objectid  = root->root_key.objectid;
958                 __entry->bg_objectid    = block_group->key.objectid;
959                 __entry->flags          = block_group->flags;
960                 __entry->start          = start;
961                 __entry->len            = len;
962         ),
963
964         TP_printk("%pU: root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
965                   "start = %Lu, len = %Lu", __entry->fsid,
966                   show_root_type(__entry->root_objectid), __entry->bg_objectid,
967                   __entry->flags, __print_flags((unsigned long)__entry->flags,
968                                                 "|", BTRFS_GROUP_FLAGS),
969                   __entry->start, __entry->len)
970 );
971
972 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
973
974         TP_PROTO(struct btrfs_root *root,
975                  struct btrfs_block_group_cache *block_group, u64 start,
976                  u64 len),
977
978         TP_ARGS(root, block_group, start, len)
979 );
980
981 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
982
983         TP_PROTO(struct btrfs_root *root,
984                  struct btrfs_block_group_cache *block_group, u64 start,
985                  u64 len),
986
987         TP_ARGS(root, block_group, start, len)
988 );
989
990 TRACE_EVENT(btrfs_find_cluster,
991
992         TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
993                  u64 bytes, u64 empty_size, u64 min_bytes),
994
995         TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
996
997         TP_STRUCT__entry(
998                 __field(        u64,    bg_objectid             )
999                 __field(        u64,    flags                   )
1000                 __field(        u64,    start                   )
1001                 __field(        u64,    bytes                   )
1002                 __field(        u64,    empty_size              )
1003                 __field(        u64,    min_bytes               )
1004         ),
1005
1006         TP_fast_assign(
1007                 __entry->bg_objectid    = block_group->key.objectid;
1008                 __entry->flags          = block_group->flags;
1009                 __entry->start          = start;
1010                 __entry->bytes          = bytes;
1011                 __entry->empty_size     = empty_size;
1012                 __entry->min_bytes      = min_bytes;
1013         ),
1014
1015         TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
1016                   " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
1017                   __entry->flags,
1018                   __print_flags((unsigned long)__entry->flags, "|",
1019                                 BTRFS_GROUP_FLAGS), __entry->start,
1020                   __entry->bytes, __entry->empty_size,  __entry->min_bytes)
1021 );
1022
1023 TRACE_EVENT(btrfs_failed_cluster_setup,
1024
1025         TP_PROTO(struct btrfs_block_group_cache *block_group),
1026
1027         TP_ARGS(block_group),
1028
1029         TP_STRUCT__entry(
1030                 __field(        u64,    bg_objectid             )
1031         ),
1032
1033         TP_fast_assign(
1034                 __entry->bg_objectid    = block_group->key.objectid;
1035         ),
1036
1037         TP_printk("block_group = %Lu", __entry->bg_objectid)
1038 );
1039
1040 TRACE_EVENT(btrfs_setup_cluster,
1041
1042         TP_PROTO(struct btrfs_block_group_cache *block_group,
1043                  struct btrfs_free_cluster *cluster, u64 size, int bitmap),
1044
1045         TP_ARGS(block_group, cluster, size, bitmap),
1046
1047         TP_STRUCT__entry(
1048                 __field(        u64,    bg_objectid             )
1049                 __field(        u64,    flags                   )
1050                 __field(        u64,    start                   )
1051                 __field(        u64,    max_size                )
1052                 __field(        u64,    size                    )
1053                 __field(        int,    bitmap                  )
1054         ),
1055
1056         TP_fast_assign(
1057                 __entry->bg_objectid    = block_group->key.objectid;
1058                 __entry->flags          = block_group->flags;
1059                 __entry->start          = cluster->window_start;
1060                 __entry->max_size       = cluster->max_size;
1061                 __entry->size           = size;
1062                 __entry->bitmap         = bitmap;
1063         ),
1064
1065         TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
1066                   "size = %Lu, max_size = %Lu, bitmap = %d",
1067                   __entry->bg_objectid,
1068                   __entry->flags,
1069                   __print_flags((unsigned long)__entry->flags, "|",
1070                                 BTRFS_GROUP_FLAGS), __entry->start,
1071                   __entry->size, __entry->max_size, __entry->bitmap)
1072 );
1073
1074 struct extent_state;
1075 TRACE_EVENT(alloc_extent_state,
1076
1077         TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
1078
1079         TP_ARGS(state, mask, IP),
1080
1081         TP_STRUCT__entry(
1082                 __field(struct extent_state *, state)
1083                 __field(gfp_t, mask)
1084                 __field(unsigned long, ip)
1085         ),
1086
1087         TP_fast_assign(
1088                 __entry->state  = state,
1089                 __entry->mask   = mask,
1090                 __entry->ip     = IP
1091         ),
1092
1093         TP_printk("state=%p; mask = %s; caller = %pS", __entry->state,
1094                   show_gfp_flags(__entry->mask), (void *)__entry->ip)
1095 );
1096
1097 TRACE_EVENT(free_extent_state,
1098
1099         TP_PROTO(struct extent_state *state, unsigned long IP),
1100
1101         TP_ARGS(state, IP),
1102
1103         TP_STRUCT__entry(
1104                 __field(struct extent_state *, state)
1105                 __field(unsigned long, ip)
1106         ),
1107
1108         TP_fast_assign(
1109                 __entry->state  = state,
1110                 __entry->ip = IP
1111         ),
1112
1113         TP_printk(" state=%p; caller = %pS", __entry->state,
1114                   (void *)__entry->ip)
1115 );
1116
1117 DECLARE_EVENT_CLASS(btrfs__work,
1118
1119         TP_PROTO(struct btrfs_work *work),
1120
1121         TP_ARGS(work),
1122
1123         TP_STRUCT__entry(
1124                 __field(        void *, work                    )
1125                 __field(        void *, wq                      )
1126                 __field(        void *, func                    )
1127                 __field(        void *, ordered_func            )
1128                 __field(        void *, ordered_free            )
1129                 __field(        void *, normal_work             )
1130         ),
1131
1132         TP_fast_assign(
1133                 __entry->work           = work;
1134                 __entry->wq             = work->wq;
1135                 __entry->func           = work->func;
1136                 __entry->ordered_func   = work->ordered_func;
1137                 __entry->ordered_free   = work->ordered_free;
1138                 __entry->normal_work    = &work->normal_work;
1139         ),
1140
1141         TP_printk("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p,"
1142                   " ordered_free=%p",
1143                   __entry->work, __entry->normal_work, __entry->wq,
1144                    __entry->func, __entry->ordered_func, __entry->ordered_free)
1145 );
1146
1147 /* For situiations that the work is freed */
1148 DECLARE_EVENT_CLASS(btrfs__work__done,
1149
1150         TP_PROTO(struct btrfs_work *work),
1151
1152         TP_ARGS(work),
1153
1154         TP_STRUCT__entry(
1155                 __field(        void *, work                    )
1156         ),
1157
1158         TP_fast_assign(
1159                 __entry->work           = work;
1160         ),
1161
1162         TP_printk("work->%p", __entry->work)
1163 );
1164
1165 DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1166
1167         TP_PROTO(struct btrfs_work *work),
1168
1169         TP_ARGS(work)
1170 );
1171
1172 DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1173
1174         TP_PROTO(struct btrfs_work *work),
1175
1176         TP_ARGS(work)
1177 );
1178
1179 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1180
1181         TP_PROTO(struct btrfs_work *work),
1182
1183         TP_ARGS(work)
1184 );
1185
1186 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1187
1188         TP_PROTO(struct btrfs_work *work),
1189
1190         TP_ARGS(work)
1191 );
1192
1193 DECLARE_EVENT_CLASS(btrfs__workqueue,
1194
1195         TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1196
1197         TP_ARGS(wq, name, high),
1198
1199         TP_STRUCT__entry(
1200                 __field(        void *, wq                      )
1201                 __string(       name,   name                    )
1202                 __field(        int ,   high                    )
1203         ),
1204
1205         TP_fast_assign(
1206                 __entry->wq             = wq;
1207                 __assign_str(name, name);
1208                 __entry->high           = high;
1209         ),
1210
1211         TP_printk("name=%s%s, wq=%p", __get_str(name),
1212                   __print_flags(__entry->high, "",
1213                                 {(WQ_HIGHPRI),  "-high"}),
1214                   __entry->wq)
1215 );
1216
1217 DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1218
1219         TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1220
1221         TP_ARGS(wq, name, high)
1222 );
1223
1224 DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1225
1226         TP_PROTO(struct __btrfs_workqueue *wq),
1227
1228         TP_ARGS(wq),
1229
1230         TP_STRUCT__entry(
1231                 __field(        void *, wq                      )
1232         ),
1233
1234         TP_fast_assign(
1235                 __entry->wq             = wq;
1236         ),
1237
1238         TP_printk("wq=%p", __entry->wq)
1239 );
1240
1241 DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1242
1243         TP_PROTO(struct __btrfs_workqueue *wq),
1244
1245         TP_ARGS(wq)
1246 );
1247
1248 DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1249
1250         TP_PROTO(struct inode *inode, u64 free_reserved),
1251
1252         TP_ARGS(inode, free_reserved),
1253
1254         TP_STRUCT__entry(
1255                 __field(        u64,            rootid          )
1256                 __field(        unsigned long,  ino             )
1257                 __field(        u64,            free_reserved   )
1258         ),
1259
1260         TP_fast_assign(
1261                 __entry->rootid         =       BTRFS_I(inode)->root->objectid;
1262                 __entry->ino            =       inode->i_ino;
1263                 __entry->free_reserved  =       free_reserved;
1264         ),
1265
1266         TP_printk("rootid=%llu, ino=%lu, free_reserved=%llu",
1267                   __entry->rootid, __entry->ino, __entry->free_reserved)
1268 );
1269
1270 DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
1271
1272         TP_PROTO(struct inode *inode, u64 free_reserved),
1273
1274         TP_ARGS(inode, free_reserved)
1275 );
1276
1277 DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
1278
1279         TP_PROTO(struct inode *inode, u64 free_reserved),
1280
1281         TP_ARGS(inode, free_reserved)
1282 );
1283
1284 #define BTRFS_QGROUP_OPERATIONS                         \
1285         { QGROUP_RESERVE,       "reserve"       },      \
1286         { QGROUP_RELEASE,       "release"       },      \
1287         { QGROUP_FREE,          "free"          }
1288
1289 DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1290
1291         TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1292
1293         TP_ARGS(inode, start, len, reserved, op),
1294
1295         TP_STRUCT__entry(
1296                 __field(        u64,            rootid          )
1297                 __field(        unsigned long,  ino             )
1298                 __field(        u64,            start           )
1299                 __field(        u64,            len             )
1300                 __field(        u64,            reserved        )
1301                 __field(        int,            op              )
1302         ),
1303
1304         TP_fast_assign(
1305                 __entry->rootid         = BTRFS_I(inode)->root->objectid;
1306                 __entry->ino            = inode->i_ino;
1307                 __entry->start          = start;
1308                 __entry->len            = len;
1309                 __entry->reserved       = reserved;
1310                 __entry->op             = op;
1311         ),
1312
1313         TP_printk("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s",
1314                   __entry->rootid, __entry->ino, __entry->start, __entry->len,
1315                   __entry->reserved,
1316                   __print_flags((unsigned long)__entry->op, "",
1317                                 BTRFS_QGROUP_OPERATIONS)
1318         )
1319 );
1320
1321 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1322
1323         TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1324
1325         TP_ARGS(inode, start, len, reserved, op)
1326 );
1327
1328 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1329
1330         TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1331
1332         TP_ARGS(inode, start, len, reserved, op)
1333 );
1334
1335 DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1336
1337         TP_PROTO(u64 ref_root, u64 reserved),
1338
1339         TP_ARGS(ref_root, reserved),
1340
1341         TP_STRUCT__entry(
1342                 __field(        u64,            ref_root        )
1343                 __field(        u64,            reserved        )
1344         ),
1345
1346         TP_fast_assign(
1347                 __entry->ref_root       = ref_root;
1348                 __entry->reserved       = reserved;
1349         ),
1350
1351         TP_printk("root=%llu, reserved=%llu, op=free",
1352                   __entry->ref_root, __entry->reserved)
1353 );
1354
1355 DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1356
1357         TP_PROTO(u64 ref_root, u64 reserved),
1358
1359         TP_ARGS(ref_root, reserved)
1360 );
1361
1362 DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1363         TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1364
1365         TP_ARGS(rec),
1366
1367         TP_STRUCT__entry(
1368                 __field(        u64,  bytenr            )
1369                 __field(        u64,  num_bytes         )
1370         ),
1371
1372         TP_fast_assign(
1373                 __entry->bytenr         = rec->bytenr,
1374                 __entry->num_bytes      = rec->num_bytes;
1375         ),
1376
1377         TP_printk("bytenr = %llu, num_bytes = %llu",
1378                   (unsigned long long)__entry->bytenr,
1379                   (unsigned long long)__entry->num_bytes)
1380 );
1381
1382 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1383
1384         TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1385
1386         TP_ARGS(rec)
1387 );
1388
1389 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_insert_dirty_extent,
1390
1391         TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1392
1393         TP_ARGS(rec)
1394 );
1395
1396 TRACE_EVENT(btrfs_qgroup_account_extent,
1397
1398         TP_PROTO(u64 bytenr, u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
1399
1400         TP_ARGS(bytenr, num_bytes, nr_old_roots, nr_new_roots),
1401
1402         TP_STRUCT__entry(
1403                 __field(        u64,  bytenr                    )
1404                 __field(        u64,  num_bytes                 )
1405                 __field(        u64,  nr_old_roots              )
1406                 __field(        u64,  nr_new_roots              )
1407         ),
1408
1409         TP_fast_assign(
1410                 __entry->bytenr         = bytenr;
1411                 __entry->num_bytes      = num_bytes;
1412                 __entry->nr_old_roots   = nr_old_roots;
1413                 __entry->nr_new_roots   = nr_new_roots;
1414         ),
1415
1416         TP_printk("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
1417                   "nr_new_roots = %llu",
1418                   __entry->bytenr,
1419                   __entry->num_bytes,
1420                   __entry->nr_old_roots,
1421                   __entry->nr_new_roots)
1422 );
1423
1424 TRACE_EVENT(qgroup_update_counters,
1425
1426         TP_PROTO(u64 qgid, u64 cur_old_count, u64 cur_new_count),
1427
1428         TP_ARGS(qgid, cur_old_count, cur_new_count),
1429
1430         TP_STRUCT__entry(
1431                 __field(        u64,  qgid                      )
1432                 __field(        u64,  cur_old_count             )
1433                 __field(        u64,  cur_new_count             )
1434         ),
1435
1436         TP_fast_assign(
1437                 __entry->qgid           = qgid;
1438                 __entry->cur_old_count  = cur_old_count;
1439                 __entry->cur_new_count  = cur_new_count;
1440         ),
1441
1442         TP_printk("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
1443                   __entry->qgid,
1444                   __entry->cur_old_count,
1445                   __entry->cur_new_count)
1446 );
1447
1448 #endif /* _TRACE_BTRFS_H */
1449
1450 /* This part must be outside protection */
1451 #include <trace/define_trace.h>