blob: 8f206263fee7aae7fab344d95eaed29bf8411f18 [file] [log] [blame]
liubo1abe9b82011-03-24 11:18:59 +00001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM btrfs
3
4#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_BTRFS_H
6
7#include <linux/writeback.h>
8#include <linux/tracepoint.h>
Vlastimil Babka420adbe92016-03-15 14:55:52 -07009#include <trace/events/mmflags.h>
liubo1abe9b82011-03-24 11:18:59 +000010
11struct btrfs_root;
12struct btrfs_fs_info;
13struct btrfs_inode;
14struct extent_map;
15struct btrfs_ordered_extent;
16struct btrfs_delayed_ref_node;
17struct btrfs_delayed_tree_ref;
18struct btrfs_delayed_data_ref;
19struct btrfs_delayed_ref_head;
Josef Bacik3f7de032011-11-10 08:29:20 -050020struct btrfs_block_group_cache;
21struct btrfs_free_cluster;
liubo1abe9b82011-03-24 11:18:59 +000022struct map_lookup;
23struct extent_buffer;
Qu Wenruo52483bc2014-03-06 04:19:50 +000024struct btrfs_work;
Qu Wenruoc3a46892014-03-12 08:05:33 +000025struct __btrfs_workqueue;
Mark Fasheh0f5dcf82016-03-29 17:19:55 -070026struct btrfs_qgroup_extent_record;
liubo1abe9b82011-03-24 11:18:59 +000027
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) \
liubo7f34b742011-04-19 09:35:31 +080037 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000038 { 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" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000046 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000047 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070048 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
49 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000050 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
51
52#define show_root_type(obj) \
53 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000054 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000055 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000056
Josef Bacik3f7de032011-11-10 08:29:20 -050057#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000058 { 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"}
Josef Bacik3f7de032011-11-10 08:29:20 -050067
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050068#define BTRFS_UUID_SIZE 16
Jeff Mahoneybc074522016-06-09 17:27:55 -040069#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_UUID_SIZE)
70
71#define TP_fast_assign_fsid(fs_info) \
72 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE)
73
74#define TP_STRUCT__entry_btrfs(args...) \
75 TP_STRUCT__entry( \
76 TP_STRUCT__entry_fsid \
77 args)
78#define TP_fast_assign_btrfs(fs_info, args...) \
79 TP_fast_assign( \
80 TP_fast_assign_fsid(fs_info); \
81 args)
82#define TP_printk_btrfs(fmt, args...) \
83 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050084
liubo1abe9b82011-03-24 11:18:59 +000085TRACE_EVENT(btrfs_transaction_commit,
86
87 TP_PROTO(struct btrfs_root *root),
88
89 TP_ARGS(root),
90
Jeff Mahoneybc074522016-06-09 17:27:55 -040091 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +000092 __field( u64, generation )
93 __field( u64, root_objectid )
94 ),
95
Jeff Mahoneybc074522016-06-09 17:27:55 -040096 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +000097 __entry->generation = root->fs_info->generation;
98 __entry->root_objectid = root->root_key.objectid;
99 ),
100
Jeff Mahoneybc074522016-06-09 17:27:55 -0400101 TP_printk_btrfs("root = %llu(%s), gen = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000102 show_root_type(__entry->root_objectid),
103 (unsigned long long)__entry->generation)
104);
105
106DECLARE_EVENT_CLASS(btrfs__inode,
107
108 TP_PROTO(struct inode *inode),
109
110 TP_ARGS(inode),
111
Jeff Mahoneybc074522016-06-09 17:27:55 -0400112 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000113 __field( ino_t, ino )
114 __field( blkcnt_t, blocks )
115 __field( u64, disk_i_size )
116 __field( u64, generation )
117 __field( u64, last_trans )
118 __field( u64, logged_trans )
119 __field( u64, root_objectid )
120 ),
121
Jeff Mahoneybc074522016-06-09 17:27:55 -0400122 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000123 __entry->ino = inode->i_ino;
124 __entry->blocks = inode->i_blocks;
125 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
126 __entry->generation = BTRFS_I(inode)->generation;
127 __entry->last_trans = BTRFS_I(inode)->last_trans;
128 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
129 __entry->root_objectid =
130 BTRFS_I(inode)->root->root_key.objectid;
131 ),
132
David Sterba562a7a02017-01-06 15:51:36 +0100133 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
134 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000135 show_root_type(__entry->root_objectid),
136 (unsigned long long)__entry->generation,
137 (unsigned long)__entry->ino,
138 (unsigned long long)__entry->blocks,
139 (unsigned long long)__entry->disk_i_size,
140 (unsigned long long)__entry->last_trans,
141 (unsigned long long)__entry->logged_trans)
142);
143
144DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
145
146 TP_PROTO(struct inode *inode),
147
148 TP_ARGS(inode)
149);
150
151DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
152
153 TP_PROTO(struct inode *inode),
154
155 TP_ARGS(inode)
156);
157
158DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
159
160 TP_PROTO(struct inode *inode),
161
162 TP_ARGS(inode)
163);
164
165#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800166 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000167 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
168 { EXTENT_MAP_HOLE, "HOLE" }, \
169 { EXTENT_MAP_INLINE, "INLINE" }, \
170 { EXTENT_MAP_DELALLOC, "DELALLOC" })
171
172#define show_map_type(type) \
173 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
174
175#define show_map_flags(flag) \
176 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800177 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
178 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
179 { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
180 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
181 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
182 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
183 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000184
Steven Rostedt4cd85872013-11-14 22:57:29 -0500185TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000186
Nikolay Borisov4a0cc7c2017-01-10 20:35:31 +0200187 TP_PROTO(struct btrfs_root *root, struct btrfs_inode *inode,
Liu Bo92a1bf72016-11-17 15:00:50 -0800188 struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000189
Liu Bo92a1bf72016-11-17 15:00:50 -0800190 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000191
Steven Rostedt4cd85872013-11-14 22:57:29 -0500192 TP_CONDITION(map),
193
Jeff Mahoneybc074522016-06-09 17:27:55 -0400194 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000195 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800196 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000197 __field( u64, start )
198 __field( u64, len )
199 __field( u64, orig_start )
200 __field( u64, block_start )
201 __field( u64, block_len )
202 __field( unsigned long, flags )
203 __field( int, refs )
204 __field( unsigned int, compress_type )
205 ),
206
Jeff Mahoneybc074522016-06-09 17:27:55 -0400207 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000208 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800209 __entry->ino = btrfs_ino(inode);
210 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000211 __entry->len = map->len;
212 __entry->orig_start = map->orig_start;
213 __entry->block_start = map->block_start;
214 __entry->block_len = map->block_len;
215 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200216 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000217 __entry->compress_type = map->compress_type;
218 ),
219
David Sterba562a7a02017-01-06 15:51:36 +0100220 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
221 "orig_start=%llu block_start=%llu(%s) "
222 "block_len=%llu flags=%s refs=%u "
223 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000224 show_root_type(__entry->root_objectid),
Liu Bo92a1bf72016-11-17 15:00:50 -0800225 (unsigned long long)__entry->ino,
liubo1abe9b82011-03-24 11:18:59 +0000226 (unsigned long long)__entry->start,
227 (unsigned long long)__entry->len,
228 (unsigned long long)__entry->orig_start,
229 show_map_type(__entry->block_start),
230 (unsigned long long)__entry->block_len,
231 show_map_flags(__entry->flags),
232 __entry->refs, __entry->compress_type)
233);
234
Liu Bo9d04a8c2013-11-06 12:04:13 +0800235#define show_ordered_flags(flags) \
236 __print_flags(flags, "|", \
237 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
238 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
239 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
240 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
241 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
242 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
243 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
244 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800245 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
246 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000247
liubo1abe9b82011-03-24 11:18:59 +0000248
249DECLARE_EVENT_CLASS(btrfs__ordered_extent,
250
251 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
252
253 TP_ARGS(inode, ordered),
254
Jeff Mahoneybc074522016-06-09 17:27:55 -0400255 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000256 __field( ino_t, ino )
257 __field( u64, file_offset )
258 __field( u64, start )
259 __field( u64, len )
260 __field( u64, disk_len )
261 __field( u64, bytes_left )
262 __field( unsigned long, flags )
263 __field( int, compress_type )
264 __field( int, refs )
265 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800266 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000267 ),
268
Jeff Mahoneybc074522016-06-09 17:27:55 -0400269 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000270 __entry->ino = inode->i_ino;
271 __entry->file_offset = ordered->file_offset;
272 __entry->start = ordered->start;
273 __entry->len = ordered->len;
274 __entry->disk_len = ordered->disk_len;
275 __entry->bytes_left = ordered->bytes_left;
276 __entry->flags = ordered->flags;
277 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200278 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000279 __entry->root_objectid =
280 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800281 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000282 ),
283
David Sterba562a7a02017-01-06 15:51:36 +0100284 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
285 "start=%llu len=%llu disk_len=%llu "
286 "truncated_len=%llu "
287 "bytes_left=%llu flags=%s compress_type=%d "
288 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000289 show_root_type(__entry->root_objectid),
290 (unsigned long long)__entry->ino,
291 (unsigned long long)__entry->file_offset,
292 (unsigned long long)__entry->start,
293 (unsigned long long)__entry->len,
294 (unsigned long long)__entry->disk_len,
Liu Bo78566542016-11-30 16:10:10 -0800295 (unsigned long long)__entry->truncated_len,
liubo1abe9b82011-03-24 11:18:59 +0000296 (unsigned long long)__entry->bytes_left,
297 show_ordered_flags(__entry->flags),
298 __entry->compress_type, __entry->refs)
299);
300
301DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
302
303 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
304
305 TP_ARGS(inode, ordered)
306);
307
308DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
309
310 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
311
312 TP_ARGS(inode, ordered)
313);
314
315DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
316
317 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
318
319 TP_ARGS(inode, ordered)
320);
321
322DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
323
324 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
325
326 TP_ARGS(inode, ordered)
327);
328
329DECLARE_EVENT_CLASS(btrfs__writepage,
330
331 TP_PROTO(struct page *page, struct inode *inode,
332 struct writeback_control *wbc),
333
334 TP_ARGS(page, inode, wbc),
335
Jeff Mahoneybc074522016-06-09 17:27:55 -0400336 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000337 __field( ino_t, ino )
338 __field( pgoff_t, index )
339 __field( long, nr_to_write )
340 __field( long, pages_skipped )
341 __field( loff_t, range_start )
342 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000343 __field( char, for_kupdate )
344 __field( char, for_reclaim )
345 __field( char, range_cyclic )
346 __field( pgoff_t, writeback_index )
347 __field( u64, root_objectid )
348 ),
349
Jeff Mahoneybc074522016-06-09 17:27:55 -0400350 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000351 __entry->ino = inode->i_ino;
352 __entry->index = page->index;
353 __entry->nr_to_write = wbc->nr_to_write;
354 __entry->pages_skipped = wbc->pages_skipped;
355 __entry->range_start = wbc->range_start;
356 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000357 __entry->for_kupdate = wbc->for_kupdate;
358 __entry->for_reclaim = wbc->for_reclaim;
359 __entry->range_cyclic = wbc->range_cyclic;
360 __entry->writeback_index = inode->i_mapping->writeback_index;
361 __entry->root_objectid =
362 BTRFS_I(inode)->root->root_key.objectid;
363 ),
364
David Sterba562a7a02017-01-06 15:51:36 +0100365 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
366 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
367 "range_end=%llu for_kupdate=%d "
368 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000369 show_root_type(__entry->root_objectid),
370 (unsigned long)__entry->ino, __entry->index,
371 __entry->nr_to_write, __entry->pages_skipped,
372 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600373 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000374 __entry->for_reclaim, __entry->range_cyclic,
375 (unsigned long)__entry->writeback_index)
376);
377
378DEFINE_EVENT(btrfs__writepage, __extent_writepage,
379
380 TP_PROTO(struct page *page, struct inode *inode,
381 struct writeback_control *wbc),
382
383 TP_ARGS(page, inode, wbc)
384);
385
386TRACE_EVENT(btrfs_writepage_end_io_hook,
387
388 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
389
390 TP_ARGS(page, start, end, uptodate),
391
Jeff Mahoneybc074522016-06-09 17:27:55 -0400392 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000393 __field( ino_t, ino )
394 __field( pgoff_t, index )
395 __field( u64, start )
396 __field( u64, end )
397 __field( int, uptodate )
398 __field( u64, root_objectid )
399 ),
400
Jeff Mahoneybc074522016-06-09 17:27:55 -0400401 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000402 __entry->ino = page->mapping->host->i_ino;
403 __entry->index = page->index;
404 __entry->start = start;
405 __entry->end = end;
406 __entry->uptodate = uptodate;
407 __entry->root_objectid =
408 BTRFS_I(page->mapping->host)->root->root_key.objectid;
409 ),
410
David Sterba562a7a02017-01-06 15:51:36 +0100411 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
412 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000413 show_root_type(__entry->root_objectid),
414 (unsigned long)__entry->ino, (unsigned long)__entry->index,
415 (unsigned long long)__entry->start,
416 (unsigned long long)__entry->end, __entry->uptodate)
417);
418
419TRACE_EVENT(btrfs_sync_file,
420
421 TP_PROTO(struct file *file, int datasync),
422
423 TP_ARGS(file, datasync),
424
Jeff Mahoneybc074522016-06-09 17:27:55 -0400425 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000426 __field( ino_t, ino )
427 __field( ino_t, parent )
428 __field( int, datasync )
429 __field( u64, root_objectid )
430 ),
431
432 TP_fast_assign(
433 struct dentry *dentry = file->f_path.dentry;
David Howells2b0143b2015-03-17 22:25:59 +0000434 struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000435
Jeff Mahoneybc074522016-06-09 17:27:55 -0400436 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
liubo1abe9b82011-03-24 11:18:59 +0000437 __entry->ino = inode->i_ino;
David Howells2b0143b2015-03-17 22:25:59 +0000438 __entry->parent = d_inode(dentry->d_parent)->i_ino;
liubo1abe9b82011-03-24 11:18:59 +0000439 __entry->datasync = datasync;
440 __entry->root_objectid =
441 BTRFS_I(inode)->root->root_key.objectid;
442 ),
443
David Sterba562a7a02017-01-06 15:51:36 +0100444 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000445 show_root_type(__entry->root_objectid),
446 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
447 __entry->datasync)
448);
449
450TRACE_EVENT(btrfs_sync_fs,
451
Jeff Mahoneybc074522016-06-09 17:27:55 -0400452 TP_PROTO(struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000453
Jeff Mahoneybc074522016-06-09 17:27:55 -0400454 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000455
Jeff Mahoneybc074522016-06-09 17:27:55 -0400456 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000457 __field( int, wait )
458 ),
459
Jeff Mahoneybc074522016-06-09 17:27:55 -0400460 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000461 __entry->wait = wait;
462 ),
463
Jeff Mahoneybc074522016-06-09 17:27:55 -0400464 TP_printk_btrfs("wait = %d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000465);
466
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400467TRACE_EVENT(btrfs_add_block_group,
468
469 TP_PROTO(struct btrfs_fs_info *fs_info,
470 struct btrfs_block_group_cache *block_group, int create),
471
472 TP_ARGS(fs_info, block_group, create),
473
474 TP_STRUCT__entry(
475 __array( u8, fsid, BTRFS_UUID_SIZE )
476 __field( u64, offset )
477 __field( u64, size )
478 __field( u64, flags )
479 __field( u64, bytes_used )
480 __field( u64, bytes_super )
481 __field( int, create )
482 ),
483
484 TP_fast_assign(
485 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
486 __entry->offset = block_group->key.objectid;
487 __entry->size = block_group->key.offset;
488 __entry->flags = block_group->flags;
489 __entry->bytes_used =
490 btrfs_block_group_used(&block_group->item);
491 __entry->bytes_super = block_group->bytes_super;
492 __entry->create = create;
493 ),
494
David Sterba562a7a02017-01-06 15:51:36 +0100495 TP_printk("%pU: block_group offset=%llu size=%llu "
496 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
497 "create=%d", __entry->fsid,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400498 (unsigned long long)__entry->offset,
499 (unsigned long long)__entry->size,
500 (unsigned long long)__entry->flags,
501 __print_flags((unsigned long)__entry->flags, "|",
502 BTRFS_GROUP_FLAGS),
503 (unsigned long long)__entry->bytes_used,
504 (unsigned long long)__entry->bytes_super, __entry->create)
505);
506
liubo1abe9b82011-03-24 11:18:59 +0000507#define show_ref_action(action) \
508 __print_symbolic(action, \
509 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
510 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
511 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
512 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
513
514
Liu Bo599c75e2013-07-16 19:03:36 +0800515DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000516
Jeff Mahoneybc074522016-06-09 17:27:55 -0400517 TP_PROTO(struct btrfs_fs_info *fs_info,
518 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000519 struct btrfs_delayed_tree_ref *full_ref,
520 int action),
521
Jeff Mahoneybc074522016-06-09 17:27:55 -0400522 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000523
Jeff Mahoneybc074522016-06-09 17:27:55 -0400524 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000525 __field( u64, bytenr )
526 __field( u64, num_bytes )
527 __field( int, action )
528 __field( u64, parent )
529 __field( u64, ref_root )
530 __field( int, level )
531 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600532 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000533 ),
534
Jeff Mahoneybc074522016-06-09 17:27:55 -0400535 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000536 __entry->bytenr = ref->bytenr;
537 __entry->num_bytes = ref->num_bytes;
538 __entry->action = action;
539 __entry->parent = full_ref->parent;
540 __entry->ref_root = full_ref->root;
541 __entry->level = full_ref->level;
542 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600543 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000544 ),
545
David Sterba562a7a02017-01-06 15:51:36 +0100546 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
547 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
548 "type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000549 (unsigned long long)__entry->bytenr,
550 (unsigned long long)__entry->num_bytes,
551 show_ref_action(__entry->action),
552 show_root_type(__entry->parent),
553 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600554 __entry->level, show_ref_type(__entry->type),
555 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000556);
557
Liu Bo599c75e2013-07-16 19:03:36 +0800558DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
559
Jeff Mahoneybc074522016-06-09 17:27:55 -0400560 TP_PROTO(struct btrfs_fs_info *fs_info,
561 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800562 struct btrfs_delayed_tree_ref *full_ref,
563 int action),
564
Jeff Mahoneybc074522016-06-09 17:27:55 -0400565 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800566);
567
568DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
569
Jeff Mahoneybc074522016-06-09 17:27:55 -0400570 TP_PROTO(struct btrfs_fs_info *fs_info,
571 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800572 struct btrfs_delayed_tree_ref *full_ref,
573 int action),
574
Jeff Mahoneybc074522016-06-09 17:27:55 -0400575 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800576);
577
578DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000579
Jeff Mahoneybc074522016-06-09 17:27:55 -0400580 TP_PROTO(struct btrfs_fs_info *fs_info,
581 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000582 struct btrfs_delayed_data_ref *full_ref,
583 int action),
584
Jeff Mahoneybc074522016-06-09 17:27:55 -0400585 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000586
Jeff Mahoneybc074522016-06-09 17:27:55 -0400587 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000588 __field( u64, bytenr )
589 __field( u64, num_bytes )
590 __field( int, action )
591 __field( u64, parent )
592 __field( u64, ref_root )
593 __field( u64, owner )
594 __field( u64, offset )
595 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600596 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000597 ),
598
Jeff Mahoneybc074522016-06-09 17:27:55 -0400599 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000600 __entry->bytenr = ref->bytenr;
601 __entry->num_bytes = ref->num_bytes;
602 __entry->action = action;
603 __entry->parent = full_ref->parent;
604 __entry->ref_root = full_ref->root;
605 __entry->owner = full_ref->objectid;
606 __entry->offset = full_ref->offset;
607 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600608 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000609 ),
610
David Sterba562a7a02017-01-06 15:51:36 +0100611 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
612 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
613 "offset=%llu type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000614 (unsigned long long)__entry->bytenr,
615 (unsigned long long)__entry->num_bytes,
616 show_ref_action(__entry->action),
617 show_root_type(__entry->parent),
618 show_root_type(__entry->ref_root),
619 (unsigned long long)__entry->owner,
620 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600621 show_ref_type(__entry->type),
622 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000623);
624
Liu Bo599c75e2013-07-16 19:03:36 +0800625DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
626
Jeff Mahoneybc074522016-06-09 17:27:55 -0400627 TP_PROTO(struct btrfs_fs_info *fs_info,
628 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800629 struct btrfs_delayed_data_ref *full_ref,
630 int action),
631
Jeff Mahoneybc074522016-06-09 17:27:55 -0400632 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800633);
634
635DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
636
Jeff Mahoneybc074522016-06-09 17:27:55 -0400637 TP_PROTO(struct btrfs_fs_info *fs_info,
638 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800639 struct btrfs_delayed_data_ref *full_ref,
640 int action),
641
Jeff Mahoneybc074522016-06-09 17:27:55 -0400642 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800643);
644
645DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000646
Jeff Mahoneybc074522016-06-09 17:27:55 -0400647 TP_PROTO(struct btrfs_fs_info *fs_info,
648 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000649 struct btrfs_delayed_ref_head *head_ref,
650 int action),
651
Jeff Mahoneybc074522016-06-09 17:27:55 -0400652 TP_ARGS(fs_info, ref, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000653
Jeff Mahoneybc074522016-06-09 17:27:55 -0400654 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000655 __field( u64, bytenr )
656 __field( u64, num_bytes )
657 __field( int, action )
658 __field( int, is_data )
659 ),
660
Jeff Mahoneybc074522016-06-09 17:27:55 -0400661 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000662 __entry->bytenr = ref->bytenr;
663 __entry->num_bytes = ref->num_bytes;
664 __entry->action = action;
665 __entry->is_data = head_ref->is_data;
666 ),
667
David Sterba562a7a02017-01-06 15:51:36 +0100668 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
liubo1abe9b82011-03-24 11:18:59 +0000669 (unsigned long long)__entry->bytenr,
670 (unsigned long long)__entry->num_bytes,
671 show_ref_action(__entry->action),
672 __entry->is_data)
673);
674
Liu Bo599c75e2013-07-16 19:03:36 +0800675DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
676
Jeff Mahoneybc074522016-06-09 17:27:55 -0400677 TP_PROTO(struct btrfs_fs_info *fs_info,
678 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800679 struct btrfs_delayed_ref_head *head_ref,
680 int action),
681
Jeff Mahoneybc074522016-06-09 17:27:55 -0400682 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800683);
684
685DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
686
Jeff Mahoneybc074522016-06-09 17:27:55 -0400687 TP_PROTO(struct btrfs_fs_info *fs_info,
688 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800689 struct btrfs_delayed_ref_head *head_ref,
690 int action),
691
Jeff Mahoneybc074522016-06-09 17:27:55 -0400692 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800693);
694
liubo1abe9b82011-03-24 11:18:59 +0000695#define show_chunk_type(type) \
696 __print_flags(type, "|", \
697 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
698 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
699 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
700 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
701 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
702 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000703 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
704 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
705 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000706
707DECLARE_EVENT_CLASS(btrfs__chunk,
708
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400709 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000710 u64 offset, u64 size),
711
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400712 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000713
Jeff Mahoneybc074522016-06-09 17:27:55 -0400714 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000715 __field( int, num_stripes )
716 __field( u64, type )
717 __field( int, sub_stripes )
718 __field( u64, offset )
719 __field( u64, size )
720 __field( u64, root_objectid )
721 ),
722
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400723 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000724 __entry->num_stripes = map->num_stripes;
725 __entry->type = map->type;
726 __entry->sub_stripes = map->sub_stripes;
727 __entry->offset = offset;
728 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400729 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000730 ),
731
David Sterba562a7a02017-01-06 15:51:36 +0100732 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
733 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000734 show_root_type(__entry->root_objectid),
735 (unsigned long long)__entry->offset,
736 (unsigned long long)__entry->size,
737 __entry->num_stripes, __entry->sub_stripes,
738 show_chunk_type(__entry->type))
739);
740
741DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
742
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400743 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000744 u64 offset, u64 size),
745
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400746 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000747);
748
749DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
750
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400751 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000752 u64 offset, u64 size),
753
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400754 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000755);
756
757TRACE_EVENT(btrfs_cow_block,
758
759 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
760 struct extent_buffer *cow),
761
762 TP_ARGS(root, buf, cow),
763
Jeff Mahoneybc074522016-06-09 17:27:55 -0400764 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000765 __field( u64, root_objectid )
766 __field( u64, buf_start )
767 __field( int, refs )
768 __field( u64, cow_start )
769 __field( int, buf_level )
770 __field( int, cow_level )
771 ),
772
Jeff Mahoneybc074522016-06-09 17:27:55 -0400773 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000774 __entry->root_objectid = root->root_key.objectid;
775 __entry->buf_start = buf->start;
776 __entry->refs = atomic_read(&buf->refs);
777 __entry->cow_start = cow->start;
778 __entry->buf_level = btrfs_header_level(buf);
779 __entry->cow_level = btrfs_header_level(cow);
780 ),
781
David Sterba562a7a02017-01-06 15:51:36 +0100782 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
783 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000784 show_root_type(__entry->root_objectid),
785 __entry->refs,
786 (unsigned long long)__entry->buf_start,
787 __entry->buf_level,
788 (unsigned long long)__entry->cow_start,
789 __entry->cow_level)
790);
791
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500792TRACE_EVENT(btrfs_space_reservation,
793
794 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
795 u64 bytes, int reserve),
796
797 TP_ARGS(fs_info, type, val, bytes, reserve),
798
Jeff Mahoneybc074522016-06-09 17:27:55 -0400799 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500800 __string( type, type )
801 __field( u64, val )
802 __field( u64, bytes )
803 __field( int, reserve )
804 ),
805
Jeff Mahoneybc074522016-06-09 17:27:55 -0400806 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500807 __assign_str(type, type);
808 __entry->val = val;
809 __entry->bytes = bytes;
810 __entry->reserve = reserve;
811 ),
812
Jeff Mahoneybc074522016-06-09 17:27:55 -0400813 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
814 __entry->reserve ? "reserve" : "release",
815 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500816);
817
Josef Bacikf376df22016-03-25 13:25:56 -0400818#define show_flush_action(action) \
819 __print_symbolic(action, \
820 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
821 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
822 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
823
824TRACE_EVENT(btrfs_trigger_flush,
825
826 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
827 int flush, char *reason),
828
829 TP_ARGS(fs_info, flags, bytes, flush, reason),
830
831 TP_STRUCT__entry(
832 __array( u8, fsid, BTRFS_UUID_SIZE )
833 __field( u64, flags )
834 __field( u64, bytes )
835 __field( int, flush )
836 __string( reason, reason )
837 ),
838
839 TP_fast_assign(
840 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
841 __entry->flags = flags;
842 __entry->bytes = bytes;
843 __entry->flush = flush;
844 __assign_str(reason, reason)
845 ),
846
David Sterba562a7a02017-01-06 15:51:36 +0100847 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
Josef Bacikf376df22016-03-25 13:25:56 -0400848 __entry->fsid, __get_str(reason), __entry->flush,
849 show_flush_action(__entry->flush),
850 (unsigned long long)__entry->flags,
851 __print_flags((unsigned long)__entry->flags, "|",
852 BTRFS_GROUP_FLAGS),
853 (unsigned long long)__entry->bytes)
854);
855
856#define show_flush_state(state) \
857 __print_symbolic(state, \
858 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
859 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
860 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
861 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
862 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
863 { COMMIT_TRANS, "COMMIT_TRANS"})
864
865TRACE_EVENT(btrfs_flush_space,
866
867 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
868 u64 orig_bytes, int state, int ret),
869
870 TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),
871
872 TP_STRUCT__entry(
873 __array( u8, fsid, BTRFS_UUID_SIZE )
874 __field( u64, flags )
875 __field( u64, num_bytes )
876 __field( u64, orig_bytes )
877 __field( int, state )
878 __field( int, ret )
879 ),
880
881 TP_fast_assign(
882 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
883 __entry->flags = flags;
884 __entry->num_bytes = num_bytes;
885 __entry->orig_bytes = orig_bytes;
886 __entry->state = state;
887 __entry->ret = ret;
888 ),
889
David Sterba562a7a02017-01-06 15:51:36 +0100890 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu "
891 "orig_bytes=%llu ret=%d", __entry->fsid, __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -0400892 show_flush_state(__entry->state),
893 (unsigned long long)__entry->flags,
894 __print_flags((unsigned long)__entry->flags, "|",
895 BTRFS_GROUP_FLAGS),
896 (unsigned long long)__entry->num_bytes,
897 (unsigned long long)__entry->orig_bytes, __entry->ret)
898);
899
liubo1abe9b82011-03-24 11:18:59 +0000900DECLARE_EVENT_CLASS(btrfs__reserved_extent,
901
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400902 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +0000903
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400904 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +0000905
Jeff Mahoneybc074522016-06-09 17:27:55 -0400906 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -0400907 __field( u64, start )
908 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +0000909 ),
910
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400911 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000912 __entry->start = start;
913 __entry->len = len;
914 ),
915
David Sterba562a7a02017-01-06 15:51:36 +0100916 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400917 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
liubo1abe9b82011-03-24 11:18:59 +0000918 (unsigned long long)__entry->start,
919 (unsigned long long)__entry->len)
920);
921
922DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
923
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400924 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +0000925
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400926 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +0000927);
928
929DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
930
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400931 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +0000932
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400933 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +0000934);
935
Josef Bacik3f7de032011-11-10 08:29:20 -0500936TRACE_EVENT(find_free_extent,
937
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400938 TP_PROTO(struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size,
Josef Bacik3f7de032011-11-10 08:29:20 -0500939 u64 data),
940
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400941 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -0500942
Jeff Mahoneybc074522016-06-09 17:27:55 -0400943 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -0500944 __field( u64, num_bytes )
945 __field( u64, empty_size )
946 __field( u64, data )
947 ),
948
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400949 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500950 __entry->num_bytes = num_bytes;
951 __entry->empty_size = empty_size;
952 __entry->data = data;
953 ),
954
David Sterba562a7a02017-01-06 15:51:36 +0100955 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400956 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -0500957 __entry->num_bytes, __entry->empty_size, __entry->data,
958 __print_flags((unsigned long)__entry->data, "|",
959 BTRFS_GROUP_FLAGS))
960);
961
962DECLARE_EVENT_CLASS(btrfs__reserve_extent,
963
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400964 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500965 struct btrfs_block_group_cache *block_group, u64 start,
966 u64 len),
967
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400968 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -0500969
Jeff Mahoneybc074522016-06-09 17:27:55 -0400970 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -0500971 __field( u64, bg_objectid )
972 __field( u64, flags )
973 __field( u64, start )
974 __field( u64, len )
975 ),
976
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400977 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500978 __entry->bg_objectid = block_group->key.objectid;
979 __entry->flags = block_group->flags;
980 __entry->start = start;
981 __entry->len = len;
982 ),
983
David Sterba562a7a02017-01-06 15:51:36 +0100984 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
985 "start=%Lu len=%Lu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400986 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
987 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -0500988 __entry->flags, __print_flags((unsigned long)__entry->flags,
989 "|", BTRFS_GROUP_FLAGS),
990 __entry->start, __entry->len)
991);
992
993DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
994
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400995 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500996 struct btrfs_block_group_cache *block_group, u64 start,
997 u64 len),
998
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400999 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001000);
1001
1002DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1003
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001004 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001005 struct btrfs_block_group_cache *block_group, u64 start,
1006 u64 len),
1007
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001008 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001009);
1010
1011TRACE_EVENT(btrfs_find_cluster,
1012
1013 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
1014 u64 bytes, u64 empty_size, u64 min_bytes),
1015
1016 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1017
Jeff Mahoneybc074522016-06-09 17:27:55 -04001018 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001019 __field( u64, bg_objectid )
1020 __field( u64, flags )
1021 __field( u64, start )
1022 __field( u64, bytes )
1023 __field( u64, empty_size )
1024 __field( u64, min_bytes )
1025 ),
1026
Jeff Mahoneybc074522016-06-09 17:27:55 -04001027 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001028 __entry->bg_objectid = block_group->key.objectid;
1029 __entry->flags = block_group->flags;
1030 __entry->start = start;
1031 __entry->bytes = bytes;
1032 __entry->empty_size = empty_size;
1033 __entry->min_bytes = min_bytes;
1034 ),
1035
David Sterba562a7a02017-01-06 15:51:36 +01001036 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1037 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001038 __entry->flags,
1039 __print_flags((unsigned long)__entry->flags, "|",
1040 BTRFS_GROUP_FLAGS), __entry->start,
1041 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1042);
1043
1044TRACE_EVENT(btrfs_failed_cluster_setup,
1045
1046 TP_PROTO(struct btrfs_block_group_cache *block_group),
1047
1048 TP_ARGS(block_group),
1049
Jeff Mahoneybc074522016-06-09 17:27:55 -04001050 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001051 __field( u64, bg_objectid )
1052 ),
1053
Jeff Mahoneybc074522016-06-09 17:27:55 -04001054 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001055 __entry->bg_objectid = block_group->key.objectid;
1056 ),
1057
David Sterba562a7a02017-01-06 15:51:36 +01001058 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001059);
1060
1061TRACE_EVENT(btrfs_setup_cluster,
1062
1063 TP_PROTO(struct btrfs_block_group_cache *block_group,
1064 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
1065
1066 TP_ARGS(block_group, cluster, size, bitmap),
1067
Jeff Mahoneybc074522016-06-09 17:27:55 -04001068 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001069 __field( u64, bg_objectid )
1070 __field( u64, flags )
1071 __field( u64, start )
1072 __field( u64, max_size )
1073 __field( u64, size )
1074 __field( int, bitmap )
1075 ),
1076
Jeff Mahoneybc074522016-06-09 17:27:55 -04001077 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001078 __entry->bg_objectid = block_group->key.objectid;
1079 __entry->flags = block_group->flags;
1080 __entry->start = cluster->window_start;
1081 __entry->max_size = cluster->max_size;
1082 __entry->size = size;
1083 __entry->bitmap = bitmap;
1084 ),
1085
David Sterba562a7a02017-01-06 15:51:36 +01001086 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1087 "size=%Lu max_size=%Lu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001088 __entry->bg_objectid,
1089 __entry->flags,
1090 __print_flags((unsigned long)__entry->flags, "|",
1091 BTRFS_GROUP_FLAGS), __entry->start,
1092 __entry->size, __entry->max_size, __entry->bitmap)
1093);
1094
Jeff Mahoney143bede2012-03-01 14:56:26 +01001095struct extent_state;
1096TRACE_EVENT(alloc_extent_state,
1097
1098 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
1099
1100 TP_ARGS(state, mask, IP),
1101
1102 TP_STRUCT__entry(
1103 __field(struct extent_state *, state)
1104 __field(gfp_t, mask)
1105 __field(unsigned long, ip)
1106 ),
1107
1108 TP_fast_assign(
1109 __entry->state = state,
1110 __entry->mask = mask,
1111 __entry->ip = IP
1112 ),
1113
David Sterba562a7a02017-01-06 15:51:36 +01001114 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney143bede2012-03-01 14:56:26 +01001115 show_gfp_flags(__entry->mask), (void *)__entry->ip)
1116);
1117
1118TRACE_EVENT(free_extent_state,
1119
1120 TP_PROTO(struct extent_state *state, unsigned long IP),
1121
1122 TP_ARGS(state, IP),
1123
1124 TP_STRUCT__entry(
1125 __field(struct extent_state *, state)
1126 __field(unsigned long, ip)
1127 ),
1128
1129 TP_fast_assign(
1130 __entry->state = state,
1131 __entry->ip = IP
1132 ),
1133
David Sterba562a7a02017-01-06 15:51:36 +01001134 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney143bede2012-03-01 14:56:26 +01001135 (void *)__entry->ip)
1136);
1137
Qu Wenruo52483bc2014-03-06 04:19:50 +00001138DECLARE_EVENT_CLASS(btrfs__work,
1139
1140 TP_PROTO(struct btrfs_work *work),
1141
1142 TP_ARGS(work),
1143
Jeff Mahoneybc074522016-06-09 17:27:55 -04001144 TP_STRUCT__entry_btrfs(
Qu Wenruo52483bc2014-03-06 04:19:50 +00001145 __field( void *, work )
1146 __field( void *, wq )
1147 __field( void *, func )
1148 __field( void *, ordered_func )
1149 __field( void *, ordered_free )
Liu Bob38a6252014-08-12 16:33:17 +08001150 __field( void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001151 ),
1152
Jeff Mahoneybc074522016-06-09 17:27:55 -04001153 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001154 __entry->work = work;
1155 __entry->wq = work->wq;
1156 __entry->func = work->func;
1157 __entry->ordered_func = work->ordered_func;
1158 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001159 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001160 ),
1161
David Sterba562a7a02017-01-06 15:51:36 +01001162 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1163 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001164 __entry->work, __entry->normal_work, __entry->wq,
1165 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001166);
1167
David Sterbaac0c7cf2017-01-06 14:12:51 +01001168/*
1169 * For situiations when the work is freed, we pass fs_info and a tag that that
1170 * matches address of the work structure so it can be paired with the
1171 * scheduling event.
1172 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001173DECLARE_EVENT_CLASS(btrfs__work__done,
1174
David Sterbaac0c7cf2017-01-06 14:12:51 +01001175 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001176
David Sterbaac0c7cf2017-01-06 14:12:51 +01001177 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001178
Jeff Mahoneybc074522016-06-09 17:27:55 -04001179 TP_STRUCT__entry_btrfs(
David Sterbaac0c7cf2017-01-06 14:12:51 +01001180 __field( void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001181 ),
1182
David Sterbaac0c7cf2017-01-06 14:12:51 +01001183 TP_fast_assign_btrfs(fs_info,
1184 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001185 ),
1186
David Sterbaac0c7cf2017-01-06 14:12:51 +01001187 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001188);
1189
1190DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1191
1192 TP_PROTO(struct btrfs_work *work),
1193
1194 TP_ARGS(work)
1195);
1196
1197DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1198
1199 TP_PROTO(struct btrfs_work *work),
1200
1201 TP_ARGS(work)
1202);
1203
Qu Wenruo52483bc2014-03-06 04:19:50 +00001204DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1205
David Sterbaac0c7cf2017-01-06 14:12:51 +01001206 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001207
David Sterbaac0c7cf2017-01-06 14:12:51 +01001208 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001209);
1210
1211DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1212
1213 TP_PROTO(struct btrfs_work *work),
1214
1215 TP_ARGS(work)
1216);
1217
Qu Wenruoc3a46892014-03-12 08:05:33 +00001218DECLARE_EVENT_CLASS(btrfs__workqueue,
1219
1220 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1221
1222 TP_ARGS(wq, name, high),
1223
Jeff Mahoneybc074522016-06-09 17:27:55 -04001224 TP_STRUCT__entry_btrfs(
Qu Wenruoc3a46892014-03-12 08:05:33 +00001225 __field( void *, wq )
1226 __string( name, name )
1227 __field( int , high )
1228 ),
1229
Jeff Mahoneybc074522016-06-09 17:27:55 -04001230 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001231 __entry->wq = wq;
1232 __assign_str(name, name);
1233 __entry->high = high;
1234 ),
1235
David Sterba562a7a02017-01-06 15:51:36 +01001236 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001237 __print_flags(__entry->high, "",
1238 {(WQ_HIGHPRI), "-high"}),
1239 __entry->wq)
1240);
1241
1242DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1243
1244 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1245
1246 TP_ARGS(wq, name, high)
1247);
1248
1249DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1250
1251 TP_PROTO(struct __btrfs_workqueue *wq),
1252
1253 TP_ARGS(wq),
1254
Jeff Mahoneybc074522016-06-09 17:27:55 -04001255 TP_STRUCT__entry_btrfs(
Qu Wenruoc3a46892014-03-12 08:05:33 +00001256 __field( void *, wq )
1257 ),
1258
Jeff Mahoneybc074522016-06-09 17:27:55 -04001259 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001260 __entry->wq = wq;
1261 ),
1262
Jeff Mahoneybc074522016-06-09 17:27:55 -04001263 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001264);
1265
1266DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1267
1268 TP_PROTO(struct __btrfs_workqueue *wq),
1269
1270 TP_ARGS(wq)
1271);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001272
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001273DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1274
1275 TP_PROTO(struct inode *inode, u64 free_reserved),
1276
1277 TP_ARGS(inode, free_reserved),
1278
Jeff Mahoneybc074522016-06-09 17:27:55 -04001279 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001280 __field( u64, rootid )
1281 __field( unsigned long, ino )
1282 __field( u64, free_reserved )
1283 ),
1284
Jeff Mahoneybc074522016-06-09 17:27:55 -04001285 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001286 __entry->rootid = BTRFS_I(inode)->root->objectid;
1287 __entry->ino = inode->i_ino;
1288 __entry->free_reserved = free_reserved;
1289 ),
1290
David Sterba562a7a02017-01-06 15:51:36 +01001291 TP_printk_btrfs("rootid=%llu ino=%lu free_reserved=%llu",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001292 __entry->rootid, __entry->ino, __entry->free_reserved)
1293);
1294
1295DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
1296
1297 TP_PROTO(struct inode *inode, u64 free_reserved),
1298
1299 TP_ARGS(inode, free_reserved)
1300);
1301
1302DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
1303
1304 TP_PROTO(struct inode *inode, u64 free_reserved),
1305
1306 TP_ARGS(inode, free_reserved)
1307);
1308
1309#define BTRFS_QGROUP_OPERATIONS \
1310 { QGROUP_RESERVE, "reserve" }, \
1311 { QGROUP_RELEASE, "release" }, \
1312 { QGROUP_FREE, "free" }
1313
1314DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1315
1316 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1317
1318 TP_ARGS(inode, start, len, reserved, op),
1319
Jeff Mahoneybc074522016-06-09 17:27:55 -04001320 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001321 __field( u64, rootid )
1322 __field( unsigned long, ino )
1323 __field( u64, start )
1324 __field( u64, len )
1325 __field( u64, reserved )
1326 __field( int, op )
1327 ),
1328
Jeff Mahoneybc074522016-06-09 17:27:55 -04001329 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001330 __entry->rootid = BTRFS_I(inode)->root->objectid;
1331 __entry->ino = inode->i_ino;
1332 __entry->start = start;
1333 __entry->len = len;
1334 __entry->reserved = reserved;
1335 __entry->op = op;
1336 ),
1337
David Sterba562a7a02017-01-06 15:51:36 +01001338 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001339 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1340 __entry->reserved,
1341 __print_flags((unsigned long)__entry->op, "",
1342 BTRFS_QGROUP_OPERATIONS)
1343 )
1344);
1345
1346DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1347
1348 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1349
1350 TP_ARGS(inode, start, len, reserved, op)
1351);
1352
1353DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1354
1355 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1356
1357 TP_ARGS(inode, start, len, reserved, op)
1358);
1359
1360DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1361
Jeff Mahoneybc074522016-06-09 17:27:55 -04001362 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001363
Jeff Mahoneybc074522016-06-09 17:27:55 -04001364 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001365
Jeff Mahoneybc074522016-06-09 17:27:55 -04001366 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001367 __field( u64, ref_root )
1368 __field( u64, reserved )
1369 ),
1370
Jeff Mahoneybc074522016-06-09 17:27:55 -04001371 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001372 __entry->ref_root = ref_root;
1373 __entry->reserved = reserved;
1374 ),
1375
David Sterba562a7a02017-01-06 15:51:36 +01001376 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001377 __entry->ref_root, __entry->reserved)
1378);
1379
1380DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1381
Jeff Mahoneybc074522016-06-09 17:27:55 -04001382 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001383
Jeff Mahoneybc074522016-06-09 17:27:55 -04001384 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001385);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001386
1387DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001388 TP_PROTO(struct btrfs_fs_info *fs_info,
1389 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001390
Jeff Mahoneybc074522016-06-09 17:27:55 -04001391 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001392
Jeff Mahoneybc074522016-06-09 17:27:55 -04001393 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001394 __field( u64, bytenr )
1395 __field( u64, num_bytes )
1396 ),
1397
Jeff Mahoneybc074522016-06-09 17:27:55 -04001398 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001399 __entry->bytenr = rec->bytenr,
1400 __entry->num_bytes = rec->num_bytes;
1401 ),
1402
David Sterba562a7a02017-01-06 15:51:36 +01001403 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001404 (unsigned long long)__entry->bytenr,
1405 (unsigned long long)__entry->num_bytes)
1406);
1407
1408DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1409
Jeff Mahoneybc074522016-06-09 17:27:55 -04001410 TP_PROTO(struct btrfs_fs_info *fs_info,
1411 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001412
Jeff Mahoneybc074522016-06-09 17:27:55 -04001413 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001414);
1415
Qu Wenruo50b3e042016-10-18 09:31:27 +08001416DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001417
Jeff Mahoneybc074522016-06-09 17:27:55 -04001418 TP_PROTO(struct btrfs_fs_info *fs_info,
1419 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001420
Jeff Mahoneybc074522016-06-09 17:27:55 -04001421 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001422);
1423
1424TRACE_EVENT(btrfs_qgroup_account_extent,
1425
Jeff Mahoneybc074522016-06-09 17:27:55 -04001426 TP_PROTO(struct btrfs_fs_info *fs_info, u64 bytenr,
1427 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001428
Jeff Mahoneybc074522016-06-09 17:27:55 -04001429 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001430
Jeff Mahoneybc074522016-06-09 17:27:55 -04001431 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001432 __field( u64, bytenr )
1433 __field( u64, num_bytes )
1434 __field( u64, nr_old_roots )
1435 __field( u64, nr_new_roots )
1436 ),
1437
Jeff Mahoneybc074522016-06-09 17:27:55 -04001438 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001439 __entry->bytenr = bytenr;
1440 __entry->num_bytes = num_bytes;
1441 __entry->nr_old_roots = nr_old_roots;
1442 __entry->nr_new_roots = nr_new_roots;
1443 ),
1444
David Sterba562a7a02017-01-06 15:51:36 +01001445 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1446 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001447 __entry->bytenr,
1448 __entry->num_bytes,
1449 __entry->nr_old_roots,
1450 __entry->nr_new_roots)
1451);
1452
1453TRACE_EVENT(qgroup_update_counters,
1454
Jeff Mahoneybc074522016-06-09 17:27:55 -04001455 TP_PROTO(struct btrfs_fs_info *fs_info, u64 qgid,
1456 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001457
Jeff Mahoneybc074522016-06-09 17:27:55 -04001458 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001459
Jeff Mahoneybc074522016-06-09 17:27:55 -04001460 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001461 __field( u64, qgid )
1462 __field( u64, cur_old_count )
1463 __field( u64, cur_new_count )
1464 ),
1465
Jeff Mahoneybc074522016-06-09 17:27:55 -04001466 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001467 __entry->qgid = qgid;
1468 __entry->cur_old_count = cur_old_count;
1469 __entry->cur_new_count = cur_new_count;
1470 ),
1471
David Sterba562a7a02017-01-06 15:51:36 +01001472 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001473 __entry->qgid,
1474 __entry->cur_old_count,
1475 __entry->cur_new_count)
1476);
1477
liubo1abe9b82011-03-24 11:18:59 +00001478#endif /* _TRACE_BTRFS_H */
1479
1480/* This part must be outside protection */
1481#include <trace/define_trace.h>