blob: 9be469706d309f8cfdf17e5a64140516ed1377ce [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
Anand Jain012e513e2017-08-30 22:36:48 +080032TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
33TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
34TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
35TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
36TRACE_DEFINE_ENUM(ALLOC_CHUNK);
37TRACE_DEFINE_ENUM(COMMIT_TRANS);
38
liubo1abe9b82011-03-24 11:18:59 +000039#define show_ref_type(type) \
40 __print_symbolic(type, \
41 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
42 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
43 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
44 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
45 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
46
47#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080048 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000049 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
50 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
51 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
52 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
53 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
54 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
55 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
56 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000057 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000058 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070059 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
60 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000061 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
62
63#define show_root_type(obj) \
64 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000065 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000066 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000067
Liu Bo09ed2f12017-03-10 11:09:48 -080068#define show_fi_type(type) \
69 __print_symbolic(type, \
70 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \
71 { BTRFS_FILE_EXTENT_REG, "REG" }, \
72 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"})
73
Qu Wenruo64ee4e72017-12-12 15:34:27 +080074#define show_qgroup_rsv_type(type) \
75 __print_symbolic(type, \
Qu Wenruo733e03a2017-12-12 15:34:29 +080076 { BTRFS_QGROUP_RSV_DATA, "DATA" }, \
77 { BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS" }, \
78 { BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC" })
Qu Wenruo64ee4e72017-12-12 15:34:27 +080079
Josef Bacik3f7de032011-11-10 08:29:20 -050080#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000081 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
82 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
83 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
84 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
85 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
86 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
87 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
88 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
89 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050090
Anand Jainb94417e2017-08-13 11:58:30 +080091#define BTRFS_FSID_SIZE 16
92#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -040093
94#define TP_fast_assign_fsid(fs_info) \
Anand Jainb94417e2017-08-13 11:58:30 +080095 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -040096
97#define TP_STRUCT__entry_btrfs(args...) \
98 TP_STRUCT__entry( \
99 TP_STRUCT__entry_fsid \
100 args)
101#define TP_fast_assign_btrfs(fs_info, args...) \
102 TP_fast_assign( \
103 TP_fast_assign_fsid(fs_info); \
104 args)
105#define TP_printk_btrfs(fmt, args...) \
106 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500107
liubo1abe9b82011-03-24 11:18:59 +0000108TRACE_EVENT(btrfs_transaction_commit,
109
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600110 TP_PROTO(const struct btrfs_root *root),
liubo1abe9b82011-03-24 11:18:59 +0000111
112 TP_ARGS(root),
113
Jeff Mahoneybc074522016-06-09 17:27:55 -0400114 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000115 __field( u64, generation )
116 __field( u64, root_objectid )
117 ),
118
Jeff Mahoneybc074522016-06-09 17:27:55 -0400119 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000120 __entry->generation = root->fs_info->generation;
121 __entry->root_objectid = root->root_key.objectid;
122 ),
123
David Sterba79bcb712018-04-03 21:21:17 +0200124 TP_printk_btrfs("root=%llu(%s) gen=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000125 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200126 __entry->generation)
liubo1abe9b82011-03-24 11:18:59 +0000127);
128
129DECLARE_EVENT_CLASS(btrfs__inode,
130
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600131 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000132
133 TP_ARGS(inode),
134
Jeff Mahoneybc074522016-06-09 17:27:55 -0400135 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200136 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000137 __field( blkcnt_t, blocks )
138 __field( u64, disk_i_size )
139 __field( u64, generation )
140 __field( u64, last_trans )
141 __field( u64, logged_trans )
142 __field( u64, root_objectid )
143 ),
144
Jeff Mahoneybc074522016-06-09 17:27:55 -0400145 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200146 __entry->ino = btrfs_ino(BTRFS_I(inode));
liubo1abe9b82011-03-24 11:18:59 +0000147 __entry->blocks = inode->i_blocks;
148 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
149 __entry->generation = BTRFS_I(inode)->generation;
150 __entry->last_trans = BTRFS_I(inode)->last_trans;
151 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
152 __entry->root_objectid =
153 BTRFS_I(inode)->root->root_key.objectid;
154 ),
155
David Sterbaf8f8e182018-04-03 20:57:21 +0200156 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
David Sterba562a7a02017-01-06 15:51:36 +0100157 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000158 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200159 __entry->generation,
160 __entry->ino,
liubo1abe9b82011-03-24 11:18:59 +0000161 (unsigned long long)__entry->blocks,
David Sterba8eec8462018-04-03 21:15:11 +0200162 __entry->disk_i_size,
163 __entry->last_trans,
164 __entry->logged_trans)
liubo1abe9b82011-03-24 11:18:59 +0000165);
166
167DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
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_request,
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
181DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
182
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600183 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000184
185 TP_ARGS(inode)
186);
187
188#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800189 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000190 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
191 { EXTENT_MAP_HOLE, "HOLE" }, \
192 { EXTENT_MAP_INLINE, "INLINE" }, \
193 { EXTENT_MAP_DELALLOC, "DELALLOC" })
194
195#define show_map_type(type) \
196 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
197
198#define show_map_flags(flag) \
199 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800200 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
201 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
Liu Bo254a2d12014-09-17 21:36:41 +0800202 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
203 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
204 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
205 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000206
Steven Rostedt4cd85872013-11-14 22:57:29 -0500207TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000208
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600209 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
210 const struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000211
Liu Bo92a1bf72016-11-17 15:00:50 -0800212 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000213
Steven Rostedt4cd85872013-11-14 22:57:29 -0500214 TP_CONDITION(map),
215
Jeff Mahoneybc074522016-06-09 17:27:55 -0400216 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000217 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800218 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000219 __field( u64, start )
220 __field( u64, len )
221 __field( u64, orig_start )
222 __field( u64, block_start )
223 __field( u64, block_len )
224 __field( unsigned long, flags )
225 __field( int, refs )
226 __field( unsigned int, compress_type )
227 ),
228
Jeff Mahoneybc074522016-06-09 17:27:55 -0400229 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000230 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800231 __entry->ino = btrfs_ino(inode);
232 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000233 __entry->len = map->len;
234 __entry->orig_start = map->orig_start;
235 __entry->block_start = map->block_start;
236 __entry->block_len = map->block_len;
237 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200238 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000239 __entry->compress_type = map->compress_type;
240 ),
241
David Sterba562a7a02017-01-06 15:51:36 +0100242 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
243 "orig_start=%llu block_start=%llu(%s) "
244 "block_len=%llu flags=%s refs=%u "
245 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000246 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200247 __entry->ino,
248 __entry->start,
249 __entry->len,
250 __entry->orig_start,
liubo1abe9b82011-03-24 11:18:59 +0000251 show_map_type(__entry->block_start),
David Sterba8eec8462018-04-03 21:15:11 +0200252 __entry->block_len,
liubo1abe9b82011-03-24 11:18:59 +0000253 show_map_flags(__entry->flags),
254 __entry->refs, __entry->compress_type)
255);
256
Liu Bo393da912018-01-05 12:51:16 -0700257TRACE_EVENT(btrfs_handle_em_exist,
258
259 TP_PROTO(const struct extent_map *existing, const struct extent_map *map, u64 start, u64 len),
260
261 TP_ARGS(existing, map, start, len),
262
263 TP_STRUCT__entry(
264 __field( u64, e_start )
265 __field( u64, e_len )
266 __field( u64, map_start )
267 __field( u64, map_len )
268 __field( u64, start )
269 __field( u64, len )
270 ),
271
272 TP_fast_assign(
273 __entry->e_start = existing->start;
274 __entry->e_len = existing->len;
275 __entry->map_start = map->start;
276 __entry->map_len = map->len;
277 __entry->start = start;
278 __entry->len = len;
279 ),
280
281 TP_printk("start=%llu len=%llu "
282 "existing(start=%llu len=%llu) "
283 "em(start=%llu len=%llu)",
David Sterba8eec8462018-04-03 21:15:11 +0200284 __entry->start,
285 __entry->len,
286 __entry->e_start,
287 __entry->e_len,
288 __entry->map_start,
289 __entry->map_len)
Liu Bo393da912018-01-05 12:51:16 -0700290);
291
Liu Bo09ed2f12017-03-10 11:09:48 -0800292/* file extent item */
293DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
294
295 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
296 struct btrfs_file_extent_item *fi, u64 start),
297
298 TP_ARGS(bi, l, fi, start),
299
300 TP_STRUCT__entry_btrfs(
301 __field( u64, root_obj )
302 __field( u64, ino )
303 __field( loff_t, isize )
304 __field( u64, disk_isize )
305 __field( u64, num_bytes )
306 __field( u64, ram_bytes )
307 __field( u64, disk_bytenr )
308 __field( u64, disk_num_bytes )
309 __field( u64, extent_offset )
310 __field( u8, extent_type )
311 __field( u8, compression )
312 __field( u64, extent_start )
313 __field( u64, extent_end )
314 ),
315
316 TP_fast_assign_btrfs(bi->root->fs_info,
317 __entry->root_obj = bi->root->objectid;
318 __entry->ino = btrfs_ino(bi);
319 __entry->isize = bi->vfs_inode.i_size;
320 __entry->disk_isize = bi->disk_i_size;
321 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
322 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
323 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
324 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
325 __entry->extent_offset = btrfs_file_extent_offset(l, fi);
326 __entry->extent_type = btrfs_file_extent_type(l, fi);
327 __entry->compression = btrfs_file_extent_compression(l, fi);
328 __entry->extent_start = start;
329 __entry->extent_end = (start + __entry->num_bytes);
330 ),
331
332 TP_printk_btrfs(
333 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
334 "file extent range=[%llu %llu] "
335 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
336 "disk_num_bytes=%llu extent_offset=%llu type=%s "
337 "compression=%u",
338 show_root_type(__entry->root_obj), __entry->ino,
339 __entry->isize,
340 __entry->disk_isize, __entry->extent_start,
341 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
342 __entry->disk_bytenr, __entry->disk_num_bytes,
343 __entry->extent_offset, show_fi_type(__entry->extent_type),
344 __entry->compression)
345);
346
347DECLARE_EVENT_CLASS(
348 btrfs__file_extent_item_inline,
349
350 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
351 struct btrfs_file_extent_item *fi, int slot, u64 start),
352
353 TP_ARGS(bi, l, fi, slot, start),
354
355 TP_STRUCT__entry_btrfs(
356 __field( u64, root_obj )
357 __field( u64, ino )
358 __field( loff_t, isize )
359 __field( u64, disk_isize )
360 __field( u8, extent_type )
361 __field( u8, compression )
362 __field( u64, extent_start )
363 __field( u64, extent_end )
364 ),
365
366 TP_fast_assign_btrfs(
367 bi->root->fs_info,
368 __entry->root_obj = bi->root->objectid;
369 __entry->ino = btrfs_ino(bi);
370 __entry->isize = bi->vfs_inode.i_size;
371 __entry->disk_isize = bi->disk_i_size;
372 __entry->extent_type = btrfs_file_extent_type(l, fi);
373 __entry->compression = btrfs_file_extent_compression(l, fi);
374 __entry->extent_start = start;
375 __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi));
376 ),
377
378 TP_printk_btrfs(
379 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
380 "file extent range=[%llu %llu] "
381 "extent_type=%s compression=%u",
382 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
383 __entry->disk_isize, __entry->extent_start,
384 __entry->extent_end, show_fi_type(__entry->extent_type),
385 __entry->compression)
386);
387
388DEFINE_EVENT(
389 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
390
391 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
392 struct btrfs_file_extent_item *fi, u64 start),
393
394 TP_ARGS(bi, l, fi, start)
395);
396
397DEFINE_EVENT(
398 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
399
400 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
401 struct btrfs_file_extent_item *fi, u64 start),
402
403 TP_ARGS(bi, l, fi, start)
404);
405
406DEFINE_EVENT(
407 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
408
409 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
410 struct btrfs_file_extent_item *fi, int slot, u64 start),
411
412 TP_ARGS(bi, l, fi, slot, start)
413);
414
415DEFINE_EVENT(
416 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
417
418 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
419 struct btrfs_file_extent_item *fi, int slot, u64 start),
420
421 TP_ARGS(bi, l, fi, slot, start)
422);
423
Liu Bo9d04a8c2013-11-06 12:04:13 +0800424#define show_ordered_flags(flags) \
425 __print_flags(flags, "|", \
426 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
427 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
428 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
429 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
430 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
431 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
432 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
433 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800434 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
435 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000436
liubo1abe9b82011-03-24 11:18:59 +0000437
438DECLARE_EVENT_CLASS(btrfs__ordered_extent,
439
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600440 TP_PROTO(const struct inode *inode,
441 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000442
443 TP_ARGS(inode, ordered),
444
Jeff Mahoneybc074522016-06-09 17:27:55 -0400445 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200446 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000447 __field( u64, file_offset )
448 __field( u64, start )
449 __field( u64, len )
450 __field( u64, disk_len )
451 __field( u64, bytes_left )
452 __field( unsigned long, flags )
453 __field( int, compress_type )
454 __field( int, refs )
455 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800456 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000457 ),
458
Jeff Mahoneybc074522016-06-09 17:27:55 -0400459 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200460 __entry->ino = btrfs_ino(BTRFS_I(inode));
liubo1abe9b82011-03-24 11:18:59 +0000461 __entry->file_offset = ordered->file_offset;
462 __entry->start = ordered->start;
463 __entry->len = ordered->len;
464 __entry->disk_len = ordered->disk_len;
465 __entry->bytes_left = ordered->bytes_left;
466 __entry->flags = ordered->flags;
467 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200468 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000469 __entry->root_objectid =
470 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800471 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000472 ),
473
David Sterba562a7a02017-01-06 15:51:36 +0100474 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
475 "start=%llu len=%llu disk_len=%llu "
476 "truncated_len=%llu "
477 "bytes_left=%llu flags=%s compress_type=%d "
478 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000479 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200480 __entry->ino,
481 __entry->file_offset,
482 __entry->start,
483 __entry->len,
484 __entry->disk_len,
485 __entry->truncated_len,
486 __entry->bytes_left,
liubo1abe9b82011-03-24 11:18:59 +0000487 show_ordered_flags(__entry->flags),
488 __entry->compress_type, __entry->refs)
489);
490
491DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
492
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600493 TP_PROTO(const struct inode *inode,
494 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000495
496 TP_ARGS(inode, ordered)
497);
498
499DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
500
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600501 TP_PROTO(const struct inode *inode,
502 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000503
504 TP_ARGS(inode, ordered)
505);
506
507DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
508
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600509 TP_PROTO(const struct inode *inode,
510 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000511
512 TP_ARGS(inode, ordered)
513);
514
515DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
516
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600517 TP_PROTO(const struct inode *inode,
518 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000519
520 TP_ARGS(inode, ordered)
521);
522
523DECLARE_EVENT_CLASS(btrfs__writepage,
524
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600525 TP_PROTO(const struct page *page, const struct inode *inode,
526 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000527
528 TP_ARGS(page, inode, wbc),
529
Jeff Mahoneybc074522016-06-09 17:27:55 -0400530 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200531 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000532 __field( pgoff_t, index )
533 __field( long, nr_to_write )
534 __field( long, pages_skipped )
535 __field( loff_t, range_start )
536 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000537 __field( char, for_kupdate )
538 __field( char, for_reclaim )
539 __field( char, range_cyclic )
540 __field( pgoff_t, writeback_index )
541 __field( u64, root_objectid )
542 ),
543
Jeff Mahoneybc074522016-06-09 17:27:55 -0400544 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200545 __entry->ino = btrfs_ino(BTRFS_I(inode));
liubo1abe9b82011-03-24 11:18:59 +0000546 __entry->index = page->index;
547 __entry->nr_to_write = wbc->nr_to_write;
548 __entry->pages_skipped = wbc->pages_skipped;
549 __entry->range_start = wbc->range_start;
550 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000551 __entry->for_kupdate = wbc->for_kupdate;
552 __entry->for_reclaim = wbc->for_reclaim;
553 __entry->range_cyclic = wbc->range_cyclic;
554 __entry->writeback_index = inode->i_mapping->writeback_index;
555 __entry->root_objectid =
556 BTRFS_I(inode)->root->root_key.objectid;
557 ),
558
David Sterbaf8f8e182018-04-03 20:57:21 +0200559 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
David Sterba562a7a02017-01-06 15:51:36 +0100560 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
561 "range_end=%llu for_kupdate=%d "
562 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000563 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200564 __entry->ino, __entry->index,
liubo1abe9b82011-03-24 11:18:59 +0000565 __entry->nr_to_write, __entry->pages_skipped,
566 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600567 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000568 __entry->for_reclaim, __entry->range_cyclic,
569 (unsigned long)__entry->writeback_index)
570);
571
572DEFINE_EVENT(btrfs__writepage, __extent_writepage,
573
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600574 TP_PROTO(const struct page *page, const struct inode *inode,
575 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000576
577 TP_ARGS(page, inode, wbc)
578);
579
580TRACE_EVENT(btrfs_writepage_end_io_hook,
581
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600582 TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
liubo1abe9b82011-03-24 11:18:59 +0000583
584 TP_ARGS(page, start, end, uptodate),
585
Jeff Mahoneybc074522016-06-09 17:27:55 -0400586 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200587 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000588 __field( pgoff_t, index )
589 __field( u64, start )
590 __field( u64, end )
591 __field( int, uptodate )
592 __field( u64, root_objectid )
593 ),
594
Jeff Mahoneybc074522016-06-09 17:27:55 -0400595 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200596 __entry->ino = btrfs_ino(BTRFS_I(page->mapping->host));
liubo1abe9b82011-03-24 11:18:59 +0000597 __entry->index = page->index;
598 __entry->start = start;
599 __entry->end = end;
600 __entry->uptodate = uptodate;
601 __entry->root_objectid =
602 BTRFS_I(page->mapping->host)->root->root_key.objectid;
603 ),
604
David Sterbaf8f8e182018-04-03 20:57:21 +0200605 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu "
David Sterba562a7a02017-01-06 15:51:36 +0100606 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000607 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200608 __entry->ino, (unsigned long)__entry->index,
609 __entry->start,
610 __entry->end, __entry->uptodate)
liubo1abe9b82011-03-24 11:18:59 +0000611);
612
613TRACE_EVENT(btrfs_sync_file,
614
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600615 TP_PROTO(const struct file *file, int datasync),
liubo1abe9b82011-03-24 11:18:59 +0000616
617 TP_ARGS(file, datasync),
618
Jeff Mahoneybc074522016-06-09 17:27:55 -0400619 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200620 __field( u64, ino )
621 __field( u64, parent )
liubo1abe9b82011-03-24 11:18:59 +0000622 __field( int, datasync )
623 __field( u64, root_objectid )
624 ),
625
626 TP_fast_assign(
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600627 const struct dentry *dentry = file->f_path.dentry;
628 const struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000629
Jeff Mahoneybc074522016-06-09 17:27:55 -0400630 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
David Sterbaf8f8e182018-04-03 20:57:21 +0200631 __entry->ino = btrfs_ino(BTRFS_I(inode));
632 __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
liubo1abe9b82011-03-24 11:18:59 +0000633 __entry->datasync = datasync;
634 __entry->root_objectid =
635 BTRFS_I(inode)->root->root_key.objectid;
636 ),
637
David Sterbaf8f8e182018-04-03 20:57:21 +0200638 TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000639 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200640 __entry->ino,
641 __entry->parent,
liubo1abe9b82011-03-24 11:18:59 +0000642 __entry->datasync)
643);
644
645TRACE_EVENT(btrfs_sync_fs,
646
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600647 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000648
Jeff Mahoneybc074522016-06-09 17:27:55 -0400649 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000650
Jeff Mahoneybc074522016-06-09 17:27:55 -0400651 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000652 __field( int, wait )
653 ),
654
Jeff Mahoneybc074522016-06-09 17:27:55 -0400655 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000656 __entry->wait = wait;
657 ),
658
David Sterba79bcb712018-04-03 21:21:17 +0200659 TP_printk_btrfs("wait=%d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000660);
661
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400662TRACE_EVENT(btrfs_add_block_group,
663
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600664 TP_PROTO(const struct btrfs_fs_info *fs_info,
665 const struct btrfs_block_group_cache *block_group, int create),
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400666
667 TP_ARGS(fs_info, block_group, create),
668
David Sterba2e63e622018-04-03 21:34:06 +0200669 TP_STRUCT__entry_btrfs(
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400670 __field( u64, offset )
671 __field( u64, size )
672 __field( u64, flags )
673 __field( u64, bytes_used )
674 __field( u64, bytes_super )
675 __field( int, create )
676 ),
677
David Sterba2e63e622018-04-03 21:34:06 +0200678 TP_fast_assign_btrfs(fs_info,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400679 __entry->offset = block_group->key.objectid;
680 __entry->size = block_group->key.offset;
681 __entry->flags = block_group->flags;
682 __entry->bytes_used =
683 btrfs_block_group_used(&block_group->item);
684 __entry->bytes_super = block_group->bytes_super;
685 __entry->create = create;
686 ),
687
David Sterba2e63e622018-04-03 21:34:06 +0200688 TP_printk_btrfs("block_group offset=%llu size=%llu "
David Sterba562a7a02017-01-06 15:51:36 +0100689 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
David Sterba2e63e622018-04-03 21:34:06 +0200690 "create=%d",
David Sterba8eec8462018-04-03 21:15:11 +0200691 __entry->offset,
692 __entry->size,
693 __entry->flags,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400694 __print_flags((unsigned long)__entry->flags, "|",
695 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +0200696 __entry->bytes_used,
697 __entry->bytes_super, __entry->create)
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400698);
699
liubo1abe9b82011-03-24 11:18:59 +0000700#define show_ref_action(action) \
701 __print_symbolic(action, \
702 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
703 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
704 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
705 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
706
707
Liu Bo599c75e2013-07-16 19:03:36 +0800708DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000709
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600710 TP_PROTO(const struct btrfs_fs_info *fs_info,
711 const struct btrfs_delayed_ref_node *ref,
712 const struct btrfs_delayed_tree_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000713 int action),
714
Jeff Mahoneybc074522016-06-09 17:27:55 -0400715 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000716
Jeff Mahoneybc074522016-06-09 17:27:55 -0400717 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000718 __field( u64, bytenr )
719 __field( u64, num_bytes )
720 __field( int, action )
721 __field( u64, parent )
722 __field( u64, ref_root )
723 __field( int, level )
724 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600725 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000726 ),
727
Jeff Mahoneybc074522016-06-09 17:27:55 -0400728 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000729 __entry->bytenr = ref->bytenr;
730 __entry->num_bytes = ref->num_bytes;
731 __entry->action = action;
732 __entry->parent = full_ref->parent;
733 __entry->ref_root = full_ref->root;
734 __entry->level = full_ref->level;
735 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600736 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000737 ),
738
David Sterba562a7a02017-01-06 15:51:36 +0100739 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
740 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
741 "type=%s seq=%llu",
David Sterba8eec8462018-04-03 21:15:11 +0200742 __entry->bytenr,
743 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000744 show_ref_action(__entry->action),
745 show_root_type(__entry->parent),
746 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600747 __entry->level, show_ref_type(__entry->type),
David Sterba8eec8462018-04-03 21:15:11 +0200748 __entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000749);
750
Liu Bo599c75e2013-07-16 19:03:36 +0800751DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
752
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600753 TP_PROTO(const struct btrfs_fs_info *fs_info,
754 const struct btrfs_delayed_ref_node *ref,
755 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800756 int action),
757
Jeff Mahoneybc074522016-06-09 17:27:55 -0400758 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800759);
760
761DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
762
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600763 TP_PROTO(const struct btrfs_fs_info *fs_info,
764 const struct btrfs_delayed_ref_node *ref,
765 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800766 int action),
767
Jeff Mahoneybc074522016-06-09 17:27:55 -0400768 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800769);
770
771DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000772
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600773 TP_PROTO(const struct btrfs_fs_info *fs_info,
774 const struct btrfs_delayed_ref_node *ref,
775 const struct btrfs_delayed_data_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000776 int action),
777
Jeff Mahoneybc074522016-06-09 17:27:55 -0400778 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000779
Jeff Mahoneybc074522016-06-09 17:27:55 -0400780 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000781 __field( u64, bytenr )
782 __field( u64, num_bytes )
783 __field( int, action )
784 __field( u64, parent )
785 __field( u64, ref_root )
786 __field( u64, owner )
787 __field( u64, offset )
788 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600789 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000790 ),
791
Jeff Mahoneybc074522016-06-09 17:27:55 -0400792 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000793 __entry->bytenr = ref->bytenr;
794 __entry->num_bytes = ref->num_bytes;
795 __entry->action = action;
796 __entry->parent = full_ref->parent;
797 __entry->ref_root = full_ref->root;
798 __entry->owner = full_ref->objectid;
799 __entry->offset = full_ref->offset;
800 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600801 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000802 ),
803
David Sterba562a7a02017-01-06 15:51:36 +0100804 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
805 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
806 "offset=%llu type=%s seq=%llu",
David Sterba8eec8462018-04-03 21:15:11 +0200807 __entry->bytenr,
808 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000809 show_ref_action(__entry->action),
810 show_root_type(__entry->parent),
811 show_root_type(__entry->ref_root),
David Sterba8eec8462018-04-03 21:15:11 +0200812 __entry->owner,
813 __entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600814 show_ref_type(__entry->type),
David Sterba8eec8462018-04-03 21:15:11 +0200815 __entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000816);
817
Liu Bo599c75e2013-07-16 19:03:36 +0800818DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
819
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600820 TP_PROTO(const struct btrfs_fs_info *fs_info,
821 const struct btrfs_delayed_ref_node *ref,
822 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800823 int action),
824
Jeff Mahoneybc074522016-06-09 17:27:55 -0400825 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800826);
827
828DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
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_data_ref *full_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, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800836);
837
838DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000839
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600840 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600841 const struct btrfs_delayed_ref_head *head_ref,
liubo1abe9b82011-03-24 11:18:59 +0000842 int action),
843
Josef Bacikd2788502017-09-29 15:43:57 -0400844 TP_ARGS(fs_info, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000845
Jeff Mahoneybc074522016-06-09 17:27:55 -0400846 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000847 __field( u64, bytenr )
848 __field( u64, num_bytes )
849 __field( int, action )
850 __field( int, is_data )
851 ),
852
Jeff Mahoneybc074522016-06-09 17:27:55 -0400853 TP_fast_assign_btrfs(fs_info,
Josef Bacikd2788502017-09-29 15:43:57 -0400854 __entry->bytenr = head_ref->bytenr;
855 __entry->num_bytes = head_ref->num_bytes;
liubo1abe9b82011-03-24 11:18:59 +0000856 __entry->action = action;
857 __entry->is_data = head_ref->is_data;
858 ),
859
David Sterba562a7a02017-01-06 15:51:36 +0100860 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
David Sterba8eec8462018-04-03 21:15:11 +0200861 __entry->bytenr,
862 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000863 show_ref_action(__entry->action),
864 __entry->is_data)
865);
866
Liu Bo599c75e2013-07-16 19:03:36 +0800867DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
868
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600869 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600870 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800871 int action),
872
Josef Bacikd2788502017-09-29 15:43:57 -0400873 TP_ARGS(fs_info, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800874);
875
876DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
877
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600878 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600879 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800880 int action),
881
Josef Bacikd2788502017-09-29 15:43:57 -0400882 TP_ARGS(fs_info, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800883);
884
liubo1abe9b82011-03-24 11:18:59 +0000885#define show_chunk_type(type) \
886 __print_flags(type, "|", \
887 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
888 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
889 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
890 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
891 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
892 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000893 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
894 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
895 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000896
897DECLARE_EVENT_CLASS(btrfs__chunk,
898
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600899 TP_PROTO(const struct btrfs_fs_info *fs_info,
900 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000901
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400902 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000903
Jeff Mahoneybc074522016-06-09 17:27:55 -0400904 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000905 __field( int, num_stripes )
906 __field( u64, type )
907 __field( int, sub_stripes )
908 __field( u64, offset )
909 __field( u64, size )
910 __field( u64, root_objectid )
911 ),
912
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400913 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000914 __entry->num_stripes = map->num_stripes;
915 __entry->type = map->type;
916 __entry->sub_stripes = map->sub_stripes;
917 __entry->offset = offset;
918 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400919 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000920 ),
921
David Sterba562a7a02017-01-06 15:51:36 +0100922 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
923 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000924 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200925 __entry->offset,
926 __entry->size,
liubo1abe9b82011-03-24 11:18:59 +0000927 __entry->num_stripes, __entry->sub_stripes,
928 show_chunk_type(__entry->type))
929);
930
931DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
932
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600933 TP_PROTO(const struct btrfs_fs_info *fs_info,
934 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000935
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400936 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000937);
938
939DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
940
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600941 TP_PROTO(const struct btrfs_fs_info *fs_info,
942 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000943
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400944 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000945);
946
947TRACE_EVENT(btrfs_cow_block,
948
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600949 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
950 const struct extent_buffer *cow),
liubo1abe9b82011-03-24 11:18:59 +0000951
952 TP_ARGS(root, buf, cow),
953
Jeff Mahoneybc074522016-06-09 17:27:55 -0400954 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000955 __field( u64, root_objectid )
956 __field( u64, buf_start )
957 __field( int, refs )
958 __field( u64, cow_start )
959 __field( int, buf_level )
960 __field( int, cow_level )
961 ),
962
Jeff Mahoneybc074522016-06-09 17:27:55 -0400963 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000964 __entry->root_objectid = root->root_key.objectid;
965 __entry->buf_start = buf->start;
966 __entry->refs = atomic_read(&buf->refs);
967 __entry->cow_start = cow->start;
968 __entry->buf_level = btrfs_header_level(buf);
969 __entry->cow_level = btrfs_header_level(cow);
970 ),
971
David Sterba562a7a02017-01-06 15:51:36 +0100972 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
973 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000974 show_root_type(__entry->root_objectid),
975 __entry->refs,
David Sterba8eec8462018-04-03 21:15:11 +0200976 __entry->buf_start,
liubo1abe9b82011-03-24 11:18:59 +0000977 __entry->buf_level,
David Sterba8eec8462018-04-03 21:15:11 +0200978 __entry->cow_start,
liubo1abe9b82011-03-24 11:18:59 +0000979 __entry->cow_level)
980);
981
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500982TRACE_EVENT(btrfs_space_reservation,
983
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600984 TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500985 u64 bytes, int reserve),
986
987 TP_ARGS(fs_info, type, val, bytes, reserve),
988
Jeff Mahoneybc074522016-06-09 17:27:55 -0400989 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500990 __string( type, type )
991 __field( u64, val )
992 __field( u64, bytes )
993 __field( int, reserve )
994 ),
995
Jeff Mahoneybc074522016-06-09 17:27:55 -0400996 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500997 __assign_str(type, type);
998 __entry->val = val;
999 __entry->bytes = bytes;
1000 __entry->reserve = reserve;
1001 ),
1002
David Sterba5439c7f2018-04-03 21:05:37 +02001003 TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001004 __entry->reserve ? "reserve" : "release",
1005 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001006);
1007
Josef Bacikf376df22016-03-25 13:25:56 -04001008#define show_flush_action(action) \
1009 __print_symbolic(action, \
1010 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
1011 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
1012 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
1013
1014TRACE_EVENT(btrfs_trigger_flush,
1015
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001016 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
Josef Bacikf376df22016-03-25 13:25:56 -04001017 int flush, char *reason),
1018
1019 TP_ARGS(fs_info, flags, bytes, flush, reason),
1020
David Sterba2e63e622018-04-03 21:34:06 +02001021 TP_STRUCT__entry_btrfs(
Josef Bacikf376df22016-03-25 13:25:56 -04001022 __field( u64, flags )
1023 __field( u64, bytes )
1024 __field( int, flush )
1025 __string( reason, reason )
1026 ),
1027
David Sterba2e63e622018-04-03 21:34:06 +02001028 TP_fast_assign_btrfs(fs_info,
Josef Bacikf376df22016-03-25 13:25:56 -04001029 __entry->flags = flags;
1030 __entry->bytes = bytes;
1031 __entry->flush = flush;
1032 __assign_str(reason, reason)
1033 ),
1034
David Sterba2e63e622018-04-03 21:34:06 +02001035 TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
1036 __get_str(reason), __entry->flush,
Josef Bacikf376df22016-03-25 13:25:56 -04001037 show_flush_action(__entry->flush),
David Sterba8eec8462018-04-03 21:15:11 +02001038 __entry->flags,
Josef Bacikf376df22016-03-25 13:25:56 -04001039 __print_flags((unsigned long)__entry->flags, "|",
1040 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +02001041 __entry->bytes)
Josef Bacikf376df22016-03-25 13:25:56 -04001042);
1043
1044#define show_flush_state(state) \
1045 __print_symbolic(state, \
1046 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
1047 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
1048 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1049 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
1050 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
1051 { COMMIT_TRANS, "COMMIT_TRANS"})
1052
1053TRACE_EVENT(btrfs_flush_space,
1054
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001055 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001056 int state, int ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001057
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001058 TP_ARGS(fs_info, flags, num_bytes, state, ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001059
David Sterba2e63e622018-04-03 21:34:06 +02001060 TP_STRUCT__entry_btrfs(
Josef Bacikf376df22016-03-25 13:25:56 -04001061 __field( u64, flags )
1062 __field( u64, num_bytes )
Josef Bacikf376df22016-03-25 13:25:56 -04001063 __field( int, state )
1064 __field( int, ret )
1065 ),
1066
David Sterba2e63e622018-04-03 21:34:06 +02001067 TP_fast_assign_btrfs(fs_info,
Josef Bacikf376df22016-03-25 13:25:56 -04001068 __entry->flags = flags;
1069 __entry->num_bytes = num_bytes;
Josef Bacikf376df22016-03-25 13:25:56 -04001070 __entry->state = state;
1071 __entry->ret = ret;
1072 ),
1073
David Sterba2e63e622018-04-03 21:34:06 +02001074 TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
1075 __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001076 show_flush_state(__entry->state),
David Sterba8eec8462018-04-03 21:15:11 +02001077 __entry->flags,
Josef Bacikf376df22016-03-25 13:25:56 -04001078 __print_flags((unsigned long)__entry->flags, "|",
1079 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +02001080 __entry->num_bytes, __entry->ret)
Josef Bacikf376df22016-03-25 13:25:56 -04001081);
1082
liubo1abe9b82011-03-24 11:18:59 +00001083DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1084
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001085 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001086
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001087 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001088
Jeff Mahoneybc074522016-06-09 17:27:55 -04001089 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001090 __field( u64, start )
1091 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001092 ),
1093
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001094 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001095 __entry->start = start;
1096 __entry->len = len;
1097 ),
1098
David Sterba562a7a02017-01-06 15:51:36 +01001099 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001100 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
David Sterba8eec8462018-04-03 21:15:11 +02001101 __entry->start,
1102 __entry->len)
liubo1abe9b82011-03-24 11:18:59 +00001103);
1104
1105DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1106
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001107 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001108
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001109 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001110);
1111
1112DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1113
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001114 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001115
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001116 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001117);
1118
Josef Bacik3f7de032011-11-10 08:29:20 -05001119TRACE_EVENT(find_free_extent,
1120
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001121 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1122 u64 empty_size, u64 data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001123
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001124 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001125
Jeff Mahoneybc074522016-06-09 17:27:55 -04001126 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001127 __field( u64, num_bytes )
1128 __field( u64, empty_size )
1129 __field( u64, data )
1130 ),
1131
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001132 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001133 __entry->num_bytes = num_bytes;
1134 __entry->empty_size = empty_size;
1135 __entry->data = data;
1136 ),
1137
David Sterba5439c7f2018-04-03 21:05:37 +02001138 TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001139 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001140 __entry->num_bytes, __entry->empty_size, __entry->data,
1141 __print_flags((unsigned long)__entry->data, "|",
1142 BTRFS_GROUP_FLAGS))
1143);
1144
1145DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1146
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001147 TP_PROTO(const struct btrfs_fs_info *fs_info,
1148 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001149 u64 len),
1150
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001151 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001152
Jeff Mahoneybc074522016-06-09 17:27:55 -04001153 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001154 __field( u64, bg_objectid )
1155 __field( u64, flags )
1156 __field( u64, start )
1157 __field( u64, len )
1158 ),
1159
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001160 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001161 __entry->bg_objectid = block_group->key.objectid;
1162 __entry->flags = block_group->flags;
1163 __entry->start = start;
1164 __entry->len = len;
1165 ),
1166
David Sterba5439c7f2018-04-03 21:05:37 +02001167 TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
1168 "start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001169 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1170 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001171 __entry->flags, __print_flags((unsigned long)__entry->flags,
1172 "|", BTRFS_GROUP_FLAGS),
1173 __entry->start, __entry->len)
1174);
1175
1176DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1177
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001178 TP_PROTO(const struct btrfs_fs_info *fs_info,
1179 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001180 u64 len),
1181
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001182 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001183);
1184
1185DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1186
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001187 TP_PROTO(const struct btrfs_fs_info *fs_info,
1188 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001189 u64 len),
1190
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001191 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001192);
1193
1194TRACE_EVENT(btrfs_find_cluster,
1195
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001196 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001197 u64 bytes, u64 empty_size, u64 min_bytes),
1198
1199 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1200
Jeff Mahoneybc074522016-06-09 17:27:55 -04001201 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001202 __field( u64, bg_objectid )
1203 __field( u64, flags )
1204 __field( u64, start )
1205 __field( u64, bytes )
1206 __field( u64, empty_size )
1207 __field( u64, min_bytes )
1208 ),
1209
Jeff Mahoneybc074522016-06-09 17:27:55 -04001210 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001211 __entry->bg_objectid = block_group->key.objectid;
1212 __entry->flags = block_group->flags;
1213 __entry->start = start;
1214 __entry->bytes = bytes;
1215 __entry->empty_size = empty_size;
1216 __entry->min_bytes = min_bytes;
1217 ),
1218
David Sterba5439c7f2018-04-03 21:05:37 +02001219 TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
1220 "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001221 __entry->flags,
1222 __print_flags((unsigned long)__entry->flags, "|",
1223 BTRFS_GROUP_FLAGS), __entry->start,
1224 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1225);
1226
1227TRACE_EVENT(btrfs_failed_cluster_setup,
1228
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001229 TP_PROTO(const struct btrfs_block_group_cache *block_group),
Josef Bacik3f7de032011-11-10 08:29:20 -05001230
1231 TP_ARGS(block_group),
1232
Jeff Mahoneybc074522016-06-09 17:27:55 -04001233 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001234 __field( u64, bg_objectid )
1235 ),
1236
Jeff Mahoneybc074522016-06-09 17:27:55 -04001237 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001238 __entry->bg_objectid = block_group->key.objectid;
1239 ),
1240
David Sterba5439c7f2018-04-03 21:05:37 +02001241 TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001242);
1243
1244TRACE_EVENT(btrfs_setup_cluster,
1245
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001246 TP_PROTO(const struct btrfs_block_group_cache *block_group,
1247 const struct btrfs_free_cluster *cluster,
1248 u64 size, int bitmap),
Josef Bacik3f7de032011-11-10 08:29:20 -05001249
1250 TP_ARGS(block_group, cluster, size, bitmap),
1251
Jeff Mahoneybc074522016-06-09 17:27:55 -04001252 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001253 __field( u64, bg_objectid )
1254 __field( u64, flags )
1255 __field( u64, start )
1256 __field( u64, max_size )
1257 __field( u64, size )
1258 __field( int, bitmap )
1259 ),
1260
Jeff Mahoneybc074522016-06-09 17:27:55 -04001261 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001262 __entry->bg_objectid = block_group->key.objectid;
1263 __entry->flags = block_group->flags;
1264 __entry->start = cluster->window_start;
1265 __entry->max_size = cluster->max_size;
1266 __entry->size = size;
1267 __entry->bitmap = bitmap;
1268 ),
1269
David Sterba5439c7f2018-04-03 21:05:37 +02001270 TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
1271 "size=%llu max_size=%llu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001272 __entry->bg_objectid,
1273 __entry->flags,
1274 __print_flags((unsigned long)__entry->flags, "|",
1275 BTRFS_GROUP_FLAGS), __entry->start,
1276 __entry->size, __entry->max_size, __entry->bitmap)
1277);
1278
Jeff Mahoney143bede2012-03-01 14:56:26 +01001279struct extent_state;
1280TRACE_EVENT(alloc_extent_state,
1281
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001282 TP_PROTO(const struct extent_state *state,
1283 gfp_t mask, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001284
1285 TP_ARGS(state, mask, IP),
1286
1287 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001288 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001289 __field(gfp_t, mask)
1290 __field(unsigned long, ip)
1291 ),
1292
1293 TP_fast_assign(
1294 __entry->state = state,
1295 __entry->mask = mask,
1296 __entry->ip = IP
1297 ),
1298
David Sterba562a7a02017-01-06 15:51:36 +01001299 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001300 show_gfp_flags(__entry->mask), (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001301);
1302
1303TRACE_EVENT(free_extent_state,
1304
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001305 TP_PROTO(const struct extent_state *state, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001306
1307 TP_ARGS(state, IP),
1308
1309 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001310 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001311 __field(unsigned long, ip)
1312 ),
1313
1314 TP_fast_assign(
1315 __entry->state = state,
1316 __entry->ip = IP
1317 ),
1318
David Sterba562a7a02017-01-06 15:51:36 +01001319 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001320 (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001321);
1322
Qu Wenruo52483bc2014-03-06 04:19:50 +00001323DECLARE_EVENT_CLASS(btrfs__work,
1324
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001325 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001326
1327 TP_ARGS(work),
1328
Jeff Mahoneybc074522016-06-09 17:27:55 -04001329 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001330 __field( const void *, work )
1331 __field( const void *, wq )
1332 __field( const void *, func )
1333 __field( const void *, ordered_func )
1334 __field( const void *, ordered_free )
1335 __field( const void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001336 ),
1337
Jeff Mahoneybc074522016-06-09 17:27:55 -04001338 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001339 __entry->work = work;
1340 __entry->wq = work->wq;
1341 __entry->func = work->func;
1342 __entry->ordered_func = work->ordered_func;
1343 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001344 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001345 ),
1346
David Sterba562a7a02017-01-06 15:51:36 +01001347 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1348 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001349 __entry->work, __entry->normal_work, __entry->wq,
1350 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001351);
1352
David Sterbaac0c7cf2017-01-06 14:12:51 +01001353/*
1354 * For situiations when the work is freed, we pass fs_info and a tag that that
1355 * matches address of the work structure so it can be paired with the
1356 * scheduling event.
1357 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001358DECLARE_EVENT_CLASS(btrfs__work__done,
1359
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001360 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001361
David Sterbaac0c7cf2017-01-06 14:12:51 +01001362 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001363
Jeff Mahoneybc074522016-06-09 17:27:55 -04001364 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001365 __field( const void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001366 ),
1367
David Sterbaac0c7cf2017-01-06 14:12:51 +01001368 TP_fast_assign_btrfs(fs_info,
1369 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001370 ),
1371
David Sterbaac0c7cf2017-01-06 14:12:51 +01001372 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001373);
1374
1375DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1376
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001377 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001378
1379 TP_ARGS(work)
1380);
1381
1382DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1383
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001384 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001385
1386 TP_ARGS(work)
1387);
1388
Qu Wenruo52483bc2014-03-06 04:19:50 +00001389DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1390
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001391 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001392
David Sterbaac0c7cf2017-01-06 14:12:51 +01001393 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001394);
1395
1396DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1397
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001398 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001399
1400 TP_ARGS(work)
1401);
1402
Qu Wenruoc3a46892014-03-12 08:05:33 +00001403DECLARE_EVENT_CLASS(btrfs__workqueue,
1404
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001405 TP_PROTO(const struct __btrfs_workqueue *wq,
1406 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001407
1408 TP_ARGS(wq, name, high),
1409
Jeff Mahoneybc074522016-06-09 17:27:55 -04001410 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001411 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001412 __string( name, name )
1413 __field( int , high )
1414 ),
1415
Jeff Mahoneybc074522016-06-09 17:27:55 -04001416 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001417 __entry->wq = wq;
1418 __assign_str(name, name);
1419 __entry->high = high;
1420 ),
1421
David Sterba562a7a02017-01-06 15:51:36 +01001422 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001423 __print_flags(__entry->high, "",
1424 {(WQ_HIGHPRI), "-high"}),
1425 __entry->wq)
1426);
1427
1428DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1429
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001430 TP_PROTO(const struct __btrfs_workqueue *wq,
1431 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001432
1433 TP_ARGS(wq, name, high)
1434);
1435
1436DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1437
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001438 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001439
1440 TP_ARGS(wq),
1441
Jeff Mahoneybc074522016-06-09 17:27:55 -04001442 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001443 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001444 ),
1445
Jeff Mahoneybc074522016-06-09 17:27:55 -04001446 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001447 __entry->wq = wq;
1448 ),
1449
Jeff Mahoneybc074522016-06-09 17:27:55 -04001450 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001451);
1452
1453DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1454
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001455 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001456
1457 TP_ARGS(wq)
1458);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001459
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001460#define BTRFS_QGROUP_OPERATIONS \
1461 { QGROUP_RESERVE, "reserve" }, \
1462 { QGROUP_RELEASE, "release" }, \
1463 { QGROUP_FREE, "free" }
1464
1465DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_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
Jeff Mahoneybc074522016-06-09 17:27:55 -04001472 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001473 __field( u64, rootid )
David Sterbaf8f8e182018-04-03 20:57:21 +02001474 __field( u64, ino )
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001475 __field( u64, start )
1476 __field( u64, len )
1477 __field( u64, reserved )
1478 __field( int, op )
1479 ),
1480
Jeff Mahoneybc074522016-06-09 17:27:55 -04001481 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001482 __entry->rootid = BTRFS_I(inode)->root->objectid;
David Sterbaf8f8e182018-04-03 20:57:21 +02001483 __entry->ino = btrfs_ino(BTRFS_I(inode));
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001484 __entry->start = start;
1485 __entry->len = len;
1486 __entry->reserved = reserved;
1487 __entry->op = op;
1488 ),
1489
David Sterbaf8f8e182018-04-03 20:57:21 +02001490 TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001491 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1492 __entry->reserved,
1493 __print_flags((unsigned long)__entry->op, "",
1494 BTRFS_QGROUP_OPERATIONS)
1495 )
1496);
1497
1498DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1499
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001500 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1501 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001502
1503 TP_ARGS(inode, start, len, reserved, op)
1504);
1505
1506DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1507
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001508 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1509 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001510
1511 TP_ARGS(inode, start, len, reserved, op)
1512);
1513
1514DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1515
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001516 TP_PROTO(const struct btrfs_fs_info *fs_info,
1517 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001518
Jeff Mahoneybc074522016-06-09 17:27:55 -04001519 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001520
Jeff Mahoneybc074522016-06-09 17:27:55 -04001521 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001522 __field( u64, ref_root )
1523 __field( u64, reserved )
1524 ),
1525
Jeff Mahoneybc074522016-06-09 17:27:55 -04001526 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001527 __entry->ref_root = ref_root;
1528 __entry->reserved = reserved;
1529 ),
1530
David Sterba562a7a02017-01-06 15:51:36 +01001531 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001532 __entry->ref_root, __entry->reserved)
1533);
1534
1535DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1536
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001537 TP_PROTO(const struct btrfs_fs_info *fs_info,
1538 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001539
Jeff Mahoneybc074522016-06-09 17:27:55 -04001540 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001541);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001542
1543DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001544 TP_PROTO(const struct btrfs_fs_info *fs_info,
1545 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001546
Jeff Mahoneybc074522016-06-09 17:27:55 -04001547 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001548
Jeff Mahoneybc074522016-06-09 17:27:55 -04001549 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001550 __field( u64, bytenr )
1551 __field( u64, num_bytes )
1552 ),
1553
Jeff Mahoneybc074522016-06-09 17:27:55 -04001554 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001555 __entry->bytenr = rec->bytenr,
1556 __entry->num_bytes = rec->num_bytes;
1557 ),
1558
David Sterba562a7a02017-01-06 15:51:36 +01001559 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001560 (unsigned long long)__entry->bytenr,
1561 (unsigned long long)__entry->num_bytes)
1562);
1563
1564DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1565
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001566 TP_PROTO(const struct btrfs_fs_info *fs_info,
1567 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001568
Jeff Mahoneybc074522016-06-09 17:27:55 -04001569 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001570);
1571
Qu Wenruo50b3e042016-10-18 09:31:27 +08001572DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001573
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001574 TP_PROTO(const struct btrfs_fs_info *fs_info,
1575 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001576
Jeff Mahoneybc074522016-06-09 17:27:55 -04001577 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001578);
1579
1580TRACE_EVENT(btrfs_qgroup_account_extent,
1581
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001582 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001583 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001584
Jeff Mahoneybc074522016-06-09 17:27:55 -04001585 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001586
Jeff Mahoneybc074522016-06-09 17:27:55 -04001587 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001588 __field( u64, bytenr )
1589 __field( u64, num_bytes )
1590 __field( u64, nr_old_roots )
1591 __field( u64, nr_new_roots )
1592 ),
1593
Jeff Mahoneybc074522016-06-09 17:27:55 -04001594 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001595 __entry->bytenr = bytenr;
1596 __entry->num_bytes = num_bytes;
1597 __entry->nr_old_roots = nr_old_roots;
1598 __entry->nr_new_roots = nr_new_roots;
1599 ),
1600
David Sterba562a7a02017-01-06 15:51:36 +01001601 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1602 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001603 __entry->bytenr,
1604 __entry->num_bytes,
1605 __entry->nr_old_roots,
1606 __entry->nr_new_roots)
1607);
1608
1609TRACE_EVENT(qgroup_update_counters,
1610
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001611 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001612 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001613
Jeff Mahoneybc074522016-06-09 17:27:55 -04001614 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001615
Jeff Mahoneybc074522016-06-09 17:27:55 -04001616 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001617 __field( u64, qgid )
1618 __field( u64, cur_old_count )
1619 __field( u64, cur_new_count )
1620 ),
1621
Jeff Mahoneybc074522016-06-09 17:27:55 -04001622 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001623 __entry->qgid = qgid;
1624 __entry->cur_old_count = cur_old_count;
1625 __entry->cur_new_count = cur_new_count;
1626 ),
1627
David Sterba562a7a02017-01-06 15:51:36 +01001628 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001629 __entry->qgid,
1630 __entry->cur_old_count,
1631 __entry->cur_new_count)
1632);
1633
Qu Wenruo3159fe72017-03-13 15:52:08 +08001634TRACE_EVENT(qgroup_update_reserve,
1635
1636 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001637 s64 diff, int type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001638
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001639 TP_ARGS(fs_info, qgroup, diff, type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001640
1641 TP_STRUCT__entry_btrfs(
1642 __field( u64, qgid )
1643 __field( u64, cur_reserved )
1644 __field( s64, diff )
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001645 __field( int, type )
Qu Wenruo3159fe72017-03-13 15:52:08 +08001646 ),
1647
1648 TP_fast_assign_btrfs(fs_info,
1649 __entry->qgid = qgroup->qgroupid;
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001650 __entry->cur_reserved = qgroup->rsv.values[type];
Qu Wenruo3159fe72017-03-13 15:52:08 +08001651 __entry->diff = diff;
1652 ),
1653
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001654 TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
1655 __entry->qgid, show_qgroup_rsv_type(__entry->type),
1656 __entry->cur_reserved, __entry->diff)
Qu Wenruo3159fe72017-03-13 15:52:08 +08001657);
1658
1659TRACE_EVENT(qgroup_meta_reserve,
1660
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001661 TP_PROTO(struct btrfs_root *root, s64 diff, int type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001662
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001663 TP_ARGS(root, diff, type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001664
1665 TP_STRUCT__entry_btrfs(
1666 __field( u64, refroot )
1667 __field( s64, diff )
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001668 __field( int, type )
Qu Wenruo3159fe72017-03-13 15:52:08 +08001669 ),
1670
1671 TP_fast_assign_btrfs(root->fs_info,
1672 __entry->refroot = root->objectid;
1673 __entry->diff = diff;
1674 ),
1675
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001676 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1677 show_root_type(__entry->refroot),
1678 show_qgroup_rsv_type(__entry->type), __entry->diff)
1679);
1680
1681TRACE_EVENT(qgroup_meta_convert,
1682
1683 TP_PROTO(struct btrfs_root *root, s64 diff),
1684
1685 TP_ARGS(root, diff),
1686
1687 TP_STRUCT__entry_btrfs(
1688 __field( u64, refroot )
1689 __field( s64, diff )
1690 __field( int, type )
1691 ),
1692
1693 TP_fast_assign_btrfs(root->fs_info,
1694 __entry->refroot = root->objectid;
1695 __entry->diff = diff;
1696 ),
1697
1698 TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
1699 show_root_type(__entry->refroot),
1700 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC),
1701 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS),
1702 __entry->diff)
1703);
1704
1705TRACE_EVENT(qgroup_meta_free_all_pertrans,
1706
1707 TP_PROTO(struct btrfs_root *root),
1708
1709 TP_ARGS(root),
1710
1711 TP_STRUCT__entry_btrfs(
1712 __field( u64, refroot )
1713 __field( s64, diff )
1714 __field( int, type )
1715 ),
1716
1717 TP_fast_assign_btrfs(root->fs_info,
1718 __entry->refroot = root->objectid;
1719 spin_lock(&root->qgroup_meta_rsv_lock);
1720 __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans;
1721 spin_unlock(&root->qgroup_meta_rsv_lock);
1722 __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS;
1723 ),
1724
1725 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1726 show_root_type(__entry->refroot),
1727 show_qgroup_rsv_type(__entry->type), __entry->diff)
Qu Wenruo3159fe72017-03-13 15:52:08 +08001728);
1729
Jeff Mahoney00142752017-07-12 16:20:08 -06001730DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1731 TP_PROTO(const struct btrfs_fs_info *fs_info,
1732 const struct prelim_ref *oldref,
1733 const struct prelim_ref *newref, u64 tree_size),
1734 TP_ARGS(fs_info, newref, oldref, tree_size),
1735
1736 TP_STRUCT__entry_btrfs(
1737 __field( u64, root_id )
1738 __field( u64, objectid )
1739 __field( u8, type )
1740 __field( u64, offset )
1741 __field( int, level )
1742 __field( int, old_count )
1743 __field( u64, parent )
1744 __field( u64, bytenr )
1745 __field( int, mod_count )
1746 __field( u64, tree_size )
1747 ),
1748
1749 TP_fast_assign_btrfs(fs_info,
1750 __entry->root_id = oldref->root_id;
1751 __entry->objectid = oldref->key_for_search.objectid;
1752 __entry->type = oldref->key_for_search.type;
1753 __entry->offset = oldref->key_for_search.offset;
1754 __entry->level = oldref->level;
1755 __entry->old_count = oldref->count;
1756 __entry->parent = oldref->parent;
1757 __entry->bytenr = oldref->wanted_disk_byte;
1758 __entry->mod_count = newref ? newref->count : 0;
1759 __entry->tree_size = tree_size;
1760 ),
1761
1762 TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
David Sterba8eec8462018-04-03 21:15:11 +02001763 __entry->root_id,
1764 __entry->objectid, __entry->type,
1765 __entry->offset, __entry->level,
Jeff Mahoney00142752017-07-12 16:20:08 -06001766 __entry->old_count, __entry->mod_count,
1767 __entry->old_count + __entry->mod_count,
David Sterba8eec8462018-04-03 21:15:11 +02001768 __entry->parent,
1769 __entry->bytenr,
1770 __entry->tree_size)
Jeff Mahoney00142752017-07-12 16:20:08 -06001771);
1772
1773DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1774 TP_PROTO(const struct btrfs_fs_info *fs_info,
1775 const struct prelim_ref *oldref,
1776 const struct prelim_ref *newref, u64 tree_size),
1777 TP_ARGS(fs_info, oldref, newref, tree_size)
1778);
1779
1780DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1781 TP_PROTO(const struct btrfs_fs_info *fs_info,
1782 const struct prelim_ref *oldref,
1783 const struct prelim_ref *newref, u64 tree_size),
1784 TP_ARGS(fs_info, oldref, newref, tree_size)
1785);
1786
Josef Bacikdd48d402017-10-19 14:15:56 -04001787TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
1788 TP_PROTO(struct btrfs_root *root, u64 ino, int mod),
1789
1790 TP_ARGS(root, ino, mod),
1791
1792 TP_STRUCT__entry_btrfs(
1793 __field( u64, root_objectid )
1794 __field( u64, ino )
1795 __field( int, mod )
1796 ),
1797
1798 TP_fast_assign_btrfs(root->fs_info,
1799 __entry->root_objectid = root->objectid;
1800 __entry->ino = ino;
1801 __entry->mod = mod;
1802 ),
1803
1804 TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1805 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +02001806 __entry->ino, __entry->mod)
Josef Bacikdd48d402017-10-19 14:15:56 -04001807);
liubo1abe9b82011-03-24 11:18:59 +00001808#endif /* _TRACE_BTRFS_H */
1809
1810/* This part must be outside protection */
1811#include <trace/define_trace.h>