blob: 77437f545c639cf4b1ec644df5b5d2d4f8a855e8 [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;
Liu Bo09ed2f12017-03-10 11:09:48 -080015struct btrfs_file_extent_item;
liubo1abe9b82011-03-24 11:18:59 +000016struct btrfs_ordered_extent;
17struct btrfs_delayed_ref_node;
18struct btrfs_delayed_tree_ref;
19struct btrfs_delayed_data_ref;
20struct btrfs_delayed_ref_head;
Josef Bacik3f7de032011-11-10 08:29:20 -050021struct btrfs_block_group_cache;
22struct btrfs_free_cluster;
liubo1abe9b82011-03-24 11:18:59 +000023struct map_lookup;
24struct extent_buffer;
Qu Wenruo52483bc2014-03-06 04:19:50 +000025struct btrfs_work;
Qu Wenruoc3a46892014-03-12 08:05:33 +000026struct __btrfs_workqueue;
Mark Fasheh0f5dcf82016-03-29 17:19:55 -070027struct btrfs_qgroup_extent_record;
Qu Wenruo3159fe72017-03-13 15:52:08 +080028struct btrfs_qgroup;
Jeff Mahoney00142752017-07-12 16:20:08 -060029struct prelim_ref;
liubo1abe9b82011-03-24 11:18:59 +000030
Anand Jain012e513e2017-08-30 22:36:48 +080031TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
32TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
33TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
34TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
35TRACE_DEFINE_ENUM(ALLOC_CHUNK);
36TRACE_DEFINE_ENUM(COMMIT_TRANS);
37
liubo1abe9b82011-03-24 11:18:59 +000038#define show_ref_type(type) \
39 __print_symbolic(type, \
40 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
41 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
42 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
43 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
44 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
45
46#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080047 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000048 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
49 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
50 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
51 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
52 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
53 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
54 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
55 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000056 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000057 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070058 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
59 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000060 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
61
62#define show_root_type(obj) \
63 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000064 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000065 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000066
Liu Bo09ed2f12017-03-10 11:09:48 -080067#define show_fi_type(type) \
68 __print_symbolic(type, \
69 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \
70 { BTRFS_FILE_EXTENT_REG, "REG" }, \
71 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"})
72
Josef Bacik3f7de032011-11-10 08:29:20 -050073#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000074 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
75 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
76 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
77 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
78 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
79 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
80 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
81 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
82 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050083
Anand Jainb94417e2017-08-13 11:58:30 +080084#define BTRFS_FSID_SIZE 16
85#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -040086
87#define TP_fast_assign_fsid(fs_info) \
Anand Jainb94417e2017-08-13 11:58:30 +080088 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -040089
90#define TP_STRUCT__entry_btrfs(args...) \
91 TP_STRUCT__entry( \
92 TP_STRUCT__entry_fsid \
93 args)
94#define TP_fast_assign_btrfs(fs_info, args...) \
95 TP_fast_assign( \
96 TP_fast_assign_fsid(fs_info); \
97 args)
98#define TP_printk_btrfs(fmt, args...) \
99 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500100
liubo1abe9b82011-03-24 11:18:59 +0000101TRACE_EVENT(btrfs_transaction_commit,
102
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600103 TP_PROTO(const struct btrfs_root *root),
liubo1abe9b82011-03-24 11:18:59 +0000104
105 TP_ARGS(root),
106
Jeff Mahoneybc074522016-06-09 17:27:55 -0400107 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000108 __field( u64, generation )
109 __field( u64, root_objectid )
110 ),
111
Jeff Mahoneybc074522016-06-09 17:27:55 -0400112 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000113 __entry->generation = root->fs_info->generation;
114 __entry->root_objectid = root->root_key.objectid;
115 ),
116
Jeff Mahoneybc074522016-06-09 17:27:55 -0400117 TP_printk_btrfs("root = %llu(%s), gen = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000118 show_root_type(__entry->root_objectid),
119 (unsigned long long)__entry->generation)
120);
121
122DECLARE_EVENT_CLASS(btrfs__inode,
123
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600124 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000125
126 TP_ARGS(inode),
127
Jeff Mahoneybc074522016-06-09 17:27:55 -0400128 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000129 __field( ino_t, ino )
130 __field( blkcnt_t, blocks )
131 __field( u64, disk_i_size )
132 __field( u64, generation )
133 __field( u64, last_trans )
134 __field( u64, logged_trans )
135 __field( u64, root_objectid )
136 ),
137
Jeff Mahoneybc074522016-06-09 17:27:55 -0400138 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000139 __entry->ino = inode->i_ino;
140 __entry->blocks = inode->i_blocks;
141 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
142 __entry->generation = BTRFS_I(inode)->generation;
143 __entry->last_trans = BTRFS_I(inode)->last_trans;
144 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
145 __entry->root_objectid =
146 BTRFS_I(inode)->root->root_key.objectid;
147 ),
148
David Sterba562a7a02017-01-06 15:51:36 +0100149 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
150 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000151 show_root_type(__entry->root_objectid),
152 (unsigned long long)__entry->generation,
153 (unsigned long)__entry->ino,
154 (unsigned long long)__entry->blocks,
155 (unsigned long long)__entry->disk_i_size,
156 (unsigned long long)__entry->last_trans,
157 (unsigned long long)__entry->logged_trans)
158);
159
160DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
161
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600162 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000163
164 TP_ARGS(inode)
165);
166
167DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
168
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600169 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000170
171 TP_ARGS(inode)
172);
173
174DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
175
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600176 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000177
178 TP_ARGS(inode)
179);
180
181#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800182 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000183 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
184 { EXTENT_MAP_HOLE, "HOLE" }, \
185 { EXTENT_MAP_INLINE, "INLINE" }, \
186 { EXTENT_MAP_DELALLOC, "DELALLOC" })
187
188#define show_map_type(type) \
189 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
190
191#define show_map_flags(flag) \
192 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800193 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
194 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
195 { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
196 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
197 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
198 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
199 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000200
Steven Rostedt4cd85872013-11-14 22:57:29 -0500201TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000202
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600203 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
204 const struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000205
Liu Bo92a1bf72016-11-17 15:00:50 -0800206 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000207
Steven Rostedt4cd85872013-11-14 22:57:29 -0500208 TP_CONDITION(map),
209
Jeff Mahoneybc074522016-06-09 17:27:55 -0400210 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000211 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800212 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000213 __field( u64, start )
214 __field( u64, len )
215 __field( u64, orig_start )
216 __field( u64, block_start )
217 __field( u64, block_len )
218 __field( unsigned long, flags )
219 __field( int, refs )
220 __field( unsigned int, compress_type )
221 ),
222
Jeff Mahoneybc074522016-06-09 17:27:55 -0400223 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000224 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800225 __entry->ino = btrfs_ino(inode);
226 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000227 __entry->len = map->len;
228 __entry->orig_start = map->orig_start;
229 __entry->block_start = map->block_start;
230 __entry->block_len = map->block_len;
231 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200232 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000233 __entry->compress_type = map->compress_type;
234 ),
235
David Sterba562a7a02017-01-06 15:51:36 +0100236 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
237 "orig_start=%llu block_start=%llu(%s) "
238 "block_len=%llu flags=%s refs=%u "
239 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000240 show_root_type(__entry->root_objectid),
Liu Bo92a1bf72016-11-17 15:00:50 -0800241 (unsigned long long)__entry->ino,
liubo1abe9b82011-03-24 11:18:59 +0000242 (unsigned long long)__entry->start,
243 (unsigned long long)__entry->len,
244 (unsigned long long)__entry->orig_start,
245 show_map_type(__entry->block_start),
246 (unsigned long long)__entry->block_len,
247 show_map_flags(__entry->flags),
248 __entry->refs, __entry->compress_type)
249);
250
Liu Bo09ed2f12017-03-10 11:09:48 -0800251/* file extent item */
252DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
253
254 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
255 struct btrfs_file_extent_item *fi, u64 start),
256
257 TP_ARGS(bi, l, fi, start),
258
259 TP_STRUCT__entry_btrfs(
260 __field( u64, root_obj )
261 __field( u64, ino )
262 __field( loff_t, isize )
263 __field( u64, disk_isize )
264 __field( u64, num_bytes )
265 __field( u64, ram_bytes )
266 __field( u64, disk_bytenr )
267 __field( u64, disk_num_bytes )
268 __field( u64, extent_offset )
269 __field( u8, extent_type )
270 __field( u8, compression )
271 __field( u64, extent_start )
272 __field( u64, extent_end )
273 ),
274
275 TP_fast_assign_btrfs(bi->root->fs_info,
276 __entry->root_obj = bi->root->objectid;
277 __entry->ino = btrfs_ino(bi);
278 __entry->isize = bi->vfs_inode.i_size;
279 __entry->disk_isize = bi->disk_i_size;
280 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
281 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
282 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
283 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
284 __entry->extent_offset = btrfs_file_extent_offset(l, fi);
285 __entry->extent_type = btrfs_file_extent_type(l, fi);
286 __entry->compression = btrfs_file_extent_compression(l, fi);
287 __entry->extent_start = start;
288 __entry->extent_end = (start + __entry->num_bytes);
289 ),
290
291 TP_printk_btrfs(
292 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
293 "file extent range=[%llu %llu] "
294 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
295 "disk_num_bytes=%llu extent_offset=%llu type=%s "
296 "compression=%u",
297 show_root_type(__entry->root_obj), __entry->ino,
298 __entry->isize,
299 __entry->disk_isize, __entry->extent_start,
300 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
301 __entry->disk_bytenr, __entry->disk_num_bytes,
302 __entry->extent_offset, show_fi_type(__entry->extent_type),
303 __entry->compression)
304);
305
306DECLARE_EVENT_CLASS(
307 btrfs__file_extent_item_inline,
308
309 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
310 struct btrfs_file_extent_item *fi, int slot, u64 start),
311
312 TP_ARGS(bi, l, fi, slot, start),
313
314 TP_STRUCT__entry_btrfs(
315 __field( u64, root_obj )
316 __field( u64, ino )
317 __field( loff_t, isize )
318 __field( u64, disk_isize )
319 __field( u8, extent_type )
320 __field( u8, compression )
321 __field( u64, extent_start )
322 __field( u64, extent_end )
323 ),
324
325 TP_fast_assign_btrfs(
326 bi->root->fs_info,
327 __entry->root_obj = bi->root->objectid;
328 __entry->ino = btrfs_ino(bi);
329 __entry->isize = bi->vfs_inode.i_size;
330 __entry->disk_isize = bi->disk_i_size;
331 __entry->extent_type = btrfs_file_extent_type(l, fi);
332 __entry->compression = btrfs_file_extent_compression(l, fi);
333 __entry->extent_start = start;
334 __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi));
335 ),
336
337 TP_printk_btrfs(
338 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
339 "file extent range=[%llu %llu] "
340 "extent_type=%s compression=%u",
341 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
342 __entry->disk_isize, __entry->extent_start,
343 __entry->extent_end, show_fi_type(__entry->extent_type),
344 __entry->compression)
345);
346
347DEFINE_EVENT(
348 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
349
350 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
351 struct btrfs_file_extent_item *fi, u64 start),
352
353 TP_ARGS(bi, l, fi, start)
354);
355
356DEFINE_EVENT(
357 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
358
359 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
360 struct btrfs_file_extent_item *fi, u64 start),
361
362 TP_ARGS(bi, l, fi, start)
363);
364
365DEFINE_EVENT(
366 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
367
368 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
369 struct btrfs_file_extent_item *fi, int slot, u64 start),
370
371 TP_ARGS(bi, l, fi, slot, start)
372);
373
374DEFINE_EVENT(
375 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
376
377 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
378 struct btrfs_file_extent_item *fi, int slot, u64 start),
379
380 TP_ARGS(bi, l, fi, slot, start)
381);
382
Liu Bo9d04a8c2013-11-06 12:04:13 +0800383#define show_ordered_flags(flags) \
384 __print_flags(flags, "|", \
385 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
386 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
387 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
388 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
389 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
390 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
391 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
392 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800393 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
394 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000395
liubo1abe9b82011-03-24 11:18:59 +0000396
397DECLARE_EVENT_CLASS(btrfs__ordered_extent,
398
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600399 TP_PROTO(const struct inode *inode,
400 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000401
402 TP_ARGS(inode, ordered),
403
Jeff Mahoneybc074522016-06-09 17:27:55 -0400404 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000405 __field( ino_t, ino )
406 __field( u64, file_offset )
407 __field( u64, start )
408 __field( u64, len )
409 __field( u64, disk_len )
410 __field( u64, bytes_left )
411 __field( unsigned long, flags )
412 __field( int, compress_type )
413 __field( int, refs )
414 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800415 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000416 ),
417
Jeff Mahoneybc074522016-06-09 17:27:55 -0400418 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000419 __entry->ino = inode->i_ino;
420 __entry->file_offset = ordered->file_offset;
421 __entry->start = ordered->start;
422 __entry->len = ordered->len;
423 __entry->disk_len = ordered->disk_len;
424 __entry->bytes_left = ordered->bytes_left;
425 __entry->flags = ordered->flags;
426 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200427 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000428 __entry->root_objectid =
429 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800430 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000431 ),
432
David Sterba562a7a02017-01-06 15:51:36 +0100433 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
434 "start=%llu len=%llu disk_len=%llu "
435 "truncated_len=%llu "
436 "bytes_left=%llu flags=%s compress_type=%d "
437 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000438 show_root_type(__entry->root_objectid),
439 (unsigned long long)__entry->ino,
440 (unsigned long long)__entry->file_offset,
441 (unsigned long long)__entry->start,
442 (unsigned long long)__entry->len,
443 (unsigned long long)__entry->disk_len,
Liu Bo78566542016-11-30 16:10:10 -0800444 (unsigned long long)__entry->truncated_len,
liubo1abe9b82011-03-24 11:18:59 +0000445 (unsigned long long)__entry->bytes_left,
446 show_ordered_flags(__entry->flags),
447 __entry->compress_type, __entry->refs)
448);
449
450DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
451
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600452 TP_PROTO(const struct inode *inode,
453 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000454
455 TP_ARGS(inode, ordered)
456);
457
458DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
459
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600460 TP_PROTO(const struct inode *inode,
461 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000462
463 TP_ARGS(inode, ordered)
464);
465
466DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
467
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600468 TP_PROTO(const struct inode *inode,
469 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000470
471 TP_ARGS(inode, ordered)
472);
473
474DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
475
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600476 TP_PROTO(const struct inode *inode,
477 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000478
479 TP_ARGS(inode, ordered)
480);
481
482DECLARE_EVENT_CLASS(btrfs__writepage,
483
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600484 TP_PROTO(const struct page *page, const struct inode *inode,
485 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000486
487 TP_ARGS(page, inode, wbc),
488
Jeff Mahoneybc074522016-06-09 17:27:55 -0400489 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000490 __field( ino_t, ino )
491 __field( pgoff_t, index )
492 __field( long, nr_to_write )
493 __field( long, pages_skipped )
494 __field( loff_t, range_start )
495 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000496 __field( char, for_kupdate )
497 __field( char, for_reclaim )
498 __field( char, range_cyclic )
499 __field( pgoff_t, writeback_index )
500 __field( u64, root_objectid )
501 ),
502
Jeff Mahoneybc074522016-06-09 17:27:55 -0400503 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000504 __entry->ino = inode->i_ino;
505 __entry->index = page->index;
506 __entry->nr_to_write = wbc->nr_to_write;
507 __entry->pages_skipped = wbc->pages_skipped;
508 __entry->range_start = wbc->range_start;
509 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000510 __entry->for_kupdate = wbc->for_kupdate;
511 __entry->for_reclaim = wbc->for_reclaim;
512 __entry->range_cyclic = wbc->range_cyclic;
513 __entry->writeback_index = inode->i_mapping->writeback_index;
514 __entry->root_objectid =
515 BTRFS_I(inode)->root->root_key.objectid;
516 ),
517
David Sterba562a7a02017-01-06 15:51:36 +0100518 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
519 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
520 "range_end=%llu for_kupdate=%d "
521 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000522 show_root_type(__entry->root_objectid),
523 (unsigned long)__entry->ino, __entry->index,
524 __entry->nr_to_write, __entry->pages_skipped,
525 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600526 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000527 __entry->for_reclaim, __entry->range_cyclic,
528 (unsigned long)__entry->writeback_index)
529);
530
531DEFINE_EVENT(btrfs__writepage, __extent_writepage,
532
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600533 TP_PROTO(const struct page *page, const struct inode *inode,
534 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000535
536 TP_ARGS(page, inode, wbc)
537);
538
539TRACE_EVENT(btrfs_writepage_end_io_hook,
540
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600541 TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
liubo1abe9b82011-03-24 11:18:59 +0000542
543 TP_ARGS(page, start, end, uptodate),
544
Jeff Mahoneybc074522016-06-09 17:27:55 -0400545 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000546 __field( ino_t, ino )
547 __field( pgoff_t, index )
548 __field( u64, start )
549 __field( u64, end )
550 __field( int, uptodate )
551 __field( u64, root_objectid )
552 ),
553
Jeff Mahoneybc074522016-06-09 17:27:55 -0400554 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000555 __entry->ino = page->mapping->host->i_ino;
556 __entry->index = page->index;
557 __entry->start = start;
558 __entry->end = end;
559 __entry->uptodate = uptodate;
560 __entry->root_objectid =
561 BTRFS_I(page->mapping->host)->root->root_key.objectid;
562 ),
563
David Sterba562a7a02017-01-06 15:51:36 +0100564 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
565 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000566 show_root_type(__entry->root_objectid),
567 (unsigned long)__entry->ino, (unsigned long)__entry->index,
568 (unsigned long long)__entry->start,
569 (unsigned long long)__entry->end, __entry->uptodate)
570);
571
572TRACE_EVENT(btrfs_sync_file,
573
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600574 TP_PROTO(const struct file *file, int datasync),
liubo1abe9b82011-03-24 11:18:59 +0000575
576 TP_ARGS(file, datasync),
577
Jeff Mahoneybc074522016-06-09 17:27:55 -0400578 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000579 __field( ino_t, ino )
580 __field( ino_t, parent )
581 __field( int, datasync )
582 __field( u64, root_objectid )
583 ),
584
585 TP_fast_assign(
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600586 const struct dentry *dentry = file->f_path.dentry;
587 const struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000588
Jeff Mahoneybc074522016-06-09 17:27:55 -0400589 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
liubo1abe9b82011-03-24 11:18:59 +0000590 __entry->ino = inode->i_ino;
David Howells2b0143b2015-03-17 22:25:59 +0000591 __entry->parent = d_inode(dentry->d_parent)->i_ino;
liubo1abe9b82011-03-24 11:18:59 +0000592 __entry->datasync = datasync;
593 __entry->root_objectid =
594 BTRFS_I(inode)->root->root_key.objectid;
595 ),
596
David Sterba562a7a02017-01-06 15:51:36 +0100597 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000598 show_root_type(__entry->root_objectid),
599 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
600 __entry->datasync)
601);
602
603TRACE_EVENT(btrfs_sync_fs,
604
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600605 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000606
Jeff Mahoneybc074522016-06-09 17:27:55 -0400607 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000608
Jeff Mahoneybc074522016-06-09 17:27:55 -0400609 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000610 __field( int, wait )
611 ),
612
Jeff Mahoneybc074522016-06-09 17:27:55 -0400613 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000614 __entry->wait = wait;
615 ),
616
Jeff Mahoneybc074522016-06-09 17:27:55 -0400617 TP_printk_btrfs("wait = %d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000618);
619
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400620TRACE_EVENT(btrfs_add_block_group,
621
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600622 TP_PROTO(const struct btrfs_fs_info *fs_info,
623 const struct btrfs_block_group_cache *block_group, int create),
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400624
625 TP_ARGS(fs_info, block_group, create),
626
627 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +0800628 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400629 __field( u64, offset )
630 __field( u64, size )
631 __field( u64, flags )
632 __field( u64, bytes_used )
633 __field( u64, bytes_super )
634 __field( int, create )
635 ),
636
637 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +0800638 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400639 __entry->offset = block_group->key.objectid;
640 __entry->size = block_group->key.offset;
641 __entry->flags = block_group->flags;
642 __entry->bytes_used =
643 btrfs_block_group_used(&block_group->item);
644 __entry->bytes_super = block_group->bytes_super;
645 __entry->create = create;
646 ),
647
David Sterba562a7a02017-01-06 15:51:36 +0100648 TP_printk("%pU: block_group offset=%llu size=%llu "
649 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
650 "create=%d", __entry->fsid,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400651 (unsigned long long)__entry->offset,
652 (unsigned long long)__entry->size,
653 (unsigned long long)__entry->flags,
654 __print_flags((unsigned long)__entry->flags, "|",
655 BTRFS_GROUP_FLAGS),
656 (unsigned long long)__entry->bytes_used,
657 (unsigned long long)__entry->bytes_super, __entry->create)
658);
659
liubo1abe9b82011-03-24 11:18:59 +0000660#define show_ref_action(action) \
661 __print_symbolic(action, \
662 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
663 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
664 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
665 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
666
667
Liu Bo599c75e2013-07-16 19:03:36 +0800668DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000669
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600670 TP_PROTO(const struct btrfs_fs_info *fs_info,
671 const struct btrfs_delayed_ref_node *ref,
672 const struct btrfs_delayed_tree_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000673 int action),
674
Jeff Mahoneybc074522016-06-09 17:27:55 -0400675 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000676
Jeff Mahoneybc074522016-06-09 17:27:55 -0400677 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000678 __field( u64, bytenr )
679 __field( u64, num_bytes )
680 __field( int, action )
681 __field( u64, parent )
682 __field( u64, ref_root )
683 __field( int, level )
684 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600685 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000686 ),
687
Jeff Mahoneybc074522016-06-09 17:27:55 -0400688 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000689 __entry->bytenr = ref->bytenr;
690 __entry->num_bytes = ref->num_bytes;
691 __entry->action = action;
692 __entry->parent = full_ref->parent;
693 __entry->ref_root = full_ref->root;
694 __entry->level = full_ref->level;
695 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600696 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000697 ),
698
David Sterba562a7a02017-01-06 15:51:36 +0100699 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
700 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
701 "type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000702 (unsigned long long)__entry->bytenr,
703 (unsigned long long)__entry->num_bytes,
704 show_ref_action(__entry->action),
705 show_root_type(__entry->parent),
706 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600707 __entry->level, show_ref_type(__entry->type),
708 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000709);
710
Liu Bo599c75e2013-07-16 19:03:36 +0800711DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
712
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600713 TP_PROTO(const struct btrfs_fs_info *fs_info,
714 const struct btrfs_delayed_ref_node *ref,
715 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800716 int action),
717
Jeff Mahoneybc074522016-06-09 17:27:55 -0400718 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800719);
720
721DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
722
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600723 TP_PROTO(const struct btrfs_fs_info *fs_info,
724 const struct btrfs_delayed_ref_node *ref,
725 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800726 int action),
727
Jeff Mahoneybc074522016-06-09 17:27:55 -0400728 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800729);
730
731DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000732
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600733 TP_PROTO(const struct btrfs_fs_info *fs_info,
734 const struct btrfs_delayed_ref_node *ref,
735 const struct btrfs_delayed_data_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000736 int action),
737
Jeff Mahoneybc074522016-06-09 17:27:55 -0400738 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000739
Jeff Mahoneybc074522016-06-09 17:27:55 -0400740 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000741 __field( u64, bytenr )
742 __field( u64, num_bytes )
743 __field( int, action )
744 __field( u64, parent )
745 __field( u64, ref_root )
746 __field( u64, owner )
747 __field( u64, offset )
748 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600749 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000750 ),
751
Jeff Mahoneybc074522016-06-09 17:27:55 -0400752 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000753 __entry->bytenr = ref->bytenr;
754 __entry->num_bytes = ref->num_bytes;
755 __entry->action = action;
756 __entry->parent = full_ref->parent;
757 __entry->ref_root = full_ref->root;
758 __entry->owner = full_ref->objectid;
759 __entry->offset = full_ref->offset;
760 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600761 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000762 ),
763
David Sterba562a7a02017-01-06 15:51:36 +0100764 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
765 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
766 "offset=%llu type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000767 (unsigned long long)__entry->bytenr,
768 (unsigned long long)__entry->num_bytes,
769 show_ref_action(__entry->action),
770 show_root_type(__entry->parent),
771 show_root_type(__entry->ref_root),
772 (unsigned long long)__entry->owner,
773 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600774 show_ref_type(__entry->type),
775 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000776);
777
Liu Bo599c75e2013-07-16 19:03:36 +0800778DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
779
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600780 TP_PROTO(const struct btrfs_fs_info *fs_info,
781 const struct btrfs_delayed_ref_node *ref,
782 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800783 int action),
784
Jeff Mahoneybc074522016-06-09 17:27:55 -0400785 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800786);
787
788DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
789
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600790 TP_PROTO(const struct btrfs_fs_info *fs_info,
791 const struct btrfs_delayed_ref_node *ref,
792 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800793 int action),
794
Jeff Mahoneybc074522016-06-09 17:27:55 -0400795 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800796);
797
798DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000799
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600800 TP_PROTO(const struct btrfs_fs_info *fs_info,
801 const struct btrfs_delayed_ref_node *ref,
802 const struct btrfs_delayed_ref_head *head_ref,
liubo1abe9b82011-03-24 11:18:59 +0000803 int action),
804
Jeff Mahoneybc074522016-06-09 17:27:55 -0400805 TP_ARGS(fs_info, ref, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000806
Jeff Mahoneybc074522016-06-09 17:27:55 -0400807 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000808 __field( u64, bytenr )
809 __field( u64, num_bytes )
810 __field( int, action )
811 __field( int, is_data )
812 ),
813
Jeff Mahoneybc074522016-06-09 17:27:55 -0400814 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000815 __entry->bytenr = ref->bytenr;
816 __entry->num_bytes = ref->num_bytes;
817 __entry->action = action;
818 __entry->is_data = head_ref->is_data;
819 ),
820
David Sterba562a7a02017-01-06 15:51:36 +0100821 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
liubo1abe9b82011-03-24 11:18:59 +0000822 (unsigned long long)__entry->bytenr,
823 (unsigned long long)__entry->num_bytes,
824 show_ref_action(__entry->action),
825 __entry->is_data)
826);
827
Liu Bo599c75e2013-07-16 19:03:36 +0800828DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
829
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600830 TP_PROTO(const struct btrfs_fs_info *fs_info,
831 const struct btrfs_delayed_ref_node *ref,
832 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800833 int action),
834
Jeff Mahoneybc074522016-06-09 17:27:55 -0400835 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800836);
837
838DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
839
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600840 TP_PROTO(const struct btrfs_fs_info *fs_info,
841 const struct btrfs_delayed_ref_node *ref,
842 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800843 int action),
844
Jeff Mahoneybc074522016-06-09 17:27:55 -0400845 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800846);
847
liubo1abe9b82011-03-24 11:18:59 +0000848#define show_chunk_type(type) \
849 __print_flags(type, "|", \
850 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
851 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
852 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
853 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
854 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
855 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000856 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
857 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
858 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000859
860DECLARE_EVENT_CLASS(btrfs__chunk,
861
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600862 TP_PROTO(const struct btrfs_fs_info *fs_info,
863 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000864
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400865 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000866
Jeff Mahoneybc074522016-06-09 17:27:55 -0400867 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000868 __field( int, num_stripes )
869 __field( u64, type )
870 __field( int, sub_stripes )
871 __field( u64, offset )
872 __field( u64, size )
873 __field( u64, root_objectid )
874 ),
875
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400876 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000877 __entry->num_stripes = map->num_stripes;
878 __entry->type = map->type;
879 __entry->sub_stripes = map->sub_stripes;
880 __entry->offset = offset;
881 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400882 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000883 ),
884
David Sterba562a7a02017-01-06 15:51:36 +0100885 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
886 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000887 show_root_type(__entry->root_objectid),
888 (unsigned long long)__entry->offset,
889 (unsigned long long)__entry->size,
890 __entry->num_stripes, __entry->sub_stripes,
891 show_chunk_type(__entry->type))
892);
893
894DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
895
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600896 TP_PROTO(const struct btrfs_fs_info *fs_info,
897 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000898
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400899 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000900);
901
902DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
903
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600904 TP_PROTO(const struct btrfs_fs_info *fs_info,
905 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000906
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400907 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000908);
909
910TRACE_EVENT(btrfs_cow_block,
911
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600912 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
913 const struct extent_buffer *cow),
liubo1abe9b82011-03-24 11:18:59 +0000914
915 TP_ARGS(root, buf, cow),
916
Jeff Mahoneybc074522016-06-09 17:27:55 -0400917 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000918 __field( u64, root_objectid )
919 __field( u64, buf_start )
920 __field( int, refs )
921 __field( u64, cow_start )
922 __field( int, buf_level )
923 __field( int, cow_level )
924 ),
925
Jeff Mahoneybc074522016-06-09 17:27:55 -0400926 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000927 __entry->root_objectid = root->root_key.objectid;
928 __entry->buf_start = buf->start;
929 __entry->refs = atomic_read(&buf->refs);
930 __entry->cow_start = cow->start;
931 __entry->buf_level = btrfs_header_level(buf);
932 __entry->cow_level = btrfs_header_level(cow);
933 ),
934
David Sterba562a7a02017-01-06 15:51:36 +0100935 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
936 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000937 show_root_type(__entry->root_objectid),
938 __entry->refs,
939 (unsigned long long)__entry->buf_start,
940 __entry->buf_level,
941 (unsigned long long)__entry->cow_start,
942 __entry->cow_level)
943);
944
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500945TRACE_EVENT(btrfs_space_reservation,
946
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600947 TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500948 u64 bytes, int reserve),
949
950 TP_ARGS(fs_info, type, val, bytes, reserve),
951
Jeff Mahoneybc074522016-06-09 17:27:55 -0400952 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500953 __string( type, type )
954 __field( u64, val )
955 __field( u64, bytes )
956 __field( int, reserve )
957 ),
958
Jeff Mahoneybc074522016-06-09 17:27:55 -0400959 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500960 __assign_str(type, type);
961 __entry->val = val;
962 __entry->bytes = bytes;
963 __entry->reserve = reserve;
964 ),
965
Jeff Mahoneybc074522016-06-09 17:27:55 -0400966 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
967 __entry->reserve ? "reserve" : "release",
968 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500969);
970
Josef Bacikf376df22016-03-25 13:25:56 -0400971#define show_flush_action(action) \
972 __print_symbolic(action, \
973 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
974 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
975 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
976
977TRACE_EVENT(btrfs_trigger_flush,
978
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600979 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
Josef Bacikf376df22016-03-25 13:25:56 -0400980 int flush, char *reason),
981
982 TP_ARGS(fs_info, flags, bytes, flush, reason),
983
984 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +0800985 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikf376df22016-03-25 13:25:56 -0400986 __field( u64, flags )
987 __field( u64, bytes )
988 __field( int, flush )
989 __string( reason, reason )
990 ),
991
992 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +0800993 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikf376df22016-03-25 13:25:56 -0400994 __entry->flags = flags;
995 __entry->bytes = bytes;
996 __entry->flush = flush;
997 __assign_str(reason, reason)
998 ),
999
David Sterba562a7a02017-01-06 15:51:36 +01001000 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
Josef Bacikf376df22016-03-25 13:25:56 -04001001 __entry->fsid, __get_str(reason), __entry->flush,
1002 show_flush_action(__entry->flush),
1003 (unsigned long long)__entry->flags,
1004 __print_flags((unsigned long)__entry->flags, "|",
1005 BTRFS_GROUP_FLAGS),
1006 (unsigned long long)__entry->bytes)
1007);
1008
1009#define show_flush_state(state) \
1010 __print_symbolic(state, \
1011 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
1012 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
1013 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1014 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
1015 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
1016 { COMMIT_TRANS, "COMMIT_TRANS"})
1017
1018TRACE_EVENT(btrfs_flush_space,
1019
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001020 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001021 int state, int ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001022
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001023 TP_ARGS(fs_info, flags, num_bytes, state, ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001024
1025 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +08001026 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikf376df22016-03-25 13:25:56 -04001027 __field( u64, flags )
1028 __field( u64, num_bytes )
Josef Bacikf376df22016-03-25 13:25:56 -04001029 __field( int, state )
1030 __field( int, ret )
1031 ),
1032
1033 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +08001034 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikf376df22016-03-25 13:25:56 -04001035 __entry->flags = flags;
1036 __entry->num_bytes = num_bytes;
Josef Bacikf376df22016-03-25 13:25:56 -04001037 __entry->state = state;
1038 __entry->ret = ret;
1039 ),
1040
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001041 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
1042 __entry->fsid, __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001043 show_flush_state(__entry->state),
1044 (unsigned long long)__entry->flags,
1045 __print_flags((unsigned long)__entry->flags, "|",
1046 BTRFS_GROUP_FLAGS),
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001047 (unsigned long long)__entry->num_bytes, __entry->ret)
Josef Bacikf376df22016-03-25 13:25:56 -04001048);
1049
liubo1abe9b82011-03-24 11:18:59 +00001050DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1051
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001052 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001053
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001054 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001055
Jeff Mahoneybc074522016-06-09 17:27:55 -04001056 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001057 __field( u64, start )
1058 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001059 ),
1060
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001061 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001062 __entry->start = start;
1063 __entry->len = len;
1064 ),
1065
David Sterba562a7a02017-01-06 15:51:36 +01001066 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001067 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
liubo1abe9b82011-03-24 11:18:59 +00001068 (unsigned long long)__entry->start,
1069 (unsigned long long)__entry->len)
1070);
1071
1072DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1073
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001074 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001075
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001076 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001077);
1078
1079DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1080
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001081 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001082
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001083 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001084);
1085
Josef Bacik3f7de032011-11-10 08:29:20 -05001086TRACE_EVENT(find_free_extent,
1087
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001088 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1089 u64 empty_size, u64 data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001090
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001091 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001092
Jeff Mahoneybc074522016-06-09 17:27:55 -04001093 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001094 __field( u64, num_bytes )
1095 __field( u64, empty_size )
1096 __field( u64, data )
1097 ),
1098
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001099 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001100 __entry->num_bytes = num_bytes;
1101 __entry->empty_size = empty_size;
1102 __entry->data = data;
1103 ),
1104
David Sterba562a7a02017-01-06 15:51:36 +01001105 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001106 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001107 __entry->num_bytes, __entry->empty_size, __entry->data,
1108 __print_flags((unsigned long)__entry->data, "|",
1109 BTRFS_GROUP_FLAGS))
1110);
1111
1112DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1113
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001114 TP_PROTO(const struct btrfs_fs_info *fs_info,
1115 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001116 u64 len),
1117
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001118 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001119
Jeff Mahoneybc074522016-06-09 17:27:55 -04001120 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001121 __field( u64, bg_objectid )
1122 __field( u64, flags )
1123 __field( u64, start )
1124 __field( u64, len )
1125 ),
1126
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001127 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001128 __entry->bg_objectid = block_group->key.objectid;
1129 __entry->flags = block_group->flags;
1130 __entry->start = start;
1131 __entry->len = len;
1132 ),
1133
David Sterba562a7a02017-01-06 15:51:36 +01001134 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
1135 "start=%Lu len=%Lu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001136 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1137 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001138 __entry->flags, __print_flags((unsigned long)__entry->flags,
1139 "|", BTRFS_GROUP_FLAGS),
1140 __entry->start, __entry->len)
1141);
1142
1143DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1144
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001145 TP_PROTO(const struct btrfs_fs_info *fs_info,
1146 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001147 u64 len),
1148
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001149 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001150);
1151
1152DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1153
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001154 TP_PROTO(const struct btrfs_fs_info *fs_info,
1155 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001156 u64 len),
1157
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001158 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001159);
1160
1161TRACE_EVENT(btrfs_find_cluster,
1162
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001163 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001164 u64 bytes, u64 empty_size, u64 min_bytes),
1165
1166 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1167
Jeff Mahoneybc074522016-06-09 17:27:55 -04001168 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001169 __field( u64, bg_objectid )
1170 __field( u64, flags )
1171 __field( u64, start )
1172 __field( u64, bytes )
1173 __field( u64, empty_size )
1174 __field( u64, min_bytes )
1175 ),
1176
Jeff Mahoneybc074522016-06-09 17:27:55 -04001177 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001178 __entry->bg_objectid = block_group->key.objectid;
1179 __entry->flags = block_group->flags;
1180 __entry->start = start;
1181 __entry->bytes = bytes;
1182 __entry->empty_size = empty_size;
1183 __entry->min_bytes = min_bytes;
1184 ),
1185
David Sterba562a7a02017-01-06 15:51:36 +01001186 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1187 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001188 __entry->flags,
1189 __print_flags((unsigned long)__entry->flags, "|",
1190 BTRFS_GROUP_FLAGS), __entry->start,
1191 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1192);
1193
1194TRACE_EVENT(btrfs_failed_cluster_setup,
1195
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001196 TP_PROTO(const struct btrfs_block_group_cache *block_group),
Josef Bacik3f7de032011-11-10 08:29:20 -05001197
1198 TP_ARGS(block_group),
1199
Jeff Mahoneybc074522016-06-09 17:27:55 -04001200 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001201 __field( u64, bg_objectid )
1202 ),
1203
Jeff Mahoneybc074522016-06-09 17:27:55 -04001204 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001205 __entry->bg_objectid = block_group->key.objectid;
1206 ),
1207
David Sterba562a7a02017-01-06 15:51:36 +01001208 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001209);
1210
1211TRACE_EVENT(btrfs_setup_cluster,
1212
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001213 TP_PROTO(const struct btrfs_block_group_cache *block_group,
1214 const struct btrfs_free_cluster *cluster,
1215 u64 size, int bitmap),
Josef Bacik3f7de032011-11-10 08:29:20 -05001216
1217 TP_ARGS(block_group, cluster, size, bitmap),
1218
Jeff Mahoneybc074522016-06-09 17:27:55 -04001219 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001220 __field( u64, bg_objectid )
1221 __field( u64, flags )
1222 __field( u64, start )
1223 __field( u64, max_size )
1224 __field( u64, size )
1225 __field( int, bitmap )
1226 ),
1227
Jeff Mahoneybc074522016-06-09 17:27:55 -04001228 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001229 __entry->bg_objectid = block_group->key.objectid;
1230 __entry->flags = block_group->flags;
1231 __entry->start = cluster->window_start;
1232 __entry->max_size = cluster->max_size;
1233 __entry->size = size;
1234 __entry->bitmap = bitmap;
1235 ),
1236
David Sterba562a7a02017-01-06 15:51:36 +01001237 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1238 "size=%Lu max_size=%Lu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001239 __entry->bg_objectid,
1240 __entry->flags,
1241 __print_flags((unsigned long)__entry->flags, "|",
1242 BTRFS_GROUP_FLAGS), __entry->start,
1243 __entry->size, __entry->max_size, __entry->bitmap)
1244);
1245
Jeff Mahoney143bede2012-03-01 14:56:26 +01001246struct extent_state;
1247TRACE_EVENT(alloc_extent_state,
1248
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001249 TP_PROTO(const struct extent_state *state,
1250 gfp_t mask, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001251
1252 TP_ARGS(state, mask, IP),
1253
1254 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001255 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001256 __field(gfp_t, mask)
1257 __field(unsigned long, ip)
1258 ),
1259
1260 TP_fast_assign(
1261 __entry->state = state,
1262 __entry->mask = mask,
1263 __entry->ip = IP
1264 ),
1265
David Sterba562a7a02017-01-06 15:51:36 +01001266 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001267 show_gfp_flags(__entry->mask), (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001268);
1269
1270TRACE_EVENT(free_extent_state,
1271
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001272 TP_PROTO(const struct extent_state *state, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001273
1274 TP_ARGS(state, IP),
1275
1276 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001277 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001278 __field(unsigned long, ip)
1279 ),
1280
1281 TP_fast_assign(
1282 __entry->state = state,
1283 __entry->ip = IP
1284 ),
1285
David Sterba562a7a02017-01-06 15:51:36 +01001286 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001287 (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001288);
1289
Qu Wenruo52483bc2014-03-06 04:19:50 +00001290DECLARE_EVENT_CLASS(btrfs__work,
1291
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001292 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001293
1294 TP_ARGS(work),
1295
Jeff Mahoneybc074522016-06-09 17:27:55 -04001296 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001297 __field( const void *, work )
1298 __field( const void *, wq )
1299 __field( const void *, func )
1300 __field( const void *, ordered_func )
1301 __field( const void *, ordered_free )
1302 __field( const void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001303 ),
1304
Jeff Mahoneybc074522016-06-09 17:27:55 -04001305 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001306 __entry->work = work;
1307 __entry->wq = work->wq;
1308 __entry->func = work->func;
1309 __entry->ordered_func = work->ordered_func;
1310 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001311 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001312 ),
1313
David Sterba562a7a02017-01-06 15:51:36 +01001314 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1315 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001316 __entry->work, __entry->normal_work, __entry->wq,
1317 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001318);
1319
David Sterbaac0c7cf2017-01-06 14:12:51 +01001320/*
1321 * For situiations when the work is freed, we pass fs_info and a tag that that
1322 * matches address of the work structure so it can be paired with the
1323 * scheduling event.
1324 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001325DECLARE_EVENT_CLASS(btrfs__work__done,
1326
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001327 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001328
David Sterbaac0c7cf2017-01-06 14:12:51 +01001329 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001330
Jeff Mahoneybc074522016-06-09 17:27:55 -04001331 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001332 __field( const void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001333 ),
1334
David Sterbaac0c7cf2017-01-06 14:12:51 +01001335 TP_fast_assign_btrfs(fs_info,
1336 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001337 ),
1338
David Sterbaac0c7cf2017-01-06 14:12:51 +01001339 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001340);
1341
1342DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1343
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001344 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001345
1346 TP_ARGS(work)
1347);
1348
1349DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1350
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001351 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001352
1353 TP_ARGS(work)
1354);
1355
Qu Wenruo52483bc2014-03-06 04:19:50 +00001356DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1357
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001358 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001359
David Sterbaac0c7cf2017-01-06 14:12:51 +01001360 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001361);
1362
1363DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1364
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001365 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001366
1367 TP_ARGS(work)
1368);
1369
Qu Wenruoc3a46892014-03-12 08:05:33 +00001370DECLARE_EVENT_CLASS(btrfs__workqueue,
1371
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001372 TP_PROTO(const struct __btrfs_workqueue *wq,
1373 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001374
1375 TP_ARGS(wq, name, high),
1376
Jeff Mahoneybc074522016-06-09 17:27:55 -04001377 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001378 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001379 __string( name, name )
1380 __field( int , high )
1381 ),
1382
Jeff Mahoneybc074522016-06-09 17:27:55 -04001383 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001384 __entry->wq = wq;
1385 __assign_str(name, name);
1386 __entry->high = high;
1387 ),
1388
David Sterba562a7a02017-01-06 15:51:36 +01001389 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001390 __print_flags(__entry->high, "",
1391 {(WQ_HIGHPRI), "-high"}),
1392 __entry->wq)
1393);
1394
1395DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1396
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001397 TP_PROTO(const struct __btrfs_workqueue *wq,
1398 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001399
1400 TP_ARGS(wq, name, high)
1401);
1402
1403DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1404
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001405 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001406
1407 TP_ARGS(wq),
1408
Jeff Mahoneybc074522016-06-09 17:27:55 -04001409 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001410 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001411 ),
1412
Jeff Mahoneybc074522016-06-09 17:27:55 -04001413 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001414 __entry->wq = wq;
1415 ),
1416
Jeff Mahoneybc074522016-06-09 17:27:55 -04001417 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001418);
1419
1420DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1421
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001422 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001423
1424 TP_ARGS(wq)
1425);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001426
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001427#define BTRFS_QGROUP_OPERATIONS \
1428 { QGROUP_RESERVE, "reserve" }, \
1429 { QGROUP_RELEASE, "release" }, \
1430 { QGROUP_FREE, "free" }
1431
1432DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1433
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001434 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1435 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001436
1437 TP_ARGS(inode, start, len, reserved, op),
1438
Jeff Mahoneybc074522016-06-09 17:27:55 -04001439 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001440 __field( u64, rootid )
1441 __field( unsigned long, ino )
1442 __field( u64, start )
1443 __field( u64, len )
1444 __field( u64, reserved )
1445 __field( int, op )
1446 ),
1447
Jeff Mahoneybc074522016-06-09 17:27:55 -04001448 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001449 __entry->rootid = BTRFS_I(inode)->root->objectid;
1450 __entry->ino = inode->i_ino;
1451 __entry->start = start;
1452 __entry->len = len;
1453 __entry->reserved = reserved;
1454 __entry->op = op;
1455 ),
1456
David Sterba562a7a02017-01-06 15:51:36 +01001457 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001458 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1459 __entry->reserved,
1460 __print_flags((unsigned long)__entry->op, "",
1461 BTRFS_QGROUP_OPERATIONS)
1462 )
1463);
1464
1465DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1466
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001467 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1468 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001469
1470 TP_ARGS(inode, start, len, reserved, op)
1471);
1472
1473DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1474
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001475 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1476 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001477
1478 TP_ARGS(inode, start, len, reserved, op)
1479);
1480
1481DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1482
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001483 TP_PROTO(const struct btrfs_fs_info *fs_info,
1484 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001485
Jeff Mahoneybc074522016-06-09 17:27:55 -04001486 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001487
Jeff Mahoneybc074522016-06-09 17:27:55 -04001488 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001489 __field( u64, ref_root )
1490 __field( u64, reserved )
1491 ),
1492
Jeff Mahoneybc074522016-06-09 17:27:55 -04001493 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001494 __entry->ref_root = ref_root;
1495 __entry->reserved = reserved;
1496 ),
1497
David Sterba562a7a02017-01-06 15:51:36 +01001498 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001499 __entry->ref_root, __entry->reserved)
1500);
1501
1502DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1503
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001504 TP_PROTO(const struct btrfs_fs_info *fs_info,
1505 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001506
Jeff Mahoneybc074522016-06-09 17:27:55 -04001507 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001508);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001509
1510DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001511 TP_PROTO(const struct btrfs_fs_info *fs_info,
1512 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001513
Jeff Mahoneybc074522016-06-09 17:27:55 -04001514 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001515
Jeff Mahoneybc074522016-06-09 17:27:55 -04001516 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001517 __field( u64, bytenr )
1518 __field( u64, num_bytes )
1519 ),
1520
Jeff Mahoneybc074522016-06-09 17:27:55 -04001521 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001522 __entry->bytenr = rec->bytenr,
1523 __entry->num_bytes = rec->num_bytes;
1524 ),
1525
David Sterba562a7a02017-01-06 15:51:36 +01001526 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001527 (unsigned long long)__entry->bytenr,
1528 (unsigned long long)__entry->num_bytes)
1529);
1530
1531DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1532
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001533 TP_PROTO(const struct btrfs_fs_info *fs_info,
1534 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001535
Jeff Mahoneybc074522016-06-09 17:27:55 -04001536 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001537);
1538
Qu Wenruo50b3e042016-10-18 09:31:27 +08001539DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001540
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001541 TP_PROTO(const struct btrfs_fs_info *fs_info,
1542 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001543
Jeff Mahoneybc074522016-06-09 17:27:55 -04001544 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001545);
1546
1547TRACE_EVENT(btrfs_qgroup_account_extent,
1548
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001549 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001550 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001551
Jeff Mahoneybc074522016-06-09 17:27:55 -04001552 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001553
Jeff Mahoneybc074522016-06-09 17:27:55 -04001554 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001555 __field( u64, bytenr )
1556 __field( u64, num_bytes )
1557 __field( u64, nr_old_roots )
1558 __field( u64, nr_new_roots )
1559 ),
1560
Jeff Mahoneybc074522016-06-09 17:27:55 -04001561 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001562 __entry->bytenr = bytenr;
1563 __entry->num_bytes = num_bytes;
1564 __entry->nr_old_roots = nr_old_roots;
1565 __entry->nr_new_roots = nr_new_roots;
1566 ),
1567
David Sterba562a7a02017-01-06 15:51:36 +01001568 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1569 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001570 __entry->bytenr,
1571 __entry->num_bytes,
1572 __entry->nr_old_roots,
1573 __entry->nr_new_roots)
1574);
1575
1576TRACE_EVENT(qgroup_update_counters,
1577
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001578 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001579 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001580
Jeff Mahoneybc074522016-06-09 17:27:55 -04001581 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001582
Jeff Mahoneybc074522016-06-09 17:27:55 -04001583 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001584 __field( u64, qgid )
1585 __field( u64, cur_old_count )
1586 __field( u64, cur_new_count )
1587 ),
1588
Jeff Mahoneybc074522016-06-09 17:27:55 -04001589 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001590 __entry->qgid = qgid;
1591 __entry->cur_old_count = cur_old_count;
1592 __entry->cur_new_count = cur_new_count;
1593 ),
1594
David Sterba562a7a02017-01-06 15:51:36 +01001595 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001596 __entry->qgid,
1597 __entry->cur_old_count,
1598 __entry->cur_new_count)
1599);
1600
Qu Wenruo3159fe72017-03-13 15:52:08 +08001601TRACE_EVENT(qgroup_update_reserve,
1602
1603 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
1604 s64 diff),
1605
1606 TP_ARGS(fs_info, qgroup, diff),
1607
1608 TP_STRUCT__entry_btrfs(
1609 __field( u64, qgid )
1610 __field( u64, cur_reserved )
1611 __field( s64, diff )
1612 ),
1613
1614 TP_fast_assign_btrfs(fs_info,
1615 __entry->qgid = qgroup->qgroupid;
1616 __entry->cur_reserved = qgroup->reserved;
1617 __entry->diff = diff;
1618 ),
1619
1620 TP_printk_btrfs("qgid=%llu cur_reserved=%llu diff=%lld",
1621 __entry->qgid, __entry->cur_reserved, __entry->diff)
1622);
1623
1624TRACE_EVENT(qgroup_meta_reserve,
1625
1626 TP_PROTO(struct btrfs_root *root, s64 diff),
1627
1628 TP_ARGS(root, diff),
1629
1630 TP_STRUCT__entry_btrfs(
1631 __field( u64, refroot )
1632 __field( s64, diff )
1633 ),
1634
1635 TP_fast_assign_btrfs(root->fs_info,
1636 __entry->refroot = root->objectid;
1637 __entry->diff = diff;
1638 ),
1639
1640 TP_printk_btrfs("refroot=%llu(%s) diff=%lld",
1641 show_root_type(__entry->refroot), __entry->diff)
1642);
1643
Jeff Mahoney00142752017-07-12 16:20:08 -06001644DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1645 TP_PROTO(const struct btrfs_fs_info *fs_info,
1646 const struct prelim_ref *oldref,
1647 const struct prelim_ref *newref, u64 tree_size),
1648 TP_ARGS(fs_info, newref, oldref, tree_size),
1649
1650 TP_STRUCT__entry_btrfs(
1651 __field( u64, root_id )
1652 __field( u64, objectid )
1653 __field( u8, type )
1654 __field( u64, offset )
1655 __field( int, level )
1656 __field( int, old_count )
1657 __field( u64, parent )
1658 __field( u64, bytenr )
1659 __field( int, mod_count )
1660 __field( u64, tree_size )
1661 ),
1662
1663 TP_fast_assign_btrfs(fs_info,
1664 __entry->root_id = oldref->root_id;
1665 __entry->objectid = oldref->key_for_search.objectid;
1666 __entry->type = oldref->key_for_search.type;
1667 __entry->offset = oldref->key_for_search.offset;
1668 __entry->level = oldref->level;
1669 __entry->old_count = oldref->count;
1670 __entry->parent = oldref->parent;
1671 __entry->bytenr = oldref->wanted_disk_byte;
1672 __entry->mod_count = newref ? newref->count : 0;
1673 __entry->tree_size = tree_size;
1674 ),
1675
1676 TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
1677 (unsigned long long)__entry->root_id,
1678 (unsigned long long)__entry->objectid, __entry->type,
1679 (unsigned long long)__entry->offset, __entry->level,
1680 __entry->old_count, __entry->mod_count,
1681 __entry->old_count + __entry->mod_count,
1682 (unsigned long long)__entry->parent,
1683 (unsigned long long)__entry->bytenr,
1684 (unsigned long long)__entry->tree_size)
1685);
1686
1687DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1688 TP_PROTO(const struct btrfs_fs_info *fs_info,
1689 const struct prelim_ref *oldref,
1690 const struct prelim_ref *newref, u64 tree_size),
1691 TP_ARGS(fs_info, oldref, newref, tree_size)
1692);
1693
1694DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1695 TP_PROTO(const struct btrfs_fs_info *fs_info,
1696 const struct prelim_ref *oldref,
1697 const struct prelim_ref *newref, u64 tree_size),
1698 TP_ARGS(fs_info, oldref, newref, tree_size)
1699);
1700
liubo1abe9b82011-03-24 11:18:59 +00001701#endif /* _TRACE_BTRFS_H */
1702
1703/* This part must be outside protection */
1704#include <trace/define_trace.h>