blob: 1773355e9365486ce1156cd234f933e00dcb8c46 [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
669 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +0800670 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400671 __field( u64, offset )
672 __field( u64, size )
673 __field( u64, flags )
674 __field( u64, bytes_used )
675 __field( u64, bytes_super )
676 __field( int, create )
677 ),
678
679 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +0800680 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400681 __entry->offset = block_group->key.objectid;
682 __entry->size = block_group->key.offset;
683 __entry->flags = block_group->flags;
684 __entry->bytes_used =
685 btrfs_block_group_used(&block_group->item);
686 __entry->bytes_super = block_group->bytes_super;
687 __entry->create = create;
688 ),
689
David Sterba562a7a02017-01-06 15:51:36 +0100690 TP_printk("%pU: block_group offset=%llu size=%llu "
691 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
692 "create=%d", __entry->fsid,
David Sterba8eec8462018-04-03 21:15:11 +0200693 __entry->offset,
694 __entry->size,
695 __entry->flags,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400696 __print_flags((unsigned long)__entry->flags, "|",
697 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +0200698 __entry->bytes_used,
699 __entry->bytes_super, __entry->create)
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400700);
701
liubo1abe9b82011-03-24 11:18:59 +0000702#define show_ref_action(action) \
703 __print_symbolic(action, \
704 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
705 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
706 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
707 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
708
709
Liu Bo599c75e2013-07-16 19:03:36 +0800710DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000711
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600712 TP_PROTO(const struct btrfs_fs_info *fs_info,
713 const struct btrfs_delayed_ref_node *ref,
714 const struct btrfs_delayed_tree_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000715 int action),
716
Jeff Mahoneybc074522016-06-09 17:27:55 -0400717 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000718
Jeff Mahoneybc074522016-06-09 17:27:55 -0400719 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000720 __field( u64, bytenr )
721 __field( u64, num_bytes )
722 __field( int, action )
723 __field( u64, parent )
724 __field( u64, ref_root )
725 __field( int, level )
726 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600727 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000728 ),
729
Jeff Mahoneybc074522016-06-09 17:27:55 -0400730 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000731 __entry->bytenr = ref->bytenr;
732 __entry->num_bytes = ref->num_bytes;
733 __entry->action = action;
734 __entry->parent = full_ref->parent;
735 __entry->ref_root = full_ref->root;
736 __entry->level = full_ref->level;
737 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600738 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000739 ),
740
David Sterba562a7a02017-01-06 15:51:36 +0100741 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
742 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
743 "type=%s seq=%llu",
David Sterba8eec8462018-04-03 21:15:11 +0200744 __entry->bytenr,
745 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000746 show_ref_action(__entry->action),
747 show_root_type(__entry->parent),
748 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600749 __entry->level, show_ref_type(__entry->type),
David Sterba8eec8462018-04-03 21:15:11 +0200750 __entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000751);
752
Liu Bo599c75e2013-07-16 19:03:36 +0800753DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
754
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600755 TP_PROTO(const struct btrfs_fs_info *fs_info,
756 const struct btrfs_delayed_ref_node *ref,
757 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800758 int action),
759
Jeff Mahoneybc074522016-06-09 17:27:55 -0400760 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800761);
762
763DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
764
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600765 TP_PROTO(const struct btrfs_fs_info *fs_info,
766 const struct btrfs_delayed_ref_node *ref,
767 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800768 int action),
769
Jeff Mahoneybc074522016-06-09 17:27:55 -0400770 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800771);
772
773DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000774
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600775 TP_PROTO(const struct btrfs_fs_info *fs_info,
776 const struct btrfs_delayed_ref_node *ref,
777 const struct btrfs_delayed_data_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000778 int action),
779
Jeff Mahoneybc074522016-06-09 17:27:55 -0400780 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000781
Jeff Mahoneybc074522016-06-09 17:27:55 -0400782 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000783 __field( u64, bytenr )
784 __field( u64, num_bytes )
785 __field( int, action )
786 __field( u64, parent )
787 __field( u64, ref_root )
788 __field( u64, owner )
789 __field( u64, offset )
790 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600791 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000792 ),
793
Jeff Mahoneybc074522016-06-09 17:27:55 -0400794 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000795 __entry->bytenr = ref->bytenr;
796 __entry->num_bytes = ref->num_bytes;
797 __entry->action = action;
798 __entry->parent = full_ref->parent;
799 __entry->ref_root = full_ref->root;
800 __entry->owner = full_ref->objectid;
801 __entry->offset = full_ref->offset;
802 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600803 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000804 ),
805
David Sterba562a7a02017-01-06 15:51:36 +0100806 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
807 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
808 "offset=%llu type=%s seq=%llu",
David Sterba8eec8462018-04-03 21:15:11 +0200809 __entry->bytenr,
810 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000811 show_ref_action(__entry->action),
812 show_root_type(__entry->parent),
813 show_root_type(__entry->ref_root),
David Sterba8eec8462018-04-03 21:15:11 +0200814 __entry->owner,
815 __entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600816 show_ref_type(__entry->type),
David Sterba8eec8462018-04-03 21:15:11 +0200817 __entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000818);
819
Liu Bo599c75e2013-07-16 19:03:36 +0800820DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
821
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600822 TP_PROTO(const struct btrfs_fs_info *fs_info,
823 const struct btrfs_delayed_ref_node *ref,
824 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800825 int action),
826
Jeff Mahoneybc074522016-06-09 17:27:55 -0400827 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800828);
829
830DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
831
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600832 TP_PROTO(const struct btrfs_fs_info *fs_info,
833 const struct btrfs_delayed_ref_node *ref,
834 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800835 int action),
836
Jeff Mahoneybc074522016-06-09 17:27:55 -0400837 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800838);
839
840DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000841
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600842 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600843 const struct btrfs_delayed_ref_head *head_ref,
liubo1abe9b82011-03-24 11:18:59 +0000844 int action),
845
Josef Bacikd2788502017-09-29 15:43:57 -0400846 TP_ARGS(fs_info, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000847
Jeff Mahoneybc074522016-06-09 17:27:55 -0400848 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000849 __field( u64, bytenr )
850 __field( u64, num_bytes )
851 __field( int, action )
852 __field( int, is_data )
853 ),
854
Jeff Mahoneybc074522016-06-09 17:27:55 -0400855 TP_fast_assign_btrfs(fs_info,
Josef Bacikd2788502017-09-29 15:43:57 -0400856 __entry->bytenr = head_ref->bytenr;
857 __entry->num_bytes = head_ref->num_bytes;
liubo1abe9b82011-03-24 11:18:59 +0000858 __entry->action = action;
859 __entry->is_data = head_ref->is_data;
860 ),
861
David Sterba562a7a02017-01-06 15:51:36 +0100862 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
David Sterba8eec8462018-04-03 21:15:11 +0200863 __entry->bytenr,
864 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000865 show_ref_action(__entry->action),
866 __entry->is_data)
867);
868
Liu Bo599c75e2013-07-16 19:03:36 +0800869DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
870
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600871 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600872 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800873 int action),
874
Josef Bacikd2788502017-09-29 15:43:57 -0400875 TP_ARGS(fs_info, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800876);
877
878DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
879
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600880 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600881 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800882 int action),
883
Josef Bacikd2788502017-09-29 15:43:57 -0400884 TP_ARGS(fs_info, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800885);
886
liubo1abe9b82011-03-24 11:18:59 +0000887#define show_chunk_type(type) \
888 __print_flags(type, "|", \
889 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
890 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
891 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
892 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
893 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
894 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000895 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
896 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
897 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000898
899DECLARE_EVENT_CLASS(btrfs__chunk,
900
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600901 TP_PROTO(const struct btrfs_fs_info *fs_info,
902 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000903
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400904 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000905
Jeff Mahoneybc074522016-06-09 17:27:55 -0400906 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000907 __field( int, num_stripes )
908 __field( u64, type )
909 __field( int, sub_stripes )
910 __field( u64, offset )
911 __field( u64, size )
912 __field( u64, root_objectid )
913 ),
914
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400915 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000916 __entry->num_stripes = map->num_stripes;
917 __entry->type = map->type;
918 __entry->sub_stripes = map->sub_stripes;
919 __entry->offset = offset;
920 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400921 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000922 ),
923
David Sterba562a7a02017-01-06 15:51:36 +0100924 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
925 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000926 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200927 __entry->offset,
928 __entry->size,
liubo1abe9b82011-03-24 11:18:59 +0000929 __entry->num_stripes, __entry->sub_stripes,
930 show_chunk_type(__entry->type))
931);
932
933DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
934
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600935 TP_PROTO(const struct btrfs_fs_info *fs_info,
936 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000937
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400938 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000939);
940
941DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
942
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600943 TP_PROTO(const struct btrfs_fs_info *fs_info,
944 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000945
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400946 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000947);
948
949TRACE_EVENT(btrfs_cow_block,
950
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600951 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
952 const struct extent_buffer *cow),
liubo1abe9b82011-03-24 11:18:59 +0000953
954 TP_ARGS(root, buf, cow),
955
Jeff Mahoneybc074522016-06-09 17:27:55 -0400956 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000957 __field( u64, root_objectid )
958 __field( u64, buf_start )
959 __field( int, refs )
960 __field( u64, cow_start )
961 __field( int, buf_level )
962 __field( int, cow_level )
963 ),
964
Jeff Mahoneybc074522016-06-09 17:27:55 -0400965 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000966 __entry->root_objectid = root->root_key.objectid;
967 __entry->buf_start = buf->start;
968 __entry->refs = atomic_read(&buf->refs);
969 __entry->cow_start = cow->start;
970 __entry->buf_level = btrfs_header_level(buf);
971 __entry->cow_level = btrfs_header_level(cow);
972 ),
973
David Sterba562a7a02017-01-06 15:51:36 +0100974 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
975 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000976 show_root_type(__entry->root_objectid),
977 __entry->refs,
David Sterba8eec8462018-04-03 21:15:11 +0200978 __entry->buf_start,
liubo1abe9b82011-03-24 11:18:59 +0000979 __entry->buf_level,
David Sterba8eec8462018-04-03 21:15:11 +0200980 __entry->cow_start,
liubo1abe9b82011-03-24 11:18:59 +0000981 __entry->cow_level)
982);
983
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500984TRACE_EVENT(btrfs_space_reservation,
985
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600986 TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500987 u64 bytes, int reserve),
988
989 TP_ARGS(fs_info, type, val, bytes, reserve),
990
Jeff Mahoneybc074522016-06-09 17:27:55 -0400991 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500992 __string( type, type )
993 __field( u64, val )
994 __field( u64, bytes )
995 __field( int, reserve )
996 ),
997
Jeff Mahoneybc074522016-06-09 17:27:55 -0400998 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500999 __assign_str(type, type);
1000 __entry->val = val;
1001 __entry->bytes = bytes;
1002 __entry->reserve = reserve;
1003 ),
1004
David Sterba5439c7f2018-04-03 21:05:37 +02001005 TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001006 __entry->reserve ? "reserve" : "release",
1007 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001008);
1009
Josef Bacikf376df22016-03-25 13:25:56 -04001010#define show_flush_action(action) \
1011 __print_symbolic(action, \
1012 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
1013 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
1014 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
1015
1016TRACE_EVENT(btrfs_trigger_flush,
1017
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001018 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
Josef Bacikf376df22016-03-25 13:25:56 -04001019 int flush, char *reason),
1020
1021 TP_ARGS(fs_info, flags, bytes, flush, reason),
1022
1023 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +08001024 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikf376df22016-03-25 13:25:56 -04001025 __field( u64, flags )
1026 __field( u64, bytes )
1027 __field( int, flush )
1028 __string( reason, reason )
1029 ),
1030
1031 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +08001032 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikf376df22016-03-25 13:25:56 -04001033 __entry->flags = flags;
1034 __entry->bytes = bytes;
1035 __entry->flush = flush;
1036 __assign_str(reason, reason)
1037 ),
1038
David Sterba562a7a02017-01-06 15:51:36 +01001039 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
Josef Bacikf376df22016-03-25 13:25:56 -04001040 __entry->fsid, __get_str(reason), __entry->flush,
1041 show_flush_action(__entry->flush),
David Sterba8eec8462018-04-03 21:15:11 +02001042 __entry->flags,
Josef Bacikf376df22016-03-25 13:25:56 -04001043 __print_flags((unsigned long)__entry->flags, "|",
1044 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +02001045 __entry->bytes)
Josef Bacikf376df22016-03-25 13:25:56 -04001046);
1047
1048#define show_flush_state(state) \
1049 __print_symbolic(state, \
1050 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
1051 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
1052 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1053 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
1054 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
1055 { COMMIT_TRANS, "COMMIT_TRANS"})
1056
1057TRACE_EVENT(btrfs_flush_space,
1058
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001059 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001060 int state, int ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001061
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001062 TP_ARGS(fs_info, flags, num_bytes, state, ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001063
1064 TP_STRUCT__entry(
Anand Jainb94417e2017-08-13 11:58:30 +08001065 __array( u8, fsid, BTRFS_FSID_SIZE )
Josef Bacikf376df22016-03-25 13:25:56 -04001066 __field( u64, flags )
1067 __field( u64, num_bytes )
Josef Bacikf376df22016-03-25 13:25:56 -04001068 __field( int, state )
1069 __field( int, ret )
1070 ),
1071
1072 TP_fast_assign(
Anand Jainb94417e2017-08-13 11:58:30 +08001073 memcpy(__entry->fsid, fs_info->fsid, BTRFS_FSID_SIZE);
Josef Bacikf376df22016-03-25 13:25:56 -04001074 __entry->flags = flags;
1075 __entry->num_bytes = num_bytes;
Josef Bacikf376df22016-03-25 13:25:56 -04001076 __entry->state = state;
1077 __entry->ret = ret;
1078 ),
1079
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001080 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
1081 __entry->fsid, __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001082 show_flush_state(__entry->state),
David Sterba8eec8462018-04-03 21:15:11 +02001083 __entry->flags,
Josef Bacikf376df22016-03-25 13:25:56 -04001084 __print_flags((unsigned long)__entry->flags, "|",
1085 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +02001086 __entry->num_bytes, __entry->ret)
Josef Bacikf376df22016-03-25 13:25:56 -04001087);
1088
liubo1abe9b82011-03-24 11:18:59 +00001089DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1090
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001091 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001092
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001093 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001094
Jeff Mahoneybc074522016-06-09 17:27:55 -04001095 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001096 __field( u64, start )
1097 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001098 ),
1099
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001100 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001101 __entry->start = start;
1102 __entry->len = len;
1103 ),
1104
David Sterba562a7a02017-01-06 15:51:36 +01001105 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001106 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
David Sterba8eec8462018-04-03 21:15:11 +02001107 __entry->start,
1108 __entry->len)
liubo1abe9b82011-03-24 11:18:59 +00001109);
1110
1111DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1112
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001113 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001114
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001115 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001116);
1117
1118DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1119
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001120 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001121
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001122 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001123);
1124
Josef Bacik3f7de032011-11-10 08:29:20 -05001125TRACE_EVENT(find_free_extent,
1126
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001127 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1128 u64 empty_size, u64 data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001129
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001130 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001131
Jeff Mahoneybc074522016-06-09 17:27:55 -04001132 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001133 __field( u64, num_bytes )
1134 __field( u64, empty_size )
1135 __field( u64, data )
1136 ),
1137
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001138 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001139 __entry->num_bytes = num_bytes;
1140 __entry->empty_size = empty_size;
1141 __entry->data = data;
1142 ),
1143
David Sterba5439c7f2018-04-03 21:05:37 +02001144 TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001145 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001146 __entry->num_bytes, __entry->empty_size, __entry->data,
1147 __print_flags((unsigned long)__entry->data, "|",
1148 BTRFS_GROUP_FLAGS))
1149);
1150
1151DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1152
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001153 TP_PROTO(const struct btrfs_fs_info *fs_info,
1154 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001155 u64 len),
1156
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001157 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001158
Jeff Mahoneybc074522016-06-09 17:27:55 -04001159 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001160 __field( u64, bg_objectid )
1161 __field( u64, flags )
1162 __field( u64, start )
1163 __field( u64, len )
1164 ),
1165
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001166 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001167 __entry->bg_objectid = block_group->key.objectid;
1168 __entry->flags = block_group->flags;
1169 __entry->start = start;
1170 __entry->len = len;
1171 ),
1172
David Sterba5439c7f2018-04-03 21:05:37 +02001173 TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
1174 "start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001175 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1176 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001177 __entry->flags, __print_flags((unsigned long)__entry->flags,
1178 "|", BTRFS_GROUP_FLAGS),
1179 __entry->start, __entry->len)
1180);
1181
1182DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1183
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001184 TP_PROTO(const struct btrfs_fs_info *fs_info,
1185 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001186 u64 len),
1187
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001188 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001189);
1190
1191DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1192
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001193 TP_PROTO(const struct btrfs_fs_info *fs_info,
1194 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001195 u64 len),
1196
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001197 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001198);
1199
1200TRACE_EVENT(btrfs_find_cluster,
1201
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001202 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001203 u64 bytes, u64 empty_size, u64 min_bytes),
1204
1205 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1206
Jeff Mahoneybc074522016-06-09 17:27:55 -04001207 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001208 __field( u64, bg_objectid )
1209 __field( u64, flags )
1210 __field( u64, start )
1211 __field( u64, bytes )
1212 __field( u64, empty_size )
1213 __field( u64, min_bytes )
1214 ),
1215
Jeff Mahoneybc074522016-06-09 17:27:55 -04001216 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001217 __entry->bg_objectid = block_group->key.objectid;
1218 __entry->flags = block_group->flags;
1219 __entry->start = start;
1220 __entry->bytes = bytes;
1221 __entry->empty_size = empty_size;
1222 __entry->min_bytes = min_bytes;
1223 ),
1224
David Sterba5439c7f2018-04-03 21:05:37 +02001225 TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
1226 "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001227 __entry->flags,
1228 __print_flags((unsigned long)__entry->flags, "|",
1229 BTRFS_GROUP_FLAGS), __entry->start,
1230 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1231);
1232
1233TRACE_EVENT(btrfs_failed_cluster_setup,
1234
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001235 TP_PROTO(const struct btrfs_block_group_cache *block_group),
Josef Bacik3f7de032011-11-10 08:29:20 -05001236
1237 TP_ARGS(block_group),
1238
Jeff Mahoneybc074522016-06-09 17:27:55 -04001239 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001240 __field( u64, bg_objectid )
1241 ),
1242
Jeff Mahoneybc074522016-06-09 17:27:55 -04001243 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001244 __entry->bg_objectid = block_group->key.objectid;
1245 ),
1246
David Sterba5439c7f2018-04-03 21:05:37 +02001247 TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001248);
1249
1250TRACE_EVENT(btrfs_setup_cluster,
1251
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001252 TP_PROTO(const struct btrfs_block_group_cache *block_group,
1253 const struct btrfs_free_cluster *cluster,
1254 u64 size, int bitmap),
Josef Bacik3f7de032011-11-10 08:29:20 -05001255
1256 TP_ARGS(block_group, cluster, size, bitmap),
1257
Jeff Mahoneybc074522016-06-09 17:27:55 -04001258 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001259 __field( u64, bg_objectid )
1260 __field( u64, flags )
1261 __field( u64, start )
1262 __field( u64, max_size )
1263 __field( u64, size )
1264 __field( int, bitmap )
1265 ),
1266
Jeff Mahoneybc074522016-06-09 17:27:55 -04001267 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001268 __entry->bg_objectid = block_group->key.objectid;
1269 __entry->flags = block_group->flags;
1270 __entry->start = cluster->window_start;
1271 __entry->max_size = cluster->max_size;
1272 __entry->size = size;
1273 __entry->bitmap = bitmap;
1274 ),
1275
David Sterba5439c7f2018-04-03 21:05:37 +02001276 TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
1277 "size=%llu max_size=%llu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001278 __entry->bg_objectid,
1279 __entry->flags,
1280 __print_flags((unsigned long)__entry->flags, "|",
1281 BTRFS_GROUP_FLAGS), __entry->start,
1282 __entry->size, __entry->max_size, __entry->bitmap)
1283);
1284
Jeff Mahoney143bede2012-03-01 14:56:26 +01001285struct extent_state;
1286TRACE_EVENT(alloc_extent_state,
1287
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001288 TP_PROTO(const struct extent_state *state,
1289 gfp_t mask, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001290
1291 TP_ARGS(state, mask, IP),
1292
1293 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001294 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001295 __field(gfp_t, mask)
1296 __field(unsigned long, ip)
1297 ),
1298
1299 TP_fast_assign(
1300 __entry->state = state,
1301 __entry->mask = mask,
1302 __entry->ip = IP
1303 ),
1304
David Sterba562a7a02017-01-06 15:51:36 +01001305 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001306 show_gfp_flags(__entry->mask), (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001307);
1308
1309TRACE_EVENT(free_extent_state,
1310
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001311 TP_PROTO(const struct extent_state *state, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001312
1313 TP_ARGS(state, IP),
1314
1315 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001316 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001317 __field(unsigned long, ip)
1318 ),
1319
1320 TP_fast_assign(
1321 __entry->state = state,
1322 __entry->ip = IP
1323 ),
1324
David Sterba562a7a02017-01-06 15:51:36 +01001325 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001326 (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001327);
1328
Qu Wenruo52483bc2014-03-06 04:19:50 +00001329DECLARE_EVENT_CLASS(btrfs__work,
1330
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001331 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001332
1333 TP_ARGS(work),
1334
Jeff Mahoneybc074522016-06-09 17:27:55 -04001335 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001336 __field( const void *, work )
1337 __field( const void *, wq )
1338 __field( const void *, func )
1339 __field( const void *, ordered_func )
1340 __field( const void *, ordered_free )
1341 __field( const void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001342 ),
1343
Jeff Mahoneybc074522016-06-09 17:27:55 -04001344 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001345 __entry->work = work;
1346 __entry->wq = work->wq;
1347 __entry->func = work->func;
1348 __entry->ordered_func = work->ordered_func;
1349 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001350 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001351 ),
1352
David Sterba562a7a02017-01-06 15:51:36 +01001353 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1354 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001355 __entry->work, __entry->normal_work, __entry->wq,
1356 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001357);
1358
David Sterbaac0c7cf2017-01-06 14:12:51 +01001359/*
1360 * For situiations when the work is freed, we pass fs_info and a tag that that
1361 * matches address of the work structure so it can be paired with the
1362 * scheduling event.
1363 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001364DECLARE_EVENT_CLASS(btrfs__work__done,
1365
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001366 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001367
David Sterbaac0c7cf2017-01-06 14:12:51 +01001368 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001369
Jeff Mahoneybc074522016-06-09 17:27:55 -04001370 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001371 __field( const void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001372 ),
1373
David Sterbaac0c7cf2017-01-06 14:12:51 +01001374 TP_fast_assign_btrfs(fs_info,
1375 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001376 ),
1377
David Sterbaac0c7cf2017-01-06 14:12:51 +01001378 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001379);
1380
1381DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1382
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001383 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001384
1385 TP_ARGS(work)
1386);
1387
1388DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1389
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001390 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001391
1392 TP_ARGS(work)
1393);
1394
Qu Wenruo52483bc2014-03-06 04:19:50 +00001395DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1396
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001397 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001398
David Sterbaac0c7cf2017-01-06 14:12:51 +01001399 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001400);
1401
1402DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1403
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001404 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001405
1406 TP_ARGS(work)
1407);
1408
Qu Wenruoc3a46892014-03-12 08:05:33 +00001409DECLARE_EVENT_CLASS(btrfs__workqueue,
1410
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001411 TP_PROTO(const struct __btrfs_workqueue *wq,
1412 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001413
1414 TP_ARGS(wq, name, high),
1415
Jeff Mahoneybc074522016-06-09 17:27:55 -04001416 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001417 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001418 __string( name, name )
1419 __field( int , high )
1420 ),
1421
Jeff Mahoneybc074522016-06-09 17:27:55 -04001422 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001423 __entry->wq = wq;
1424 __assign_str(name, name);
1425 __entry->high = high;
1426 ),
1427
David Sterba562a7a02017-01-06 15:51:36 +01001428 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001429 __print_flags(__entry->high, "",
1430 {(WQ_HIGHPRI), "-high"}),
1431 __entry->wq)
1432);
1433
1434DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1435
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001436 TP_PROTO(const struct __btrfs_workqueue *wq,
1437 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001438
1439 TP_ARGS(wq, name, high)
1440);
1441
1442DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1443
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001444 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001445
1446 TP_ARGS(wq),
1447
Jeff Mahoneybc074522016-06-09 17:27:55 -04001448 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001449 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001450 ),
1451
Jeff Mahoneybc074522016-06-09 17:27:55 -04001452 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001453 __entry->wq = wq;
1454 ),
1455
Jeff Mahoneybc074522016-06-09 17:27:55 -04001456 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001457);
1458
1459DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1460
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001461 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001462
1463 TP_ARGS(wq)
1464);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001465
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001466#define BTRFS_QGROUP_OPERATIONS \
1467 { QGROUP_RESERVE, "reserve" }, \
1468 { QGROUP_RELEASE, "release" }, \
1469 { QGROUP_FREE, "free" }
1470
1471DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1472
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001473 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1474 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001475
1476 TP_ARGS(inode, start, len, reserved, op),
1477
Jeff Mahoneybc074522016-06-09 17:27:55 -04001478 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001479 __field( u64, rootid )
David Sterbaf8f8e182018-04-03 20:57:21 +02001480 __field( u64, ino )
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001481 __field( u64, start )
1482 __field( u64, len )
1483 __field( u64, reserved )
1484 __field( int, op )
1485 ),
1486
Jeff Mahoneybc074522016-06-09 17:27:55 -04001487 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001488 __entry->rootid = BTRFS_I(inode)->root->objectid;
David Sterbaf8f8e182018-04-03 20:57:21 +02001489 __entry->ino = btrfs_ino(BTRFS_I(inode));
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001490 __entry->start = start;
1491 __entry->len = len;
1492 __entry->reserved = reserved;
1493 __entry->op = op;
1494 ),
1495
David Sterbaf8f8e182018-04-03 20:57:21 +02001496 TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001497 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1498 __entry->reserved,
1499 __print_flags((unsigned long)__entry->op, "",
1500 BTRFS_QGROUP_OPERATIONS)
1501 )
1502);
1503
1504DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1505
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001506 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1507 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001508
1509 TP_ARGS(inode, start, len, reserved, op)
1510);
1511
1512DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1513
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001514 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1515 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001516
1517 TP_ARGS(inode, start, len, reserved, op)
1518);
1519
1520DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1521
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001522 TP_PROTO(const struct btrfs_fs_info *fs_info,
1523 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001524
Jeff Mahoneybc074522016-06-09 17:27:55 -04001525 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001526
Jeff Mahoneybc074522016-06-09 17:27:55 -04001527 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001528 __field( u64, ref_root )
1529 __field( u64, reserved )
1530 ),
1531
Jeff Mahoneybc074522016-06-09 17:27:55 -04001532 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001533 __entry->ref_root = ref_root;
1534 __entry->reserved = reserved;
1535 ),
1536
David Sterba562a7a02017-01-06 15:51:36 +01001537 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001538 __entry->ref_root, __entry->reserved)
1539);
1540
1541DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1542
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001543 TP_PROTO(const struct btrfs_fs_info *fs_info,
1544 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001545
Jeff Mahoneybc074522016-06-09 17:27:55 -04001546 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001547);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001548
1549DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001550 TP_PROTO(const struct btrfs_fs_info *fs_info,
1551 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001552
Jeff Mahoneybc074522016-06-09 17:27:55 -04001553 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001554
Jeff Mahoneybc074522016-06-09 17:27:55 -04001555 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001556 __field( u64, bytenr )
1557 __field( u64, num_bytes )
1558 ),
1559
Jeff Mahoneybc074522016-06-09 17:27:55 -04001560 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001561 __entry->bytenr = rec->bytenr,
1562 __entry->num_bytes = rec->num_bytes;
1563 ),
1564
David Sterba562a7a02017-01-06 15:51:36 +01001565 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001566 (unsigned long long)__entry->bytenr,
1567 (unsigned long long)__entry->num_bytes)
1568);
1569
1570DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1571
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001572 TP_PROTO(const struct btrfs_fs_info *fs_info,
1573 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001574
Jeff Mahoneybc074522016-06-09 17:27:55 -04001575 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001576);
1577
Qu Wenruo50b3e042016-10-18 09:31:27 +08001578DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001579
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001580 TP_PROTO(const struct btrfs_fs_info *fs_info,
1581 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001582
Jeff Mahoneybc074522016-06-09 17:27:55 -04001583 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001584);
1585
1586TRACE_EVENT(btrfs_qgroup_account_extent,
1587
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001588 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001589 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001590
Jeff Mahoneybc074522016-06-09 17:27:55 -04001591 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001592
Jeff Mahoneybc074522016-06-09 17:27:55 -04001593 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001594 __field( u64, bytenr )
1595 __field( u64, num_bytes )
1596 __field( u64, nr_old_roots )
1597 __field( u64, nr_new_roots )
1598 ),
1599
Jeff Mahoneybc074522016-06-09 17:27:55 -04001600 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001601 __entry->bytenr = bytenr;
1602 __entry->num_bytes = num_bytes;
1603 __entry->nr_old_roots = nr_old_roots;
1604 __entry->nr_new_roots = nr_new_roots;
1605 ),
1606
David Sterba562a7a02017-01-06 15:51:36 +01001607 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1608 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001609 __entry->bytenr,
1610 __entry->num_bytes,
1611 __entry->nr_old_roots,
1612 __entry->nr_new_roots)
1613);
1614
1615TRACE_EVENT(qgroup_update_counters,
1616
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001617 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001618 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001619
Jeff Mahoneybc074522016-06-09 17:27:55 -04001620 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001621
Jeff Mahoneybc074522016-06-09 17:27:55 -04001622 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001623 __field( u64, qgid )
1624 __field( u64, cur_old_count )
1625 __field( u64, cur_new_count )
1626 ),
1627
Jeff Mahoneybc074522016-06-09 17:27:55 -04001628 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001629 __entry->qgid = qgid;
1630 __entry->cur_old_count = cur_old_count;
1631 __entry->cur_new_count = cur_new_count;
1632 ),
1633
David Sterba562a7a02017-01-06 15:51:36 +01001634 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001635 __entry->qgid,
1636 __entry->cur_old_count,
1637 __entry->cur_new_count)
1638);
1639
Qu Wenruo3159fe72017-03-13 15:52:08 +08001640TRACE_EVENT(qgroup_update_reserve,
1641
1642 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001643 s64 diff, int type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001644
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001645 TP_ARGS(fs_info, qgroup, diff, type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001646
1647 TP_STRUCT__entry_btrfs(
1648 __field( u64, qgid )
1649 __field( u64, cur_reserved )
1650 __field( s64, diff )
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001651 __field( int, type )
Qu Wenruo3159fe72017-03-13 15:52:08 +08001652 ),
1653
1654 TP_fast_assign_btrfs(fs_info,
1655 __entry->qgid = qgroup->qgroupid;
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001656 __entry->cur_reserved = qgroup->rsv.values[type];
Qu Wenruo3159fe72017-03-13 15:52:08 +08001657 __entry->diff = diff;
1658 ),
1659
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001660 TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
1661 __entry->qgid, show_qgroup_rsv_type(__entry->type),
1662 __entry->cur_reserved, __entry->diff)
Qu Wenruo3159fe72017-03-13 15:52:08 +08001663);
1664
1665TRACE_EVENT(qgroup_meta_reserve,
1666
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001667 TP_PROTO(struct btrfs_root *root, s64 diff, int type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001668
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001669 TP_ARGS(root, diff, type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001670
1671 TP_STRUCT__entry_btrfs(
1672 __field( u64, refroot )
1673 __field( s64, diff )
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001674 __field( int, type )
Qu Wenruo3159fe72017-03-13 15:52:08 +08001675 ),
1676
1677 TP_fast_assign_btrfs(root->fs_info,
1678 __entry->refroot = root->objectid;
1679 __entry->diff = diff;
1680 ),
1681
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001682 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1683 show_root_type(__entry->refroot),
1684 show_qgroup_rsv_type(__entry->type), __entry->diff)
1685);
1686
1687TRACE_EVENT(qgroup_meta_convert,
1688
1689 TP_PROTO(struct btrfs_root *root, s64 diff),
1690
1691 TP_ARGS(root, diff),
1692
1693 TP_STRUCT__entry_btrfs(
1694 __field( u64, refroot )
1695 __field( s64, diff )
1696 __field( int, type )
1697 ),
1698
1699 TP_fast_assign_btrfs(root->fs_info,
1700 __entry->refroot = root->objectid;
1701 __entry->diff = diff;
1702 ),
1703
1704 TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
1705 show_root_type(__entry->refroot),
1706 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC),
1707 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS),
1708 __entry->diff)
1709);
1710
1711TRACE_EVENT(qgroup_meta_free_all_pertrans,
1712
1713 TP_PROTO(struct btrfs_root *root),
1714
1715 TP_ARGS(root),
1716
1717 TP_STRUCT__entry_btrfs(
1718 __field( u64, refroot )
1719 __field( s64, diff )
1720 __field( int, type )
1721 ),
1722
1723 TP_fast_assign_btrfs(root->fs_info,
1724 __entry->refroot = root->objectid;
1725 spin_lock(&root->qgroup_meta_rsv_lock);
1726 __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans;
1727 spin_unlock(&root->qgroup_meta_rsv_lock);
1728 __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS;
1729 ),
1730
1731 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1732 show_root_type(__entry->refroot),
1733 show_qgroup_rsv_type(__entry->type), __entry->diff)
Qu Wenruo3159fe72017-03-13 15:52:08 +08001734);
1735
Jeff Mahoney00142752017-07-12 16:20:08 -06001736DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1737 TP_PROTO(const struct btrfs_fs_info *fs_info,
1738 const struct prelim_ref *oldref,
1739 const struct prelim_ref *newref, u64 tree_size),
1740 TP_ARGS(fs_info, newref, oldref, tree_size),
1741
1742 TP_STRUCT__entry_btrfs(
1743 __field( u64, root_id )
1744 __field( u64, objectid )
1745 __field( u8, type )
1746 __field( u64, offset )
1747 __field( int, level )
1748 __field( int, old_count )
1749 __field( u64, parent )
1750 __field( u64, bytenr )
1751 __field( int, mod_count )
1752 __field( u64, tree_size )
1753 ),
1754
1755 TP_fast_assign_btrfs(fs_info,
1756 __entry->root_id = oldref->root_id;
1757 __entry->objectid = oldref->key_for_search.objectid;
1758 __entry->type = oldref->key_for_search.type;
1759 __entry->offset = oldref->key_for_search.offset;
1760 __entry->level = oldref->level;
1761 __entry->old_count = oldref->count;
1762 __entry->parent = oldref->parent;
1763 __entry->bytenr = oldref->wanted_disk_byte;
1764 __entry->mod_count = newref ? newref->count : 0;
1765 __entry->tree_size = tree_size;
1766 ),
1767
1768 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 +02001769 __entry->root_id,
1770 __entry->objectid, __entry->type,
1771 __entry->offset, __entry->level,
Jeff Mahoney00142752017-07-12 16:20:08 -06001772 __entry->old_count, __entry->mod_count,
1773 __entry->old_count + __entry->mod_count,
David Sterba8eec8462018-04-03 21:15:11 +02001774 __entry->parent,
1775 __entry->bytenr,
1776 __entry->tree_size)
Jeff Mahoney00142752017-07-12 16:20:08 -06001777);
1778
1779DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1780 TP_PROTO(const struct btrfs_fs_info *fs_info,
1781 const struct prelim_ref *oldref,
1782 const struct prelim_ref *newref, u64 tree_size),
1783 TP_ARGS(fs_info, oldref, newref, tree_size)
1784);
1785
1786DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1787 TP_PROTO(const struct btrfs_fs_info *fs_info,
1788 const struct prelim_ref *oldref,
1789 const struct prelim_ref *newref, u64 tree_size),
1790 TP_ARGS(fs_info, oldref, newref, tree_size)
1791);
1792
Josef Bacikdd48d402017-10-19 14:15:56 -04001793TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
1794 TP_PROTO(struct btrfs_root *root, u64 ino, int mod),
1795
1796 TP_ARGS(root, ino, mod),
1797
1798 TP_STRUCT__entry_btrfs(
1799 __field( u64, root_objectid )
1800 __field( u64, ino )
1801 __field( int, mod )
1802 ),
1803
1804 TP_fast_assign_btrfs(root->fs_info,
1805 __entry->root_objectid = root->objectid;
1806 __entry->ino = ino;
1807 __entry->mod = mod;
1808 ),
1809
1810 TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1811 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +02001812 __entry->ino, __entry->mod)
Josef Bacikdd48d402017-10-19 14:15:56 -04001813);
liubo1abe9b82011-03-24 11:18:59 +00001814#endif /* _TRACE_BTRFS_H */
1815
1816/* This part must be outside protection */
1817#include <trace/define_trace.h>