blob: 3048f52053633f833c282884fef7eb565df33dc0 [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
Jeff Mahoneybc074522016-06-09 17:27:55 -0400133 TP_printk_btrfs("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
liubo1abe9b82011-03-24 11:18:59 +0000134 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
135 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
Liu Bo92a1bf72016-11-17 15:00:50 -0800187 TP_PROTO(struct btrfs_root *root, struct inode *inode,
188 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;
216 __entry->refs = atomic_read(&map->refs);
217 __entry->compress_type = map->compress_type;
218 ),
219
Liu Bo92a1bf72016-11-17 15:00:50 -0800220 TP_printk_btrfs("root = %llu(%s), ino = %llu start = %llu, len = %llu, "
liubo1abe9b82011-03-24 11:18:59 +0000221 "orig_start = %llu, block_start = %llu(%s), "
222 "block_len = %llu, flags = %s, refs = %u, "
223 "compress_type = %u",
224 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 )
266 ),
267
Jeff Mahoneybc074522016-06-09 17:27:55 -0400268 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000269 __entry->ino = inode->i_ino;
270 __entry->file_offset = ordered->file_offset;
271 __entry->start = ordered->start;
272 __entry->len = ordered->len;
273 __entry->disk_len = ordered->disk_len;
274 __entry->bytes_left = ordered->bytes_left;
275 __entry->flags = ordered->flags;
276 __entry->compress_type = ordered->compress_type;
277 __entry->refs = atomic_read(&ordered->refs);
278 __entry->root_objectid =
279 BTRFS_I(inode)->root->root_key.objectid;
280 ),
281
Jeff Mahoneybc074522016-06-09 17:27:55 -0400282 TP_printk_btrfs("root = %llu(%s), ino = %llu, file_offset = %llu, "
liubo1abe9b82011-03-24 11:18:59 +0000283 "start = %llu, len = %llu, disk_len = %llu, "
284 "bytes_left = %llu, flags = %s, compress_type = %d, "
285 "refs = %d",
286 show_root_type(__entry->root_objectid),
287 (unsigned long long)__entry->ino,
288 (unsigned long long)__entry->file_offset,
289 (unsigned long long)__entry->start,
290 (unsigned long long)__entry->len,
291 (unsigned long long)__entry->disk_len,
292 (unsigned long long)__entry->bytes_left,
293 show_ordered_flags(__entry->flags),
294 __entry->compress_type, __entry->refs)
295);
296
297DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
298
299 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
300
301 TP_ARGS(inode, ordered)
302);
303
304DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
305
306 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
307
308 TP_ARGS(inode, ordered)
309);
310
311DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
312
313 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
314
315 TP_ARGS(inode, ordered)
316);
317
318DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
319
320 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
321
322 TP_ARGS(inode, ordered)
323);
324
325DECLARE_EVENT_CLASS(btrfs__writepage,
326
327 TP_PROTO(struct page *page, struct inode *inode,
328 struct writeback_control *wbc),
329
330 TP_ARGS(page, inode, wbc),
331
Jeff Mahoneybc074522016-06-09 17:27:55 -0400332 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000333 __field( ino_t, ino )
334 __field( pgoff_t, index )
335 __field( long, nr_to_write )
336 __field( long, pages_skipped )
337 __field( loff_t, range_start )
338 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000339 __field( char, for_kupdate )
340 __field( char, for_reclaim )
341 __field( char, range_cyclic )
342 __field( pgoff_t, writeback_index )
343 __field( u64, root_objectid )
344 ),
345
Jeff Mahoneybc074522016-06-09 17:27:55 -0400346 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000347 __entry->ino = inode->i_ino;
348 __entry->index = page->index;
349 __entry->nr_to_write = wbc->nr_to_write;
350 __entry->pages_skipped = wbc->pages_skipped;
351 __entry->range_start = wbc->range_start;
352 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000353 __entry->for_kupdate = wbc->for_kupdate;
354 __entry->for_reclaim = wbc->for_reclaim;
355 __entry->range_cyclic = wbc->range_cyclic;
356 __entry->writeback_index = inode->i_mapping->writeback_index;
357 __entry->root_objectid =
358 BTRFS_I(inode)->root->root_key.objectid;
359 ),
360
Jeff Mahoneybc074522016-06-09 17:27:55 -0400361 TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, "
liubo1abe9b82011-03-24 11:18:59 +0000362 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
Wu Fengguang846d5a02011-05-05 21:10:38 -0600363 "range_end = %llu, for_kupdate = %d, "
liubo1abe9b82011-03-24 11:18:59 +0000364 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
365 show_root_type(__entry->root_objectid),
366 (unsigned long)__entry->ino, __entry->index,
367 __entry->nr_to_write, __entry->pages_skipped,
368 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600369 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000370 __entry->for_reclaim, __entry->range_cyclic,
371 (unsigned long)__entry->writeback_index)
372);
373
374DEFINE_EVENT(btrfs__writepage, __extent_writepage,
375
376 TP_PROTO(struct page *page, struct inode *inode,
377 struct writeback_control *wbc),
378
379 TP_ARGS(page, inode, wbc)
380);
381
382TRACE_EVENT(btrfs_writepage_end_io_hook,
383
384 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
385
386 TP_ARGS(page, start, end, uptodate),
387
Jeff Mahoneybc074522016-06-09 17:27:55 -0400388 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000389 __field( ino_t, ino )
390 __field( pgoff_t, index )
391 __field( u64, start )
392 __field( u64, end )
393 __field( int, uptodate )
394 __field( u64, root_objectid )
395 ),
396
Jeff Mahoneybc074522016-06-09 17:27:55 -0400397 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000398 __entry->ino = page->mapping->host->i_ino;
399 __entry->index = page->index;
400 __entry->start = start;
401 __entry->end = end;
402 __entry->uptodate = uptodate;
403 __entry->root_objectid =
404 BTRFS_I(page->mapping->host)->root->root_key.objectid;
405 ),
406
Jeff Mahoneybc074522016-06-09 17:27:55 -0400407 TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
liubo1abe9b82011-03-24 11:18:59 +0000408 "end = %llu, uptodate = %d",
409 show_root_type(__entry->root_objectid),
410 (unsigned long)__entry->ino, (unsigned long)__entry->index,
411 (unsigned long long)__entry->start,
412 (unsigned long long)__entry->end, __entry->uptodate)
413);
414
415TRACE_EVENT(btrfs_sync_file,
416
417 TP_PROTO(struct file *file, int datasync),
418
419 TP_ARGS(file, datasync),
420
Jeff Mahoneybc074522016-06-09 17:27:55 -0400421 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000422 __field( ino_t, ino )
423 __field( ino_t, parent )
424 __field( int, datasync )
425 __field( u64, root_objectid )
426 ),
427
428 TP_fast_assign(
429 struct dentry *dentry = file->f_path.dentry;
David Howells2b0143b2015-03-17 22:25:59 +0000430 struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000431
Jeff Mahoneybc074522016-06-09 17:27:55 -0400432 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
liubo1abe9b82011-03-24 11:18:59 +0000433 __entry->ino = inode->i_ino;
David Howells2b0143b2015-03-17 22:25:59 +0000434 __entry->parent = d_inode(dentry->d_parent)->i_ino;
liubo1abe9b82011-03-24 11:18:59 +0000435 __entry->datasync = datasync;
436 __entry->root_objectid =
437 BTRFS_I(inode)->root->root_key.objectid;
438 ),
439
Jeff Mahoneybc074522016-06-09 17:27:55 -0400440 TP_printk_btrfs("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
liubo1abe9b82011-03-24 11:18:59 +0000441 show_root_type(__entry->root_objectid),
442 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
443 __entry->datasync)
444);
445
446TRACE_EVENT(btrfs_sync_fs,
447
Jeff Mahoneybc074522016-06-09 17:27:55 -0400448 TP_PROTO(struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000449
Jeff Mahoneybc074522016-06-09 17:27:55 -0400450 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000451
Jeff Mahoneybc074522016-06-09 17:27:55 -0400452 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000453 __field( int, wait )
454 ),
455
Jeff Mahoneybc074522016-06-09 17:27:55 -0400456 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000457 __entry->wait = wait;
458 ),
459
Jeff Mahoneybc074522016-06-09 17:27:55 -0400460 TP_printk_btrfs("wait = %d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000461);
462
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400463TRACE_EVENT(btrfs_add_block_group,
464
465 TP_PROTO(struct btrfs_fs_info *fs_info,
466 struct btrfs_block_group_cache *block_group, int create),
467
468 TP_ARGS(fs_info, block_group, create),
469
470 TP_STRUCT__entry(
471 __array( u8, fsid, BTRFS_UUID_SIZE )
472 __field( u64, offset )
473 __field( u64, size )
474 __field( u64, flags )
475 __field( u64, bytes_used )
476 __field( u64, bytes_super )
477 __field( int, create )
478 ),
479
480 TP_fast_assign(
481 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
482 __entry->offset = block_group->key.objectid;
483 __entry->size = block_group->key.offset;
484 __entry->flags = block_group->flags;
485 __entry->bytes_used =
486 btrfs_block_group_used(&block_group->item);
487 __entry->bytes_super = block_group->bytes_super;
488 __entry->create = create;
489 ),
490
491 TP_printk("%pU: block_group offset = %llu, size = %llu, "
492 "flags = %llu(%s), bytes_used = %llu, bytes_super = %llu, "
493 "create = %d", __entry->fsid,
494 (unsigned long long)__entry->offset,
495 (unsigned long long)__entry->size,
496 (unsigned long long)__entry->flags,
497 __print_flags((unsigned long)__entry->flags, "|",
498 BTRFS_GROUP_FLAGS),
499 (unsigned long long)__entry->bytes_used,
500 (unsigned long long)__entry->bytes_super, __entry->create)
501);
502
liubo1abe9b82011-03-24 11:18:59 +0000503#define show_ref_action(action) \
504 __print_symbolic(action, \
505 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
506 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
507 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
508 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
509
510
Liu Bo599c75e2013-07-16 19:03:36 +0800511DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000512
Jeff Mahoneybc074522016-06-09 17:27:55 -0400513 TP_PROTO(struct btrfs_fs_info *fs_info,
514 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000515 struct btrfs_delayed_tree_ref *full_ref,
516 int action),
517
Jeff Mahoneybc074522016-06-09 17:27:55 -0400518 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000519
Jeff Mahoneybc074522016-06-09 17:27:55 -0400520 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000521 __field( u64, bytenr )
522 __field( u64, num_bytes )
523 __field( int, action )
524 __field( u64, parent )
525 __field( u64, ref_root )
526 __field( int, level )
527 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600528 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000529 ),
530
Jeff Mahoneybc074522016-06-09 17:27:55 -0400531 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000532 __entry->bytenr = ref->bytenr;
533 __entry->num_bytes = ref->num_bytes;
534 __entry->action = action;
535 __entry->parent = full_ref->parent;
536 __entry->ref_root = full_ref->root;
537 __entry->level = full_ref->level;
538 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600539 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000540 ),
541
Jeff Mahoneybc074522016-06-09 17:27:55 -0400542 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, "
liubo1abe9b82011-03-24 11:18:59 +0000543 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
Liu Bodea7d762012-09-07 20:01:27 -0600544 "type = %s, seq = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000545 (unsigned long long)__entry->bytenr,
546 (unsigned long long)__entry->num_bytes,
547 show_ref_action(__entry->action),
548 show_root_type(__entry->parent),
549 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600550 __entry->level, show_ref_type(__entry->type),
551 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000552);
553
Liu Bo599c75e2013-07-16 19:03:36 +0800554DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
555
Jeff Mahoneybc074522016-06-09 17:27:55 -0400556 TP_PROTO(struct btrfs_fs_info *fs_info,
557 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800558 struct btrfs_delayed_tree_ref *full_ref,
559 int action),
560
Jeff Mahoneybc074522016-06-09 17:27:55 -0400561 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800562);
563
564DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
565
Jeff Mahoneybc074522016-06-09 17:27:55 -0400566 TP_PROTO(struct btrfs_fs_info *fs_info,
567 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800568 struct btrfs_delayed_tree_ref *full_ref,
569 int action),
570
Jeff Mahoneybc074522016-06-09 17:27:55 -0400571 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800572);
573
574DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000575
Jeff Mahoneybc074522016-06-09 17:27:55 -0400576 TP_PROTO(struct btrfs_fs_info *fs_info,
577 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000578 struct btrfs_delayed_data_ref *full_ref,
579 int action),
580
Jeff Mahoneybc074522016-06-09 17:27:55 -0400581 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000582
Jeff Mahoneybc074522016-06-09 17:27:55 -0400583 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000584 __field( u64, bytenr )
585 __field( u64, num_bytes )
586 __field( int, action )
587 __field( u64, parent )
588 __field( u64, ref_root )
589 __field( u64, owner )
590 __field( u64, offset )
591 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600592 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000593 ),
594
Jeff Mahoneybc074522016-06-09 17:27:55 -0400595 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000596 __entry->bytenr = ref->bytenr;
597 __entry->num_bytes = ref->num_bytes;
598 __entry->action = action;
599 __entry->parent = full_ref->parent;
600 __entry->ref_root = full_ref->root;
601 __entry->owner = full_ref->objectid;
602 __entry->offset = full_ref->offset;
603 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600604 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000605 ),
606
Jeff Mahoneybc074522016-06-09 17:27:55 -0400607 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, "
liubo1abe9b82011-03-24 11:18:59 +0000608 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
Liu Bodea7d762012-09-07 20:01:27 -0600609 "offset = %llu, type = %s, seq = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000610 (unsigned long long)__entry->bytenr,
611 (unsigned long long)__entry->num_bytes,
612 show_ref_action(__entry->action),
613 show_root_type(__entry->parent),
614 show_root_type(__entry->ref_root),
615 (unsigned long long)__entry->owner,
616 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600617 show_ref_type(__entry->type),
618 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000619);
620
Liu Bo599c75e2013-07-16 19:03:36 +0800621DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
622
Jeff Mahoneybc074522016-06-09 17:27:55 -0400623 TP_PROTO(struct btrfs_fs_info *fs_info,
624 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800625 struct btrfs_delayed_data_ref *full_ref,
626 int action),
627
Jeff Mahoneybc074522016-06-09 17:27:55 -0400628 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800629);
630
631DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
632
Jeff Mahoneybc074522016-06-09 17:27:55 -0400633 TP_PROTO(struct btrfs_fs_info *fs_info,
634 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800635 struct btrfs_delayed_data_ref *full_ref,
636 int action),
637
Jeff Mahoneybc074522016-06-09 17:27:55 -0400638 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800639);
640
641DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000642
Jeff Mahoneybc074522016-06-09 17:27:55 -0400643 TP_PROTO(struct btrfs_fs_info *fs_info,
644 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000645 struct btrfs_delayed_ref_head *head_ref,
646 int action),
647
Jeff Mahoneybc074522016-06-09 17:27:55 -0400648 TP_ARGS(fs_info, ref, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000649
Jeff Mahoneybc074522016-06-09 17:27:55 -0400650 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000651 __field( u64, bytenr )
652 __field( u64, num_bytes )
653 __field( int, action )
654 __field( int, is_data )
655 ),
656
Jeff Mahoneybc074522016-06-09 17:27:55 -0400657 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000658 __entry->bytenr = ref->bytenr;
659 __entry->num_bytes = ref->num_bytes;
660 __entry->action = action;
661 __entry->is_data = head_ref->is_data;
662 ),
663
Jeff Mahoneybc074522016-06-09 17:27:55 -0400664 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
liubo1abe9b82011-03-24 11:18:59 +0000665 (unsigned long long)__entry->bytenr,
666 (unsigned long long)__entry->num_bytes,
667 show_ref_action(__entry->action),
668 __entry->is_data)
669);
670
Liu Bo599c75e2013-07-16 19:03:36 +0800671DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
672
Jeff Mahoneybc074522016-06-09 17:27:55 -0400673 TP_PROTO(struct btrfs_fs_info *fs_info,
674 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800675 struct btrfs_delayed_ref_head *head_ref,
676 int action),
677
Jeff Mahoneybc074522016-06-09 17:27:55 -0400678 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800679);
680
681DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
682
Jeff Mahoneybc074522016-06-09 17:27:55 -0400683 TP_PROTO(struct btrfs_fs_info *fs_info,
684 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800685 struct btrfs_delayed_ref_head *head_ref,
686 int action),
687
Jeff Mahoneybc074522016-06-09 17:27:55 -0400688 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800689);
690
liubo1abe9b82011-03-24 11:18:59 +0000691#define show_chunk_type(type) \
692 __print_flags(type, "|", \
693 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
694 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
695 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
696 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
697 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
698 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000699 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
700 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
701 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000702
703DECLARE_EVENT_CLASS(btrfs__chunk,
704
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400705 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000706 u64 offset, u64 size),
707
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400708 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000709
Jeff Mahoneybc074522016-06-09 17:27:55 -0400710 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000711 __field( int, num_stripes )
712 __field( u64, type )
713 __field( int, sub_stripes )
714 __field( u64, offset )
715 __field( u64, size )
716 __field( u64, root_objectid )
717 ),
718
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400719 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000720 __entry->num_stripes = map->num_stripes;
721 __entry->type = map->type;
722 __entry->sub_stripes = map->sub_stripes;
723 __entry->offset = offset;
724 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400725 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000726 ),
727
Jeff Mahoneybc074522016-06-09 17:27:55 -0400728 TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, "
liubo1abe9b82011-03-24 11:18:59 +0000729 "num_stripes = %d, sub_stripes = %d, type = %s",
730 show_root_type(__entry->root_objectid),
731 (unsigned long long)__entry->offset,
732 (unsigned long long)__entry->size,
733 __entry->num_stripes, __entry->sub_stripes,
734 show_chunk_type(__entry->type))
735);
736
737DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
738
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400739 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000740 u64 offset, u64 size),
741
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400742 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000743);
744
745DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
746
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400747 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000748 u64 offset, u64 size),
749
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400750 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000751);
752
753TRACE_EVENT(btrfs_cow_block,
754
755 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
756 struct extent_buffer *cow),
757
758 TP_ARGS(root, buf, cow),
759
Jeff Mahoneybc074522016-06-09 17:27:55 -0400760 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000761 __field( u64, root_objectid )
762 __field( u64, buf_start )
763 __field( int, refs )
764 __field( u64, cow_start )
765 __field( int, buf_level )
766 __field( int, cow_level )
767 ),
768
Jeff Mahoneybc074522016-06-09 17:27:55 -0400769 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000770 __entry->root_objectid = root->root_key.objectid;
771 __entry->buf_start = buf->start;
772 __entry->refs = atomic_read(&buf->refs);
773 __entry->cow_start = cow->start;
774 __entry->buf_level = btrfs_header_level(buf);
775 __entry->cow_level = btrfs_header_level(cow);
776 ),
777
Jeff Mahoneybc074522016-06-09 17:27:55 -0400778 TP_printk_btrfs("root = %llu(%s), refs = %d, orig_buf = %llu "
liubo1abe9b82011-03-24 11:18:59 +0000779 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
780 show_root_type(__entry->root_objectid),
781 __entry->refs,
782 (unsigned long long)__entry->buf_start,
783 __entry->buf_level,
784 (unsigned long long)__entry->cow_start,
785 __entry->cow_level)
786);
787
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500788TRACE_EVENT(btrfs_space_reservation,
789
790 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
791 u64 bytes, int reserve),
792
793 TP_ARGS(fs_info, type, val, bytes, reserve),
794
Jeff Mahoneybc074522016-06-09 17:27:55 -0400795 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500796 __string( type, type )
797 __field( u64, val )
798 __field( u64, bytes )
799 __field( int, reserve )
800 ),
801
Jeff Mahoneybc074522016-06-09 17:27:55 -0400802 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500803 __assign_str(type, type);
804 __entry->val = val;
805 __entry->bytes = bytes;
806 __entry->reserve = reserve;
807 ),
808
Jeff Mahoneybc074522016-06-09 17:27:55 -0400809 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
810 __entry->reserve ? "reserve" : "release",
811 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500812);
813
Josef Bacikf376df22016-03-25 13:25:56 -0400814#define show_flush_action(action) \
815 __print_symbolic(action, \
816 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
817 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
818 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
819
820TRACE_EVENT(btrfs_trigger_flush,
821
822 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
823 int flush, char *reason),
824
825 TP_ARGS(fs_info, flags, bytes, flush, reason),
826
827 TP_STRUCT__entry(
828 __array( u8, fsid, BTRFS_UUID_SIZE )
829 __field( u64, flags )
830 __field( u64, bytes )
831 __field( int, flush )
832 __string( reason, reason )
833 ),
834
835 TP_fast_assign(
836 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
837 __entry->flags = flags;
838 __entry->bytes = bytes;
839 __entry->flush = flush;
840 __assign_str(reason, reason)
841 ),
842
843 TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu",
844 __entry->fsid, __get_str(reason), __entry->flush,
845 show_flush_action(__entry->flush),
846 (unsigned long long)__entry->flags,
847 __print_flags((unsigned long)__entry->flags, "|",
848 BTRFS_GROUP_FLAGS),
849 (unsigned long long)__entry->bytes)
850);
851
852#define show_flush_state(state) \
853 __print_symbolic(state, \
854 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
855 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
856 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
857 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
858 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
859 { COMMIT_TRANS, "COMMIT_TRANS"})
860
861TRACE_EVENT(btrfs_flush_space,
862
863 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
864 u64 orig_bytes, int state, int ret),
865
866 TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),
867
868 TP_STRUCT__entry(
869 __array( u8, fsid, BTRFS_UUID_SIZE )
870 __field( u64, flags )
871 __field( u64, num_bytes )
872 __field( u64, orig_bytes )
873 __field( int, state )
874 __field( int, ret )
875 ),
876
877 TP_fast_assign(
878 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
879 __entry->flags = flags;
880 __entry->num_bytes = num_bytes;
881 __entry->orig_bytes = orig_bytes;
882 __entry->state = state;
883 __entry->ret = ret;
884 ),
885
886 TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, "
887 "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state,
888 show_flush_state(__entry->state),
889 (unsigned long long)__entry->flags,
890 __print_flags((unsigned long)__entry->flags, "|",
891 BTRFS_GROUP_FLAGS),
892 (unsigned long long)__entry->num_bytes,
893 (unsigned long long)__entry->orig_bytes, __entry->ret)
894);
895
liubo1abe9b82011-03-24 11:18:59 +0000896DECLARE_EVENT_CLASS(btrfs__reserved_extent,
897
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400898 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +0000899
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400900 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +0000901
Jeff Mahoneybc074522016-06-09 17:27:55 -0400902 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -0400903 __field( u64, start )
904 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +0000905 ),
906
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400907 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000908 __entry->start = start;
909 __entry->len = len;
910 ),
911
Jeff Mahoneybc074522016-06-09 17:27:55 -0400912 TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400913 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
liubo1abe9b82011-03-24 11:18:59 +0000914 (unsigned long long)__entry->start,
915 (unsigned long long)__entry->len)
916);
917
918DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
919
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400920 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +0000921
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400922 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +0000923);
924
925DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
926
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400927 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +0000928
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400929 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +0000930);
931
Josef Bacik3f7de032011-11-10 08:29:20 -0500932TRACE_EVENT(find_free_extent,
933
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400934 TP_PROTO(struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size,
Josef Bacik3f7de032011-11-10 08:29:20 -0500935 u64 data),
936
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400937 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -0500938
Jeff Mahoneybc074522016-06-09 17:27:55 -0400939 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -0500940 __field( u64, num_bytes )
941 __field( u64, empty_size )
942 __field( u64, data )
943 ),
944
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400945 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500946 __entry->num_bytes = num_bytes;
947 __entry->empty_size = empty_size;
948 __entry->data = data;
949 ),
950
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400951 TP_printk_btrfs("root = %Lu(%s), len = %Lu, empty_size = %Lu, flags = %Lu(%s)",
952 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -0500953 __entry->num_bytes, __entry->empty_size, __entry->data,
954 __print_flags((unsigned long)__entry->data, "|",
955 BTRFS_GROUP_FLAGS))
956);
957
958DECLARE_EVENT_CLASS(btrfs__reserve_extent,
959
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400960 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500961 struct btrfs_block_group_cache *block_group, u64 start,
962 u64 len),
963
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400964 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -0500965
Jeff Mahoneybc074522016-06-09 17:27:55 -0400966 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -0500967 __field( u64, bg_objectid )
968 __field( u64, flags )
969 __field( u64, start )
970 __field( u64, len )
971 ),
972
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400973 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500974 __entry->bg_objectid = block_group->key.objectid;
975 __entry->flags = block_group->flags;
976 __entry->start = start;
977 __entry->len = len;
978 ),
979
Jeff Mahoneybc074522016-06-09 17:27:55 -0400980 TP_printk_btrfs("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
981 "start = %Lu, len = %Lu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400982 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
983 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -0500984 __entry->flags, __print_flags((unsigned long)__entry->flags,
985 "|", BTRFS_GROUP_FLAGS),
986 __entry->start, __entry->len)
987);
988
989DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
990
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400991 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -0500992 struct btrfs_block_group_cache *block_group, u64 start,
993 u64 len),
994
Jeff Mahoney71ff6432016-09-06 16:00:42 -0400995 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -0500996);
997
998DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
999
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001000 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001001 struct btrfs_block_group_cache *block_group, u64 start,
1002 u64 len),
1003
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001004 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001005);
1006
1007TRACE_EVENT(btrfs_find_cluster,
1008
1009 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
1010 u64 bytes, u64 empty_size, u64 min_bytes),
1011
1012 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1013
Jeff Mahoneybc074522016-06-09 17:27:55 -04001014 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001015 __field( u64, bg_objectid )
1016 __field( u64, flags )
1017 __field( u64, start )
1018 __field( u64, bytes )
1019 __field( u64, empty_size )
1020 __field( u64, min_bytes )
1021 ),
1022
Jeff Mahoneybc074522016-06-09 17:27:55 -04001023 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001024 __entry->bg_objectid = block_group->key.objectid;
1025 __entry->flags = block_group->flags;
1026 __entry->start = start;
1027 __entry->bytes = bytes;
1028 __entry->empty_size = empty_size;
1029 __entry->min_bytes = min_bytes;
1030 ),
1031
Jeff Mahoneybc074522016-06-09 17:27:55 -04001032 TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
Josef Bacik3f7de032011-11-10 08:29:20 -05001033 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
1034 __entry->flags,
1035 __print_flags((unsigned long)__entry->flags, "|",
1036 BTRFS_GROUP_FLAGS), __entry->start,
1037 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1038);
1039
1040TRACE_EVENT(btrfs_failed_cluster_setup,
1041
1042 TP_PROTO(struct btrfs_block_group_cache *block_group),
1043
1044 TP_ARGS(block_group),
1045
Jeff Mahoneybc074522016-06-09 17:27:55 -04001046 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001047 __field( u64, bg_objectid )
1048 ),
1049
Jeff Mahoneybc074522016-06-09 17:27:55 -04001050 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001051 __entry->bg_objectid = block_group->key.objectid;
1052 ),
1053
Jeff Mahoneybc074522016-06-09 17:27:55 -04001054 TP_printk_btrfs("block_group = %Lu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001055);
1056
1057TRACE_EVENT(btrfs_setup_cluster,
1058
1059 TP_PROTO(struct btrfs_block_group_cache *block_group,
1060 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
1061
1062 TP_ARGS(block_group, cluster, size, bitmap),
1063
Jeff Mahoneybc074522016-06-09 17:27:55 -04001064 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001065 __field( u64, bg_objectid )
1066 __field( u64, flags )
1067 __field( u64, start )
1068 __field( u64, max_size )
1069 __field( u64, size )
1070 __field( int, bitmap )
1071 ),
1072
Jeff Mahoneybc074522016-06-09 17:27:55 -04001073 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001074 __entry->bg_objectid = block_group->key.objectid;
1075 __entry->flags = block_group->flags;
1076 __entry->start = cluster->window_start;
1077 __entry->max_size = cluster->max_size;
1078 __entry->size = size;
1079 __entry->bitmap = bitmap;
1080 ),
1081
Jeff Mahoneybc074522016-06-09 17:27:55 -04001082 TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
Josef Bacik3f7de032011-11-10 08:29:20 -05001083 "size = %Lu, max_size = %Lu, bitmap = %d",
1084 __entry->bg_objectid,
1085 __entry->flags,
1086 __print_flags((unsigned long)__entry->flags, "|",
1087 BTRFS_GROUP_FLAGS), __entry->start,
1088 __entry->size, __entry->max_size, __entry->bitmap)
1089);
1090
Jeff Mahoney143bede2012-03-01 14:56:26 +01001091struct extent_state;
1092TRACE_EVENT(alloc_extent_state,
1093
1094 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
1095
1096 TP_ARGS(state, mask, IP),
1097
1098 TP_STRUCT__entry(
1099 __field(struct extent_state *, state)
1100 __field(gfp_t, mask)
1101 __field(unsigned long, ip)
1102 ),
1103
1104 TP_fast_assign(
1105 __entry->state = state,
1106 __entry->mask = mask,
1107 __entry->ip = IP
1108 ),
1109
Scott Woodbbedb172015-03-11 22:13:57 -05001110 TP_printk("state=%p; mask = %s; caller = %pS", __entry->state,
Jeff Mahoney143bede2012-03-01 14:56:26 +01001111 show_gfp_flags(__entry->mask), (void *)__entry->ip)
1112);
1113
1114TRACE_EVENT(free_extent_state,
1115
1116 TP_PROTO(struct extent_state *state, unsigned long IP),
1117
1118 TP_ARGS(state, IP),
1119
1120 TP_STRUCT__entry(
1121 __field(struct extent_state *, state)
1122 __field(unsigned long, ip)
1123 ),
1124
1125 TP_fast_assign(
1126 __entry->state = state,
1127 __entry->ip = IP
1128 ),
1129
Scott Woodbbedb172015-03-11 22:13:57 -05001130 TP_printk(" state=%p; caller = %pS", __entry->state,
Jeff Mahoney143bede2012-03-01 14:56:26 +01001131 (void *)__entry->ip)
1132);
1133
Qu Wenruo52483bc2014-03-06 04:19:50 +00001134DECLARE_EVENT_CLASS(btrfs__work,
1135
1136 TP_PROTO(struct btrfs_work *work),
1137
1138 TP_ARGS(work),
1139
Jeff Mahoneybc074522016-06-09 17:27:55 -04001140 TP_STRUCT__entry_btrfs(
Qu Wenruo52483bc2014-03-06 04:19:50 +00001141 __field( void *, work )
1142 __field( void *, wq )
1143 __field( void *, func )
1144 __field( void *, ordered_func )
1145 __field( void *, ordered_free )
Liu Bob38a6252014-08-12 16:33:17 +08001146 __field( void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001147 ),
1148
Jeff Mahoneybc074522016-06-09 17:27:55 -04001149 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001150 __entry->work = work;
1151 __entry->wq = work->wq;
1152 __entry->func = work->func;
1153 __entry->ordered_func = work->ordered_func;
1154 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001155 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001156 ),
1157
Jeff Mahoneybc074522016-06-09 17:27:55 -04001158 TP_printk_btrfs("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p,"
Liu Bob38a6252014-08-12 16:33:17 +08001159 " ordered_free=%p",
1160 __entry->work, __entry->normal_work, __entry->wq,
1161 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001162);
1163
David Sterbaac0c7cf2017-01-06 14:12:51 +01001164/*
1165 * For situiations when the work is freed, we pass fs_info and a tag that that
1166 * matches address of the work structure so it can be paired with the
1167 * scheduling event.
1168 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001169DECLARE_EVENT_CLASS(btrfs__work__done,
1170
David Sterbaac0c7cf2017-01-06 14:12:51 +01001171 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001172
David Sterbaac0c7cf2017-01-06 14:12:51 +01001173 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001174
Jeff Mahoneybc074522016-06-09 17:27:55 -04001175 TP_STRUCT__entry_btrfs(
David Sterbaac0c7cf2017-01-06 14:12:51 +01001176 __field( void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001177 ),
1178
David Sterbaac0c7cf2017-01-06 14:12:51 +01001179 TP_fast_assign_btrfs(fs_info,
1180 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001181 ),
1182
David Sterbaac0c7cf2017-01-06 14:12:51 +01001183 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001184);
1185
1186DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1187
1188 TP_PROTO(struct btrfs_work *work),
1189
1190 TP_ARGS(work)
1191);
1192
1193DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1194
1195 TP_PROTO(struct btrfs_work *work),
1196
1197 TP_ARGS(work)
1198);
1199
Qu Wenruo52483bc2014-03-06 04:19:50 +00001200DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1201
David Sterbaac0c7cf2017-01-06 14:12:51 +01001202 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001203
David Sterbaac0c7cf2017-01-06 14:12:51 +01001204 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001205);
1206
1207DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1208
1209 TP_PROTO(struct btrfs_work *work),
1210
1211 TP_ARGS(work)
1212);
1213
Qu Wenruoc3a46892014-03-12 08:05:33 +00001214DECLARE_EVENT_CLASS(btrfs__workqueue,
1215
1216 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1217
1218 TP_ARGS(wq, name, high),
1219
Jeff Mahoneybc074522016-06-09 17:27:55 -04001220 TP_STRUCT__entry_btrfs(
Qu Wenruoc3a46892014-03-12 08:05:33 +00001221 __field( void *, wq )
1222 __string( name, name )
1223 __field( int , high )
1224 ),
1225
Jeff Mahoneybc074522016-06-09 17:27:55 -04001226 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001227 __entry->wq = wq;
1228 __assign_str(name, name);
1229 __entry->high = high;
1230 ),
1231
Jeff Mahoneybc074522016-06-09 17:27:55 -04001232 TP_printk_btrfs("name=%s%s, wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001233 __print_flags(__entry->high, "",
1234 {(WQ_HIGHPRI), "-high"}),
1235 __entry->wq)
1236);
1237
1238DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1239
1240 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1241
1242 TP_ARGS(wq, name, high)
1243);
1244
1245DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1246
1247 TP_PROTO(struct __btrfs_workqueue *wq),
1248
1249 TP_ARGS(wq),
1250
Jeff Mahoneybc074522016-06-09 17:27:55 -04001251 TP_STRUCT__entry_btrfs(
Qu Wenruoc3a46892014-03-12 08:05:33 +00001252 __field( void *, wq )
1253 ),
1254
Jeff Mahoneybc074522016-06-09 17:27:55 -04001255 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001256 __entry->wq = wq;
1257 ),
1258
Jeff Mahoneybc074522016-06-09 17:27:55 -04001259 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001260);
1261
1262DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1263
1264 TP_PROTO(struct __btrfs_workqueue *wq),
1265
1266 TP_ARGS(wq)
1267);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001268
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001269DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1270
1271 TP_PROTO(struct inode *inode, u64 free_reserved),
1272
1273 TP_ARGS(inode, free_reserved),
1274
Jeff Mahoneybc074522016-06-09 17:27:55 -04001275 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001276 __field( u64, rootid )
1277 __field( unsigned long, ino )
1278 __field( u64, free_reserved )
1279 ),
1280
Jeff Mahoneybc074522016-06-09 17:27:55 -04001281 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001282 __entry->rootid = BTRFS_I(inode)->root->objectid;
1283 __entry->ino = inode->i_ino;
1284 __entry->free_reserved = free_reserved;
1285 ),
1286
Jeff Mahoneybc074522016-06-09 17:27:55 -04001287 TP_printk_btrfs("rootid=%llu, ino=%lu, free_reserved=%llu",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001288 __entry->rootid, __entry->ino, __entry->free_reserved)
1289);
1290
1291DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
1292
1293 TP_PROTO(struct inode *inode, u64 free_reserved),
1294
1295 TP_ARGS(inode, free_reserved)
1296);
1297
1298DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
1299
1300 TP_PROTO(struct inode *inode, u64 free_reserved),
1301
1302 TP_ARGS(inode, free_reserved)
1303);
1304
1305#define BTRFS_QGROUP_OPERATIONS \
1306 { QGROUP_RESERVE, "reserve" }, \
1307 { QGROUP_RELEASE, "release" }, \
1308 { QGROUP_FREE, "free" }
1309
1310DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1311
1312 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1313
1314 TP_ARGS(inode, start, len, reserved, op),
1315
Jeff Mahoneybc074522016-06-09 17:27:55 -04001316 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001317 __field( u64, rootid )
1318 __field( unsigned long, ino )
1319 __field( u64, start )
1320 __field( u64, len )
1321 __field( u64, reserved )
1322 __field( int, op )
1323 ),
1324
Jeff Mahoneybc074522016-06-09 17:27:55 -04001325 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001326 __entry->rootid = BTRFS_I(inode)->root->objectid;
1327 __entry->ino = inode->i_ino;
1328 __entry->start = start;
1329 __entry->len = len;
1330 __entry->reserved = reserved;
1331 __entry->op = op;
1332 ),
1333
Jeff Mahoneybc074522016-06-09 17:27:55 -04001334 TP_printk_btrfs("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001335 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1336 __entry->reserved,
1337 __print_flags((unsigned long)__entry->op, "",
1338 BTRFS_QGROUP_OPERATIONS)
1339 )
1340);
1341
1342DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1343
1344 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1345
1346 TP_ARGS(inode, start, len, reserved, op)
1347);
1348
1349DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1350
1351 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1352
1353 TP_ARGS(inode, start, len, reserved, op)
1354);
1355
1356DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1357
Jeff Mahoneybc074522016-06-09 17:27:55 -04001358 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001359
Jeff Mahoneybc074522016-06-09 17:27:55 -04001360 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001361
Jeff Mahoneybc074522016-06-09 17:27:55 -04001362 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001363 __field( u64, ref_root )
1364 __field( u64, reserved )
1365 ),
1366
Jeff Mahoneybc074522016-06-09 17:27:55 -04001367 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001368 __entry->ref_root = ref_root;
1369 __entry->reserved = reserved;
1370 ),
1371
Jeff Mahoneybc074522016-06-09 17:27:55 -04001372 TP_printk_btrfs("root=%llu, reserved=%llu, op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001373 __entry->ref_root, __entry->reserved)
1374);
1375
1376DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1377
Jeff Mahoneybc074522016-06-09 17:27:55 -04001378 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001379
Jeff Mahoneybc074522016-06-09 17:27:55 -04001380 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001381);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001382
1383DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001384 TP_PROTO(struct btrfs_fs_info *fs_info,
1385 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001386
Jeff Mahoneybc074522016-06-09 17:27:55 -04001387 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001388
Jeff Mahoneybc074522016-06-09 17:27:55 -04001389 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001390 __field( u64, bytenr )
1391 __field( u64, num_bytes )
1392 ),
1393
Jeff Mahoneybc074522016-06-09 17:27:55 -04001394 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001395 __entry->bytenr = rec->bytenr,
1396 __entry->num_bytes = rec->num_bytes;
1397 ),
1398
Jeff Mahoneybc074522016-06-09 17:27:55 -04001399 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001400 (unsigned long long)__entry->bytenr,
1401 (unsigned long long)__entry->num_bytes)
1402);
1403
1404DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1405
Jeff Mahoneybc074522016-06-09 17:27:55 -04001406 TP_PROTO(struct btrfs_fs_info *fs_info,
1407 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001408
Jeff Mahoneybc074522016-06-09 17:27:55 -04001409 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001410);
1411
Qu Wenruo50b3e042016-10-18 09:31:27 +08001412DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001413
Jeff Mahoneybc074522016-06-09 17:27:55 -04001414 TP_PROTO(struct btrfs_fs_info *fs_info,
1415 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001416
Jeff Mahoneybc074522016-06-09 17:27:55 -04001417 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001418);
1419
1420TRACE_EVENT(btrfs_qgroup_account_extent,
1421
Jeff Mahoneybc074522016-06-09 17:27:55 -04001422 TP_PROTO(struct btrfs_fs_info *fs_info, u64 bytenr,
1423 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001424
Jeff Mahoneybc074522016-06-09 17:27:55 -04001425 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001426
Jeff Mahoneybc074522016-06-09 17:27:55 -04001427 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001428 __field( u64, bytenr )
1429 __field( u64, num_bytes )
1430 __field( u64, nr_old_roots )
1431 __field( u64, nr_new_roots )
1432 ),
1433
Jeff Mahoneybc074522016-06-09 17:27:55 -04001434 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001435 __entry->bytenr = bytenr;
1436 __entry->num_bytes = num_bytes;
1437 __entry->nr_old_roots = nr_old_roots;
1438 __entry->nr_new_roots = nr_new_roots;
1439 ),
1440
Jeff Mahoneybc074522016-06-09 17:27:55 -04001441 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001442 "nr_new_roots = %llu",
1443 __entry->bytenr,
1444 __entry->num_bytes,
1445 __entry->nr_old_roots,
1446 __entry->nr_new_roots)
1447);
1448
1449TRACE_EVENT(qgroup_update_counters,
1450
Jeff Mahoneybc074522016-06-09 17:27:55 -04001451 TP_PROTO(struct btrfs_fs_info *fs_info, u64 qgid,
1452 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001453
Jeff Mahoneybc074522016-06-09 17:27:55 -04001454 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001455
Jeff Mahoneybc074522016-06-09 17:27:55 -04001456 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001457 __field( u64, qgid )
1458 __field( u64, cur_old_count )
1459 __field( u64, cur_new_count )
1460 ),
1461
Jeff Mahoneybc074522016-06-09 17:27:55 -04001462 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001463 __entry->qgid = qgid;
1464 __entry->cur_old_count = cur_old_count;
1465 __entry->cur_new_count = cur_new_count;
1466 ),
1467
Jeff Mahoneybc074522016-06-09 17:27:55 -04001468 TP_printk_btrfs("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001469 __entry->qgid,
1470 __entry->cur_old_count,
1471 __entry->cur_new_count)
1472);
1473
liubo1abe9b82011-03-24 11:18:59 +00001474#endif /* _TRACE_BTRFS_H */
1475
1476/* This part must be outside protection */
1477#include <trace/define_trace.h>