blob: 880a5c0e0f211bc5c9df8a000898f3c1c4ab2e57 [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;
David Sterba32da53862019-10-29 19:20:18 +010022struct btrfs_block_group;
Josef Bacik3f7de032011-11-10 08:29:20 -050023struct 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;
Qu Wenruoa1d19842019-03-01 10:48:00 +080030struct extent_io_tree;
Jeff Mahoney00142752017-07-12 16:20:08 -060031struct prelim_ref;
Qu Wenruo480b9b42019-04-29 14:03:33 +080032struct btrfs_space_info;
liubo1abe9b82011-03-24 11:18:59 +000033
Anand Jain012e513e2017-08-30 22:36:48 +080034TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
35TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
36TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
37TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
38TRACE_DEFINE_ENUM(ALLOC_CHUNK);
39TRACE_DEFINE_ENUM(COMMIT_TRANS);
40
liubo1abe9b82011-03-24 11:18:59 +000041#define show_ref_type(type) \
42 __print_symbolic(type, \
43 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
44 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
45 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
46 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
47 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
48
49#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080050 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000051 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
52 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
53 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
54 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
55 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
56 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
57 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
58 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000059 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000060 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070061 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
62 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000063 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
64
65#define show_root_type(obj) \
66 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000067 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000068 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000069
Nikolay Borisov5bca2c92020-06-19 15:24:48 +030070#define FLUSH_ACTIONS \
71 EM( BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH") \
72 EM( BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT") \
73 EM( BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL") \
74 EMe(BTRFS_RESERVE_FLUSH_ALL_STEAL, "BTRFS_RESERVE_FLUSH_ALL_STEAL")
75
Nikolay Borisov0840dd22020-06-19 15:24:47 +030076#define FI_TYPES \
77 EM( BTRFS_FILE_EXTENT_INLINE, "INLINE") \
78 EM( BTRFS_FILE_EXTENT_REG, "REG") \
79 EMe(BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC")
80
Nikolay Borisov1cb1f0b2020-06-19 15:24:49 +030081#define QGROUP_RSV_TYPES \
82 EM( BTRFS_QGROUP_RSV_DATA, "DATA") \
83 EM( BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS") \
84 EMe(BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC")
85
Nikolay Borisovc92bb302020-06-19 15:24:50 +030086#define IO_TREE_OWNER \
87 EM( IO_TREE_FS_PINNED_EXTENTS, "PINNED_EXTENTS") \
88 EM( IO_TREE_FS_EXCLUDED_EXTENTS, "EXCLUDED_EXTENTS") \
89 EM( IO_TREE_INODE_IO, "INODE_IO") \
90 EM( IO_TREE_INODE_IO_FAILURE, "INODE_IO_FAILURE") \
91 EM( IO_TREE_RELOC_BLOCKS, "RELOC_BLOCKS") \
92 EM( IO_TREE_TRANS_DIRTY_PAGES, "TRANS_DIRTY_PAGES") \
93 EM( IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES") \
94 EM( IO_TREE_INODE_FILE_EXTENT, "INODE_FILE_EXTENT") \
95 EM( IO_TREE_LOG_CSUM_RANGE, "LOG_CSUM_RANGE") \
96 EMe(IO_TREE_SELFTEST, "SELFTEST")
97
Nikolay Borisov5bca2c92020-06-19 15:24:48 +030098/*
99 * First define the enums in the above macros to be exported to userspace via
100 * TRACE_DEFINE_ENUM().
101 */
102
Nikolay Borisov0840dd22020-06-19 15:24:47 +0300103#undef EM
104#undef EMe
105#define EM(a, b) TRACE_DEFINE_ENUM(a);
106#define EMe(a, b) TRACE_DEFINE_ENUM(a);
107
Nikolay Borisov5bca2c92020-06-19 15:24:48 +0300108FLUSH_ACTIONS
Nikolay Borisov0840dd22020-06-19 15:24:47 +0300109FI_TYPES
Nikolay Borisov1cb1f0b2020-06-19 15:24:49 +0300110QGROUP_RSV_TYPES
Nikolay Borisovc92bb302020-06-19 15:24:50 +0300111IO_TREE_OWNER
Nikolay Borisov0840dd22020-06-19 15:24:47 +0300112
Nikolay Borisov5bca2c92020-06-19 15:24:48 +0300113/*
114 * Now redefine the EM and EMe macros to map the enums to the strings that will
115 * be printed in the output
116 */
117
Nikolay Borisov0840dd22020-06-19 15:24:47 +0300118#undef EM
119#undef EMe
120#define EM(a, b) {a, b},
121#define EMe(a, b) {a, b}
Liu Bo09ed2f12017-03-10 11:09:48 -0800122
Qu Wenruoa1d19842019-03-01 10:48:00 +0800123
Josef Bacik3f7de032011-11-10 08:29:20 -0500124#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +0000125 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
126 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
127 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
128 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
129 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
130 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
131 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
132 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
133 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -0500134
Qu Wenruoa1d19842019-03-01 10:48:00 +0800135#define EXTENT_FLAGS \
136 { EXTENT_DIRTY, "DIRTY"}, \
Qu Wenruoa1d19842019-03-01 10:48:00 +0800137 { EXTENT_UPTODATE, "UPTODATE"}, \
138 { EXTENT_LOCKED, "LOCKED"}, \
139 { EXTENT_NEW, "NEW"}, \
140 { EXTENT_DELALLOC, "DELALLOC"}, \
141 { EXTENT_DEFRAG, "DEFRAG"}, \
142 { EXTENT_BOUNDARY, "BOUNDARY"}, \
143 { EXTENT_NODATASUM, "NODATASUM"}, \
144 { EXTENT_CLEAR_META_RESV, "CLEAR_META_RESV"}, \
145 { EXTENT_NEED_WAIT, "NEED_WAIT"}, \
146 { EXTENT_DAMAGED, "DAMAGED"}, \
147 { EXTENT_NORESERVE, "NORESERVE"}, \
148 { EXTENT_QGROUP_RESERVED, "QGROUP_RESERVED"}, \
149 { EXTENT_CLEAR_DATA_RESV, "CLEAR_DATA_RESV"}, \
150 { EXTENT_DELALLOC_NEW, "DELALLOC_NEW"}
151
Anand Jainb94417e2017-08-13 11:58:30 +0800152#define BTRFS_FSID_SIZE 16
153#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
Jeff Mahoneybc074522016-06-09 17:27:55 -0400154
155#define TP_fast_assign_fsid(fs_info) \
Qu Wenruoa1d19842019-03-01 10:48:00 +0800156({ \
157 if (fs_info) \
158 memcpy(__entry->fsid, fs_info->fs_devices->fsid, \
159 BTRFS_FSID_SIZE); \
160 else \
161 memset(__entry->fsid, 0, BTRFS_FSID_SIZE); \
162})
Jeff Mahoneybc074522016-06-09 17:27:55 -0400163
164#define TP_STRUCT__entry_btrfs(args...) \
165 TP_STRUCT__entry( \
166 TP_STRUCT__entry_fsid \
167 args)
168#define TP_fast_assign_btrfs(fs_info, args...) \
169 TP_fast_assign( \
170 TP_fast_assign_fsid(fs_info); \
171 args)
172#define TP_printk_btrfs(fmt, args...) \
173 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500174
liubo1abe9b82011-03-24 11:18:59 +0000175TRACE_EVENT(btrfs_transaction_commit,
176
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600177 TP_PROTO(const struct btrfs_root *root),
liubo1abe9b82011-03-24 11:18:59 +0000178
179 TP_ARGS(root),
180
Jeff Mahoneybc074522016-06-09 17:27:55 -0400181 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000182 __field( u64, generation )
183 __field( u64, root_objectid )
184 ),
185
Jeff Mahoneybc074522016-06-09 17:27:55 -0400186 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000187 __entry->generation = root->fs_info->generation;
188 __entry->root_objectid = root->root_key.objectid;
189 ),
190
David Sterba79bcb712018-04-03 21:21:17 +0200191 TP_printk_btrfs("root=%llu(%s) gen=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000192 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200193 __entry->generation)
liubo1abe9b82011-03-24 11:18:59 +0000194);
195
196DECLARE_EVENT_CLASS(btrfs__inode,
197
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600198 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000199
200 TP_ARGS(inode),
201
Jeff Mahoneybc074522016-06-09 17:27:55 -0400202 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200203 __field( u64, ino )
David Sterba94c3f6c2019-10-17 13:28:55 +0200204 __field( u64, blocks )
liubo1abe9b82011-03-24 11:18:59 +0000205 __field( u64, disk_i_size )
206 __field( u64, generation )
207 __field( u64, last_trans )
208 __field( u64, logged_trans )
209 __field( u64, root_objectid )
210 ),
211
Jeff Mahoneybc074522016-06-09 17:27:55 -0400212 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200213 __entry->ino = btrfs_ino(BTRFS_I(inode));
liubo1abe9b82011-03-24 11:18:59 +0000214 __entry->blocks = inode->i_blocks;
215 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
216 __entry->generation = BTRFS_I(inode)->generation;
217 __entry->last_trans = BTRFS_I(inode)->last_trans;
218 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
219 __entry->root_objectid =
220 BTRFS_I(inode)->root->root_key.objectid;
221 ),
222
David Sterbaf8f8e182018-04-03 20:57:21 +0200223 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
David Sterba562a7a02017-01-06 15:51:36 +0100224 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000225 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200226 __entry->generation,
227 __entry->ino,
David Sterba94c3f6c2019-10-17 13:28:55 +0200228 __entry->blocks,
David Sterba8eec8462018-04-03 21:15:11 +0200229 __entry->disk_i_size,
230 __entry->last_trans,
231 __entry->logged_trans)
liubo1abe9b82011-03-24 11:18:59 +0000232);
233
234DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
235
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600236 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000237
238 TP_ARGS(inode)
239);
240
241DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
242
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600243 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000244
245 TP_ARGS(inode)
246);
247
248DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
249
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600250 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000251
252 TP_ARGS(inode)
253);
254
255#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800256 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000257 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
258 { EXTENT_MAP_HOLE, "HOLE" }, \
259 { EXTENT_MAP_INLINE, "INLINE" }, \
260 { EXTENT_MAP_DELALLOC, "DELALLOC" })
261
262#define show_map_type(type) \
263 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
264
265#define show_map_flags(flag) \
266 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800267 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
268 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
Liu Bo254a2d12014-09-17 21:36:41 +0800269 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
270 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
271 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
272 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000273
Steven Rostedt4cd85872013-11-14 22:57:29 -0500274TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000275
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600276 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
277 const struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000278
Liu Bo92a1bf72016-11-17 15:00:50 -0800279 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000280
Steven Rostedt4cd85872013-11-14 22:57:29 -0500281 TP_CONDITION(map),
282
Jeff Mahoneybc074522016-06-09 17:27:55 -0400283 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000284 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800285 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000286 __field( u64, start )
287 __field( u64, len )
288 __field( u64, orig_start )
289 __field( u64, block_start )
290 __field( u64, block_len )
291 __field( unsigned long, flags )
292 __field( int, refs )
293 __field( unsigned int, compress_type )
294 ),
295
Jeff Mahoneybc074522016-06-09 17:27:55 -0400296 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000297 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800298 __entry->ino = btrfs_ino(inode);
299 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000300 __entry->len = map->len;
301 __entry->orig_start = map->orig_start;
302 __entry->block_start = map->block_start;
303 __entry->block_len = map->block_len;
304 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200305 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000306 __entry->compress_type = map->compress_type;
307 ),
308
David Sterba562a7a02017-01-06 15:51:36 +0100309 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
310 "orig_start=%llu block_start=%llu(%s) "
311 "block_len=%llu flags=%s refs=%u "
312 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000313 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200314 __entry->ino,
315 __entry->start,
316 __entry->len,
317 __entry->orig_start,
liubo1abe9b82011-03-24 11:18:59 +0000318 show_map_type(__entry->block_start),
David Sterba8eec8462018-04-03 21:15:11 +0200319 __entry->block_len,
liubo1abe9b82011-03-24 11:18:59 +0000320 show_map_flags(__entry->flags),
321 __entry->refs, __entry->compress_type)
322);
323
Liu Bo393da912018-01-05 12:51:16 -0700324TRACE_EVENT(btrfs_handle_em_exist,
325
David Sterba1d2e7c72019-10-17 13:28:57 +0200326 TP_PROTO(const struct btrfs_fs_info *fs_info,
David Sterbaf46b24c2018-04-03 21:45:57 +0200327 const struct extent_map *existing, const struct extent_map *map,
328 u64 start, u64 len),
Liu Bo393da912018-01-05 12:51:16 -0700329
David Sterbaf46b24c2018-04-03 21:45:57 +0200330 TP_ARGS(fs_info, existing, map, start, len),
Liu Bo393da912018-01-05 12:51:16 -0700331
David Sterbaf46b24c2018-04-03 21:45:57 +0200332 TP_STRUCT__entry_btrfs(
Liu Bo393da912018-01-05 12:51:16 -0700333 __field( u64, e_start )
334 __field( u64, e_len )
335 __field( u64, map_start )
336 __field( u64, map_len )
337 __field( u64, start )
338 __field( u64, len )
339 ),
340
David Sterbaf46b24c2018-04-03 21:45:57 +0200341 TP_fast_assign_btrfs(fs_info,
Liu Bo393da912018-01-05 12:51:16 -0700342 __entry->e_start = existing->start;
343 __entry->e_len = existing->len;
344 __entry->map_start = map->start;
345 __entry->map_len = map->len;
346 __entry->start = start;
347 __entry->len = len;
348 ),
349
David Sterbaf46b24c2018-04-03 21:45:57 +0200350 TP_printk_btrfs("start=%llu len=%llu "
Liu Bo393da912018-01-05 12:51:16 -0700351 "existing(start=%llu len=%llu) "
352 "em(start=%llu len=%llu)",
David Sterba8eec8462018-04-03 21:15:11 +0200353 __entry->start,
354 __entry->len,
355 __entry->e_start,
356 __entry->e_len,
357 __entry->map_start,
358 __entry->map_len)
Liu Bo393da912018-01-05 12:51:16 -0700359);
360
Liu Bo09ed2f12017-03-10 11:09:48 -0800361/* file extent item */
362DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
363
David Sterba1d2e7c72019-10-17 13:28:57 +0200364 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
365 const struct btrfs_file_extent_item *fi, u64 start),
Liu Bo09ed2f12017-03-10 11:09:48 -0800366
367 TP_ARGS(bi, l, fi, start),
368
369 TP_STRUCT__entry_btrfs(
370 __field( u64, root_obj )
371 __field( u64, ino )
372 __field( loff_t, isize )
373 __field( u64, disk_isize )
374 __field( u64, num_bytes )
375 __field( u64, ram_bytes )
376 __field( u64, disk_bytenr )
377 __field( u64, disk_num_bytes )
378 __field( u64, extent_offset )
379 __field( u8, extent_type )
380 __field( u8, compression )
381 __field( u64, extent_start )
382 __field( u64, extent_end )
383 ),
384
385 TP_fast_assign_btrfs(bi->root->fs_info,
Misono Tomohiro4fd786e2018-08-06 14:25:24 +0900386 __entry->root_obj = bi->root->root_key.objectid;
Liu Bo09ed2f12017-03-10 11:09:48 -0800387 __entry->ino = btrfs_ino(bi);
388 __entry->isize = bi->vfs_inode.i_size;
389 __entry->disk_isize = bi->disk_i_size;
390 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
391 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
392 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
393 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
394 __entry->extent_offset = btrfs_file_extent_offset(l, fi);
395 __entry->extent_type = btrfs_file_extent_type(l, fi);
396 __entry->compression = btrfs_file_extent_compression(l, fi);
397 __entry->extent_start = start;
398 __entry->extent_end = (start + __entry->num_bytes);
399 ),
400
401 TP_printk_btrfs(
402 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
403 "file extent range=[%llu %llu] "
404 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
405 "disk_num_bytes=%llu extent_offset=%llu type=%s "
406 "compression=%u",
407 show_root_type(__entry->root_obj), __entry->ino,
408 __entry->isize,
409 __entry->disk_isize, __entry->extent_start,
410 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
411 __entry->disk_bytenr, __entry->disk_num_bytes,
Nikolay Borisov0840dd22020-06-19 15:24:47 +0300412 __entry->extent_offset, __print_symbolic(__entry->extent_type, FI_TYPES),
Liu Bo09ed2f12017-03-10 11:09:48 -0800413 __entry->compression)
414);
415
416DECLARE_EVENT_CLASS(
417 btrfs__file_extent_item_inline,
418
David Sterba1d2e7c72019-10-17 13:28:57 +0200419 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
420 const struct btrfs_file_extent_item *fi, int slot, u64 start),
Liu Bo09ed2f12017-03-10 11:09:48 -0800421
422 TP_ARGS(bi, l, fi, slot, start),
423
424 TP_STRUCT__entry_btrfs(
425 __field( u64, root_obj )
426 __field( u64, ino )
427 __field( loff_t, isize )
428 __field( u64, disk_isize )
429 __field( u8, extent_type )
430 __field( u8, compression )
431 __field( u64, extent_start )
432 __field( u64, extent_end )
433 ),
434
435 TP_fast_assign_btrfs(
436 bi->root->fs_info,
Misono Tomohiro4fd786e2018-08-06 14:25:24 +0900437 __entry->root_obj = bi->root->root_key.objectid;
Liu Bo09ed2f12017-03-10 11:09:48 -0800438 __entry->ino = btrfs_ino(bi);
439 __entry->isize = bi->vfs_inode.i_size;
440 __entry->disk_isize = bi->disk_i_size;
441 __entry->extent_type = btrfs_file_extent_type(l, fi);
442 __entry->compression = btrfs_file_extent_compression(l, fi);
443 __entry->extent_start = start;
Qu Wenruoe41ca582018-06-06 15:41:49 +0800444 __entry->extent_end = (start + btrfs_file_extent_ram_bytes(l, fi));
Liu Bo09ed2f12017-03-10 11:09:48 -0800445 ),
446
447 TP_printk_btrfs(
448 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
449 "file extent range=[%llu %llu] "
450 "extent_type=%s compression=%u",
451 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
452 __entry->disk_isize, __entry->extent_start,
Nikolay Borisov0840dd22020-06-19 15:24:47 +0300453 __entry->extent_end, __print_symbolic(__entry->extent_type, FI_TYPES),
Liu Bo09ed2f12017-03-10 11:09:48 -0800454 __entry->compression)
455);
456
457DEFINE_EVENT(
458 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
459
David Sterba1d2e7c72019-10-17 13:28:57 +0200460 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
461 const struct btrfs_file_extent_item *fi, u64 start),
Liu Bo09ed2f12017-03-10 11:09:48 -0800462
463 TP_ARGS(bi, l, fi, start)
464);
465
466DEFINE_EVENT(
467 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
468
David Sterba1d2e7c72019-10-17 13:28:57 +0200469 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
470 const struct btrfs_file_extent_item *fi, u64 start),
Liu Bo09ed2f12017-03-10 11:09:48 -0800471
472 TP_ARGS(bi, l, fi, start)
473);
474
475DEFINE_EVENT(
476 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
477
David Sterba1d2e7c72019-10-17 13:28:57 +0200478 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
479 const struct btrfs_file_extent_item *fi, int slot, u64 start),
Liu Bo09ed2f12017-03-10 11:09:48 -0800480
481 TP_ARGS(bi, l, fi, slot, start)
482);
483
484DEFINE_EVENT(
485 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
486
David Sterba1d2e7c72019-10-17 13:28:57 +0200487 TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
488 const struct btrfs_file_extent_item *fi, int slot, u64 start),
Liu Bo09ed2f12017-03-10 11:09:48 -0800489
490 TP_ARGS(bi, l, fi, slot, start)
491);
492
Liu Bo9d04a8c2013-11-06 12:04:13 +0800493#define show_ordered_flags(flags) \
494 __print_flags(flags, "|", \
495 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
496 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
497 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
498 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
499 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
500 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
501 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800502 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000503
liubo1abe9b82011-03-24 11:18:59 +0000504
505DECLARE_EVENT_CLASS(btrfs__ordered_extent,
506
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600507 TP_PROTO(const struct inode *inode,
508 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000509
510 TP_ARGS(inode, ordered),
511
Jeff Mahoneybc074522016-06-09 17:27:55 -0400512 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200513 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000514 __field( u64, file_offset )
515 __field( u64, start )
516 __field( u64, len )
517 __field( u64, disk_len )
518 __field( u64, bytes_left )
519 __field( unsigned long, flags )
520 __field( int, compress_type )
521 __field( int, refs )
522 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800523 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000524 ),
525
Jeff Mahoneybc074522016-06-09 17:27:55 -0400526 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200527 __entry->ino = btrfs_ino(BTRFS_I(inode));
liubo1abe9b82011-03-24 11:18:59 +0000528 __entry->file_offset = ordered->file_offset;
Omar Sandovalbffe6332019-12-02 17:34:19 -0800529 __entry->start = ordered->disk_bytenr;
530 __entry->len = ordered->num_bytes;
531 __entry->disk_len = ordered->disk_num_bytes;
liubo1abe9b82011-03-24 11:18:59 +0000532 __entry->bytes_left = ordered->bytes_left;
533 __entry->flags = ordered->flags;
534 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200535 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000536 __entry->root_objectid =
537 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800538 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000539 ),
540
David Sterba562a7a02017-01-06 15:51:36 +0100541 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
542 "start=%llu len=%llu disk_len=%llu "
543 "truncated_len=%llu "
544 "bytes_left=%llu flags=%s compress_type=%d "
545 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000546 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200547 __entry->ino,
548 __entry->file_offset,
549 __entry->start,
550 __entry->len,
551 __entry->disk_len,
552 __entry->truncated_len,
553 __entry->bytes_left,
liubo1abe9b82011-03-24 11:18:59 +0000554 show_ordered_flags(__entry->flags),
555 __entry->compress_type, __entry->refs)
556);
557
558DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
559
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600560 TP_PROTO(const struct inode *inode,
561 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000562
563 TP_ARGS(inode, ordered)
564);
565
566DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
567
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600568 TP_PROTO(const struct inode *inode,
569 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000570
571 TP_ARGS(inode, ordered)
572);
573
574DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
575
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600576 TP_PROTO(const struct inode *inode,
577 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000578
579 TP_ARGS(inode, ordered)
580);
581
582DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
583
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600584 TP_PROTO(const struct inode *inode,
585 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000586
587 TP_ARGS(inode, ordered)
588);
589
590DECLARE_EVENT_CLASS(btrfs__writepage,
591
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600592 TP_PROTO(const struct page *page, const struct inode *inode,
593 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000594
595 TP_ARGS(page, inode, wbc),
596
Jeff Mahoneybc074522016-06-09 17:27:55 -0400597 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200598 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000599 __field( pgoff_t, index )
600 __field( long, nr_to_write )
601 __field( long, pages_skipped )
602 __field( loff_t, range_start )
603 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000604 __field( char, for_kupdate )
605 __field( char, for_reclaim )
606 __field( char, range_cyclic )
David Sterba94c3f6c2019-10-17 13:28:55 +0200607 __field( unsigned long, writeback_index )
liubo1abe9b82011-03-24 11:18:59 +0000608 __field( u64, root_objectid )
609 ),
610
Jeff Mahoneybc074522016-06-09 17:27:55 -0400611 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200612 __entry->ino = btrfs_ino(BTRFS_I(inode));
liubo1abe9b82011-03-24 11:18:59 +0000613 __entry->index = page->index;
614 __entry->nr_to_write = wbc->nr_to_write;
615 __entry->pages_skipped = wbc->pages_skipped;
616 __entry->range_start = wbc->range_start;
617 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000618 __entry->for_kupdate = wbc->for_kupdate;
619 __entry->for_reclaim = wbc->for_reclaim;
620 __entry->range_cyclic = wbc->range_cyclic;
621 __entry->writeback_index = inode->i_mapping->writeback_index;
622 __entry->root_objectid =
623 BTRFS_I(inode)->root->root_key.objectid;
624 ),
625
David Sterbaf8f8e182018-04-03 20:57:21 +0200626 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
David Sterba562a7a02017-01-06 15:51:36 +0100627 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
628 "range_end=%llu for_kupdate=%d "
629 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000630 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200631 __entry->ino, __entry->index,
liubo1abe9b82011-03-24 11:18:59 +0000632 __entry->nr_to_write, __entry->pages_skipped,
633 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600634 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000635 __entry->for_reclaim, __entry->range_cyclic,
David Sterba94c3f6c2019-10-17 13:28:55 +0200636 __entry->writeback_index)
liubo1abe9b82011-03-24 11:18:59 +0000637);
638
639DEFINE_EVENT(btrfs__writepage, __extent_writepage,
640
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600641 TP_PROTO(const struct page *page, const struct inode *inode,
642 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000643
644 TP_ARGS(page, inode, wbc)
645);
646
647TRACE_EVENT(btrfs_writepage_end_io_hook,
648
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600649 TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
liubo1abe9b82011-03-24 11:18:59 +0000650
651 TP_ARGS(page, start, end, uptodate),
652
Jeff Mahoneybc074522016-06-09 17:27:55 -0400653 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200654 __field( u64, ino )
David Sterba94c3f6c2019-10-17 13:28:55 +0200655 __field( unsigned long, index )
liubo1abe9b82011-03-24 11:18:59 +0000656 __field( u64, start )
657 __field( u64, end )
658 __field( int, uptodate )
659 __field( u64, root_objectid )
660 ),
661
Jeff Mahoneybc074522016-06-09 17:27:55 -0400662 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
David Sterbaf8f8e182018-04-03 20:57:21 +0200663 __entry->ino = btrfs_ino(BTRFS_I(page->mapping->host));
liubo1abe9b82011-03-24 11:18:59 +0000664 __entry->index = page->index;
665 __entry->start = start;
666 __entry->end = end;
667 __entry->uptodate = uptodate;
668 __entry->root_objectid =
669 BTRFS_I(page->mapping->host)->root->root_key.objectid;
670 ),
671
David Sterbaf8f8e182018-04-03 20:57:21 +0200672 TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu "
David Sterba562a7a02017-01-06 15:51:36 +0100673 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000674 show_root_type(__entry->root_objectid),
David Sterba94c3f6c2019-10-17 13:28:55 +0200675 __entry->ino, __entry->index,
David Sterba8eec8462018-04-03 21:15:11 +0200676 __entry->start,
677 __entry->end, __entry->uptodate)
liubo1abe9b82011-03-24 11:18:59 +0000678);
679
680TRACE_EVENT(btrfs_sync_file,
681
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600682 TP_PROTO(const struct file *file, int datasync),
liubo1abe9b82011-03-24 11:18:59 +0000683
684 TP_ARGS(file, datasync),
685
Jeff Mahoneybc074522016-06-09 17:27:55 -0400686 TP_STRUCT__entry_btrfs(
David Sterbaf8f8e182018-04-03 20:57:21 +0200687 __field( u64, ino )
688 __field( u64, parent )
liubo1abe9b82011-03-24 11:18:59 +0000689 __field( int, datasync )
690 __field( u64, root_objectid )
691 ),
692
693 TP_fast_assign(
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600694 const struct dentry *dentry = file->f_path.dentry;
695 const struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000696
Jeff Mahoneybc074522016-06-09 17:27:55 -0400697 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
David Sterbaf8f8e182018-04-03 20:57:21 +0200698 __entry->ino = btrfs_ino(BTRFS_I(inode));
699 __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
liubo1abe9b82011-03-24 11:18:59 +0000700 __entry->datasync = datasync;
701 __entry->root_objectid =
702 BTRFS_I(inode)->root->root_key.objectid;
703 ),
704
David Sterbaf8f8e182018-04-03 20:57:21 +0200705 TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000706 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200707 __entry->ino,
708 __entry->parent,
liubo1abe9b82011-03-24 11:18:59 +0000709 __entry->datasync)
710);
711
712TRACE_EVENT(btrfs_sync_fs,
713
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600714 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000715
Jeff Mahoneybc074522016-06-09 17:27:55 -0400716 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000717
Jeff Mahoneybc074522016-06-09 17:27:55 -0400718 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000719 __field( int, wait )
720 ),
721
Jeff Mahoneybc074522016-06-09 17:27:55 -0400722 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000723 __entry->wait = wait;
724 ),
725
David Sterba79bcb712018-04-03 21:21:17 +0200726 TP_printk_btrfs("wait=%d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000727);
728
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400729TRACE_EVENT(btrfs_add_block_group,
730
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600731 TP_PROTO(const struct btrfs_fs_info *fs_info,
David Sterba32da53862019-10-29 19:20:18 +0100732 const struct btrfs_block_group *block_group, int create),
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400733
734 TP_ARGS(fs_info, block_group, create),
735
David Sterba2e63e622018-04-03 21:34:06 +0200736 TP_STRUCT__entry_btrfs(
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400737 __field( u64, offset )
738 __field( u64, size )
739 __field( u64, flags )
740 __field( u64, bytes_used )
741 __field( u64, bytes_super )
742 __field( int, create )
743 ),
744
David Sterba2e63e622018-04-03 21:34:06 +0200745 TP_fast_assign_btrfs(fs_info,
David Sterbab3470b52019-10-23 18:48:22 +0200746 __entry->offset = block_group->start;
747 __entry->size = block_group->length;
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400748 __entry->flags = block_group->flags;
David Sterbabf38be62019-10-23 18:48:11 +0200749 __entry->bytes_used = block_group->used;
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400750 __entry->bytes_super = block_group->bytes_super;
751 __entry->create = create;
752 ),
753
David Sterba2e63e622018-04-03 21:34:06 +0200754 TP_printk_btrfs("block_group offset=%llu size=%llu "
David Sterba562a7a02017-01-06 15:51:36 +0100755 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
David Sterba2e63e622018-04-03 21:34:06 +0200756 "create=%d",
David Sterba8eec8462018-04-03 21:15:11 +0200757 __entry->offset,
758 __entry->size,
759 __entry->flags,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400760 __print_flags((unsigned long)__entry->flags, "|",
761 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +0200762 __entry->bytes_used,
763 __entry->bytes_super, __entry->create)
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400764);
765
liubo1abe9b82011-03-24 11:18:59 +0000766#define show_ref_action(action) \
767 __print_symbolic(action, \
768 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
769 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
770 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
771 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
772
773
Liu Bo599c75e2013-07-16 19:03:36 +0800774DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000775
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600776 TP_PROTO(const struct btrfs_fs_info *fs_info,
777 const struct btrfs_delayed_ref_node *ref,
778 const struct btrfs_delayed_tree_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000779 int action),
780
Jeff Mahoneybc074522016-06-09 17:27:55 -0400781 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000782
Jeff Mahoneybc074522016-06-09 17:27:55 -0400783 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000784 __field( u64, bytenr )
785 __field( u64, num_bytes )
786 __field( int, action )
787 __field( u64, parent )
788 __field( u64, ref_root )
789 __field( int, level )
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->level = full_ref->level;
801 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600802 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000803 ),
804
David Sterba562a7a02017-01-06 15:51:36 +0100805 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
806 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
807 "type=%s seq=%llu",
David Sterba8eec8462018-04-03 21:15:11 +0200808 __entry->bytenr,
809 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000810 show_ref_action(__entry->action),
811 show_root_type(__entry->parent),
812 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600813 __entry->level, show_ref_type(__entry->type),
David Sterba8eec8462018-04-03 21:15:11 +0200814 __entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000815);
816
Liu Bo599c75e2013-07-16 19:03:36 +0800817DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
818
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600819 TP_PROTO(const struct btrfs_fs_info *fs_info,
820 const struct btrfs_delayed_ref_node *ref,
821 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800822 int action),
823
Jeff Mahoneybc074522016-06-09 17:27:55 -0400824 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800825);
826
827DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
828
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600829 TP_PROTO(const struct btrfs_fs_info *fs_info,
830 const struct btrfs_delayed_ref_node *ref,
831 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800832 int action),
833
Jeff Mahoneybc074522016-06-09 17:27:55 -0400834 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800835);
836
837DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000838
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600839 TP_PROTO(const struct btrfs_fs_info *fs_info,
840 const struct btrfs_delayed_ref_node *ref,
841 const struct btrfs_delayed_data_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000842 int action),
843
Jeff Mahoneybc074522016-06-09 17:27:55 -0400844 TP_ARGS(fs_info, ref, full_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( u64, parent )
851 __field( u64, ref_root )
852 __field( u64, owner )
853 __field( u64, offset )
854 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600855 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000856 ),
857
Jeff Mahoneybc074522016-06-09 17:27:55 -0400858 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000859 __entry->bytenr = ref->bytenr;
860 __entry->num_bytes = ref->num_bytes;
861 __entry->action = action;
862 __entry->parent = full_ref->parent;
863 __entry->ref_root = full_ref->root;
864 __entry->owner = full_ref->objectid;
865 __entry->offset = full_ref->offset;
866 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600867 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000868 ),
869
David Sterba562a7a02017-01-06 15:51:36 +0100870 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
871 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
872 "offset=%llu type=%s seq=%llu",
David Sterba8eec8462018-04-03 21:15:11 +0200873 __entry->bytenr,
874 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000875 show_ref_action(__entry->action),
876 show_root_type(__entry->parent),
877 show_root_type(__entry->ref_root),
David Sterba8eec8462018-04-03 21:15:11 +0200878 __entry->owner,
879 __entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600880 show_ref_type(__entry->type),
David Sterba8eec8462018-04-03 21:15:11 +0200881 __entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000882);
883
Liu Bo599c75e2013-07-16 19:03:36 +0800884DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
885
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600886 TP_PROTO(const struct btrfs_fs_info *fs_info,
887 const struct btrfs_delayed_ref_node *ref,
888 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800889 int action),
890
Jeff Mahoneybc074522016-06-09 17:27:55 -0400891 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800892);
893
894DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
895
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600896 TP_PROTO(const struct btrfs_fs_info *fs_info,
897 const struct btrfs_delayed_ref_node *ref,
898 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800899 int action),
900
Jeff Mahoneybc074522016-06-09 17:27:55 -0400901 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800902);
903
904DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000905
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600906 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600907 const struct btrfs_delayed_ref_head *head_ref,
liubo1abe9b82011-03-24 11:18:59 +0000908 int action),
909
Josef Bacikd2788502017-09-29 15:43:57 -0400910 TP_ARGS(fs_info, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000911
Jeff Mahoneybc074522016-06-09 17:27:55 -0400912 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000913 __field( u64, bytenr )
914 __field( u64, num_bytes )
915 __field( int, action )
916 __field( int, is_data )
917 ),
918
Jeff Mahoneybc074522016-06-09 17:27:55 -0400919 TP_fast_assign_btrfs(fs_info,
Josef Bacikd2788502017-09-29 15:43:57 -0400920 __entry->bytenr = head_ref->bytenr;
921 __entry->num_bytes = head_ref->num_bytes;
liubo1abe9b82011-03-24 11:18:59 +0000922 __entry->action = action;
923 __entry->is_data = head_ref->is_data;
924 ),
925
David Sterba562a7a02017-01-06 15:51:36 +0100926 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
David Sterba8eec8462018-04-03 21:15:11 +0200927 __entry->bytenr,
928 __entry->num_bytes,
liubo1abe9b82011-03-24 11:18:59 +0000929 show_ref_action(__entry->action),
930 __entry->is_data)
931);
932
Liu Bo599c75e2013-07-16 19:03:36 +0800933DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
934
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600935 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600936 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800937 int action),
938
Josef Bacikd2788502017-09-29 15:43:57 -0400939 TP_ARGS(fs_info, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800940);
941
942DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
943
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600944 TP_PROTO(const struct btrfs_fs_info *fs_info,
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600945 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800946 int action),
947
Josef Bacikd2788502017-09-29 15:43:57 -0400948 TP_ARGS(fs_info, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800949);
950
liubo1abe9b82011-03-24 11:18:59 +0000951#define show_chunk_type(type) \
952 __print_flags(type, "|", \
953 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
954 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
955 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
956 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
957 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
958 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000959 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
960 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
961 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000962
963DECLARE_EVENT_CLASS(btrfs__chunk,
964
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600965 TP_PROTO(const struct btrfs_fs_info *fs_info,
966 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000967
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400968 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000969
Jeff Mahoneybc074522016-06-09 17:27:55 -0400970 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000971 __field( int, num_stripes )
972 __field( u64, type )
973 __field( int, sub_stripes )
974 __field( u64, offset )
975 __field( u64, size )
976 __field( u64, root_objectid )
977 ),
978
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400979 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000980 __entry->num_stripes = map->num_stripes;
981 __entry->type = map->type;
982 __entry->sub_stripes = map->sub_stripes;
983 __entry->offset = offset;
984 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400985 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000986 ),
987
David Sterba562a7a02017-01-06 15:51:36 +0100988 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
989 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000990 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +0200991 __entry->offset,
992 __entry->size,
liubo1abe9b82011-03-24 11:18:59 +0000993 __entry->num_stripes, __entry->sub_stripes,
994 show_chunk_type(__entry->type))
995);
996
997DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
998
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600999 TP_PROTO(const struct btrfs_fs_info *fs_info,
1000 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +00001001
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -04001002 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +00001003);
1004
1005DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
1006
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001007 TP_PROTO(const struct btrfs_fs_info *fs_info,
1008 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +00001009
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -04001010 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +00001011);
1012
1013TRACE_EVENT(btrfs_cow_block,
1014
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001015 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
1016 const struct extent_buffer *cow),
liubo1abe9b82011-03-24 11:18:59 +00001017
1018 TP_ARGS(root, buf, cow),
1019
Jeff Mahoneybc074522016-06-09 17:27:55 -04001020 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +00001021 __field( u64, root_objectid )
1022 __field( u64, buf_start )
1023 __field( int, refs )
1024 __field( u64, cow_start )
1025 __field( int, buf_level )
1026 __field( int, cow_level )
1027 ),
1028
Jeff Mahoneybc074522016-06-09 17:27:55 -04001029 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001030 __entry->root_objectid = root->root_key.objectid;
1031 __entry->buf_start = buf->start;
1032 __entry->refs = atomic_read(&buf->refs);
1033 __entry->cow_start = cow->start;
1034 __entry->buf_level = btrfs_header_level(buf);
1035 __entry->cow_level = btrfs_header_level(cow);
1036 ),
1037
David Sterba562a7a02017-01-06 15:51:36 +01001038 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
1039 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +00001040 show_root_type(__entry->root_objectid),
1041 __entry->refs,
David Sterba8eec8462018-04-03 21:15:11 +02001042 __entry->buf_start,
liubo1abe9b82011-03-24 11:18:59 +00001043 __entry->buf_level,
David Sterba8eec8462018-04-03 21:15:11 +02001044 __entry->cow_start,
liubo1abe9b82011-03-24 11:18:59 +00001045 __entry->cow_level)
1046);
1047
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001048TRACE_EVENT(btrfs_space_reservation,
1049
David Sterba1d2e7c72019-10-17 13:28:57 +02001050 TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001051 u64 bytes, int reserve),
1052
1053 TP_ARGS(fs_info, type, val, bytes, reserve),
1054
Jeff Mahoneybc074522016-06-09 17:27:55 -04001055 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001056 __string( type, type )
1057 __field( u64, val )
1058 __field( u64, bytes )
1059 __field( int, reserve )
1060 ),
1061
Jeff Mahoneybc074522016-06-09 17:27:55 -04001062 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001063 __assign_str(type, type);
1064 __entry->val = val;
1065 __entry->bytes = bytes;
1066 __entry->reserve = reserve;
1067 ),
1068
David Sterba5439c7f2018-04-03 21:05:37 +02001069 TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001070 __entry->reserve ? "reserve" : "release",
1071 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -05001072);
1073
Josef Bacikf376df22016-03-25 13:25:56 -04001074TRACE_EVENT(btrfs_trigger_flush,
1075
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001076 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
David Sterba1d2e7c72019-10-17 13:28:57 +02001077 int flush, const char *reason),
Josef Bacikf376df22016-03-25 13:25:56 -04001078
1079 TP_ARGS(fs_info, flags, bytes, flush, reason),
1080
David Sterba2e63e622018-04-03 21:34:06 +02001081 TP_STRUCT__entry_btrfs(
Josef Bacikf376df22016-03-25 13:25:56 -04001082 __field( u64, flags )
1083 __field( u64, bytes )
1084 __field( int, flush )
1085 __string( reason, reason )
1086 ),
1087
David Sterba2e63e622018-04-03 21:34:06 +02001088 TP_fast_assign_btrfs(fs_info,
Josef Bacikf376df22016-03-25 13:25:56 -04001089 __entry->flags = flags;
1090 __entry->bytes = bytes;
1091 __entry->flush = flush;
1092 __assign_str(reason, reason)
1093 ),
1094
David Sterba2e63e622018-04-03 21:34:06 +02001095 TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
1096 __get_str(reason), __entry->flush,
Nikolay Borisov45e31862020-06-19 15:24:46 +03001097 __print_symbolic(__entry->flush, FLUSH_ACTIONS),
David Sterba8eec8462018-04-03 21:15:11 +02001098 __entry->flags,
Josef Bacikf376df22016-03-25 13:25:56 -04001099 __print_flags((unsigned long)__entry->flags, "|",
1100 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +02001101 __entry->bytes)
Josef Bacikf376df22016-03-25 13:25:56 -04001102);
1103
1104#define show_flush_state(state) \
1105 __print_symbolic(state, \
1106 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
1107 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
1108 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1109 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
Josef Bacik413df722018-12-03 10:20:35 -05001110 { FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR"}, \
1111 { FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS"}, \
Josef Bacikf376df22016-03-25 13:25:56 -04001112 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
Josef Bacik450114f2018-11-21 14:03:08 -05001113 { ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE"}, \
Josef Bacik844245b2019-08-01 18:19:33 -04001114 { RUN_DELAYED_IPUTS, "RUN_DELAYED_IPUTS"}, \
Josef Bacikf376df22016-03-25 13:25:56 -04001115 { COMMIT_TRANS, "COMMIT_TRANS"})
1116
1117TRACE_EVENT(btrfs_flush_space,
1118
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001119 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001120 int state, int ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001121
Nikolay Borisov7bdd6272017-07-11 13:25:13 +03001122 TP_ARGS(fs_info, flags, num_bytes, state, ret),
Josef Bacikf376df22016-03-25 13:25:56 -04001123
David Sterba2e63e622018-04-03 21:34:06 +02001124 TP_STRUCT__entry_btrfs(
Josef Bacikf376df22016-03-25 13:25:56 -04001125 __field( u64, flags )
1126 __field( u64, num_bytes )
Josef Bacikf376df22016-03-25 13:25:56 -04001127 __field( int, state )
1128 __field( int, ret )
1129 ),
1130
David Sterba2e63e622018-04-03 21:34:06 +02001131 TP_fast_assign_btrfs(fs_info,
Josef Bacikf376df22016-03-25 13:25:56 -04001132 __entry->flags = flags;
1133 __entry->num_bytes = num_bytes;
Josef Bacikf376df22016-03-25 13:25:56 -04001134 __entry->state = state;
1135 __entry->ret = ret;
1136 ),
1137
David Sterba2e63e622018-04-03 21:34:06 +02001138 TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
1139 __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001140 show_flush_state(__entry->state),
David Sterba8eec8462018-04-03 21:15:11 +02001141 __entry->flags,
Josef Bacikf376df22016-03-25 13:25:56 -04001142 __print_flags((unsigned long)__entry->flags, "|",
1143 BTRFS_GROUP_FLAGS),
David Sterba8eec8462018-04-03 21:15:11 +02001144 __entry->num_bytes, __entry->ret)
Josef Bacikf376df22016-03-25 13:25:56 -04001145);
1146
liubo1abe9b82011-03-24 11:18:59 +00001147DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1148
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001149 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001150
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001151 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001152
Jeff Mahoneybc074522016-06-09 17:27:55 -04001153 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001154 __field( u64, start )
1155 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001156 ),
1157
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001158 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001159 __entry->start = start;
1160 __entry->len = len;
1161 ),
1162
David Sterba562a7a02017-01-06 15:51:36 +01001163 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001164 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
David Sterba8eec8462018-04-03 21:15:11 +02001165 __entry->start,
1166 __entry->len)
liubo1abe9b82011-03-24 11:18:59 +00001167);
1168
1169DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1170
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001171 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001172
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001173 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001174);
1175
1176DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1177
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001178 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001179
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001180 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001181);
1182
Josef Bacik3f7de032011-11-10 08:29:20 -05001183TRACE_EVENT(find_free_extent,
1184
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001185 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1186 u64 empty_size, u64 data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001187
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001188 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001189
Jeff Mahoneybc074522016-06-09 17:27:55 -04001190 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001191 __field( u64, num_bytes )
1192 __field( u64, empty_size )
1193 __field( u64, data )
1194 ),
1195
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001196 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001197 __entry->num_bytes = num_bytes;
1198 __entry->empty_size = empty_size;
1199 __entry->data = data;
1200 ),
1201
David Sterba5439c7f2018-04-03 21:05:37 +02001202 TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001203 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001204 __entry->num_bytes, __entry->empty_size, __entry->data,
1205 __print_flags((unsigned long)__entry->data, "|",
1206 BTRFS_GROUP_FLAGS))
1207);
1208
1209DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1210
David Sterba32da53862019-10-29 19:20:18 +01001211 TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001212 u64 len),
1213
Qu Wenruo3dca5c92018-04-26 14:24:25 +08001214 TP_ARGS(block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001215
Jeff Mahoneybc074522016-06-09 17:27:55 -04001216 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001217 __field( u64, bg_objectid )
1218 __field( u64, flags )
1219 __field( u64, start )
1220 __field( u64, len )
1221 ),
1222
Qu Wenruo3dca5c92018-04-26 14:24:25 +08001223 TP_fast_assign_btrfs(block_group->fs_info,
David Sterbab3470b52019-10-23 18:48:22 +02001224 __entry->bg_objectid = block_group->start;
Josef Bacik3f7de032011-11-10 08:29:20 -05001225 __entry->flags = block_group->flags;
1226 __entry->start = start;
1227 __entry->len = len;
1228 ),
1229
David Sterba5439c7f2018-04-03 21:05:37 +02001230 TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
1231 "start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001232 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1233 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001234 __entry->flags, __print_flags((unsigned long)__entry->flags,
1235 "|", BTRFS_GROUP_FLAGS),
1236 __entry->start, __entry->len)
1237);
1238
1239DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1240
David Sterba32da53862019-10-29 19:20:18 +01001241 TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001242 u64 len),
1243
Qu Wenruo3dca5c92018-04-26 14:24:25 +08001244 TP_ARGS(block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001245);
1246
1247DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1248
David Sterba32da53862019-10-29 19:20:18 +01001249 TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001250 u64 len),
1251
Qu Wenruo3dca5c92018-04-26 14:24:25 +08001252 TP_ARGS(block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001253);
1254
1255TRACE_EVENT(btrfs_find_cluster,
1256
David Sterba32da53862019-10-29 19:20:18 +01001257 TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001258 u64 bytes, u64 empty_size, u64 min_bytes),
1259
1260 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1261
Jeff Mahoneybc074522016-06-09 17:27:55 -04001262 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001263 __field( u64, bg_objectid )
1264 __field( u64, flags )
1265 __field( u64, start )
1266 __field( u64, bytes )
1267 __field( u64, empty_size )
1268 __field( u64, min_bytes )
1269 ),
1270
Jeff Mahoneybc074522016-06-09 17:27:55 -04001271 TP_fast_assign_btrfs(block_group->fs_info,
David Sterbab3470b52019-10-23 18:48:22 +02001272 __entry->bg_objectid = block_group->start;
Josef Bacik3f7de032011-11-10 08:29:20 -05001273 __entry->flags = block_group->flags;
1274 __entry->start = start;
1275 __entry->bytes = bytes;
1276 __entry->empty_size = empty_size;
1277 __entry->min_bytes = min_bytes;
1278 ),
1279
David Sterba5439c7f2018-04-03 21:05:37 +02001280 TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
1281 "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001282 __entry->flags,
1283 __print_flags((unsigned long)__entry->flags, "|",
1284 BTRFS_GROUP_FLAGS), __entry->start,
1285 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1286);
1287
1288TRACE_EVENT(btrfs_failed_cluster_setup,
1289
David Sterba32da53862019-10-29 19:20:18 +01001290 TP_PROTO(const struct btrfs_block_group *block_group),
Josef Bacik3f7de032011-11-10 08:29:20 -05001291
1292 TP_ARGS(block_group),
1293
Jeff Mahoneybc074522016-06-09 17:27:55 -04001294 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001295 __field( u64, bg_objectid )
1296 ),
1297
Jeff Mahoneybc074522016-06-09 17:27:55 -04001298 TP_fast_assign_btrfs(block_group->fs_info,
David Sterbab3470b52019-10-23 18:48:22 +02001299 __entry->bg_objectid = block_group->start;
Josef Bacik3f7de032011-11-10 08:29:20 -05001300 ),
1301
David Sterba5439c7f2018-04-03 21:05:37 +02001302 TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001303);
1304
1305TRACE_EVENT(btrfs_setup_cluster,
1306
David Sterba32da53862019-10-29 19:20:18 +01001307 TP_PROTO(const struct btrfs_block_group *block_group,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001308 const struct btrfs_free_cluster *cluster,
1309 u64 size, int bitmap),
Josef Bacik3f7de032011-11-10 08:29:20 -05001310
1311 TP_ARGS(block_group, cluster, size, bitmap),
1312
Jeff Mahoneybc074522016-06-09 17:27:55 -04001313 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001314 __field( u64, bg_objectid )
1315 __field( u64, flags )
1316 __field( u64, start )
1317 __field( u64, max_size )
1318 __field( u64, size )
1319 __field( int, bitmap )
1320 ),
1321
Jeff Mahoneybc074522016-06-09 17:27:55 -04001322 TP_fast_assign_btrfs(block_group->fs_info,
David Sterbab3470b52019-10-23 18:48:22 +02001323 __entry->bg_objectid = block_group->start;
Josef Bacik3f7de032011-11-10 08:29:20 -05001324 __entry->flags = block_group->flags;
1325 __entry->start = cluster->window_start;
1326 __entry->max_size = cluster->max_size;
1327 __entry->size = size;
1328 __entry->bitmap = bitmap;
1329 ),
1330
David Sterba5439c7f2018-04-03 21:05:37 +02001331 TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
1332 "size=%llu max_size=%llu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001333 __entry->bg_objectid,
1334 __entry->flags,
1335 __print_flags((unsigned long)__entry->flags, "|",
1336 BTRFS_GROUP_FLAGS), __entry->start,
1337 __entry->size, __entry->max_size, __entry->bitmap)
1338);
1339
Jeff Mahoney143bede2012-03-01 14:56:26 +01001340struct extent_state;
1341TRACE_EVENT(alloc_extent_state,
1342
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001343 TP_PROTO(const struct extent_state *state,
1344 gfp_t mask, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001345
1346 TP_ARGS(state, mask, IP),
1347
1348 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001349 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001350 __field(gfp_t, mask)
David Sterba94c3f6c2019-10-17 13:28:55 +02001351 __field(const void*, ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001352 ),
1353
1354 TP_fast_assign(
1355 __entry->state = state,
1356 __entry->mask = mask,
David Sterba94c3f6c2019-10-17 13:28:55 +02001357 __entry->ip = (const void *)IP
Jeff Mahoney143bede2012-03-01 14:56:26 +01001358 ),
1359
David Sterba562a7a02017-01-06 15:51:36 +01001360 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
David Sterba94c3f6c2019-10-17 13:28:55 +02001361 show_gfp_flags(__entry->mask), __entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001362);
1363
1364TRACE_EVENT(free_extent_state,
1365
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001366 TP_PROTO(const struct extent_state *state, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001367
1368 TP_ARGS(state, IP),
1369
1370 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001371 __field(const struct extent_state *, state)
David Sterba94c3f6c2019-10-17 13:28:55 +02001372 __field(const void*, ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001373 ),
1374
1375 TP_fast_assign(
1376 __entry->state = state,
David Sterba94c3f6c2019-10-17 13:28:55 +02001377 __entry->ip = (const void *)IP
Jeff Mahoney143bede2012-03-01 14:56:26 +01001378 ),
1379
David Sterba94c3f6c2019-10-17 13:28:55 +02001380 TP_printk("state=%p caller=%pS", __entry->state, __entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001381);
1382
Qu Wenruo52483bc2014-03-06 04:19:50 +00001383DECLARE_EVENT_CLASS(btrfs__work,
1384
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001385 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001386
1387 TP_ARGS(work),
1388
Jeff Mahoneybc074522016-06-09 17:27:55 -04001389 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001390 __field( const void *, work )
1391 __field( const void *, wq )
1392 __field( const void *, func )
1393 __field( const void *, ordered_func )
1394 __field( const void *, ordered_free )
1395 __field( const void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001396 ),
1397
Jeff Mahoneybc074522016-06-09 17:27:55 -04001398 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001399 __entry->work = work;
1400 __entry->wq = work->wq;
1401 __entry->func = work->func;
1402 __entry->ordered_func = work->ordered_func;
1403 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001404 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001405 ),
1406
Sakari Ailusd75f7732019-03-25 21:32:28 +02001407 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
David Sterba562a7a02017-01-06 15:51:36 +01001408 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001409 __entry->work, __entry->normal_work, __entry->wq,
1410 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001411);
1412
David Sterbaac0c7cf2017-01-06 14:12:51 +01001413/*
Omar Sandovalc9eb55d2019-09-16 11:30:58 -07001414 * For situations when the work is freed, we pass fs_info and a tag that matches
1415 * the address of the work structure so it can be paired with the scheduling
1416 * event. DO NOT add anything here that dereferences wtag.
David Sterbaac0c7cf2017-01-06 14:12:51 +01001417 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001418DECLARE_EVENT_CLASS(btrfs__work__done,
1419
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001420 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001421
David Sterbaac0c7cf2017-01-06 14:12:51 +01001422 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001423
Jeff Mahoneybc074522016-06-09 17:27:55 -04001424 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001425 __field( const void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001426 ),
1427
David Sterbaac0c7cf2017-01-06 14:12:51 +01001428 TP_fast_assign_btrfs(fs_info,
1429 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001430 ),
1431
David Sterbaac0c7cf2017-01-06 14:12:51 +01001432 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001433);
1434
1435DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1436
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001437 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001438
1439 TP_ARGS(work)
1440);
1441
1442DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1443
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001444 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001445
1446 TP_ARGS(work)
1447);
1448
Qu Wenruo52483bc2014-03-06 04:19:50 +00001449DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1450
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001451 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001452
David Sterbaac0c7cf2017-01-06 14:12:51 +01001453 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001454);
1455
1456DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1457
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001458 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001459
1460 TP_ARGS(work)
1461);
1462
Qu Wenruoc3a46892014-03-12 08:05:33 +00001463DECLARE_EVENT_CLASS(btrfs__workqueue,
1464
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001465 TP_PROTO(const struct __btrfs_workqueue *wq,
1466 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001467
1468 TP_ARGS(wq, name, high),
1469
Jeff Mahoneybc074522016-06-09 17:27:55 -04001470 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001471 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001472 __string( name, name )
1473 __field( int , high )
1474 ),
1475
Jeff Mahoneybc074522016-06-09 17:27:55 -04001476 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001477 __entry->wq = wq;
1478 __assign_str(name, name);
1479 __entry->high = high;
1480 ),
1481
David Sterba562a7a02017-01-06 15:51:36 +01001482 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001483 __print_flags(__entry->high, "",
1484 {(WQ_HIGHPRI), "-high"}),
1485 __entry->wq)
1486);
1487
1488DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1489
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001490 TP_PROTO(const struct __btrfs_workqueue *wq,
1491 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001492
1493 TP_ARGS(wq, name, high)
1494);
1495
1496DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1497
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001498 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001499
1500 TP_ARGS(wq),
1501
Jeff Mahoneybc074522016-06-09 17:27:55 -04001502 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001503 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001504 ),
1505
Jeff Mahoneybc074522016-06-09 17:27:55 -04001506 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001507 __entry->wq = wq;
1508 ),
1509
Jeff Mahoneybc074522016-06-09 17:27:55 -04001510 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001511);
1512
1513DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1514
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001515 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001516
1517 TP_ARGS(wq)
1518);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001519
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001520#define BTRFS_QGROUP_OPERATIONS \
1521 { QGROUP_RESERVE, "reserve" }, \
1522 { QGROUP_RELEASE, "release" }, \
1523 { QGROUP_FREE, "free" }
1524
1525DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1526
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001527 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1528 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001529
1530 TP_ARGS(inode, start, len, reserved, op),
1531
Jeff Mahoneybc074522016-06-09 17:27:55 -04001532 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001533 __field( u64, rootid )
David Sterbaf8f8e182018-04-03 20:57:21 +02001534 __field( u64, ino )
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001535 __field( u64, start )
1536 __field( u64, len )
1537 __field( u64, reserved )
1538 __field( int, op )
1539 ),
1540
Jeff Mahoneybc074522016-06-09 17:27:55 -04001541 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Misono Tomohiro4fd786e2018-08-06 14:25:24 +09001542 __entry->rootid =
1543 BTRFS_I(inode)->root->root_key.objectid;
David Sterbaf8f8e182018-04-03 20:57:21 +02001544 __entry->ino = btrfs_ino(BTRFS_I(inode));
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001545 __entry->start = start;
1546 __entry->len = len;
1547 __entry->reserved = reserved;
1548 __entry->op = op;
1549 ),
1550
David Sterbaf8f8e182018-04-03 20:57:21 +02001551 TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001552 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1553 __entry->reserved,
1554 __print_flags((unsigned long)__entry->op, "",
1555 BTRFS_QGROUP_OPERATIONS)
1556 )
1557);
1558
1559DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1560
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001561 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1562 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001563
1564 TP_ARGS(inode, start, len, reserved, op)
1565);
1566
1567DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1568
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001569 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1570 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001571
1572 TP_ARGS(inode, start, len, reserved, op)
1573);
1574
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001575DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001576 TP_PROTO(const struct btrfs_fs_info *fs_info,
1577 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001578
Jeff Mahoneybc074522016-06-09 17:27:55 -04001579 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001580
Jeff Mahoneybc074522016-06-09 17:27:55 -04001581 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001582 __field( u64, bytenr )
1583 __field( u64, num_bytes )
1584 ),
1585
Jeff Mahoneybc074522016-06-09 17:27:55 -04001586 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001587 __entry->bytenr = rec->bytenr,
1588 __entry->num_bytes = rec->num_bytes;
1589 ),
1590
David Sterba562a7a02017-01-06 15:51:36 +01001591 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
David Sterba94c3f6c2019-10-17 13:28:55 +02001592 __entry->bytenr, __entry->num_bytes)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001593);
1594
1595DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1596
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001597 TP_PROTO(const struct btrfs_fs_info *fs_info,
1598 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001599
Jeff Mahoneybc074522016-06-09 17:27:55 -04001600 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001601);
1602
Qu Wenruo50b3e042016-10-18 09:31:27 +08001603DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001604
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001605 TP_PROTO(const struct btrfs_fs_info *fs_info,
1606 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001607
Jeff Mahoneybc074522016-06-09 17:27:55 -04001608 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001609);
1610
Qu Wenruoc337e7b2018-09-27 14:42:29 +08001611TRACE_EVENT(qgroup_num_dirty_extents,
1612
1613 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1614 u64 num_dirty_extents),
1615
1616 TP_ARGS(fs_info, transid, num_dirty_extents),
1617
1618 TP_STRUCT__entry_btrfs(
1619 __field( u64, transid )
1620 __field( u64, num_dirty_extents )
1621 ),
1622
1623 TP_fast_assign_btrfs(fs_info,
1624 __entry->transid = transid;
1625 __entry->num_dirty_extents = num_dirty_extents;
1626 ),
1627
1628 TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1629 __entry->transid, __entry->num_dirty_extents)
1630);
1631
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001632TRACE_EVENT(btrfs_qgroup_account_extent,
1633
Qu Wenruoc9f6f3c2018-05-03 09:59:02 +08001634 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001635 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001636
Qu Wenruoc9f6f3c2018-05-03 09:59:02 +08001637 TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1638 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001639
Jeff Mahoneybc074522016-06-09 17:27:55 -04001640 TP_STRUCT__entry_btrfs(
Qu Wenruoc9f6f3c2018-05-03 09:59:02 +08001641 __field( u64, transid )
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001642 __field( u64, bytenr )
1643 __field( u64, num_bytes )
1644 __field( u64, nr_old_roots )
1645 __field( u64, nr_new_roots )
1646 ),
1647
Jeff Mahoneybc074522016-06-09 17:27:55 -04001648 TP_fast_assign_btrfs(fs_info,
Qu Wenruoc9f6f3c2018-05-03 09:59:02 +08001649 __entry->transid = transid;
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001650 __entry->bytenr = bytenr;
1651 __entry->num_bytes = num_bytes;
1652 __entry->nr_old_roots = nr_old_roots;
1653 __entry->nr_new_roots = nr_new_roots;
1654 ),
1655
Qu Wenruoc9f6f3c2018-05-03 09:59:02 +08001656 TP_printk_btrfs(
1657"transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1658 __entry->transid,
1659 __entry->bytenr,
1660 __entry->num_bytes,
1661 __entry->nr_old_roots,
1662 __entry->nr_new_roots)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001663);
1664
1665TRACE_EVENT(qgroup_update_counters,
1666
Qu Wenruo8b317902018-04-30 15:04:44 +08001667 TP_PROTO(const struct btrfs_fs_info *fs_info,
David Sterba1d2e7c72019-10-17 13:28:57 +02001668 const struct btrfs_qgroup *qgroup,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001669 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001670
Qu Wenruo8b317902018-04-30 15:04:44 +08001671 TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001672
Jeff Mahoneybc074522016-06-09 17:27:55 -04001673 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001674 __field( u64, qgid )
Qu Wenruo8b317902018-04-30 15:04:44 +08001675 __field( u64, old_rfer )
1676 __field( u64, old_excl )
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001677 __field( u64, cur_old_count )
1678 __field( u64, cur_new_count )
1679 ),
1680
Jeff Mahoneybc074522016-06-09 17:27:55 -04001681 TP_fast_assign_btrfs(fs_info,
Qu Wenruo8b317902018-04-30 15:04:44 +08001682 __entry->qgid = qgroup->qgroupid;
1683 __entry->old_rfer = qgroup->rfer;
1684 __entry->old_excl = qgroup->excl;
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001685 __entry->cur_old_count = cur_old_count;
1686 __entry->cur_new_count = cur_new_count;
1687 ),
1688
Qu Wenruo8b317902018-04-30 15:04:44 +08001689 TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
1690 __entry->qgid, __entry->old_rfer, __entry->old_excl,
1691 __entry->cur_old_count, __entry->cur_new_count)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001692);
1693
Qu Wenruo3159fe72017-03-13 15:52:08 +08001694TRACE_EVENT(qgroup_update_reserve,
1695
1696 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001697 s64 diff, int type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001698
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001699 TP_ARGS(fs_info, qgroup, diff, type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001700
1701 TP_STRUCT__entry_btrfs(
1702 __field( u64, qgid )
1703 __field( u64, cur_reserved )
1704 __field( s64, diff )
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001705 __field( int, type )
Qu Wenruo3159fe72017-03-13 15:52:08 +08001706 ),
1707
1708 TP_fast_assign_btrfs(fs_info,
1709 __entry->qgid = qgroup->qgroupid;
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001710 __entry->cur_reserved = qgroup->rsv.values[type];
Qu Wenruo3159fe72017-03-13 15:52:08 +08001711 __entry->diff = diff;
Qu Wenruo1b2442b2019-10-17 10:38:37 +08001712 __entry->type = type;
Qu Wenruo3159fe72017-03-13 15:52:08 +08001713 ),
1714
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001715 TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
Nikolay Borisov1cb1f0b2020-06-19 15:24:49 +03001716 __entry->qgid, __print_symbolic(__entry->type, QGROUP_RSV_TYPES),
Qu Wenruo64ee4e72017-12-12 15:34:27 +08001717 __entry->cur_reserved, __entry->diff)
Qu Wenruo3159fe72017-03-13 15:52:08 +08001718);
1719
1720TRACE_EVENT(qgroup_meta_reserve,
1721
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001722 TP_PROTO(struct btrfs_root *root, s64 diff, int type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001723
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001724 TP_ARGS(root, diff, type),
Qu Wenruo3159fe72017-03-13 15:52:08 +08001725
1726 TP_STRUCT__entry_btrfs(
1727 __field( u64, refroot )
1728 __field( s64, diff )
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001729 __field( int, type )
Qu Wenruo3159fe72017-03-13 15:52:08 +08001730 ),
1731
1732 TP_fast_assign_btrfs(root->fs_info,
Misono Tomohiro4fd786e2018-08-06 14:25:24 +09001733 __entry->refroot = root->root_key.objectid;
Qu Wenruo3159fe72017-03-13 15:52:08 +08001734 __entry->diff = diff;
Qu Wenruo1b2442b2019-10-17 10:38:37 +08001735 __entry->type = type;
Qu Wenruo3159fe72017-03-13 15:52:08 +08001736 ),
1737
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001738 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1739 show_root_type(__entry->refroot),
Nikolay Borisov1cb1f0b2020-06-19 15:24:49 +03001740 __print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001741);
1742
1743TRACE_EVENT(qgroup_meta_convert,
1744
1745 TP_PROTO(struct btrfs_root *root, s64 diff),
1746
1747 TP_ARGS(root, diff),
1748
1749 TP_STRUCT__entry_btrfs(
1750 __field( u64, refroot )
1751 __field( s64, diff )
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001752 ),
1753
1754 TP_fast_assign_btrfs(root->fs_info,
Misono Tomohiro4fd786e2018-08-06 14:25:24 +09001755 __entry->refroot = root->root_key.objectid;
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001756 __entry->diff = diff;
1757 ),
1758
1759 TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
1760 show_root_type(__entry->refroot),
Nikolay Borisov1cb1f0b2020-06-19 15:24:49 +03001761 __print_symbolic(BTRFS_QGROUP_RSV_META_PREALLOC, QGROUP_RSV_TYPES),
1762 __print_symbolic(BTRFS_QGROUP_RSV_META_PERTRANS, QGROUP_RSV_TYPES),
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001763 __entry->diff)
1764);
1765
1766TRACE_EVENT(qgroup_meta_free_all_pertrans,
1767
1768 TP_PROTO(struct btrfs_root *root),
1769
1770 TP_ARGS(root),
1771
1772 TP_STRUCT__entry_btrfs(
1773 __field( u64, refroot )
1774 __field( s64, diff )
1775 __field( int, type )
1776 ),
1777
1778 TP_fast_assign_btrfs(root->fs_info,
Misono Tomohiro4fd786e2018-08-06 14:25:24 +09001779 __entry->refroot = root->root_key.objectid;
Qu Wenruo4ee0d882017-12-12 15:34:35 +08001780 spin_lock(&root->qgroup_meta_rsv_lock);
1781 __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans;
1782 spin_unlock(&root->qgroup_meta_rsv_lock);
1783 __entry->type = BTRFS_QGROUP_RSV_META_PERTRANS;
1784 ),
1785
1786 TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1787 show_root_type(__entry->refroot),
Nikolay Borisov1cb1f0b2020-06-19 15:24:49 +03001788 __print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
Qu Wenruo3159fe72017-03-13 15:52:08 +08001789);
1790
Jeff Mahoney00142752017-07-12 16:20:08 -06001791DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1792 TP_PROTO(const struct btrfs_fs_info *fs_info,
1793 const struct prelim_ref *oldref,
1794 const struct prelim_ref *newref, u64 tree_size),
1795 TP_ARGS(fs_info, newref, oldref, tree_size),
1796
1797 TP_STRUCT__entry_btrfs(
1798 __field( u64, root_id )
1799 __field( u64, objectid )
1800 __field( u8, type )
1801 __field( u64, offset )
1802 __field( int, level )
1803 __field( int, old_count )
1804 __field( u64, parent )
1805 __field( u64, bytenr )
1806 __field( int, mod_count )
1807 __field( u64, tree_size )
1808 ),
1809
1810 TP_fast_assign_btrfs(fs_info,
1811 __entry->root_id = oldref->root_id;
1812 __entry->objectid = oldref->key_for_search.objectid;
1813 __entry->type = oldref->key_for_search.type;
1814 __entry->offset = oldref->key_for_search.offset;
1815 __entry->level = oldref->level;
1816 __entry->old_count = oldref->count;
1817 __entry->parent = oldref->parent;
1818 __entry->bytenr = oldref->wanted_disk_byte;
1819 __entry->mod_count = newref ? newref->count : 0;
1820 __entry->tree_size = tree_size;
1821 ),
1822
1823 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 +02001824 __entry->root_id,
1825 __entry->objectid, __entry->type,
1826 __entry->offset, __entry->level,
Jeff Mahoney00142752017-07-12 16:20:08 -06001827 __entry->old_count, __entry->mod_count,
1828 __entry->old_count + __entry->mod_count,
David Sterba8eec8462018-04-03 21:15:11 +02001829 __entry->parent,
1830 __entry->bytenr,
1831 __entry->tree_size)
Jeff Mahoney00142752017-07-12 16:20:08 -06001832);
1833
1834DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1835 TP_PROTO(const struct btrfs_fs_info *fs_info,
1836 const struct prelim_ref *oldref,
1837 const struct prelim_ref *newref, u64 tree_size),
1838 TP_ARGS(fs_info, oldref, newref, tree_size)
1839);
1840
1841DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1842 TP_PROTO(const struct btrfs_fs_info *fs_info,
1843 const struct prelim_ref *oldref,
1844 const struct prelim_ref *newref, u64 tree_size),
1845 TP_ARGS(fs_info, oldref, newref, tree_size)
1846);
1847
Josef Bacikdd48d402017-10-19 14:15:56 -04001848TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
David Sterba1d2e7c72019-10-17 13:28:57 +02001849 TP_PROTO(const struct btrfs_root *root, u64 ino, int mod),
Josef Bacikdd48d402017-10-19 14:15:56 -04001850
1851 TP_ARGS(root, ino, mod),
1852
1853 TP_STRUCT__entry_btrfs(
1854 __field( u64, root_objectid )
1855 __field( u64, ino )
1856 __field( int, mod )
1857 ),
1858
1859 TP_fast_assign_btrfs(root->fs_info,
Misono Tomohiro4fd786e2018-08-06 14:25:24 +09001860 __entry->root_objectid = root->root_key.objectid;
Josef Bacikdd48d402017-10-19 14:15:56 -04001861 __entry->ino = ino;
1862 __entry->mod = mod;
1863 ),
1864
1865 TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1866 show_root_type(__entry->root_objectid),
David Sterba8eec8462018-04-03 21:15:11 +02001867 __entry->ino, __entry->mod)
Josef Bacikdd48d402017-10-19 14:15:56 -04001868);
Qu Wenruo3dca5c92018-04-26 14:24:25 +08001869
Qu Wenruo4ed0a7a2018-04-26 17:17:20 +08001870DECLARE_EVENT_CLASS(btrfs__block_group,
David Sterba32da53862019-10-29 19:20:18 +01001871 TP_PROTO(const struct btrfs_block_group *bg_cache),
Qu Wenruo4ed0a7a2018-04-26 17:17:20 +08001872
1873 TP_ARGS(bg_cache),
1874
1875 TP_STRUCT__entry_btrfs(
1876 __field( u64, bytenr )
1877 __field( u64, len )
1878 __field( u64, used )
1879 __field( u64, flags )
1880 ),
1881
1882 TP_fast_assign_btrfs(bg_cache->fs_info,
David Sterbab3470b52019-10-23 18:48:22 +02001883 __entry->bytenr = bg_cache->start,
1884 __entry->len = bg_cache->length,
David Sterbabf38be62019-10-23 18:48:11 +02001885 __entry->used = bg_cache->used;
Qu Wenruo4ed0a7a2018-04-26 17:17:20 +08001886 __entry->flags = bg_cache->flags;
1887 ),
1888
1889 TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
1890 __entry->bytenr, __entry->len, __entry->used, __entry->flags,
1891 __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
1892);
1893
1894DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
David Sterba32da53862019-10-29 19:20:18 +01001895 TP_PROTO(const struct btrfs_block_group *bg_cache),
Qu Wenruo4ed0a7a2018-04-26 17:17:20 +08001896
1897 TP_ARGS(bg_cache)
1898);
1899
1900DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
David Sterba32da53862019-10-29 19:20:18 +01001901 TP_PROTO(const struct btrfs_block_group *bg_cache),
Qu Wenruo4ed0a7a2018-04-26 17:17:20 +08001902
1903 TP_ARGS(bg_cache)
1904);
1905
1906DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
David Sterba32da53862019-10-29 19:20:18 +01001907 TP_PROTO(const struct btrfs_block_group *bg_cache),
Qu Wenruo4ed0a7a2018-04-26 17:17:20 +08001908
1909 TP_ARGS(bg_cache)
1910);
1911
Qu Wenruoa1d19842019-03-01 10:48:00 +08001912TRACE_EVENT(btrfs_set_extent_bit,
1913 TP_PROTO(const struct extent_io_tree *tree,
1914 u64 start, u64 len, unsigned set_bits),
1915
1916 TP_ARGS(tree, start, len, set_bits),
1917
1918 TP_STRUCT__entry_btrfs(
1919 __field( unsigned, owner )
1920 __field( u64, ino )
1921 __field( u64, rootid )
1922 __field( u64, start )
1923 __field( u64, len )
1924 __field( unsigned, set_bits)
1925 ),
1926
1927 TP_fast_assign_btrfs(tree->fs_info,
1928 __entry->owner = tree->owner;
1929 if (tree->private_data) {
David Sterba1d2e7c72019-10-17 13:28:57 +02001930 const struct inode *inode = tree->private_data;
Qu Wenruoa1d19842019-03-01 10:48:00 +08001931
1932 __entry->ino = btrfs_ino(BTRFS_I(inode));
1933 __entry->rootid =
1934 BTRFS_I(inode)->root->root_key.objectid;
1935 } else {
1936 __entry->ino = 0;
1937 __entry->rootid = 0;
1938 }
1939 __entry->start = start;
1940 __entry->len = len;
1941 __entry->set_bits = set_bits;
1942 ),
1943
1944 TP_printk_btrfs(
1945 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s",
Nikolay Borisovc92bb302020-06-19 15:24:50 +03001946 __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
Qu Wenruoa1d19842019-03-01 10:48:00 +08001947 __entry->rootid, __entry->start, __entry->len,
1948 __print_flags(__entry->set_bits, "|", EXTENT_FLAGS))
1949);
1950
1951TRACE_EVENT(btrfs_clear_extent_bit,
1952 TP_PROTO(const struct extent_io_tree *tree,
1953 u64 start, u64 len, unsigned clear_bits),
1954
1955 TP_ARGS(tree, start, len, clear_bits),
1956
1957 TP_STRUCT__entry_btrfs(
1958 __field( unsigned, owner )
1959 __field( u64, ino )
1960 __field( u64, rootid )
1961 __field( u64, start )
1962 __field( u64, len )
1963 __field( unsigned, clear_bits)
1964 ),
1965
1966 TP_fast_assign_btrfs(tree->fs_info,
1967 __entry->owner = tree->owner;
1968 if (tree->private_data) {
David Sterba1d2e7c72019-10-17 13:28:57 +02001969 const struct inode *inode = tree->private_data;
Qu Wenruoa1d19842019-03-01 10:48:00 +08001970
1971 __entry->ino = btrfs_ino(BTRFS_I(inode));
1972 __entry->rootid =
1973 BTRFS_I(inode)->root->root_key.objectid;
1974 } else {
1975 __entry->ino = 0;
1976 __entry->rootid = 0;
1977 }
1978 __entry->start = start;
1979 __entry->len = len;
1980 __entry->clear_bits = clear_bits;
1981 ),
1982
1983 TP_printk_btrfs(
1984 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s",
Nikolay Borisovc92bb302020-06-19 15:24:50 +03001985 __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
Qu Wenruoa1d19842019-03-01 10:48:00 +08001986 __entry->rootid, __entry->start, __entry->len,
1987 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
1988);
1989
1990TRACE_EVENT(btrfs_convert_extent_bit,
1991 TP_PROTO(const struct extent_io_tree *tree,
1992 u64 start, u64 len, unsigned set_bits, unsigned clear_bits),
1993
1994 TP_ARGS(tree, start, len, set_bits, clear_bits),
1995
1996 TP_STRUCT__entry_btrfs(
1997 __field( unsigned, owner )
1998 __field( u64, ino )
1999 __field( u64, rootid )
2000 __field( u64, start )
2001 __field( u64, len )
2002 __field( unsigned, set_bits)
2003 __field( unsigned, clear_bits)
2004 ),
2005
2006 TP_fast_assign_btrfs(tree->fs_info,
2007 __entry->owner = tree->owner;
2008 if (tree->private_data) {
David Sterba1d2e7c72019-10-17 13:28:57 +02002009 const struct inode *inode = tree->private_data;
Qu Wenruoa1d19842019-03-01 10:48:00 +08002010
2011 __entry->ino = btrfs_ino(BTRFS_I(inode));
2012 __entry->rootid =
2013 BTRFS_I(inode)->root->root_key.objectid;
2014 } else {
2015 __entry->ino = 0;
2016 __entry->rootid = 0;
2017 }
2018 __entry->start = start;
2019 __entry->len = len;
2020 __entry->set_bits = set_bits;
2021 __entry->clear_bits = clear_bits;
2022 ),
2023
2024 TP_printk_btrfs(
2025"io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s",
Nikolay Borisovc92bb302020-06-19 15:24:50 +03002026 __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
Qu Wenruoa1d19842019-03-01 10:48:00 +08002027 __entry->rootid, __entry->start, __entry->len,
2028 __print_flags(__entry->set_bits , "|", EXTENT_FLAGS),
2029 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2030);
2031
Qu Wenruo34e73cc2019-04-15 21:15:24 +08002032DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock,
2033 TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2034
2035 TP_ARGS(eb, start_ns),
2036
2037 TP_STRUCT__entry_btrfs(
2038 __field( u64, block )
2039 __field( u64, generation )
2040 __field( u64, start_ns )
2041 __field( u64, end_ns )
2042 __field( u64, diff_ns )
2043 __field( u64, owner )
2044 __field( int, is_log_tree )
2045 ),
2046
2047 TP_fast_assign_btrfs(eb->fs_info,
2048 __entry->block = eb->start;
2049 __entry->generation = btrfs_header_generation(eb);
2050 __entry->start_ns = start_ns;
2051 __entry->end_ns = ktime_get_ns();
2052 __entry->diff_ns = __entry->end_ns - start_ns;
2053 __entry->owner = btrfs_header_owner(eb);
2054 __entry->is_log_tree = (eb->log_index >= 0);
2055 ),
2056
2057 TP_printk_btrfs(
2058"block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d",
2059 __entry->block, __entry->generation,
2060 __entry->start_ns, __entry->end_ns, __entry->diff_ns,
2061 __entry->owner, __entry->is_log_tree)
2062);
2063
2064DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock,
2065 TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2066
2067 TP_ARGS(eb, start_ns)
2068);
2069
2070DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock,
2071 TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2072
2073 TP_ARGS(eb, start_ns)
2074);
2075
Qu Wenruo31aab402019-04-15 21:15:25 +08002076DECLARE_EVENT_CLASS(btrfs_locking_events,
2077 TP_PROTO(const struct extent_buffer *eb),
2078
2079 TP_ARGS(eb),
2080
2081 TP_STRUCT__entry_btrfs(
2082 __field( u64, block )
2083 __field( u64, generation )
2084 __field( u64, owner )
2085 __field( int, is_log_tree )
2086 ),
2087
2088 TP_fast_assign_btrfs(eb->fs_info,
2089 __entry->block = eb->start;
2090 __entry->generation = btrfs_header_generation(eb);
2091 __entry->owner = btrfs_header_owner(eb);
2092 __entry->is_log_tree = (eb->log_index >= 0);
2093 ),
2094
2095 TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d",
2096 __entry->block, __entry->generation,
2097 __entry->owner, __entry->is_log_tree)
2098);
2099
2100#define DEFINE_BTRFS_LOCK_EVENT(name) \
2101DEFINE_EVENT(btrfs_locking_events, name, \
2102 TP_PROTO(const struct extent_buffer *eb), \
2103 \
2104 TP_ARGS(eb) \
2105)
2106
2107DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock);
2108DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock);
2109DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking);
2110DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read);
2111DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write);
Qu Wenruo31aab402019-04-15 21:15:25 +08002112DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock);
2113DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock);
2114DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic);
2115
Qu Wenruo480b9b42019-04-29 14:03:33 +08002116DECLARE_EVENT_CLASS(btrfs__space_info_update,
2117
David Sterba1d2e7c72019-10-17 13:28:57 +02002118 TP_PROTO(const struct btrfs_fs_info *fs_info,
2119 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
Qu Wenruo480b9b42019-04-29 14:03:33 +08002120
2121 TP_ARGS(fs_info, sinfo, old, diff),
2122
2123 TP_STRUCT__entry_btrfs(
2124 __field( u64, type )
2125 __field( u64, old )
2126 __field( s64, diff )
2127 ),
2128
2129 TP_fast_assign_btrfs(fs_info,
2130 __entry->type = sinfo->flags;
2131 __entry->old = old;
2132 __entry->diff = diff;
2133 ),
2134 TP_printk_btrfs("type=%s old=%llu diff=%lld",
2135 __print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS),
2136 __entry->old, __entry->diff)
2137);
2138
2139DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use,
2140
David Sterba1d2e7c72019-10-17 13:28:57 +02002141 TP_PROTO(const struct btrfs_fs_info *fs_info,
2142 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
Qu Wenruo480b9b42019-04-29 14:03:33 +08002143
2144 TP_ARGS(fs_info, sinfo, old, diff)
2145);
2146
2147DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned,
2148
David Sterba1d2e7c72019-10-17 13:28:57 +02002149 TP_PROTO(const struct btrfs_fs_info *fs_info,
2150 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
Qu Wenruo480b9b42019-04-29 14:03:33 +08002151
2152 TP_ARGS(fs_info, sinfo, old, diff)
2153);
2154
liubo1abe9b82011-03-24 11:18:59 +00002155#endif /* _TRACE_BTRFS_H */
2156
2157/* This part must be outside protection */
2158#include <trace/define_trace.h>