blob: 32d0c1fe2bfa7d177ba63a1ca1613cd4f2144c0d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
liubo1abe9b82011-03-24 11:18:59 +00002#undef TRACE_SYSTEM
3#define TRACE_SYSTEM btrfs
4
5#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_BTRFS_H
7
8#include <linux/writeback.h>
9#include <linux/tracepoint.h>
Vlastimil Babka420adbe92016-03-15 14:55:52 -070010#include <trace/events/mmflags.h>
liubo1abe9b82011-03-24 11:18:59 +000011
12struct btrfs_root;
13struct btrfs_fs_info;
14struct btrfs_inode;
15struct extent_map;
Liu Bo09ed2f12017-03-10 11:09:48 -080016struct btrfs_file_extent_item;
liubo1abe9b82011-03-24 11:18:59 +000017struct btrfs_ordered_extent;
18struct btrfs_delayed_ref_node;
19struct btrfs_delayed_tree_ref;
20struct btrfs_delayed_data_ref;
21struct btrfs_delayed_ref_head;
Josef Bacik3f7de032011-11-10 08:29:20 -050022struct btrfs_block_group_cache;
23struct btrfs_free_cluster;
liubo1abe9b82011-03-24 11:18:59 +000024struct map_lookup;
25struct extent_buffer;
Qu Wenruo52483bc2014-03-06 04:19:50 +000026struct btrfs_work;
Qu Wenruoc3a46892014-03-12 08:05:33 +000027struct __btrfs_workqueue;
Mark Fasheh0f5dcf82016-03-29 17:19:55 -070028struct btrfs_qgroup_extent_record;
Qu Wenruo3159fe72017-03-13 15:52:08 +080029struct btrfs_qgroup;
Jeff Mahoney00142752017-07-12 16:20:08 -060030struct prelim_ref;
liubo1abe9b82011-03-24 11:18:59 +000031
32#define show_ref_type(type) \
33 __print_symbolic(type, \
34 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
35 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
36 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
37 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
38 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
39
40#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080041 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000042 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
43 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
44 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
45 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
46 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
47 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
48 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
49 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000050 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000051 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070052 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
53 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000054 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
55
56#define show_root_type(obj) \
57 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000058 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000059 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000060
Liu Bo09ed2f12017-03-10 11:09:48 -080061#define show_fi_type(type) \
62 __print_symbolic(type, \
63 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \
64 { BTRFS_FILE_EXTENT_REG, "REG" }, \
65 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"})
66
Josef Bacik3f7de032011-11-10 08:29:20 -050067#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000068 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
69 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
70 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
71 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
72 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
73 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
74 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
75 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
76 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050077
Anand Jainb94417e2017-08-13 11:58:30 +080078#define BTRFS_FSID_SIZE 16
79#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -040080
81#define TP_fast_assign_fsid(fs_info) \
Anand Jainb94417e2017-08-13 11:58:30 +080082 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -040083
84#define TP_STRUCT__entry_btrfs(args...) \
85 TP_STRUCT__entry( \
86 TP_STRUCT__entry_fsid \
87 args)
88#define TP_fast_assign_btrfs(fs_info, args...) \
89 TP_fast_assign( \
90 TP_fast_assign_fsid(fs_info); \
91 args)
92#define TP_printk_btrfs(fmt, args...) \
93 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050094
liubo1abe9b82011-03-24 11:18:59 +000095TRACE_EVENT(btrfs_transaction_commit,
96
Jeff Mahoney9a35b632017-06-28 21:56:54 -060097 TP_PROTO(const struct btrfs_root *root),
liubo1abe9b82011-03-24 11:18:59 +000098
99 TP_ARGS(root),
100
Jeff Mahoneybc074522016-06-09 17:27:55 -0400101 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000102 __field( u64, generation )
103 __field( u64, root_objectid )
104 ),
105
Jeff Mahoneybc074522016-06-09 17:27:55 -0400106 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000107 __entry->generation = root->fs_info->generation;
108 __entry->root_objectid = root->root_key.objectid;
109 ),
110
Jeff Mahoneybc074522016-06-09 17:27:55 -0400111 TP_printk_btrfs("root = %llu(%s), gen = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000112 show_root_type(__entry->root_objectid),
113 (unsigned long long)__entry->generation)
114);
115
116DECLARE_EVENT_CLASS(btrfs__inode,
117
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600118 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000119
120 TP_ARGS(inode),
121
Jeff Mahoneybc074522016-06-09 17:27:55 -0400122 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000123 __field( ino_t, ino )
124 __field( blkcnt_t, blocks )
125 __field( u64, disk_i_size )
126 __field( u64, generation )
127 __field( u64, last_trans )
128 __field( u64, logged_trans )
129 __field( u64, root_objectid )
130 ),
131
Jeff Mahoneybc074522016-06-09 17:27:55 -0400132 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000133 __entry->ino = inode->i_ino;
134 __entry->blocks = inode->i_blocks;
135 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
136 __entry->generation = BTRFS_I(inode)->generation;
137 __entry->last_trans = BTRFS_I(inode)->last_trans;
138 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
139 __entry->root_objectid =
140 BTRFS_I(inode)->root->root_key.objectid;
141 ),
142
David Sterba562a7a02017-01-06 15:51:36 +0100143 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
144 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000145 show_root_type(__entry->root_objectid),
146 (unsigned long long)__entry->generation,
147 (unsigned long)__entry->ino,
148 (unsigned long long)__entry->blocks,
149 (unsigned long long)__entry->disk_i_size,
150 (unsigned long long)__entry->last_trans,
151 (unsigned long long)__entry->logged_trans)
152);
153
154DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
155
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600156 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000157
158 TP_ARGS(inode)
159);
160
161DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
162
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600163 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000164
165 TP_ARGS(inode)
166);
167
168DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
169
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600170 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000171
172 TP_ARGS(inode)
173);
174
175#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800176 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000177 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
178 { EXTENT_MAP_HOLE, "HOLE" }, \
179 { EXTENT_MAP_INLINE, "INLINE" }, \
180 { EXTENT_MAP_DELALLOC, "DELALLOC" })
181
182#define show_map_type(type) \
183 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
184
185#define show_map_flags(flag) \
186 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800187 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
188 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
189 { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
190 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
191 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
192 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
193 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000194
Steven Rostedt4cd85872013-11-14 22:57:29 -0500195TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000196
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600197 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
198 const struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000199
Liu Bo92a1bf72016-11-17 15:00:50 -0800200 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000201
Steven Rostedt4cd85872013-11-14 22:57:29 -0500202 TP_CONDITION(map),
203
Jeff Mahoneybc074522016-06-09 17:27:55 -0400204 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000205 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800206 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000207 __field( u64, start )
208 __field( u64, len )
209 __field( u64, orig_start )
210 __field( u64, block_start )
211 __field( u64, block_len )
212 __field( unsigned long, flags )
213 __field( int, refs )
214 __field( unsigned int, compress_type )
215 ),
216
Jeff Mahoneybc074522016-06-09 17:27:55 -0400217 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000218 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800219 __entry->ino = btrfs_ino(inode);
220 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000221 __entry->len = map->len;
222 __entry->orig_start = map->orig_start;
223 __entry->block_start = map->block_start;
224 __entry->block_len = map->block_len;
225 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200226 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000227 __entry->compress_type = map->compress_type;
228 ),
229
David Sterba562a7a02017-01-06 15:51:36 +0100230 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
231 "orig_start=%llu block_start=%llu(%s) "
232 "block_len=%llu flags=%s refs=%u "
233 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000234 show_root_type(__entry->root_objectid),
Liu Bo92a1bf72016-11-17 15:00:50 -0800235 (unsigned long long)__entry->ino,
liubo1abe9b82011-03-24 11:18:59 +0000236 (unsigned long long)__entry->start,
237 (unsigned long long)__entry->len,
238 (unsigned long long)__entry->orig_start,
239 show_map_type(__entry->block_start),
240 (unsigned long long)__entry->block_len,
241 show_map_flags(__entry->flags),
242 __entry->refs, __entry->compress_type)
243);
244
Liu Bo09ed2f12017-03-10 11:09:48 -0800245/* file extent item */
246DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
247
248 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
249 struct btrfs_file_extent_item *fi, u64 start),
250
251 TP_ARGS(bi, l, fi, start),
252
253 TP_STRUCT__entry_btrfs(
254 __field( u64, root_obj )
255 __field( u64, ino )
256 __field( loff_t, isize )
257 __field( u64, disk_isize )
258 __field( u64, num_bytes )
259 __field( u64, ram_bytes )
260 __field( u64, disk_bytenr )
261 __field( u64, disk_num_bytes )
262 __field( u64, extent_offset )
263 __field( u8, extent_type )
264 __field( u8, compression )
265 __field( u64, extent_start )
266 __field( u64, extent_end )
267 ),
268
269 TP_fast_assign_btrfs(bi->root->fs_info,
270 __entry->root_obj = bi->root->objectid;
271 __entry->ino = btrfs_ino(bi);
272 __entry->isize = bi->vfs_inode.i_size;
273 __entry->disk_isize = bi->disk_i_size;
274 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
275 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
276 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
277 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
278 __entry->extent_offset = btrfs_file_extent_offset(l, fi);
279 __entry->extent_type = btrfs_file_extent_type(l, fi);
280 __entry->compression = btrfs_file_extent_compression(l, fi);
281 __entry->extent_start = start;
282 __entry->extent_end = (start + __entry->num_bytes);
283 ),
284
285 TP_printk_btrfs(
286 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
287 "file extent range=[%llu %llu] "
288 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
289 "disk_num_bytes=%llu extent_offset=%llu type=%s "
290 "compression=%u",
291 show_root_type(__entry->root_obj), __entry->ino,
292 __entry->isize,
293 __entry->disk_isize, __entry->extent_start,
294 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
295 __entry->disk_bytenr, __entry->disk_num_bytes,
296 __entry->extent_offset, show_fi_type(__entry->extent_type),
297 __entry->compression)
298);
299
300DECLARE_EVENT_CLASS(
301 btrfs__file_extent_item_inline,
302
303 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
304 struct btrfs_file_extent_item *fi, int slot, u64 start),
305
306 TP_ARGS(bi, l, fi, slot, start),
307
308 TP_STRUCT__entry_btrfs(
309 __field( u64, root_obj )
310 __field( u64, ino )
311 __field( loff_t, isize )
312 __field( u64, disk_isize )
313 __field( u8, extent_type )
314 __field( u8, compression )
315 __field( u64, extent_start )
316 __field( u64, extent_end )
317 ),
318
319 TP_fast_assign_btrfs(
320 bi->root->fs_info,
321 __entry->root_obj = bi->root->objectid;
322 __entry->ino = btrfs_ino(bi);
323 __entry->isize = bi->vfs_inode.i_size;
324 __entry->disk_isize = bi->disk_i_size;
325 __entry->extent_type = btrfs_file_extent_type(l, fi);
326 __entry->compression = btrfs_file_extent_compression(l, fi);
327 __entry->extent_start = start;
328 __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi));
329 ),
330
331 TP_printk_btrfs(
332 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
333 "file extent range=[%llu %llu] "
334 "extent_type=%s compression=%u",
335 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
336 __entry->disk_isize, __entry->extent_start,
337 __entry->extent_end, show_fi_type(__entry->extent_type),
338 __entry->compression)
339);
340
341DEFINE_EVENT(
342 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
343
344 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
345 struct btrfs_file_extent_item *fi, u64 start),
346
347 TP_ARGS(bi, l, fi, start)
348);
349
350DEFINE_EVENT(
351 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
352
353 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
354 struct btrfs_file_extent_item *fi, u64 start),
355
356 TP_ARGS(bi, l, fi, start)
357);
358
359DEFINE_EVENT(
360 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
361
362 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
363 struct btrfs_file_extent_item *fi, int slot, u64 start),
364
365 TP_ARGS(bi, l, fi, slot, start)
366);
367
368DEFINE_EVENT(
369 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
370
371 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
372 struct btrfs_file_extent_item *fi, int slot, u64 start),
373
374 TP_ARGS(bi, l, fi, slot, start)
375);
376
Liu Bo9d04a8c2013-11-06 12:04:13 +0800377#define show_ordered_flags(flags) \
378 __print_flags(flags, "|", \
379 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
380 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
381 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
382 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
383 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
384 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
385 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
386 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800387 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
388 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000389
liubo1abe9b82011-03-24 11:18:59 +0000390
391DECLARE_EVENT_CLASS(btrfs__ordered_extent,
392
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600393 TP_PROTO(const struct inode *inode,
394 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000395
396 TP_ARGS(inode, ordered),
397
Jeff Mahoneybc074522016-06-09 17:27:55 -0400398 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000399 __field( ino_t, ino )
400 __field( u64, file_offset )
401 __field( u64, start )
402 __field( u64, len )
403 __field( u64, disk_len )
404 __field( u64, bytes_left )
405 __field( unsigned long, flags )
406 __field( int, compress_type )
407 __field( int, refs )
408 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800409 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000410 ),
411
Jeff Mahoneybc074522016-06-09 17:27:55 -0400412 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000413 __entry->ino = inode->i_ino;
414 __entry->file_offset = ordered->file_offset;
415 __entry->start = ordered->start;
416 __entry->len = ordered->len;
417 __entry->disk_len = ordered->disk_len;
418 __entry->bytes_left = ordered->bytes_left;
419 __entry->flags = ordered->flags;
420 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200421 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000422 __entry->root_objectid =
423 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800424 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000425 ),
426
David Sterba562a7a02017-01-06 15:51:36 +0100427 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
428 "start=%llu len=%llu disk_len=%llu "
429 "truncated_len=%llu "
430 "bytes_left=%llu flags=%s compress_type=%d "
431 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000432 show_root_type(__entry->root_objectid),
433 (unsigned long long)__entry->ino,
434 (unsigned long long)__entry->file_offset,
435 (unsigned long long)__entry->start,
436 (unsigned long long)__entry->len,
437 (unsigned long long)__entry->disk_len,
Liu Bo78566542016-11-30 16:10:10 -0800438 (unsigned long long)__entry->truncated_len,
liubo1abe9b82011-03-24 11:18:59 +0000439 (unsigned long long)__entry->bytes_left,
440 show_ordered_flags(__entry->flags),
441 __entry->compress_type, __entry->refs)
442);
443
444DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
445
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600446 TP_PROTO(const struct inode *inode,
447 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000448
449 TP_ARGS(inode, ordered)
450);
451
452DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
453
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600454 TP_PROTO(const struct inode *inode,
455 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000456
457 TP_ARGS(inode, ordered)
458);
459
460DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
461
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600462 TP_PROTO(const struct inode *inode,
463 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000464
465 TP_ARGS(inode, ordered)
466);
467
468DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
469
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600470 TP_PROTO(const struct inode *inode,
471 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000472
473 TP_ARGS(inode, ordered)
474);
475
476DECLARE_EVENT_CLASS(btrfs__writepage,
477
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600478 TP_PROTO(const struct page *page, const struct inode *inode,
479 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000480
481 TP_ARGS(page, inode, wbc),
482
Jeff Mahoneybc074522016-06-09 17:27:55 -0400483 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000484 __field( ino_t, ino )
485 __field( pgoff_t, index )
486 __field( long, nr_to_write )
487 __field( long, pages_skipped )
488 __field( loff_t, range_start )
489 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000490 __field( char, for_kupdate )
491 __field( char, for_reclaim )
492 __field( char, range_cyclic )
493 __field( pgoff_t, writeback_index )
494 __field( u64, root_objectid )
495 ),
496
Jeff Mahoneybc074522016-06-09 17:27:55 -0400497 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000498 __entry->ino = inode->i_ino;
499 __entry->index = page->index;
500 __entry->nr_to_write = wbc->nr_to_write;
501 __entry->pages_skipped = wbc->pages_skipped;
502 __entry->range_start = wbc->range_start;
503 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000504 __entry->for_kupdate = wbc->for_kupdate;
505 __entry->for_reclaim = wbc->for_reclaim;
506 __entry->range_cyclic = wbc->range_cyclic;
507 __entry->writeback_index = inode->i_mapping->writeback_index;
508 __entry->root_objectid =
509 BTRFS_I(inode)->root->root_key.objectid;
510 ),
511
David Sterba562a7a02017-01-06 15:51:36 +0100512 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
513 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
514 "range_end=%llu for_kupdate=%d "
515 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000516 show_root_type(__entry->root_objectid),
517 (unsigned long)__entry->ino, __entry->index,
518 __entry->nr_to_write, __entry->pages_skipped,
519 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600520 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000521 __entry->for_reclaim, __entry->range_cyclic,
522 (unsigned long)__entry->writeback_index)
523);
524
525DEFINE_EVENT(btrfs__writepage, __extent_writepage,
526
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600527 TP_PROTO(const struct page *page, const struct inode *inode,
528 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000529
530 TP_ARGS(page, inode, wbc)
531);
532
533TRACE_EVENT(btrfs_writepage_end_io_hook,
534
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600535 TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
liubo1abe9b82011-03-24 11:18:59 +0000536
537 TP_ARGS(page, start, end, uptodate),
538
Jeff Mahoneybc074522016-06-09 17:27:55 -0400539 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000540 __field( ino_t, ino )
541 __field( pgoff_t, index )
542 __field( u64, start )
543 __field( u64, end )
544 __field( int, uptodate )
545 __field( u64, root_objectid )
546 ),
547
Jeff Mahoneybc074522016-06-09 17:27:55 -0400548 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000549 __entry->ino = page->mapping->host->i_ino;
550 __entry->index = page->index;
551 __entry->start = start;
552 __entry->end = end;
553 __entry->uptodate = uptodate;
554 __entry->root_objectid =
555 BTRFS_I(page->mapping->host)->root->root_key.objectid;
556 ),
557
David Sterba562a7a02017-01-06 15:51:36 +0100558 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
559 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000560 show_root_type(__entry->root_objectid),
561 (unsigned long)__entry->ino, (unsigned long)__entry->index,
562 (unsigned long long)__entry->start,
563 (unsigned long long)__entry->end, __entry->uptodate)
564);
565
566TRACE_EVENT(btrfs_sync_file,
567
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600568 TP_PROTO(const struct file *file, int datasync),
liubo1abe9b82011-03-24 11:18:59 +0000569
570 TP_ARGS(file, datasync),
571
Jeff Mahoneybc074522016-06-09 17:27:55 -0400572 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000573 __field( ino_t, ino )
574 __field( ino_t, parent )
575 __field( int, datasync )
576 __field( u64, root_objectid )
577 ),
578
579 TP_fast_assign(
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600580 const struct dentry *dentry = file->f_path.dentry;
581 const struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000582
Jeff Mahoneybc074522016-06-09 17:27:55 -0400583 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
liubo1abe9b82011-03-24 11:18:59 +0000584 __entry->ino = inode->i_ino;
David Howells2b0143b2015-03-17 22:25:59 +0000585 __entry->parent = d_inode(dentry->d_parent)->i_ino;
liubo1abe9b82011-03-24 11:18:59 +0000586 __entry->datasync = datasync;
587 __entry->root_objectid =
588 BTRFS_I(inode)->root->root_key.objectid;
589 ),
590
David Sterba562a7a02017-01-06 15:51:36 +0100591 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000592 show_root_type(__entry->root_objectid),
593 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
594 __entry->datasync)
595);
596
597TRACE_EVENT(btrfs_sync_fs,
598
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600599 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000600
Jeff Mahoneybc074522016-06-09 17:27:55 -0400601 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000602
Jeff Mahoneybc074522016-06-09 17:27:55 -0400603 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000604 __field( int, wait )
605 ),
606
Jeff Mahoneybc074522016-06-09 17:27:55 -0400607 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000608 __entry->wait = wait;
609 ),
610
Jeff Mahoneybc074522016-06-09 17:27:55 -0400611 TP_printk_btrfs("wait = %d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000612);
613
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400614TRACE_EVENT(btrfs_add_block_group,
615
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600616 TP_PROTO(const struct btrfs_fs_info *fs_info,
617 const struct btrfs_block_group_cache *block_group, int create),
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400618
619 TP_ARGS(fs_info, block_group, create),
620
621 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +0800622 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400623 __field( u64, offset )
624 __field( u64, size )
625 __field( u64, flags )
626 __field( u64, bytes_used )
627 __field( u64, bytes_super )
628 __field( int, create )
629 ),
630
631 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +0800632 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400633 __entry->offset = block_group->key.objectid;
634 __entry->size = block_group->key.offset;
635 __entry->flags = block_group->flags;
636 __entry->bytes_used =
637 btrfs_block_group_used(&block_group->item);
638 __entry->bytes_super = block_group->bytes_super;
639 __entry->create = create;
640 ),
641
David Sterba562a7a02017-01-06 15:51:36 +0100642 TP_printk("%pU: block_group offset=%llu size=%llu "
643 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
644 "create=%d", __entry->fsid,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400645 (unsigned long long)__entry->offset,
646 (unsigned long long)__entry->size,
647 (unsigned long long)__entry->flags,
648 __print_flags((unsigned long)__entry->flags, "|",
649 BTRFS_GROUP_FLAGS),
650 (unsigned long long)__entry->bytes_used,
651 (unsigned long long)__entry->bytes_super, __entry->create)
652);
653
liubo1abe9b82011-03-24 11:18:59 +0000654#define show_ref_action(action) \
655 __print_symbolic(action, \
656 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
657 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
658 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
659 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
660
661
Liu Bo599c75e2013-07-16 19:03:36 +0800662DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000663
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600664 TP_PROTO(const struct btrfs_fs_info *fs_info,
665 const struct btrfs_delayed_ref_node *ref,
666 const struct btrfs_delayed_tree_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000667 int action),
668
Jeff Mahoneybc074522016-06-09 17:27:55 -0400669 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000670
Jeff Mahoneybc074522016-06-09 17:27:55 -0400671 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000672 __field( u64, bytenr )
673 __field( u64, num_bytes )
674 __field( int, action )
675 __field( u64, parent )
676 __field( u64, ref_root )
677 __field( int, level )
678 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600679 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000680 ),
681
Jeff Mahoneybc074522016-06-09 17:27:55 -0400682 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000683 __entry->bytenr = ref->bytenr;
684 __entry->num_bytes = ref->num_bytes;
685 __entry->action = action;
686 __entry->parent = full_ref->parent;
687 __entry->ref_root = full_ref->root;
688 __entry->level = full_ref->level;
689 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600690 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000691 ),
692
David Sterba562a7a02017-01-06 15:51:36 +0100693 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
694 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
695 "type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000696 (unsigned long long)__entry->bytenr,
697 (unsigned long long)__entry->num_bytes,
698 show_ref_action(__entry->action),
699 show_root_type(__entry->parent),
700 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600701 __entry->level, show_ref_type(__entry->type),
702 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000703);
704
Liu Bo599c75e2013-07-16 19:03:36 +0800705DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
706
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600707 TP_PROTO(const struct btrfs_fs_info *fs_info,
708 const struct btrfs_delayed_ref_node *ref,
709 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800710 int action),
711
Jeff Mahoneybc074522016-06-09 17:27:55 -0400712 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800713);
714
715DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
716
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600717 TP_PROTO(const struct btrfs_fs_info *fs_info,
718 const struct btrfs_delayed_ref_node *ref,
719 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800720 int action),
721
Jeff Mahoneybc074522016-06-09 17:27:55 -0400722 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800723);
724
725DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000726
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600727 TP_PROTO(const struct btrfs_fs_info *fs_info,
728 const struct btrfs_delayed_ref_node *ref,
729 const struct btrfs_delayed_data_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000730 int action),
731
Jeff Mahoneybc074522016-06-09 17:27:55 -0400732 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000733
Jeff Mahoneybc074522016-06-09 17:27:55 -0400734 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000735 __field( u64, bytenr )
736 __field( u64, num_bytes )
737 __field( int, action )
738 __field( u64, parent )
739 __field( u64, ref_root )
740 __field( u64, owner )
741 __field( u64, offset )
742 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600743 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000744 ),
745
Jeff Mahoneybc074522016-06-09 17:27:55 -0400746 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000747 __entry->bytenr = ref->bytenr;
748 __entry->num_bytes = ref->num_bytes;
749 __entry->action = action;
750 __entry->parent = full_ref->parent;
751 __entry->ref_root = full_ref->root;
752 __entry->owner = full_ref->objectid;
753 __entry->offset = full_ref->offset;
754 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600755 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000756 ),
757
David Sterba562a7a02017-01-06 15:51:36 +0100758 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
759 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
760 "offset=%llu type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000761 (unsigned long long)__entry->bytenr,
762 (unsigned long long)__entry->num_bytes,
763 show_ref_action(__entry->action),
764 show_root_type(__entry->parent),
765 show_root_type(__entry->ref_root),
766 (unsigned long long)__entry->owner,
767 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600768 show_ref_type(__entry->type),
769 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000770);
771
Liu Bo599c75e2013-07-16 19:03:36 +0800772DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
773
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600774 TP_PROTO(const struct btrfs_fs_info *fs_info,
775 const struct btrfs_delayed_ref_node *ref,
776 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800777 int action),
778
Jeff Mahoneybc074522016-06-09 17:27:55 -0400779 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800780);
781
782DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
783
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600784 TP_PROTO(const struct btrfs_fs_info *fs_info,
785 const struct btrfs_delayed_ref_node *ref,
786 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800787 int action),
788
Jeff Mahoneybc074522016-06-09 17:27:55 -0400789 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800790);
791
792DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000793
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600794 TP_PROTO(const struct btrfs_fs_info *fs_info,
795 const struct btrfs_delayed_ref_node *ref,
796 const struct btrfs_delayed_ref_head *head_ref,
liubo1abe9b82011-03-24 11:18:59 +0000797 int action),
798
Jeff Mahoneybc074522016-06-09 17:27:55 -0400799 TP_ARGS(fs_info, ref, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000800
Jeff Mahoneybc074522016-06-09 17:27:55 -0400801 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000802 __field( u64, bytenr )
803 __field( u64, num_bytes )
804 __field( int, action )
805 __field( int, is_data )
806 ),
807
Jeff Mahoneybc074522016-06-09 17:27:55 -0400808 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000809 __entry->bytenr = ref->bytenr;
810 __entry->num_bytes = ref->num_bytes;
811 __entry->action = action;
812 __entry->is_data = head_ref->is_data;
813 ),
814
David Sterba562a7a02017-01-06 15:51:36 +0100815 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
liubo1abe9b82011-03-24 11:18:59 +0000816 (unsigned long long)__entry->bytenr,
817 (unsigned long long)__entry->num_bytes,
818 show_ref_action(__entry->action),
819 __entry->is_data)
820);
821
Liu Bo599c75e2013-07-16 19:03:36 +0800822DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
823
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600824 TP_PROTO(const struct btrfs_fs_info *fs_info,
825 const struct btrfs_delayed_ref_node *ref,
826 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800827 int action),
828
Jeff Mahoneybc074522016-06-09 17:27:55 -0400829 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800830);
831
832DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
833
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600834 TP_PROTO(const struct btrfs_fs_info *fs_info,
835 const struct btrfs_delayed_ref_node *ref,
836 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800837 int action),
838
Jeff Mahoneybc074522016-06-09 17:27:55 -0400839 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800840);
841
liubo1abe9b82011-03-24 11:18:59 +0000842#define show_chunk_type(type) \
843 __print_flags(type, "|", \
844 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
845 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
846 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
847 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
848 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
849 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000850 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
851 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
852 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000853
854DECLARE_EVENT_CLASS(btrfs__chunk,
855
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600856 TP_PROTO(const struct btrfs_fs_info *fs_info,
857 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000858
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400859 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000860
Jeff Mahoneybc074522016-06-09 17:27:55 -0400861 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000862 __field( int, num_stripes )
863 __field( u64, type )
864 __field( int, sub_stripes )
865 __field( u64, offset )
866 __field( u64, size )
867 __field( u64, root_objectid )
868 ),
869
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400870 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000871 __entry->num_stripes = map->num_stripes;
872 __entry->type = map->type;
873 __entry->sub_stripes = map->sub_stripes;
874 __entry->offset = offset;
875 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400876 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000877 ),
878
David Sterba562a7a02017-01-06 15:51:36 +0100879 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
880 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000881 show_root_type(__entry->root_objectid),
882 (unsigned long long)__entry->offset,
883 (unsigned long long)__entry->size,
884 __entry->num_stripes, __entry->sub_stripes,
885 show_chunk_type(__entry->type))
886);
887
888DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
889
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600890 TP_PROTO(const struct btrfs_fs_info *fs_info,
891 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000892
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400893 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000894);
895
896DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
897
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600898 TP_PROTO(const struct btrfs_fs_info *fs_info,
899 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000900
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400901 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000902);
903
904TRACE_EVENT(btrfs_cow_block,
905
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600906 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
907 const struct extent_buffer *cow),
liubo1abe9b82011-03-24 11:18:59 +0000908
909 TP_ARGS(root, buf, cow),
910
Jeff Mahoneybc074522016-06-09 17:27:55 -0400911 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000912 __field( u64, root_objectid )
913 __field( u64, buf_start )
914 __field( int, refs )
915 __field( u64, cow_start )
916 __field( int, buf_level )
917 __field( int, cow_level )
918 ),
919
Jeff Mahoneybc074522016-06-09 17:27:55 -0400920 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000921 __entry->root_objectid = root->root_key.objectid;
922 __entry->buf_start = buf->start;
923 __entry->refs = atomic_read(&buf->refs);
924 __entry->cow_start = cow->start;
925 __entry->buf_level = btrfs_header_level(buf);
926 __entry->cow_level = btrfs_header_level(cow);
927 ),
928
David Sterba562a7a02017-01-06 15:51:36 +0100929 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
930 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000931 show_root_type(__entry->root_objectid),
932 __entry->refs,
933 (unsigned long long)__entry->buf_start,
934 __entry->buf_level,
935 (unsigned long long)__entry->cow_start,
936 __entry->cow_level)
937);
938
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500939TRACE_EVENT(btrfs_space_reservation,
940
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600941 TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500942 u64 bytes, int reserve),
943
944 TP_ARGS(fs_info, type, val, bytes, reserve),
945
Jeff Mahoneybc074522016-06-09 17:27:55 -0400946 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500947 __string( type, type )
948 __field( u64, val )
949 __field( u64, bytes )
950 __field( int, reserve )
951 ),
952
Jeff Mahoneybc074522016-06-09 17:27:55 -0400953 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500954 __assign_str(type, type);
955 __entry->val = val;
956 __entry->bytes = bytes;
957 __entry->reserve = reserve;
958 ),
959
Jeff Mahoneybc074522016-06-09 17:27:55 -0400960 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
961 __entry->reserve ? "reserve" : "release",
962 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500963);
964
Josef Bacikf376df22016-03-25 13:25:56 -0400965#define show_flush_action(action) \
966 __print_symbolic(action, \
967 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
968 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
969 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
970
971TRACE_EVENT(btrfs_trigger_flush,
972
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600973 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
Josef Bacikf376df22016-03-25 13:25:56 -0400974 int flush, char *reason),
975
976 TP_ARGS(fs_info, flags, bytes, flush, reason),
977
978 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +0800979 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikf376df22016-03-25 13:25:56 -0400980 __field( u64, flags )
981 __field( u64, bytes )
982 __field( int, flush )
983 __string( reason, reason )
984 ),
985
986 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +0800987 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikf376df22016-03-25 13:25:56 -0400988 __entry->flags = flags;
989 __entry->bytes = bytes;
990 __entry->flush = flush;
991 __assign_str(reason, reason)
992 ),
993
David Sterba562a7a02017-01-06 15:51:36 +0100994 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
Josef Bacikf376df22016-03-25 13:25:56 -0400995 __entry->fsid, __get_str(reason), __entry->flush,
996 show_flush_action(__entry->flush),
997 (unsigned long long)__entry->flags,
998 __print_flags((unsigned long)__entry->flags, "|",
999 BTRFS_GROUP_FLAGS),
1000 (unsigned long long)__entry->bytes)
1001);
1002
1003#define show_flush_state(state) \
1004 __print_symbolic(state, \
1005 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
1006 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
1007 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1008 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
1009 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
1010 { COMMIT_TRANS, "COMMIT_TRANS"})
1011
1012TRACE_EVENT(btrfs_flush_space,
1013
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001014 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001015 int state, int ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001016
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001017 TP_ARGS(fs_info, flags, num_bytes, state, ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001018
1019 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +08001020 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikf376df22016-03-25 13:25:56 -04001021 __field( u64, flags )
1022 __field( u64, num_bytes )
Josef Bacikf376df22016-03-25 13:25:56 -04001023 __field( int, state )
1024 __field( int, ret )
1025 ),
1026
1027 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +08001028 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikf376df22016-03-25 13:25:56 -04001029 __entry->flags = flags;
1030 __entry->num_bytes = num_bytes;
Josef Bacikf376df22016-03-25 13:25:56 -04001031 __entry->state = state;
1032 __entry->ret = ret;
1033 ),
1034
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001035 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
1036 __entry->fsid, __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001037 show_flush_state(__entry->state),
1038 (unsigned long long)__entry->flags,
1039 __print_flags((unsigned long)__entry->flags, "|",
1040 BTRFS_GROUP_FLAGS),
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001041 (unsigned long long)__entry->num_bytes, __entry->ret)
Josef Bacikf376df22016-03-25 13:25:56 -04001042);
1043
liubo1abe9b82011-03-24 11:18:59 +00001044DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1045
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001046 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001047
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001048 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001049
Jeff Mahoneybc074522016-06-09 17:27:55 -04001050 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001051 __field( u64, start )
1052 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001053 ),
1054
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001055 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001056 __entry->start = start;
1057 __entry->len = len;
1058 ),
1059
David Sterba562a7a02017-01-06 15:51:36 +01001060 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001061 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
liubo1abe9b82011-03-24 11:18:59 +00001062 (unsigned long long)__entry->start,
1063 (unsigned long long)__entry->len)
1064);
1065
1066DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1067
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001068 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001069
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001070 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001071);
1072
1073DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1074
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001075 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001076
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001077 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001078);
1079
Josef Bacik3f7de032011-11-10 08:29:20 -05001080TRACE_EVENT(find_free_extent,
1081
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001082 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1083 u64 empty_size, u64 data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001084
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001085 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001086
Jeff Mahoneybc074522016-06-09 17:27:55 -04001087 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001088 __field( u64, num_bytes )
1089 __field( u64, empty_size )
1090 __field( u64, data )
1091 ),
1092
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001093 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001094 __entry->num_bytes = num_bytes;
1095 __entry->empty_size = empty_size;
1096 __entry->data = data;
1097 ),
1098
David Sterba562a7a02017-01-06 15:51:36 +01001099 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001100 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001101 __entry->num_bytes, __entry->empty_size, __entry->data,
1102 __print_flags((unsigned long)__entry->data, "|",
1103 BTRFS_GROUP_FLAGS))
1104);
1105
1106DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1107
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001108 TP_PROTO(const struct btrfs_fs_info *fs_info,
1109 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001110 u64 len),
1111
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001112 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001113
Jeff Mahoneybc074522016-06-09 17:27:55 -04001114 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001115 __field( u64, bg_objectid )
1116 __field( u64, flags )
1117 __field( u64, start )
1118 __field( u64, len )
1119 ),
1120
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001121 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001122 __entry->bg_objectid = block_group->key.objectid;
1123 __entry->flags = block_group->flags;
1124 __entry->start = start;
1125 __entry->len = len;
1126 ),
1127
David Sterba562a7a02017-01-06 15:51:36 +01001128 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
1129 "start=%Lu len=%Lu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001130 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1131 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001132 __entry->flags, __print_flags((unsigned long)__entry->flags,
1133 "|", BTRFS_GROUP_FLAGS),
1134 __entry->start, __entry->len)
1135);
1136
1137DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1138
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001139 TP_PROTO(const struct btrfs_fs_info *fs_info,
1140 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001141 u64 len),
1142
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001143 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001144);
1145
1146DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1147
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001148 TP_PROTO(const struct btrfs_fs_info *fs_info,
1149 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001150 u64 len),
1151
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001152 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001153);
1154
1155TRACE_EVENT(btrfs_find_cluster,
1156
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001157 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001158 u64 bytes, u64 empty_size, u64 min_bytes),
1159
1160 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1161
Jeff Mahoneybc074522016-06-09 17:27:55 -04001162 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001163 __field( u64, bg_objectid )
1164 __field( u64, flags )
1165 __field( u64, start )
1166 __field( u64, bytes )
1167 __field( u64, empty_size )
1168 __field( u64, min_bytes )
1169 ),
1170
Jeff Mahoneybc074522016-06-09 17:27:55 -04001171 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001172 __entry->bg_objectid = block_group->key.objectid;
1173 __entry->flags = block_group->flags;
1174 __entry->start = start;
1175 __entry->bytes = bytes;
1176 __entry->empty_size = empty_size;
1177 __entry->min_bytes = min_bytes;
1178 ),
1179
David Sterba562a7a02017-01-06 15:51:36 +01001180 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1181 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001182 __entry->flags,
1183 __print_flags((unsigned long)__entry->flags, "|",
1184 BTRFS_GROUP_FLAGS), __entry->start,
1185 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1186);
1187
1188TRACE_EVENT(btrfs_failed_cluster_setup,
1189
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001190 TP_PROTO(const struct btrfs_block_group_cache *block_group),
Josef Bacik3f7de032011-11-10 08:29:20 -05001191
1192 TP_ARGS(block_group),
1193
Jeff Mahoneybc074522016-06-09 17:27:55 -04001194 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001195 __field( u64, bg_objectid )
1196 ),
1197
Jeff Mahoneybc074522016-06-09 17:27:55 -04001198 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001199 __entry->bg_objectid = block_group->key.objectid;
1200 ),
1201
David Sterba562a7a02017-01-06 15:51:36 +01001202 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001203);
1204
1205TRACE_EVENT(btrfs_setup_cluster,
1206
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001207 TP_PROTO(const struct btrfs_block_group_cache *block_group,
1208 const struct btrfs_free_cluster *cluster,
1209 u64 size, int bitmap),
Josef Bacik3f7de032011-11-10 08:29:20 -05001210
1211 TP_ARGS(block_group, cluster, size, bitmap),
1212
Jeff Mahoneybc074522016-06-09 17:27:55 -04001213 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001214 __field( u64, bg_objectid )
1215 __field( u64, flags )
1216 __field( u64, start )
1217 __field( u64, max_size )
1218 __field( u64, size )
1219 __field( int, bitmap )
1220 ),
1221
Jeff Mahoneybc074522016-06-09 17:27:55 -04001222 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001223 __entry->bg_objectid = block_group->key.objectid;
1224 __entry->flags = block_group->flags;
1225 __entry->start = cluster->window_start;
1226 __entry->max_size = cluster->max_size;
1227 __entry->size = size;
1228 __entry->bitmap = bitmap;
1229 ),
1230
David Sterba562a7a02017-01-06 15:51:36 +01001231 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1232 "size=%Lu max_size=%Lu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001233 __entry->bg_objectid,
1234 __entry->flags,
1235 __print_flags((unsigned long)__entry->flags, "|",
1236 BTRFS_GROUP_FLAGS), __entry->start,
1237 __entry->size, __entry->max_size, __entry->bitmap)
1238);
1239
Jeff Mahoney143bede2012-03-01 14:56:26 +01001240struct extent_state;
1241TRACE_EVENT(alloc_extent_state,
1242
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001243 TP_PROTO(const struct extent_state *state,
1244 gfp_t mask, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001245
1246 TP_ARGS(state, mask, IP),
1247
1248 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001249 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001250 __field(gfp_t, mask)
1251 __field(unsigned long, ip)
1252 ),
1253
1254 TP_fast_assign(
1255 __entry->state = state,
1256 __entry->mask = mask,
1257 __entry->ip = IP
1258 ),
1259
David Sterba562a7a02017-01-06 15:51:36 +01001260 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001261 show_gfp_flags(__entry->mask), (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001262);
1263
1264TRACE_EVENT(free_extent_state,
1265
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001266 TP_PROTO(const struct extent_state *state, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001267
1268 TP_ARGS(state, IP),
1269
1270 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001271 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001272 __field(unsigned long, ip)
1273 ),
1274
1275 TP_fast_assign(
1276 __entry->state = state,
1277 __entry->ip = IP
1278 ),
1279
David Sterba562a7a02017-01-06 15:51:36 +01001280 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001281 (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001282);
1283
Qu Wenruo52483bc2014-03-06 04:19:50 +00001284DECLARE_EVENT_CLASS(btrfs__work,
1285
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001286 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001287
1288 TP_ARGS(work),
1289
Jeff Mahoneybc074522016-06-09 17:27:55 -04001290 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001291 __field( const void *, work )
1292 __field( const void *, wq )
1293 __field( const void *, func )
1294 __field( const void *, ordered_func )
1295 __field( const void *, ordered_free )
1296 __field( const void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001297 ),
1298
Jeff Mahoneybc074522016-06-09 17:27:55 -04001299 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001300 __entry->work = work;
1301 __entry->wq = work->wq;
1302 __entry->func = work->func;
1303 __entry->ordered_func = work->ordered_func;
1304 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001305 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001306 ),
1307
David Sterba562a7a02017-01-06 15:51:36 +01001308 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1309 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001310 __entry->work, __entry->normal_work, __entry->wq,
1311 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001312);
1313
David Sterbaac0c7cf2017-01-06 14:12:51 +01001314/*
1315 * For situiations when the work is freed, we pass fs_info and a tag that that
1316 * matches address of the work structure so it can be paired with the
1317 * scheduling event.
1318 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001319DECLARE_EVENT_CLASS(btrfs__work__done,
1320
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001321 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001322
David Sterbaac0c7cf2017-01-06 14:12:51 +01001323 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001324
Jeff Mahoneybc074522016-06-09 17:27:55 -04001325 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001326 __field( const void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001327 ),
1328
David Sterbaac0c7cf2017-01-06 14:12:51 +01001329 TP_fast_assign_btrfs(fs_info,
1330 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001331 ),
1332
David Sterbaac0c7cf2017-01-06 14:12:51 +01001333 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001334);
1335
1336DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1337
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001338 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001339
1340 TP_ARGS(work)
1341);
1342
1343DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1344
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001345 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001346
1347 TP_ARGS(work)
1348);
1349
Qu Wenruo52483bc2014-03-06 04:19:50 +00001350DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1351
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001352 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001353
David Sterbaac0c7cf2017-01-06 14:12:51 +01001354 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001355);
1356
1357DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1358
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001359 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001360
1361 TP_ARGS(work)
1362);
1363
Qu Wenruoc3a46892014-03-12 08:05:33 +00001364DECLARE_EVENT_CLASS(btrfs__workqueue,
1365
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001366 TP_PROTO(const struct __btrfs_workqueue *wq,
1367 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001368
1369 TP_ARGS(wq, name, high),
1370
Jeff Mahoneybc074522016-06-09 17:27:55 -04001371 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001372 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001373 __string( name, name )
1374 __field( int , high )
1375 ),
1376
Jeff Mahoneybc074522016-06-09 17:27:55 -04001377 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001378 __entry->wq = wq;
1379 __assign_str(name, name);
1380 __entry->high = high;
1381 ),
1382
David Sterba562a7a02017-01-06 15:51:36 +01001383 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001384 __print_flags(__entry->high, "",
1385 {(WQ_HIGHPRI), "-high"}),
1386 __entry->wq)
1387);
1388
1389DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1390
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001391 TP_PROTO(const struct __btrfs_workqueue *wq,
1392 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001393
1394 TP_ARGS(wq, name, high)
1395);
1396
1397DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1398
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001399 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001400
1401 TP_ARGS(wq),
1402
Jeff Mahoneybc074522016-06-09 17:27:55 -04001403 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001404 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001405 ),
1406
Jeff Mahoneybc074522016-06-09 17:27:55 -04001407 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001408 __entry->wq = wq;
1409 ),
1410
Jeff Mahoneybc074522016-06-09 17:27:55 -04001411 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001412);
1413
1414DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1415
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001416 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001417
1418 TP_ARGS(wq)
1419);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001420
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001421#define BTRFS_QGROUP_OPERATIONS \
1422 { QGROUP_RESERVE, "reserve" }, \
1423 { QGROUP_RELEASE, "release" }, \
1424 { QGROUP_FREE, "free" }
1425
1426DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1427
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001428 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1429 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001430
1431 TP_ARGS(inode, start, len, reserved, op),
1432
Jeff Mahoneybc074522016-06-09 17:27:55 -04001433 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001434 __field( u64, rootid )
1435 __field( unsigned long, ino )
1436 __field( u64, start )
1437 __field( u64, len )
1438 __field( u64, reserved )
1439 __field( int, op )
1440 ),
1441
Jeff Mahoneybc074522016-06-09 17:27:55 -04001442 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001443 __entry->rootid = BTRFS_I(inode)->root->objectid;
1444 __entry->ino = inode->i_ino;
1445 __entry->start = start;
1446 __entry->len = len;
1447 __entry->reserved = reserved;
1448 __entry->op = op;
1449 ),
1450
David Sterba562a7a02017-01-06 15:51:36 +01001451 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001452 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1453 __entry->reserved,
1454 __print_flags((unsigned long)__entry->op, "",
1455 BTRFS_QGROUP_OPERATIONS)
1456 )
1457);
1458
1459DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1460
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001461 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1462 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001463
1464 TP_ARGS(inode, start, len, reserved, op)
1465);
1466
1467DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1468
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001469 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1470 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001471
1472 TP_ARGS(inode, start, len, reserved, op)
1473);
1474
1475DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1476
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001477 TP_PROTO(const struct btrfs_fs_info *fs_info,
1478 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001479
Jeff Mahoneybc074522016-06-09 17:27:55 -04001480 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001481
Jeff Mahoneybc074522016-06-09 17:27:55 -04001482 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001483 __field( u64, ref_root )
1484 __field( u64, reserved )
1485 ),
1486
Jeff Mahoneybc074522016-06-09 17:27:55 -04001487 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001488 __entry->ref_root = ref_root;
1489 __entry->reserved = reserved;
1490 ),
1491
David Sterba562a7a02017-01-06 15:51:36 +01001492 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001493 __entry->ref_root, __entry->reserved)
1494);
1495
1496DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1497
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001498 TP_PROTO(const struct btrfs_fs_info *fs_info,
1499 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001500
Jeff Mahoneybc074522016-06-09 17:27:55 -04001501 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001502);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001503
1504DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001505 TP_PROTO(const struct btrfs_fs_info *fs_info,
1506 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001507
Jeff Mahoneybc074522016-06-09 17:27:55 -04001508 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001509
Jeff Mahoneybc074522016-06-09 17:27:55 -04001510 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001511 __field( u64, bytenr )
1512 __field( u64, num_bytes )
1513 ),
1514
Jeff Mahoneybc074522016-06-09 17:27:55 -04001515 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001516 __entry->bytenr = rec->bytenr,
1517 __entry->num_bytes = rec->num_bytes;
1518 ),
1519
David Sterba562a7a02017-01-06 15:51:36 +01001520 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001521 (unsigned long long)__entry->bytenr,
1522 (unsigned long long)__entry->num_bytes)
1523);
1524
1525DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1526
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001527 TP_PROTO(const struct btrfs_fs_info *fs_info,
1528 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001529
Jeff Mahoneybc074522016-06-09 17:27:55 -04001530 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001531);
1532
Qu Wenruo50b3e042016-10-18 09:31:27 +08001533DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001534
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001535 TP_PROTO(const struct btrfs_fs_info *fs_info,
1536 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001537
Jeff Mahoneybc074522016-06-09 17:27:55 -04001538 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001539);
1540
1541TRACE_EVENT(btrfs_qgroup_account_extent,
1542
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001543 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001544 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001545
Jeff Mahoneybc074522016-06-09 17:27:55 -04001546 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001547
Jeff Mahoneybc074522016-06-09 17:27:55 -04001548 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001549 __field( u64, bytenr )
1550 __field( u64, num_bytes )
1551 __field( u64, nr_old_roots )
1552 __field( u64, nr_new_roots )
1553 ),
1554
Jeff Mahoneybc074522016-06-09 17:27:55 -04001555 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001556 __entry->bytenr = bytenr;
1557 __entry->num_bytes = num_bytes;
1558 __entry->nr_old_roots = nr_old_roots;
1559 __entry->nr_new_roots = nr_new_roots;
1560 ),
1561
David Sterba562a7a02017-01-06 15:51:36 +01001562 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1563 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001564 __entry->bytenr,
1565 __entry->num_bytes,
1566 __entry->nr_old_roots,
1567 __entry->nr_new_roots)
1568);
1569
1570TRACE_EVENT(qgroup_update_counters,
1571
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001572 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001573 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001574
Jeff Mahoneybc074522016-06-09 17:27:55 -04001575 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001576
Jeff Mahoneybc074522016-06-09 17:27:55 -04001577 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001578 __field( u64, qgid )
1579 __field( u64, cur_old_count )
1580 __field( u64, cur_new_count )
1581 ),
1582
Jeff Mahoneybc074522016-06-09 17:27:55 -04001583 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001584 __entry->qgid = qgid;
1585 __entry->cur_old_count = cur_old_count;
1586 __entry->cur_new_count = cur_new_count;
1587 ),
1588
David Sterba562a7a02017-01-06 15:51:36 +01001589 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001590 __entry->qgid,
1591 __entry->cur_old_count,
1592 __entry->cur_new_count)
1593);
1594
Qu Wenruo3159fe72017-03-13 15:52:08 +08001595TRACE_EVENT(qgroup_update_reserve,
1596
1597 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
1598 s64 diff),
1599
1600 TP_ARGS(fs_info, qgroup, diff),
1601
1602 TP_STRUCT__entry_btrfs(
1603 __field( u64, qgid )
1604 __field( u64, cur_reserved )
1605 __field( s64, diff )
1606 ),
1607
1608 TP_fast_assign_btrfs(fs_info,
1609 __entry->qgid = qgroup->qgroupid;
1610 __entry->cur_reserved = qgroup->reserved;
1611 __entry->diff = diff;
1612 ),
1613
1614 TP_printk_btrfs("qgid=%llu cur_reserved=%llu diff=%lld",
1615 __entry->qgid, __entry->cur_reserved, __entry->diff)
1616);
1617
1618TRACE_EVENT(qgroup_meta_reserve,
1619
1620 TP_PROTO(struct btrfs_root *root, s64 diff),
1621
1622 TP_ARGS(root, diff),
1623
1624 TP_STRUCT__entry_btrfs(
1625 __field( u64, refroot )
1626 __field( s64, diff )
1627 ),
1628
1629 TP_fast_assign_btrfs(root->fs_info,
1630 __entry->refroot = root->objectid;
1631 __entry->diff = diff;
1632 ),
1633
1634 TP_printk_btrfs("refroot=%llu(%s) diff=%lld",
1635 show_root_type(__entry->refroot), __entry->diff)
1636);
1637
Jeff Mahoney00142752017-07-12 16:20:08 -06001638DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1639 TP_PROTO(const struct btrfs_fs_info *fs_info,
1640 const struct prelim_ref *oldref,
1641 const struct prelim_ref *newref, u64 tree_size),
1642 TP_ARGS(fs_info, newref, oldref, tree_size),
1643
1644 TP_STRUCT__entry_btrfs(
1645 __field( u64, root_id )
1646 __field( u64, objectid )
1647 __field( u8, type )
1648 __field( u64, offset )
1649 __field( int, level )
1650 __field( int, old_count )
1651 __field( u64, parent )
1652 __field( u64, bytenr )
1653 __field( int, mod_count )
1654 __field( u64, tree_size )
1655 ),
1656
1657 TP_fast_assign_btrfs(fs_info,
1658 __entry->root_id = oldref->root_id;
1659 __entry->objectid = oldref->key_for_search.objectid;
1660 __entry->type = oldref->key_for_search.type;
1661 __entry->offset = oldref->key_for_search.offset;
1662 __entry->level = oldref->level;
1663 __entry->old_count = oldref->count;
1664 __entry->parent = oldref->parent;
1665 __entry->bytenr = oldref->wanted_disk_byte;
1666 __entry->mod_count = newref ? newref->count : 0;
1667 __entry->tree_size = tree_size;
1668 ),
1669
1670 TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
1671 (unsigned long long)__entry->root_id,
1672 (unsigned long long)__entry->objectid, __entry->type,
1673 (unsigned long long)__entry->offset, __entry->level,
1674 __entry->old_count, __entry->mod_count,
1675 __entry->old_count + __entry->mod_count,
1676 (unsigned long long)__entry->parent,
1677 (unsigned long long)__entry->bytenr,
1678 (unsigned long long)__entry->tree_size)
1679);
1680
1681DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1682 TP_PROTO(const struct btrfs_fs_info *fs_info,
1683 const struct prelim_ref *oldref,
1684 const struct prelim_ref *newref, u64 tree_size),
1685 TP_ARGS(fs_info, oldref, newref, tree_size)
1686);
1687
1688DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1689 TP_PROTO(const struct btrfs_fs_info *fs_info,
1690 const struct prelim_ref *oldref,
1691 const struct prelim_ref *newref, u64 tree_size),
1692 TP_ARGS(fs_info, oldref, newref, tree_size)
1693);
1694
liubo1abe9b82011-03-24 11:18:59 +00001695#endif /* _TRACE_BTRFS_H */
1696
1697/* This part must be outside protection */
1698#include <trace/define_trace.h>