blob: 42560feb992071372ab01004ac875386858b76bf [file] [log] [blame]
liubo1abe9b82011-03-24 11:18:59 +00001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM btrfs
3
4#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_BTRFS_H
6
7#include <linux/writeback.h>
8#include <linux/tracepoint.h>
Vlastimil Babka420adbe92016-03-15 14:55:52 -07009#include <trace/events/mmflags.h>
liubo1abe9b82011-03-24 11:18:59 +000010
11struct btrfs_root;
12struct btrfs_fs_info;
13struct btrfs_inode;
14struct extent_map;
Liu Bo09ed2f12017-03-10 11:09:48 -080015struct btrfs_file_extent_item;
liubo1abe9b82011-03-24 11:18:59 +000016struct btrfs_ordered_extent;
17struct btrfs_delayed_ref_node;
18struct btrfs_delayed_tree_ref;
19struct btrfs_delayed_data_ref;
20struct btrfs_delayed_ref_head;
Josef Bacik3f7de032011-11-10 08:29:20 -050021struct btrfs_block_group_cache;
22struct btrfs_free_cluster;
liubo1abe9b82011-03-24 11:18:59 +000023struct map_lookup;
24struct extent_buffer;
Qu Wenruo52483bc2014-03-06 04:19:50 +000025struct btrfs_work;
Qu Wenruoc3a46892014-03-12 08:05:33 +000026struct __btrfs_workqueue;
Mark Fasheh0f5dcf82016-03-29 17:19:55 -070027struct btrfs_qgroup_extent_record;
Qu Wenruo3159fe72017-03-13 15:52:08 +080028struct btrfs_qgroup;
liubo1abe9b82011-03-24 11:18:59 +000029
30#define show_ref_type(type) \
31 __print_symbolic(type, \
32 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
33 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
34 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
35 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
36 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
37
38#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080039 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000040 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
41 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
42 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
43 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
44 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
45 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
46 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
47 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000048 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000049 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070050 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
51 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000052 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
53
54#define show_root_type(obj) \
55 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000056 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000057 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000058
Liu Bo09ed2f12017-03-10 11:09:48 -080059#define show_fi_type(type) \
60 __print_symbolic(type, \
61 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \
62 { BTRFS_FILE_EXTENT_REG, "REG" }, \
63 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"})
64
Josef Bacik3f7de032011-11-10 08:29:20 -050065#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000066 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
67 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
68 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
69 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
70 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
71 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
72 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
73 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
74 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050075
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050076#define BTRFS_UUID_SIZE 16
Jeff Mahoneybc074522016-06-09 17:27:55 -040077#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_UUID_SIZE)
78
79#define TP_fast_assign_fsid(fs_info) \
80 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE)
81
82#define TP_STRUCT__entry_btrfs(args...) \
83 TP_STRUCT__entry( \
84 TP_STRUCT__entry_fsid \
85 args)
86#define TP_fast_assign_btrfs(fs_info, args...) \
87 TP_fast_assign( \
88 TP_fast_assign_fsid(fs_info); \
89 args)
90#define TP_printk_btrfs(fmt, args...) \
91 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050092
liubo1abe9b82011-03-24 11:18:59 +000093TRACE_EVENT(btrfs_transaction_commit,
94
Jeff Mahoney9a35b632017-06-28 21:56:54 -060095 TP_PROTO(const struct btrfs_root *root),
liubo1abe9b82011-03-24 11:18:59 +000096
97 TP_ARGS(root),
98
Jeff Mahoneybc074522016-06-09 17:27:55 -040099 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000100 __field( u64, generation )
101 __field( u64, root_objectid )
102 ),
103
Jeff Mahoneybc074522016-06-09 17:27:55 -0400104 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000105 __entry->generation = root->fs_info->generation;
106 __entry->root_objectid = root->root_key.objectid;
107 ),
108
Jeff Mahoneybc074522016-06-09 17:27:55 -0400109 TP_printk_btrfs("root = %llu(%s), gen = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000110 show_root_type(__entry->root_objectid),
111 (unsigned long long)__entry->generation)
112);
113
114DECLARE_EVENT_CLASS(btrfs__inode,
115
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600116 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000117
118 TP_ARGS(inode),
119
Jeff Mahoneybc074522016-06-09 17:27:55 -0400120 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000121 __field( ino_t, ino )
122 __field( blkcnt_t, blocks )
123 __field( u64, disk_i_size )
124 __field( u64, generation )
125 __field( u64, last_trans )
126 __field( u64, logged_trans )
127 __field( u64, root_objectid )
128 ),
129
Jeff Mahoneybc074522016-06-09 17:27:55 -0400130 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000131 __entry->ino = inode->i_ino;
132 __entry->blocks = inode->i_blocks;
133 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
134 __entry->generation = BTRFS_I(inode)->generation;
135 __entry->last_trans = BTRFS_I(inode)->last_trans;
136 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
137 __entry->root_objectid =
138 BTRFS_I(inode)->root->root_key.objectid;
139 ),
140
David Sterba562a7a02017-01-06 15:51:36 +0100141 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
142 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000143 show_root_type(__entry->root_objectid),
144 (unsigned long long)__entry->generation,
145 (unsigned long)__entry->ino,
146 (unsigned long long)__entry->blocks,
147 (unsigned long long)__entry->disk_i_size,
148 (unsigned long long)__entry->last_trans,
149 (unsigned long long)__entry->logged_trans)
150);
151
152DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
153
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600154 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000155
156 TP_ARGS(inode)
157);
158
159DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
160
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600161 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000162
163 TP_ARGS(inode)
164);
165
166DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
167
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600168 TP_PROTO(const struct inode *inode),
liubo1abe9b82011-03-24 11:18:59 +0000169
170 TP_ARGS(inode)
171);
172
173#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800174 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000175 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
176 { EXTENT_MAP_HOLE, "HOLE" }, \
177 { EXTENT_MAP_INLINE, "INLINE" }, \
178 { EXTENT_MAP_DELALLOC, "DELALLOC" })
179
180#define show_map_type(type) \
181 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
182
183#define show_map_flags(flag) \
184 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800185 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
186 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
187 { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
188 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
189 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
190 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
191 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000192
Steven Rostedt4cd85872013-11-14 22:57:29 -0500193TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000194
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600195 TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
196 const struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000197
Liu Bo92a1bf72016-11-17 15:00:50 -0800198 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000199
Steven Rostedt4cd85872013-11-14 22:57:29 -0500200 TP_CONDITION(map),
201
Jeff Mahoneybc074522016-06-09 17:27:55 -0400202 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000203 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800204 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000205 __field( u64, start )
206 __field( u64, len )
207 __field( u64, orig_start )
208 __field( u64, block_start )
209 __field( u64, block_len )
210 __field( unsigned long, flags )
211 __field( int, refs )
212 __field( unsigned int, compress_type )
213 ),
214
Jeff Mahoneybc074522016-06-09 17:27:55 -0400215 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000216 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800217 __entry->ino = btrfs_ino(inode);
218 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000219 __entry->len = map->len;
220 __entry->orig_start = map->orig_start;
221 __entry->block_start = map->block_start;
222 __entry->block_len = map->block_len;
223 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200224 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000225 __entry->compress_type = map->compress_type;
226 ),
227
David Sterba562a7a02017-01-06 15:51:36 +0100228 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
229 "orig_start=%llu block_start=%llu(%s) "
230 "block_len=%llu flags=%s refs=%u "
231 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000232 show_root_type(__entry->root_objectid),
Liu Bo92a1bf72016-11-17 15:00:50 -0800233 (unsigned long long)__entry->ino,
liubo1abe9b82011-03-24 11:18:59 +0000234 (unsigned long long)__entry->start,
235 (unsigned long long)__entry->len,
236 (unsigned long long)__entry->orig_start,
237 show_map_type(__entry->block_start),
238 (unsigned long long)__entry->block_len,
239 show_map_flags(__entry->flags),
240 __entry->refs, __entry->compress_type)
241);
242
Liu Bo09ed2f12017-03-10 11:09:48 -0800243/* file extent item */
244DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
245
246 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
247 struct btrfs_file_extent_item *fi, u64 start),
248
249 TP_ARGS(bi, l, fi, start),
250
251 TP_STRUCT__entry_btrfs(
252 __field( u64, root_obj )
253 __field( u64, ino )
254 __field( loff_t, isize )
255 __field( u64, disk_isize )
256 __field( u64, num_bytes )
257 __field( u64, ram_bytes )
258 __field( u64, disk_bytenr )
259 __field( u64, disk_num_bytes )
260 __field( u64, extent_offset )
261 __field( u8, extent_type )
262 __field( u8, compression )
263 __field( u64, extent_start )
264 __field( u64, extent_end )
265 ),
266
267 TP_fast_assign_btrfs(bi->root->fs_info,
268 __entry->root_obj = bi->root->objectid;
269 __entry->ino = btrfs_ino(bi);
270 __entry->isize = bi->vfs_inode.i_size;
271 __entry->disk_isize = bi->disk_i_size;
272 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
273 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
274 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
275 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
276 __entry->extent_offset = btrfs_file_extent_offset(l, fi);
277 __entry->extent_type = btrfs_file_extent_type(l, fi);
278 __entry->compression = btrfs_file_extent_compression(l, fi);
279 __entry->extent_start = start;
280 __entry->extent_end = (start + __entry->num_bytes);
281 ),
282
283 TP_printk_btrfs(
284 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
285 "file extent range=[%llu %llu] "
286 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
287 "disk_num_bytes=%llu extent_offset=%llu type=%s "
288 "compression=%u",
289 show_root_type(__entry->root_obj), __entry->ino,
290 __entry->isize,
291 __entry->disk_isize, __entry->extent_start,
292 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
293 __entry->disk_bytenr, __entry->disk_num_bytes,
294 __entry->extent_offset, show_fi_type(__entry->extent_type),
295 __entry->compression)
296);
297
298DECLARE_EVENT_CLASS(
299 btrfs__file_extent_item_inline,
300
301 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
302 struct btrfs_file_extent_item *fi, int slot, u64 start),
303
304 TP_ARGS(bi, l, fi, slot, start),
305
306 TP_STRUCT__entry_btrfs(
307 __field( u64, root_obj )
308 __field( u64, ino )
309 __field( loff_t, isize )
310 __field( u64, disk_isize )
311 __field( u8, extent_type )
312 __field( u8, compression )
313 __field( u64, extent_start )
314 __field( u64, extent_end )
315 ),
316
317 TP_fast_assign_btrfs(
318 bi->root->fs_info,
319 __entry->root_obj = bi->root->objectid;
320 __entry->ino = btrfs_ino(bi);
321 __entry->isize = bi->vfs_inode.i_size;
322 __entry->disk_isize = bi->disk_i_size;
323 __entry->extent_type = btrfs_file_extent_type(l, fi);
324 __entry->compression = btrfs_file_extent_compression(l, fi);
325 __entry->extent_start = start;
326 __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi));
327 ),
328
329 TP_printk_btrfs(
330 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
331 "file extent range=[%llu %llu] "
332 "extent_type=%s compression=%u",
333 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
334 __entry->disk_isize, __entry->extent_start,
335 __entry->extent_end, show_fi_type(__entry->extent_type),
336 __entry->compression)
337);
338
339DEFINE_EVENT(
340 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
341
342 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
343 struct btrfs_file_extent_item *fi, u64 start),
344
345 TP_ARGS(bi, l, fi, start)
346);
347
348DEFINE_EVENT(
349 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
350
351 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
352 struct btrfs_file_extent_item *fi, u64 start),
353
354 TP_ARGS(bi, l, fi, start)
355);
356
357DEFINE_EVENT(
358 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
359
360 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
361 struct btrfs_file_extent_item *fi, int slot, u64 start),
362
363 TP_ARGS(bi, l, fi, slot, start)
364);
365
366DEFINE_EVENT(
367 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
368
369 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
370 struct btrfs_file_extent_item *fi, int slot, u64 start),
371
372 TP_ARGS(bi, l, fi, slot, start)
373);
374
Liu Bo9d04a8c2013-11-06 12:04:13 +0800375#define show_ordered_flags(flags) \
376 __print_flags(flags, "|", \
377 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
378 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
379 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
380 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
381 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
382 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
383 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
384 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800385 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
386 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000387
liubo1abe9b82011-03-24 11:18:59 +0000388
389DECLARE_EVENT_CLASS(btrfs__ordered_extent,
390
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600391 TP_PROTO(const struct inode *inode,
392 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000393
394 TP_ARGS(inode, ordered),
395
Jeff Mahoneybc074522016-06-09 17:27:55 -0400396 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000397 __field( ino_t, ino )
398 __field( u64, file_offset )
399 __field( u64, start )
400 __field( u64, len )
401 __field( u64, disk_len )
402 __field( u64, bytes_left )
403 __field( unsigned long, flags )
404 __field( int, compress_type )
405 __field( int, refs )
406 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800407 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000408 ),
409
Jeff Mahoneybc074522016-06-09 17:27:55 -0400410 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000411 __entry->ino = inode->i_ino;
412 __entry->file_offset = ordered->file_offset;
413 __entry->start = ordered->start;
414 __entry->len = ordered->len;
415 __entry->disk_len = ordered->disk_len;
416 __entry->bytes_left = ordered->bytes_left;
417 __entry->flags = ordered->flags;
418 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200419 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000420 __entry->root_objectid =
421 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800422 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000423 ),
424
David Sterba562a7a02017-01-06 15:51:36 +0100425 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
426 "start=%llu len=%llu disk_len=%llu "
427 "truncated_len=%llu "
428 "bytes_left=%llu flags=%s compress_type=%d "
429 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000430 show_root_type(__entry->root_objectid),
431 (unsigned long long)__entry->ino,
432 (unsigned long long)__entry->file_offset,
433 (unsigned long long)__entry->start,
434 (unsigned long long)__entry->len,
435 (unsigned long long)__entry->disk_len,
Liu Bo78566542016-11-30 16:10:10 -0800436 (unsigned long long)__entry->truncated_len,
liubo1abe9b82011-03-24 11:18:59 +0000437 (unsigned long long)__entry->bytes_left,
438 show_ordered_flags(__entry->flags),
439 __entry->compress_type, __entry->refs)
440);
441
442DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
443
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600444 TP_PROTO(const struct inode *inode,
445 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000446
447 TP_ARGS(inode, ordered)
448);
449
450DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
451
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600452 TP_PROTO(const struct inode *inode,
453 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000454
455 TP_ARGS(inode, ordered)
456);
457
458DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
459
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600460 TP_PROTO(const struct inode *inode,
461 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000462
463 TP_ARGS(inode, ordered)
464);
465
466DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
467
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600468 TP_PROTO(const struct inode *inode,
469 const struct btrfs_ordered_extent *ordered),
liubo1abe9b82011-03-24 11:18:59 +0000470
471 TP_ARGS(inode, ordered)
472);
473
474DECLARE_EVENT_CLASS(btrfs__writepage,
475
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600476 TP_PROTO(const struct page *page, const struct inode *inode,
477 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000478
479 TP_ARGS(page, inode, wbc),
480
Jeff Mahoneybc074522016-06-09 17:27:55 -0400481 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000482 __field( ino_t, ino )
483 __field( pgoff_t, index )
484 __field( long, nr_to_write )
485 __field( long, pages_skipped )
486 __field( loff_t, range_start )
487 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000488 __field( char, for_kupdate )
489 __field( char, for_reclaim )
490 __field( char, range_cyclic )
491 __field( pgoff_t, writeback_index )
492 __field( u64, root_objectid )
493 ),
494
Jeff Mahoneybc074522016-06-09 17:27:55 -0400495 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000496 __entry->ino = inode->i_ino;
497 __entry->index = page->index;
498 __entry->nr_to_write = wbc->nr_to_write;
499 __entry->pages_skipped = wbc->pages_skipped;
500 __entry->range_start = wbc->range_start;
501 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000502 __entry->for_kupdate = wbc->for_kupdate;
503 __entry->for_reclaim = wbc->for_reclaim;
504 __entry->range_cyclic = wbc->range_cyclic;
505 __entry->writeback_index = inode->i_mapping->writeback_index;
506 __entry->root_objectid =
507 BTRFS_I(inode)->root->root_key.objectid;
508 ),
509
David Sterba562a7a02017-01-06 15:51:36 +0100510 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
511 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
512 "range_end=%llu for_kupdate=%d "
513 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000514 show_root_type(__entry->root_objectid),
515 (unsigned long)__entry->ino, __entry->index,
516 __entry->nr_to_write, __entry->pages_skipped,
517 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600518 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000519 __entry->for_reclaim, __entry->range_cyclic,
520 (unsigned long)__entry->writeback_index)
521);
522
523DEFINE_EVENT(btrfs__writepage, __extent_writepage,
524
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600525 TP_PROTO(const struct page *page, const struct inode *inode,
526 const struct writeback_control *wbc),
liubo1abe9b82011-03-24 11:18:59 +0000527
528 TP_ARGS(page, inode, wbc)
529);
530
531TRACE_EVENT(btrfs_writepage_end_io_hook,
532
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600533 TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
liubo1abe9b82011-03-24 11:18:59 +0000534
535 TP_ARGS(page, start, end, uptodate),
536
Jeff Mahoneybc074522016-06-09 17:27:55 -0400537 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000538 __field( ino_t, ino )
539 __field( pgoff_t, index )
540 __field( u64, start )
541 __field( u64, end )
542 __field( int, uptodate )
543 __field( u64, root_objectid )
544 ),
545
Jeff Mahoneybc074522016-06-09 17:27:55 -0400546 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000547 __entry->ino = page->mapping->host->i_ino;
548 __entry->index = page->index;
549 __entry->start = start;
550 __entry->end = end;
551 __entry->uptodate = uptodate;
552 __entry->root_objectid =
553 BTRFS_I(page->mapping->host)->root->root_key.objectid;
554 ),
555
David Sterba562a7a02017-01-06 15:51:36 +0100556 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
557 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000558 show_root_type(__entry->root_objectid),
559 (unsigned long)__entry->ino, (unsigned long)__entry->index,
560 (unsigned long long)__entry->start,
561 (unsigned long long)__entry->end, __entry->uptodate)
562);
563
564TRACE_EVENT(btrfs_sync_file,
565
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600566 TP_PROTO(const struct file *file, int datasync),
liubo1abe9b82011-03-24 11:18:59 +0000567
568 TP_ARGS(file, datasync),
569
Jeff Mahoneybc074522016-06-09 17:27:55 -0400570 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000571 __field( ino_t, ino )
572 __field( ino_t, parent )
573 __field( int, datasync )
574 __field( u64, root_objectid )
575 ),
576
577 TP_fast_assign(
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600578 const struct dentry *dentry = file->f_path.dentry;
579 const struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000580
Jeff Mahoneybc074522016-06-09 17:27:55 -0400581 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
liubo1abe9b82011-03-24 11:18:59 +0000582 __entry->ino = inode->i_ino;
David Howells2b0143b2015-03-17 22:25:59 +0000583 __entry->parent = d_inode(dentry->d_parent)->i_ino;
liubo1abe9b82011-03-24 11:18:59 +0000584 __entry->datasync = datasync;
585 __entry->root_objectid =
586 BTRFS_I(inode)->root->root_key.objectid;
587 ),
588
David Sterba562a7a02017-01-06 15:51:36 +0100589 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000590 show_root_type(__entry->root_objectid),
591 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
592 __entry->datasync)
593);
594
595TRACE_EVENT(btrfs_sync_fs,
596
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600597 TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000598
Jeff Mahoneybc074522016-06-09 17:27:55 -0400599 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000600
Jeff Mahoneybc074522016-06-09 17:27:55 -0400601 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000602 __field( int, wait )
603 ),
604
Jeff Mahoneybc074522016-06-09 17:27:55 -0400605 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000606 __entry->wait = wait;
607 ),
608
Jeff Mahoneybc074522016-06-09 17:27:55 -0400609 TP_printk_btrfs("wait = %d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000610);
611
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400612TRACE_EVENT(btrfs_add_block_group,
613
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600614 TP_PROTO(const struct btrfs_fs_info *fs_info,
615 const struct btrfs_block_group_cache *block_group, int create),
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400616
617 TP_ARGS(fs_info, block_group, create),
618
619 TP_STRUCT__entry(
620 __array( u8, fsid, BTRFS_UUID_SIZE )
621 __field( u64, offset )
622 __field( u64, size )
623 __field( u64, flags )
624 __field( u64, bytes_used )
625 __field( u64, bytes_super )
626 __field( int, create )
627 ),
628
629 TP_fast_assign(
630 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
631 __entry->offset = block_group->key.objectid;
632 __entry->size = block_group->key.offset;
633 __entry->flags = block_group->flags;
634 __entry->bytes_used =
635 btrfs_block_group_used(&block_group->item);
636 __entry->bytes_super = block_group->bytes_super;
637 __entry->create = create;
638 ),
639
David Sterba562a7a02017-01-06 15:51:36 +0100640 TP_printk("%pU: block_group offset=%llu size=%llu "
641 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
642 "create=%d", __entry->fsid,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400643 (unsigned long long)__entry->offset,
644 (unsigned long long)__entry->size,
645 (unsigned long long)__entry->flags,
646 __print_flags((unsigned long)__entry->flags, "|",
647 BTRFS_GROUP_FLAGS),
648 (unsigned long long)__entry->bytes_used,
649 (unsigned long long)__entry->bytes_super, __entry->create)
650);
651
liubo1abe9b82011-03-24 11:18:59 +0000652#define show_ref_action(action) \
653 __print_symbolic(action, \
654 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
655 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
656 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
657 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
658
659
Liu Bo599c75e2013-07-16 19:03:36 +0800660DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000661
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600662 TP_PROTO(const struct btrfs_fs_info *fs_info,
663 const struct btrfs_delayed_ref_node *ref,
664 const struct btrfs_delayed_tree_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000665 int action),
666
Jeff Mahoneybc074522016-06-09 17:27:55 -0400667 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000668
Jeff Mahoneybc074522016-06-09 17:27:55 -0400669 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000670 __field( u64, bytenr )
671 __field( u64, num_bytes )
672 __field( int, action )
673 __field( u64, parent )
674 __field( u64, ref_root )
675 __field( int, level )
676 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600677 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000678 ),
679
Jeff Mahoneybc074522016-06-09 17:27:55 -0400680 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000681 __entry->bytenr = ref->bytenr;
682 __entry->num_bytes = ref->num_bytes;
683 __entry->action = action;
684 __entry->parent = full_ref->parent;
685 __entry->ref_root = full_ref->root;
686 __entry->level = full_ref->level;
687 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600688 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000689 ),
690
David Sterba562a7a02017-01-06 15:51:36 +0100691 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
692 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
693 "type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000694 (unsigned long long)__entry->bytenr,
695 (unsigned long long)__entry->num_bytes,
696 show_ref_action(__entry->action),
697 show_root_type(__entry->parent),
698 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600699 __entry->level, show_ref_type(__entry->type),
700 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000701);
702
Liu Bo599c75e2013-07-16 19:03:36 +0800703DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
704
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600705 TP_PROTO(const struct btrfs_fs_info *fs_info,
706 const struct btrfs_delayed_ref_node *ref,
707 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800708 int action),
709
Jeff Mahoneybc074522016-06-09 17:27:55 -0400710 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800711);
712
713DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
714
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600715 TP_PROTO(const struct btrfs_fs_info *fs_info,
716 const struct btrfs_delayed_ref_node *ref,
717 const struct btrfs_delayed_tree_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800718 int action),
719
Jeff Mahoneybc074522016-06-09 17:27:55 -0400720 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800721);
722
723DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000724
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600725 TP_PROTO(const struct btrfs_fs_info *fs_info,
726 const struct btrfs_delayed_ref_node *ref,
727 const struct btrfs_delayed_data_ref *full_ref,
liubo1abe9b82011-03-24 11:18:59 +0000728 int action),
729
Jeff Mahoneybc074522016-06-09 17:27:55 -0400730 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000731
Jeff Mahoneybc074522016-06-09 17:27:55 -0400732 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000733 __field( u64, bytenr )
734 __field( u64, num_bytes )
735 __field( int, action )
736 __field( u64, parent )
737 __field( u64, ref_root )
738 __field( u64, owner )
739 __field( u64, offset )
740 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600741 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000742 ),
743
Jeff Mahoneybc074522016-06-09 17:27:55 -0400744 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000745 __entry->bytenr = ref->bytenr;
746 __entry->num_bytes = ref->num_bytes;
747 __entry->action = action;
748 __entry->parent = full_ref->parent;
749 __entry->ref_root = full_ref->root;
750 __entry->owner = full_ref->objectid;
751 __entry->offset = full_ref->offset;
752 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600753 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000754 ),
755
David Sterba562a7a02017-01-06 15:51:36 +0100756 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
757 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
758 "offset=%llu type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000759 (unsigned long long)__entry->bytenr,
760 (unsigned long long)__entry->num_bytes,
761 show_ref_action(__entry->action),
762 show_root_type(__entry->parent),
763 show_root_type(__entry->ref_root),
764 (unsigned long long)__entry->owner,
765 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600766 show_ref_type(__entry->type),
767 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000768);
769
Liu Bo599c75e2013-07-16 19:03:36 +0800770DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
771
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600772 TP_PROTO(const struct btrfs_fs_info *fs_info,
773 const struct btrfs_delayed_ref_node *ref,
774 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800775 int action),
776
Jeff Mahoneybc074522016-06-09 17:27:55 -0400777 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800778);
779
780DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
781
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600782 TP_PROTO(const struct btrfs_fs_info *fs_info,
783 const struct btrfs_delayed_ref_node *ref,
784 const struct btrfs_delayed_data_ref *full_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800785 int action),
786
Jeff Mahoneybc074522016-06-09 17:27:55 -0400787 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800788);
789
790DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000791
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600792 TP_PROTO(const struct btrfs_fs_info *fs_info,
793 const struct btrfs_delayed_ref_node *ref,
794 const struct btrfs_delayed_ref_head *head_ref,
liubo1abe9b82011-03-24 11:18:59 +0000795 int action),
796
Jeff Mahoneybc074522016-06-09 17:27:55 -0400797 TP_ARGS(fs_info, ref, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000798
Jeff Mahoneybc074522016-06-09 17:27:55 -0400799 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000800 __field( u64, bytenr )
801 __field( u64, num_bytes )
802 __field( int, action )
803 __field( int, is_data )
804 ),
805
Jeff Mahoneybc074522016-06-09 17:27:55 -0400806 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000807 __entry->bytenr = ref->bytenr;
808 __entry->num_bytes = ref->num_bytes;
809 __entry->action = action;
810 __entry->is_data = head_ref->is_data;
811 ),
812
David Sterba562a7a02017-01-06 15:51:36 +0100813 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
liubo1abe9b82011-03-24 11:18:59 +0000814 (unsigned long long)__entry->bytenr,
815 (unsigned long long)__entry->num_bytes,
816 show_ref_action(__entry->action),
817 __entry->is_data)
818);
819
Liu Bo599c75e2013-07-16 19:03:36 +0800820DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
821
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600822 TP_PROTO(const struct btrfs_fs_info *fs_info,
823 const struct btrfs_delayed_ref_node *ref,
824 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800825 int action),
826
Jeff Mahoneybc074522016-06-09 17:27:55 -0400827 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800828);
829
830DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
831
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600832 TP_PROTO(const struct btrfs_fs_info *fs_info,
833 const struct btrfs_delayed_ref_node *ref,
834 const struct btrfs_delayed_ref_head *head_ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800835 int action),
836
Jeff Mahoneybc074522016-06-09 17:27:55 -0400837 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800838);
839
liubo1abe9b82011-03-24 11:18:59 +0000840#define show_chunk_type(type) \
841 __print_flags(type, "|", \
842 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
843 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
844 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
845 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
846 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
847 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000848 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
849 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
850 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000851
852DECLARE_EVENT_CLASS(btrfs__chunk,
853
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600854 TP_PROTO(const struct btrfs_fs_info *fs_info,
855 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000856
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400857 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000858
Jeff Mahoneybc074522016-06-09 17:27:55 -0400859 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000860 __field( int, num_stripes )
861 __field( u64, type )
862 __field( int, sub_stripes )
863 __field( u64, offset )
864 __field( u64, size )
865 __field( u64, root_objectid )
866 ),
867
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400868 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000869 __entry->num_stripes = map->num_stripes;
870 __entry->type = map->type;
871 __entry->sub_stripes = map->sub_stripes;
872 __entry->offset = offset;
873 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400874 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000875 ),
876
David Sterba562a7a02017-01-06 15:51:36 +0100877 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
878 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000879 show_root_type(__entry->root_objectid),
880 (unsigned long long)__entry->offset,
881 (unsigned long long)__entry->size,
882 __entry->num_stripes, __entry->sub_stripes,
883 show_chunk_type(__entry->type))
884);
885
886DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
887
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600888 TP_PROTO(const struct btrfs_fs_info *fs_info,
889 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000890
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400891 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000892);
893
894DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
895
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600896 TP_PROTO(const struct btrfs_fs_info *fs_info,
897 const struct map_lookup *map, u64 offset, u64 size),
liubo1abe9b82011-03-24 11:18:59 +0000898
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400899 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000900);
901
902TRACE_EVENT(btrfs_cow_block,
903
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600904 TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
905 const struct extent_buffer *cow),
liubo1abe9b82011-03-24 11:18:59 +0000906
907 TP_ARGS(root, buf, cow),
908
Jeff Mahoneybc074522016-06-09 17:27:55 -0400909 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000910 __field( u64, root_objectid )
911 __field( u64, buf_start )
912 __field( int, refs )
913 __field( u64, cow_start )
914 __field( int, buf_level )
915 __field( int, cow_level )
916 ),
917
Jeff Mahoneybc074522016-06-09 17:27:55 -0400918 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000919 __entry->root_objectid = root->root_key.objectid;
920 __entry->buf_start = buf->start;
921 __entry->refs = atomic_read(&buf->refs);
922 __entry->cow_start = cow->start;
923 __entry->buf_level = btrfs_header_level(buf);
924 __entry->cow_level = btrfs_header_level(cow);
925 ),
926
David Sterba562a7a02017-01-06 15:51:36 +0100927 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
928 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000929 show_root_type(__entry->root_objectid),
930 __entry->refs,
931 (unsigned long long)__entry->buf_start,
932 __entry->buf_level,
933 (unsigned long long)__entry->cow_start,
934 __entry->cow_level)
935);
936
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500937TRACE_EVENT(btrfs_space_reservation,
938
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600939 TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500940 u64 bytes, int reserve),
941
942 TP_ARGS(fs_info, type, val, bytes, reserve),
943
Jeff Mahoneybc074522016-06-09 17:27:55 -0400944 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500945 __string( type, type )
946 __field( u64, val )
947 __field( u64, bytes )
948 __field( int, reserve )
949 ),
950
Jeff Mahoneybc074522016-06-09 17:27:55 -0400951 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500952 __assign_str(type, type);
953 __entry->val = val;
954 __entry->bytes = bytes;
955 __entry->reserve = reserve;
956 ),
957
Jeff Mahoneybc074522016-06-09 17:27:55 -0400958 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
959 __entry->reserve ? "reserve" : "release",
960 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500961);
962
Josef Bacikf376df22016-03-25 13:25:56 -0400963#define show_flush_action(action) \
964 __print_symbolic(action, \
965 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
966 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
967 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
968
969TRACE_EVENT(btrfs_trigger_flush,
970
Jeff Mahoney9a35b632017-06-28 21:56:54 -0600971 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
Josef Bacikf376df22016-03-25 13:25:56 -0400972 int flush, char *reason),
973
974 TP_ARGS(fs_info, flags, bytes, flush, reason),
975
976 TP_STRUCT__entry(
977 __array( u8, fsid, BTRFS_UUID_SIZE )
978 __field( u64, flags )
979 __field( u64, bytes )
980 __field( int, flush )
981 __string( reason, reason )
982 ),
983
984 TP_fast_assign(
985 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
986 __entry->flags = flags;
987 __entry->bytes = bytes;
988 __entry->flush = flush;
989 __assign_str(reason, reason)
990 ),
991
David Sterba562a7a02017-01-06 15:51:36 +0100992 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
Josef Bacikf376df22016-03-25 13:25:56 -0400993 __entry->fsid, __get_str(reason), __entry->flush,
994 show_flush_action(__entry->flush),
995 (unsigned long long)__entry->flags,
996 __print_flags((unsigned long)__entry->flags, "|",
997 BTRFS_GROUP_FLAGS),
998 (unsigned long long)__entry->bytes)
999);
1000
1001#define show_flush_state(state) \
1002 __print_symbolic(state, \
1003 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
1004 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
1005 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1006 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
1007 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
1008 { COMMIT_TRANS, "COMMIT_TRANS"})
1009
1010TRACE_EVENT(btrfs_flush_space,
1011
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001012 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
Josef Bacikf376df22016-03-25 13:25:56 -04001013 u64 orig_bytes, int state, int ret),
1014
1015 TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),
1016
1017 TP_STRUCT__entry(
1018 __array( u8, fsid, BTRFS_UUID_SIZE )
1019 __field( u64, flags )
1020 __field( u64, num_bytes )
1021 __field( u64, orig_bytes )
1022 __field( int, state )
1023 __field( int, ret )
1024 ),
1025
1026 TP_fast_assign(
1027 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
1028 __entry->flags = flags;
1029 __entry->num_bytes = num_bytes;
1030 __entry->orig_bytes = orig_bytes;
1031 __entry->state = state;
1032 __entry->ret = ret;
1033 ),
1034
David Sterba562a7a02017-01-06 15:51:36 +01001035 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu "
1036 "orig_bytes=%llu ret=%d", __entry->fsid, __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001037 show_flush_state(__entry->state),
1038 (unsigned long long)__entry->flags,
1039 __print_flags((unsigned long)__entry->flags, "|",
1040 BTRFS_GROUP_FLAGS),
1041 (unsigned long long)__entry->num_bytes,
1042 (unsigned long long)__entry->orig_bytes, __entry->ret)
1043);
1044
liubo1abe9b82011-03-24 11:18:59 +00001045DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1046
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001047 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001048
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001049 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001050
Jeff Mahoneybc074522016-06-09 17:27:55 -04001051 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001052 __field( u64, start )
1053 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001054 ),
1055
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001056 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001057 __entry->start = start;
1058 __entry->len = len;
1059 ),
1060
David Sterba562a7a02017-01-06 15:51:36 +01001061 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001062 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
liubo1abe9b82011-03-24 11:18:59 +00001063 (unsigned long long)__entry->start,
1064 (unsigned long long)__entry->len)
1065);
1066
1067DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1068
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001069 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001070
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001071 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001072);
1073
1074DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1075
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001076 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001077
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001078 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001079);
1080
Josef Bacik3f7de032011-11-10 08:29:20 -05001081TRACE_EVENT(find_free_extent,
1082
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001083 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1084 u64 empty_size, u64 data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001085
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001086 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001087
Jeff Mahoneybc074522016-06-09 17:27:55 -04001088 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001089 __field( u64, num_bytes )
1090 __field( u64, empty_size )
1091 __field( u64, data )
1092 ),
1093
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001094 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001095 __entry->num_bytes = num_bytes;
1096 __entry->empty_size = empty_size;
1097 __entry->data = data;
1098 ),
1099
David Sterba562a7a02017-01-06 15:51:36 +01001100 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001101 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001102 __entry->num_bytes, __entry->empty_size, __entry->data,
1103 __print_flags((unsigned long)__entry->data, "|",
1104 BTRFS_GROUP_FLAGS))
1105);
1106
1107DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1108
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001109 TP_PROTO(const struct btrfs_fs_info *fs_info,
1110 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001111 u64 len),
1112
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001113 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001114
Jeff Mahoneybc074522016-06-09 17:27:55 -04001115 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001116 __field( u64, bg_objectid )
1117 __field( u64, flags )
1118 __field( u64, start )
1119 __field( u64, len )
1120 ),
1121
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001122 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001123 __entry->bg_objectid = block_group->key.objectid;
1124 __entry->flags = block_group->flags;
1125 __entry->start = start;
1126 __entry->len = len;
1127 ),
1128
David Sterba562a7a02017-01-06 15:51:36 +01001129 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
1130 "start=%Lu len=%Lu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001131 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1132 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001133 __entry->flags, __print_flags((unsigned long)__entry->flags,
1134 "|", BTRFS_GROUP_FLAGS),
1135 __entry->start, __entry->len)
1136);
1137
1138DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1139
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001140 TP_PROTO(const struct btrfs_fs_info *fs_info,
1141 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001142 u64 len),
1143
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001144 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001145);
1146
1147DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1148
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001149 TP_PROTO(const struct btrfs_fs_info *fs_info,
1150 const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001151 u64 len),
1152
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001153 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001154);
1155
1156TRACE_EVENT(btrfs_find_cluster,
1157
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001158 TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
Josef Bacik3f7de032011-11-10 08:29:20 -05001159 u64 bytes, u64 empty_size, u64 min_bytes),
1160
1161 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1162
Jeff Mahoneybc074522016-06-09 17:27:55 -04001163 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001164 __field( u64, bg_objectid )
1165 __field( u64, flags )
1166 __field( u64, start )
1167 __field( u64, bytes )
1168 __field( u64, empty_size )
1169 __field( u64, min_bytes )
1170 ),
1171
Jeff Mahoneybc074522016-06-09 17:27:55 -04001172 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001173 __entry->bg_objectid = block_group->key.objectid;
1174 __entry->flags = block_group->flags;
1175 __entry->start = start;
1176 __entry->bytes = bytes;
1177 __entry->empty_size = empty_size;
1178 __entry->min_bytes = min_bytes;
1179 ),
1180
David Sterba562a7a02017-01-06 15:51:36 +01001181 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1182 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001183 __entry->flags,
1184 __print_flags((unsigned long)__entry->flags, "|",
1185 BTRFS_GROUP_FLAGS), __entry->start,
1186 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1187);
1188
1189TRACE_EVENT(btrfs_failed_cluster_setup,
1190
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001191 TP_PROTO(const struct btrfs_block_group_cache *block_group),
Josef Bacik3f7de032011-11-10 08:29:20 -05001192
1193 TP_ARGS(block_group),
1194
Jeff Mahoneybc074522016-06-09 17:27:55 -04001195 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001196 __field( u64, bg_objectid )
1197 ),
1198
Jeff Mahoneybc074522016-06-09 17:27:55 -04001199 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001200 __entry->bg_objectid = block_group->key.objectid;
1201 ),
1202
David Sterba562a7a02017-01-06 15:51:36 +01001203 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001204);
1205
1206TRACE_EVENT(btrfs_setup_cluster,
1207
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001208 TP_PROTO(const struct btrfs_block_group_cache *block_group,
1209 const struct btrfs_free_cluster *cluster,
1210 u64 size, int bitmap),
Josef Bacik3f7de032011-11-10 08:29:20 -05001211
1212 TP_ARGS(block_group, cluster, size, bitmap),
1213
Jeff Mahoneybc074522016-06-09 17:27:55 -04001214 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001215 __field( u64, bg_objectid )
1216 __field( u64, flags )
1217 __field( u64, start )
1218 __field( u64, max_size )
1219 __field( u64, size )
1220 __field( int, bitmap )
1221 ),
1222
Jeff Mahoneybc074522016-06-09 17:27:55 -04001223 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001224 __entry->bg_objectid = block_group->key.objectid;
1225 __entry->flags = block_group->flags;
1226 __entry->start = cluster->window_start;
1227 __entry->max_size = cluster->max_size;
1228 __entry->size = size;
1229 __entry->bitmap = bitmap;
1230 ),
1231
David Sterba562a7a02017-01-06 15:51:36 +01001232 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1233 "size=%Lu max_size=%Lu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001234 __entry->bg_objectid,
1235 __entry->flags,
1236 __print_flags((unsigned long)__entry->flags, "|",
1237 BTRFS_GROUP_FLAGS), __entry->start,
1238 __entry->size, __entry->max_size, __entry->bitmap)
1239);
1240
Jeff Mahoney143bede2012-03-01 14:56:26 +01001241struct extent_state;
1242TRACE_EVENT(alloc_extent_state,
1243
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001244 TP_PROTO(const struct extent_state *state,
1245 gfp_t mask, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001246
1247 TP_ARGS(state, mask, IP),
1248
1249 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001250 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001251 __field(gfp_t, mask)
1252 __field(unsigned long, ip)
1253 ),
1254
1255 TP_fast_assign(
1256 __entry->state = state,
1257 __entry->mask = mask,
1258 __entry->ip = IP
1259 ),
1260
David Sterba562a7a02017-01-06 15:51:36 +01001261 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001262 show_gfp_flags(__entry->mask), (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001263);
1264
1265TRACE_EVENT(free_extent_state,
1266
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001267 TP_PROTO(const struct extent_state *state, unsigned long IP),
Jeff Mahoney143bede2012-03-01 14:56:26 +01001268
1269 TP_ARGS(state, IP),
1270
1271 TP_STRUCT__entry(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001272 __field(const struct extent_state *, state)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001273 __field(unsigned long, ip)
1274 ),
1275
1276 TP_fast_assign(
1277 __entry->state = state,
1278 __entry->ip = IP
1279 ),
1280
David Sterba562a7a02017-01-06 15:51:36 +01001281 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001282 (const void *)__entry->ip)
Jeff Mahoney143bede2012-03-01 14:56:26 +01001283);
1284
Qu Wenruo52483bc2014-03-06 04:19:50 +00001285DECLARE_EVENT_CLASS(btrfs__work,
1286
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001287 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001288
1289 TP_ARGS(work),
1290
Jeff Mahoneybc074522016-06-09 17:27:55 -04001291 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001292 __field( const void *, work )
1293 __field( const void *, wq )
1294 __field( const void *, func )
1295 __field( const void *, ordered_func )
1296 __field( const void *, ordered_free )
1297 __field( const void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001298 ),
1299
Jeff Mahoneybc074522016-06-09 17:27:55 -04001300 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001301 __entry->work = work;
1302 __entry->wq = work->wq;
1303 __entry->func = work->func;
1304 __entry->ordered_func = work->ordered_func;
1305 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001306 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001307 ),
1308
David Sterba562a7a02017-01-06 15:51:36 +01001309 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1310 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001311 __entry->work, __entry->normal_work, __entry->wq,
1312 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001313);
1314
David Sterbaac0c7cf2017-01-06 14:12:51 +01001315/*
1316 * For situiations when the work is freed, we pass fs_info and a tag that that
1317 * matches address of the work structure so it can be paired with the
1318 * scheduling event.
1319 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001320DECLARE_EVENT_CLASS(btrfs__work__done,
1321
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001322 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001323
David Sterbaac0c7cf2017-01-06 14:12:51 +01001324 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001325
Jeff Mahoneybc074522016-06-09 17:27:55 -04001326 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001327 __field( const void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001328 ),
1329
David Sterbaac0c7cf2017-01-06 14:12:51 +01001330 TP_fast_assign_btrfs(fs_info,
1331 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001332 ),
1333
David Sterbaac0c7cf2017-01-06 14:12:51 +01001334 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001335);
1336
1337DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1338
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001339 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001340
1341 TP_ARGS(work)
1342);
1343
1344DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1345
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001346 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001347
1348 TP_ARGS(work)
1349);
1350
Qu Wenruo52483bc2014-03-06 04:19:50 +00001351DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1352
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001353 TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001354
David Sterbaac0c7cf2017-01-06 14:12:51 +01001355 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001356);
1357
1358DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1359
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001360 TP_PROTO(const struct btrfs_work *work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001361
1362 TP_ARGS(work)
1363);
1364
Qu Wenruoc3a46892014-03-12 08:05:33 +00001365DECLARE_EVENT_CLASS(btrfs__workqueue,
1366
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001367 TP_PROTO(const struct __btrfs_workqueue *wq,
1368 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001369
1370 TP_ARGS(wq, name, high),
1371
Jeff Mahoneybc074522016-06-09 17:27:55 -04001372 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001373 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001374 __string( name, name )
1375 __field( int , high )
1376 ),
1377
Jeff Mahoneybc074522016-06-09 17:27:55 -04001378 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001379 __entry->wq = wq;
1380 __assign_str(name, name);
1381 __entry->high = high;
1382 ),
1383
David Sterba562a7a02017-01-06 15:51:36 +01001384 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001385 __print_flags(__entry->high, "",
1386 {(WQ_HIGHPRI), "-high"}),
1387 __entry->wq)
1388);
1389
1390DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1391
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001392 TP_PROTO(const struct __btrfs_workqueue *wq,
1393 const char *name, int high),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001394
1395 TP_ARGS(wq, name, high)
1396);
1397
1398DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1399
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001400 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001401
1402 TP_ARGS(wq),
1403
Jeff Mahoneybc074522016-06-09 17:27:55 -04001404 TP_STRUCT__entry_btrfs(
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001405 __field( const void *, wq )
Qu Wenruoc3a46892014-03-12 08:05:33 +00001406 ),
1407
Jeff Mahoneybc074522016-06-09 17:27:55 -04001408 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001409 __entry->wq = wq;
1410 ),
1411
Jeff Mahoneybc074522016-06-09 17:27:55 -04001412 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001413);
1414
1415DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1416
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001417 TP_PROTO(const struct __btrfs_workqueue *wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001418
1419 TP_ARGS(wq)
1420);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001421
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001422#define BTRFS_QGROUP_OPERATIONS \
1423 { QGROUP_RESERVE, "reserve" }, \
1424 { QGROUP_RELEASE, "release" }, \
1425 { QGROUP_FREE, "free" }
1426
1427DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1428
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001429 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1430 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001431
1432 TP_ARGS(inode, start, len, reserved, op),
1433
Jeff Mahoneybc074522016-06-09 17:27:55 -04001434 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001435 __field( u64, rootid )
1436 __field( unsigned long, ino )
1437 __field( u64, start )
1438 __field( u64, len )
1439 __field( u64, reserved )
1440 __field( int, op )
1441 ),
1442
Jeff Mahoneybc074522016-06-09 17:27:55 -04001443 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001444 __entry->rootid = BTRFS_I(inode)->root->objectid;
1445 __entry->ino = inode->i_ino;
1446 __entry->start = start;
1447 __entry->len = len;
1448 __entry->reserved = reserved;
1449 __entry->op = op;
1450 ),
1451
David Sterba562a7a02017-01-06 15:51:36 +01001452 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001453 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1454 __entry->reserved,
1455 __print_flags((unsigned long)__entry->op, "",
1456 BTRFS_QGROUP_OPERATIONS)
1457 )
1458);
1459
1460DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1461
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001462 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1463 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001464
1465 TP_ARGS(inode, start, len, reserved, op)
1466);
1467
1468DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1469
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001470 TP_PROTO(const struct inode *inode, u64 start, u64 len,
1471 u64 reserved, int op),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001472
1473 TP_ARGS(inode, start, len, reserved, op)
1474);
1475
1476DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1477
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001478 TP_PROTO(const struct btrfs_fs_info *fs_info,
1479 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001480
Jeff Mahoneybc074522016-06-09 17:27:55 -04001481 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001482
Jeff Mahoneybc074522016-06-09 17:27:55 -04001483 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001484 __field( u64, ref_root )
1485 __field( u64, reserved )
1486 ),
1487
Jeff Mahoneybc074522016-06-09 17:27:55 -04001488 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001489 __entry->ref_root = ref_root;
1490 __entry->reserved = reserved;
1491 ),
1492
David Sterba562a7a02017-01-06 15:51:36 +01001493 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001494 __entry->ref_root, __entry->reserved)
1495);
1496
1497DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1498
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001499 TP_PROTO(const struct btrfs_fs_info *fs_info,
1500 u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001501
Jeff Mahoneybc074522016-06-09 17:27:55 -04001502 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001503);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001504
1505DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001506 TP_PROTO(const struct btrfs_fs_info *fs_info,
1507 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001508
Jeff Mahoneybc074522016-06-09 17:27:55 -04001509 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001510
Jeff Mahoneybc074522016-06-09 17:27:55 -04001511 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001512 __field( u64, bytenr )
1513 __field( u64, num_bytes )
1514 ),
1515
Jeff Mahoneybc074522016-06-09 17:27:55 -04001516 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001517 __entry->bytenr = rec->bytenr,
1518 __entry->num_bytes = rec->num_bytes;
1519 ),
1520
David Sterba562a7a02017-01-06 15:51:36 +01001521 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001522 (unsigned long long)__entry->bytenr,
1523 (unsigned long long)__entry->num_bytes)
1524);
1525
1526DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1527
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001528 TP_PROTO(const struct btrfs_fs_info *fs_info,
1529 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001530
Jeff Mahoneybc074522016-06-09 17:27:55 -04001531 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001532);
1533
Qu Wenruo50b3e042016-10-18 09:31:27 +08001534DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001535
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001536 TP_PROTO(const struct btrfs_fs_info *fs_info,
1537 const struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001538
Jeff Mahoneybc074522016-06-09 17:27:55 -04001539 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001540);
1541
1542TRACE_EVENT(btrfs_qgroup_account_extent,
1543
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001544 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 bytenr,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001545 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001546
Jeff Mahoneybc074522016-06-09 17:27:55 -04001547 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001548
Jeff Mahoneybc074522016-06-09 17:27:55 -04001549 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001550 __field( u64, bytenr )
1551 __field( u64, num_bytes )
1552 __field( u64, nr_old_roots )
1553 __field( u64, nr_new_roots )
1554 ),
1555
Jeff Mahoneybc074522016-06-09 17:27:55 -04001556 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001557 __entry->bytenr = bytenr;
1558 __entry->num_bytes = num_bytes;
1559 __entry->nr_old_roots = nr_old_roots;
1560 __entry->nr_new_roots = nr_new_roots;
1561 ),
1562
David Sterba562a7a02017-01-06 15:51:36 +01001563 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1564 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001565 __entry->bytenr,
1566 __entry->num_bytes,
1567 __entry->nr_old_roots,
1568 __entry->nr_new_roots)
1569);
1570
1571TRACE_EVENT(qgroup_update_counters,
1572
Jeff Mahoney9a35b632017-06-28 21:56:54 -06001573 TP_PROTO(const struct btrfs_fs_info *fs_info, u64 qgid,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001574 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001575
Jeff Mahoneybc074522016-06-09 17:27:55 -04001576 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001577
Jeff Mahoneybc074522016-06-09 17:27:55 -04001578 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001579 __field( u64, qgid )
1580 __field( u64, cur_old_count )
1581 __field( u64, cur_new_count )
1582 ),
1583
Jeff Mahoneybc074522016-06-09 17:27:55 -04001584 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001585 __entry->qgid = qgid;
1586 __entry->cur_old_count = cur_old_count;
1587 __entry->cur_new_count = cur_new_count;
1588 ),
1589
David Sterba562a7a02017-01-06 15:51:36 +01001590 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001591 __entry->qgid,
1592 __entry->cur_old_count,
1593 __entry->cur_new_count)
1594);
1595
Qu Wenruo3159fe72017-03-13 15:52:08 +08001596TRACE_EVENT(qgroup_update_reserve,
1597
1598 TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
1599 s64 diff),
1600
1601 TP_ARGS(fs_info, qgroup, diff),
1602
1603 TP_STRUCT__entry_btrfs(
1604 __field( u64, qgid )
1605 __field( u64, cur_reserved )
1606 __field( s64, diff )
1607 ),
1608
1609 TP_fast_assign_btrfs(fs_info,
1610 __entry->qgid = qgroup->qgroupid;
1611 __entry->cur_reserved = qgroup->reserved;
1612 __entry->diff = diff;
1613 ),
1614
1615 TP_printk_btrfs("qgid=%llu cur_reserved=%llu diff=%lld",
1616 __entry->qgid, __entry->cur_reserved, __entry->diff)
1617);
1618
1619TRACE_EVENT(qgroup_meta_reserve,
1620
1621 TP_PROTO(struct btrfs_root *root, s64 diff),
1622
1623 TP_ARGS(root, diff),
1624
1625 TP_STRUCT__entry_btrfs(
1626 __field( u64, refroot )
1627 __field( s64, diff )
1628 ),
1629
1630 TP_fast_assign_btrfs(root->fs_info,
1631 __entry->refroot = root->objectid;
1632 __entry->diff = diff;
1633 ),
1634
1635 TP_printk_btrfs("refroot=%llu(%s) diff=%lld",
1636 show_root_type(__entry->refroot), __entry->diff)
1637);
1638
liubo1abe9b82011-03-24 11:18:59 +00001639#endif /* _TRACE_BTRFS_H */
1640
1641/* This part must be outside protection */
1642#include <trace/define_trace.h>