blob: cef39e2baf2161c34be1b41afbaadf24601018d4 [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;
liubo1abe9b82011-03-24 11:18:59 +000028
29#define show_ref_type(type) \
30 __print_symbolic(type, \
31 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
32 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
33 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
34 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
35 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
36
37#define __show_root_type(obj) \
liubo7f34b742011-04-19 09:35:31 +080038 __print_symbolic_u64(obj, \
liubo1abe9b82011-03-24 11:18:59 +000039 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
40 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
41 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
42 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
43 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
44 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
45 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
46 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
Liu Boe112e2b2013-05-26 13:50:28 +000047 { BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000048 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
Omar Sandoval208acb82015-09-29 20:50:34 -070049 { BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" }, \
50 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" }, \
liubo1abe9b82011-03-24 11:18:59 +000051 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
52
53#define show_root_type(obj) \
54 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
Liu Bofb57dc82012-11-30 11:24:22 +000055 (obj >= BTRFS_ROOT_TREE_OBJECTID && \
Liu Boe112e2b2013-05-26 13:50:28 +000056 obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
liubo1abe9b82011-03-24 11:18:59 +000057
Liu Bo09ed2f12017-03-10 11:09:48 -080058#define show_fi_type(type) \
59 __print_symbolic(type, \
60 { BTRFS_FILE_EXTENT_INLINE, "INLINE" }, \
61 { BTRFS_FILE_EXTENT_REG, "REG" }, \
62 { BTRFS_FILE_EXTENT_PREALLOC, "PREALLOC"})
63
Josef Bacik3f7de032011-11-10 08:29:20 -050064#define BTRFS_GROUP_FLAGS \
Liu Boe112e2b2013-05-26 13:50:28 +000065 { BTRFS_BLOCK_GROUP_DATA, "DATA"}, \
66 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
67 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
68 { BTRFS_BLOCK_GROUP_RAID0, "RAID0"}, \
69 { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \
70 { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \
71 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
72 { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \
73 { BTRFS_BLOCK_GROUP_RAID6, "RAID6"}
Josef Bacik3f7de032011-11-10 08:29:20 -050074
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050075#define BTRFS_UUID_SIZE 16
Jeff Mahoneybc074522016-06-09 17:27:55 -040076#define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_UUID_SIZE)
77
78#define TP_fast_assign_fsid(fs_info) \
79 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE)
80
81#define TP_STRUCT__entry_btrfs(args...) \
82 TP_STRUCT__entry( \
83 TP_STRUCT__entry_fsid \
84 args)
85#define TP_fast_assign_btrfs(fs_info, args...) \
86 TP_fast_assign( \
87 TP_fast_assign_fsid(fs_info); \
88 args)
89#define TP_printk_btrfs(fmt, args...) \
90 TP_printk("%pU: " fmt, __entry->fsid, args)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -050091
liubo1abe9b82011-03-24 11:18:59 +000092TRACE_EVENT(btrfs_transaction_commit,
93
94 TP_PROTO(struct btrfs_root *root),
95
96 TP_ARGS(root),
97
Jeff Mahoneybc074522016-06-09 17:27:55 -040098 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +000099 __field( u64, generation )
100 __field( u64, root_objectid )
101 ),
102
Jeff Mahoneybc074522016-06-09 17:27:55 -0400103 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000104 __entry->generation = root->fs_info->generation;
105 __entry->root_objectid = root->root_key.objectid;
106 ),
107
Jeff Mahoneybc074522016-06-09 17:27:55 -0400108 TP_printk_btrfs("root = %llu(%s), gen = %llu",
liubo1abe9b82011-03-24 11:18:59 +0000109 show_root_type(__entry->root_objectid),
110 (unsigned long long)__entry->generation)
111);
112
113DECLARE_EVENT_CLASS(btrfs__inode,
114
115 TP_PROTO(struct inode *inode),
116
117 TP_ARGS(inode),
118
Jeff Mahoneybc074522016-06-09 17:27:55 -0400119 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000120 __field( ino_t, ino )
121 __field( blkcnt_t, blocks )
122 __field( u64, disk_i_size )
123 __field( u64, generation )
124 __field( u64, last_trans )
125 __field( u64, logged_trans )
126 __field( u64, root_objectid )
127 ),
128
Jeff Mahoneybc074522016-06-09 17:27:55 -0400129 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000130 __entry->ino = inode->i_ino;
131 __entry->blocks = inode->i_blocks;
132 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
133 __entry->generation = BTRFS_I(inode)->generation;
134 __entry->last_trans = BTRFS_I(inode)->last_trans;
135 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
136 __entry->root_objectid =
137 BTRFS_I(inode)->root->root_key.objectid;
138 ),
139
David Sterba562a7a02017-01-06 15:51:36 +0100140 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
141 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000142 show_root_type(__entry->root_objectid),
143 (unsigned long long)__entry->generation,
144 (unsigned long)__entry->ino,
145 (unsigned long long)__entry->blocks,
146 (unsigned long long)__entry->disk_i_size,
147 (unsigned long long)__entry->last_trans,
148 (unsigned long long)__entry->logged_trans)
149);
150
151DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
152
153 TP_PROTO(struct inode *inode),
154
155 TP_ARGS(inode)
156);
157
158DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
159
160 TP_PROTO(struct inode *inode),
161
162 TP_ARGS(inode)
163);
164
165DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
166
167 TP_PROTO(struct inode *inode),
168
169 TP_ARGS(inode)
170);
171
172#define __show_map_type(type) \
liubo7f34b742011-04-19 09:35:31 +0800173 __print_symbolic_u64(type, \
liubo1abe9b82011-03-24 11:18:59 +0000174 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
175 { EXTENT_MAP_HOLE, "HOLE" }, \
176 { EXTENT_MAP_INLINE, "INLINE" }, \
177 { EXTENT_MAP_DELALLOC, "DELALLOC" })
178
179#define show_map_type(type) \
180 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
181
182#define show_map_flags(flag) \
183 __print_flags(flag, "|", \
Liu Bo254a2d12014-09-17 21:36:41 +0800184 { (1 << EXTENT_FLAG_PINNED), "PINNED" },\
185 { (1 << EXTENT_FLAG_COMPRESSED), "COMPRESSED" },\
186 { (1 << EXTENT_FLAG_VACANCY), "VACANCY" },\
187 { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\
188 { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\
189 { (1 << EXTENT_FLAG_FILLING), "FILLING" },\
190 { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" })
liubo1abe9b82011-03-24 11:18:59 +0000191
Steven Rostedt4cd85872013-11-14 22:57:29 -0500192TRACE_EVENT_CONDITION(btrfs_get_extent,
liubo1abe9b82011-03-24 11:18:59 +0000193
Nikolay Borisov4a0cc7c2017-01-10 20:35:31 +0200194 TP_PROTO(struct btrfs_root *root, struct btrfs_inode *inode,
Liu Bo92a1bf72016-11-17 15:00:50 -0800195 struct extent_map *map),
liubo1abe9b82011-03-24 11:18:59 +0000196
Liu Bo92a1bf72016-11-17 15:00:50 -0800197 TP_ARGS(root, inode, map),
liubo1abe9b82011-03-24 11:18:59 +0000198
Steven Rostedt4cd85872013-11-14 22:57:29 -0500199 TP_CONDITION(map),
200
Jeff Mahoneybc074522016-06-09 17:27:55 -0400201 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000202 __field( u64, root_objectid )
Liu Bo92a1bf72016-11-17 15:00:50 -0800203 __field( u64, ino )
liubo1abe9b82011-03-24 11:18:59 +0000204 __field( u64, start )
205 __field( u64, len )
206 __field( u64, orig_start )
207 __field( u64, block_start )
208 __field( u64, block_len )
209 __field( unsigned long, flags )
210 __field( int, refs )
211 __field( unsigned int, compress_type )
212 ),
213
Jeff Mahoneybc074522016-06-09 17:27:55 -0400214 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000215 __entry->root_objectid = root->root_key.objectid;
Liu Bo92a1bf72016-11-17 15:00:50 -0800216 __entry->ino = btrfs_ino(inode);
217 __entry->start = map->start;
liubo1abe9b82011-03-24 11:18:59 +0000218 __entry->len = map->len;
219 __entry->orig_start = map->orig_start;
220 __entry->block_start = map->block_start;
221 __entry->block_len = map->block_len;
222 __entry->flags = map->flags;
Elena Reshetova490b54d2017-03-03 10:55:12 +0200223 __entry->refs = refcount_read(&map->refs);
liubo1abe9b82011-03-24 11:18:59 +0000224 __entry->compress_type = map->compress_type;
225 ),
226
David Sterba562a7a02017-01-06 15:51:36 +0100227 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
228 "orig_start=%llu block_start=%llu(%s) "
229 "block_len=%llu flags=%s refs=%u "
230 "compress_type=%u",
liubo1abe9b82011-03-24 11:18:59 +0000231 show_root_type(__entry->root_objectid),
Liu Bo92a1bf72016-11-17 15:00:50 -0800232 (unsigned long long)__entry->ino,
liubo1abe9b82011-03-24 11:18:59 +0000233 (unsigned long long)__entry->start,
234 (unsigned long long)__entry->len,
235 (unsigned long long)__entry->orig_start,
236 show_map_type(__entry->block_start),
237 (unsigned long long)__entry->block_len,
238 show_map_flags(__entry->flags),
239 __entry->refs, __entry->compress_type)
240);
241
Liu Bo09ed2f12017-03-10 11:09:48 -0800242/* file extent item */
243DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
244
245 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
246 struct btrfs_file_extent_item *fi, u64 start),
247
248 TP_ARGS(bi, l, fi, start),
249
250 TP_STRUCT__entry_btrfs(
251 __field( u64, root_obj )
252 __field( u64, ino )
253 __field( loff_t, isize )
254 __field( u64, disk_isize )
255 __field( u64, num_bytes )
256 __field( u64, ram_bytes )
257 __field( u64, disk_bytenr )
258 __field( u64, disk_num_bytes )
259 __field( u64, extent_offset )
260 __field( u8, extent_type )
261 __field( u8, compression )
262 __field( u64, extent_start )
263 __field( u64, extent_end )
264 ),
265
266 TP_fast_assign_btrfs(bi->root->fs_info,
267 __entry->root_obj = bi->root->objectid;
268 __entry->ino = btrfs_ino(bi);
269 __entry->isize = bi->vfs_inode.i_size;
270 __entry->disk_isize = bi->disk_i_size;
271 __entry->num_bytes = btrfs_file_extent_num_bytes(l, fi);
272 __entry->ram_bytes = btrfs_file_extent_ram_bytes(l, fi);
273 __entry->disk_bytenr = btrfs_file_extent_disk_bytenr(l, fi);
274 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
275 __entry->extent_offset = btrfs_file_extent_offset(l, fi);
276 __entry->extent_type = btrfs_file_extent_type(l, fi);
277 __entry->compression = btrfs_file_extent_compression(l, fi);
278 __entry->extent_start = start;
279 __entry->extent_end = (start + __entry->num_bytes);
280 ),
281
282 TP_printk_btrfs(
283 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
284 "file extent range=[%llu %llu] "
285 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
286 "disk_num_bytes=%llu extent_offset=%llu type=%s "
287 "compression=%u",
288 show_root_type(__entry->root_obj), __entry->ino,
289 __entry->isize,
290 __entry->disk_isize, __entry->extent_start,
291 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
292 __entry->disk_bytenr, __entry->disk_num_bytes,
293 __entry->extent_offset, show_fi_type(__entry->extent_type),
294 __entry->compression)
295);
296
297DECLARE_EVENT_CLASS(
298 btrfs__file_extent_item_inline,
299
300 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
301 struct btrfs_file_extent_item *fi, int slot, u64 start),
302
303 TP_ARGS(bi, l, fi, slot, start),
304
305 TP_STRUCT__entry_btrfs(
306 __field( u64, root_obj )
307 __field( u64, ino )
308 __field( loff_t, isize )
309 __field( u64, disk_isize )
310 __field( u8, extent_type )
311 __field( u8, compression )
312 __field( u64, extent_start )
313 __field( u64, extent_end )
314 ),
315
316 TP_fast_assign_btrfs(
317 bi->root->fs_info,
318 __entry->root_obj = bi->root->objectid;
319 __entry->ino = btrfs_ino(bi);
320 __entry->isize = bi->vfs_inode.i_size;
321 __entry->disk_isize = bi->disk_i_size;
322 __entry->extent_type = btrfs_file_extent_type(l, fi);
323 __entry->compression = btrfs_file_extent_compression(l, fi);
324 __entry->extent_start = start;
325 __entry->extent_end = (start + btrfs_file_extent_inline_len(l, slot, fi));
326 ),
327
328 TP_printk_btrfs(
329 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
330 "file extent range=[%llu %llu] "
331 "extent_type=%s compression=%u",
332 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
333 __entry->disk_isize, __entry->extent_start,
334 __entry->extent_end, show_fi_type(__entry->extent_type),
335 __entry->compression)
336);
337
338DEFINE_EVENT(
339 btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
340
341 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
342 struct btrfs_file_extent_item *fi, u64 start),
343
344 TP_ARGS(bi, l, fi, start)
345);
346
347DEFINE_EVENT(
348 btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
349
350 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
351 struct btrfs_file_extent_item *fi, u64 start),
352
353 TP_ARGS(bi, l, fi, start)
354);
355
356DEFINE_EVENT(
357 btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
358
359 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
360 struct btrfs_file_extent_item *fi, int slot, u64 start),
361
362 TP_ARGS(bi, l, fi, slot, start)
363);
364
365DEFINE_EVENT(
366 btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
367
368 TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
369 struct btrfs_file_extent_item *fi, int slot, u64 start),
370
371 TP_ARGS(bi, l, fi, slot, start)
372);
373
Liu Bo9d04a8c2013-11-06 12:04:13 +0800374#define show_ordered_flags(flags) \
375 __print_flags(flags, "|", \
376 { (1 << BTRFS_ORDERED_IO_DONE), "IO_DONE" }, \
377 { (1 << BTRFS_ORDERED_COMPLETE), "COMPLETE" }, \
378 { (1 << BTRFS_ORDERED_NOCOW), "NOCOW" }, \
379 { (1 << BTRFS_ORDERED_COMPRESSED), "COMPRESSED" }, \
380 { (1 << BTRFS_ORDERED_PREALLOC), "PREALLOC" }, \
381 { (1 << BTRFS_ORDERED_DIRECT), "DIRECT" }, \
382 { (1 << BTRFS_ORDERED_IOERR), "IOERR" }, \
383 { (1 << BTRFS_ORDERED_UPDATED_ISIZE), "UPDATED_ISIZE" }, \
Liu Bo792ddef2013-11-06 12:04:14 +0800384 { (1 << BTRFS_ORDERED_LOGGED_CSUM), "LOGGED_CSUM" }, \
385 { (1 << BTRFS_ORDERED_TRUNCATED), "TRUNCATED" })
Liu Boe112e2b2013-05-26 13:50:28 +0000386
liubo1abe9b82011-03-24 11:18:59 +0000387
388DECLARE_EVENT_CLASS(btrfs__ordered_extent,
389
390 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
391
392 TP_ARGS(inode, ordered),
393
Jeff Mahoneybc074522016-06-09 17:27:55 -0400394 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000395 __field( ino_t, ino )
396 __field( u64, file_offset )
397 __field( u64, start )
398 __field( u64, len )
399 __field( u64, disk_len )
400 __field( u64, bytes_left )
401 __field( unsigned long, flags )
402 __field( int, compress_type )
403 __field( int, refs )
404 __field( u64, root_objectid )
Liu Bo78566542016-11-30 16:10:10 -0800405 __field( u64, truncated_len )
liubo1abe9b82011-03-24 11:18:59 +0000406 ),
407
Jeff Mahoneybc074522016-06-09 17:27:55 -0400408 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000409 __entry->ino = inode->i_ino;
410 __entry->file_offset = ordered->file_offset;
411 __entry->start = ordered->start;
412 __entry->len = ordered->len;
413 __entry->disk_len = ordered->disk_len;
414 __entry->bytes_left = ordered->bytes_left;
415 __entry->flags = ordered->flags;
416 __entry->compress_type = ordered->compress_type;
Elena Reshetovae76edab2017-03-03 10:55:13 +0200417 __entry->refs = refcount_read(&ordered->refs);
liubo1abe9b82011-03-24 11:18:59 +0000418 __entry->root_objectid =
419 BTRFS_I(inode)->root->root_key.objectid;
Liu Bo78566542016-11-30 16:10:10 -0800420 __entry->truncated_len = ordered->truncated_len;
liubo1abe9b82011-03-24 11:18:59 +0000421 ),
422
David Sterba562a7a02017-01-06 15:51:36 +0100423 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
424 "start=%llu len=%llu disk_len=%llu "
425 "truncated_len=%llu "
426 "bytes_left=%llu flags=%s compress_type=%d "
427 "refs=%d",
liubo1abe9b82011-03-24 11:18:59 +0000428 show_root_type(__entry->root_objectid),
429 (unsigned long long)__entry->ino,
430 (unsigned long long)__entry->file_offset,
431 (unsigned long long)__entry->start,
432 (unsigned long long)__entry->len,
433 (unsigned long long)__entry->disk_len,
Liu Bo78566542016-11-30 16:10:10 -0800434 (unsigned long long)__entry->truncated_len,
liubo1abe9b82011-03-24 11:18:59 +0000435 (unsigned long long)__entry->bytes_left,
436 show_ordered_flags(__entry->flags),
437 __entry->compress_type, __entry->refs)
438);
439
440DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
441
442 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
443
444 TP_ARGS(inode, ordered)
445);
446
447DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
448
449 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
450
451 TP_ARGS(inode, ordered)
452);
453
454DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
455
456 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
457
458 TP_ARGS(inode, ordered)
459);
460
461DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
462
463 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
464
465 TP_ARGS(inode, ordered)
466);
467
468DECLARE_EVENT_CLASS(btrfs__writepage,
469
470 TP_PROTO(struct page *page, struct inode *inode,
471 struct writeback_control *wbc),
472
473 TP_ARGS(page, inode, wbc),
474
Jeff Mahoneybc074522016-06-09 17:27:55 -0400475 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000476 __field( ino_t, ino )
477 __field( pgoff_t, index )
478 __field( long, nr_to_write )
479 __field( long, pages_skipped )
480 __field( loff_t, range_start )
481 __field( loff_t, range_end )
liubo1abe9b82011-03-24 11:18:59 +0000482 __field( char, for_kupdate )
483 __field( char, for_reclaim )
484 __field( char, range_cyclic )
485 __field( pgoff_t, writeback_index )
486 __field( u64, root_objectid )
487 ),
488
Jeff Mahoneybc074522016-06-09 17:27:55 -0400489 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000490 __entry->ino = inode->i_ino;
491 __entry->index = page->index;
492 __entry->nr_to_write = wbc->nr_to_write;
493 __entry->pages_skipped = wbc->pages_skipped;
494 __entry->range_start = wbc->range_start;
495 __entry->range_end = wbc->range_end;
liubo1abe9b82011-03-24 11:18:59 +0000496 __entry->for_kupdate = wbc->for_kupdate;
497 __entry->for_reclaim = wbc->for_reclaim;
498 __entry->range_cyclic = wbc->range_cyclic;
499 __entry->writeback_index = inode->i_mapping->writeback_index;
500 __entry->root_objectid =
501 BTRFS_I(inode)->root->root_key.objectid;
502 ),
503
David Sterba562a7a02017-01-06 15:51:36 +0100504 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
505 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
506 "range_end=%llu for_kupdate=%d "
507 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
liubo1abe9b82011-03-24 11:18:59 +0000508 show_root_type(__entry->root_objectid),
509 (unsigned long)__entry->ino, __entry->index,
510 __entry->nr_to_write, __entry->pages_skipped,
511 __entry->range_start, __entry->range_end,
Wu Fengguang846d5a02011-05-05 21:10:38 -0600512 __entry->for_kupdate,
liubo1abe9b82011-03-24 11:18:59 +0000513 __entry->for_reclaim, __entry->range_cyclic,
514 (unsigned long)__entry->writeback_index)
515);
516
517DEFINE_EVENT(btrfs__writepage, __extent_writepage,
518
519 TP_PROTO(struct page *page, struct inode *inode,
520 struct writeback_control *wbc),
521
522 TP_ARGS(page, inode, wbc)
523);
524
525TRACE_EVENT(btrfs_writepage_end_io_hook,
526
527 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
528
529 TP_ARGS(page, start, end, uptodate),
530
Jeff Mahoneybc074522016-06-09 17:27:55 -0400531 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000532 __field( ino_t, ino )
533 __field( pgoff_t, index )
534 __field( u64, start )
535 __field( u64, end )
536 __field( int, uptodate )
537 __field( u64, root_objectid )
538 ),
539
Jeff Mahoneybc074522016-06-09 17:27:55 -0400540 TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
liubo1abe9b82011-03-24 11:18:59 +0000541 __entry->ino = page->mapping->host->i_ino;
542 __entry->index = page->index;
543 __entry->start = start;
544 __entry->end = end;
545 __entry->uptodate = uptodate;
546 __entry->root_objectid =
547 BTRFS_I(page->mapping->host)->root->root_key.objectid;
548 ),
549
David Sterba562a7a02017-01-06 15:51:36 +0100550 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
551 "end=%llu uptodate=%d",
liubo1abe9b82011-03-24 11:18:59 +0000552 show_root_type(__entry->root_objectid),
553 (unsigned long)__entry->ino, (unsigned long)__entry->index,
554 (unsigned long long)__entry->start,
555 (unsigned long long)__entry->end, __entry->uptodate)
556);
557
558TRACE_EVENT(btrfs_sync_file,
559
560 TP_PROTO(struct file *file, int datasync),
561
562 TP_ARGS(file, datasync),
563
Jeff Mahoneybc074522016-06-09 17:27:55 -0400564 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000565 __field( ino_t, ino )
566 __field( ino_t, parent )
567 __field( int, datasync )
568 __field( u64, root_objectid )
569 ),
570
571 TP_fast_assign(
572 struct dentry *dentry = file->f_path.dentry;
David Howells2b0143b2015-03-17 22:25:59 +0000573 struct inode *inode = d_inode(dentry);
liubo1abe9b82011-03-24 11:18:59 +0000574
Jeff Mahoneybc074522016-06-09 17:27:55 -0400575 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
liubo1abe9b82011-03-24 11:18:59 +0000576 __entry->ino = inode->i_ino;
David Howells2b0143b2015-03-17 22:25:59 +0000577 __entry->parent = d_inode(dentry->d_parent)->i_ino;
liubo1abe9b82011-03-24 11:18:59 +0000578 __entry->datasync = datasync;
579 __entry->root_objectid =
580 BTRFS_I(inode)->root->root_key.objectid;
581 ),
582
David Sterba562a7a02017-01-06 15:51:36 +0100583 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
liubo1abe9b82011-03-24 11:18:59 +0000584 show_root_type(__entry->root_objectid),
585 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
586 __entry->datasync)
587);
588
589TRACE_EVENT(btrfs_sync_fs,
590
Jeff Mahoneybc074522016-06-09 17:27:55 -0400591 TP_PROTO(struct btrfs_fs_info *fs_info, int wait),
liubo1abe9b82011-03-24 11:18:59 +0000592
Jeff Mahoneybc074522016-06-09 17:27:55 -0400593 TP_ARGS(fs_info, wait),
liubo1abe9b82011-03-24 11:18:59 +0000594
Jeff Mahoneybc074522016-06-09 17:27:55 -0400595 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000596 __field( int, wait )
597 ),
598
Jeff Mahoneybc074522016-06-09 17:27:55 -0400599 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000600 __entry->wait = wait;
601 ),
602
Jeff Mahoneybc074522016-06-09 17:27:55 -0400603 TP_printk_btrfs("wait = %d", __entry->wait)
liubo1abe9b82011-03-24 11:18:59 +0000604);
605
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400606TRACE_EVENT(btrfs_add_block_group,
607
608 TP_PROTO(struct btrfs_fs_info *fs_info,
609 struct btrfs_block_group_cache *block_group, int create),
610
611 TP_ARGS(fs_info, block_group, create),
612
613 TP_STRUCT__entry(
614 __array( u8, fsid, BTRFS_UUID_SIZE )
615 __field( u64, offset )
616 __field( u64, size )
617 __field( u64, flags )
618 __field( u64, bytes_used )
619 __field( u64, bytes_super )
620 __field( int, create )
621 ),
622
623 TP_fast_assign(
624 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
625 __entry->offset = block_group->key.objectid;
626 __entry->size = block_group->key.offset;
627 __entry->flags = block_group->flags;
628 __entry->bytes_used =
629 btrfs_block_group_used(&block_group->item);
630 __entry->bytes_super = block_group->bytes_super;
631 __entry->create = create;
632 ),
633
David Sterba562a7a02017-01-06 15:51:36 +0100634 TP_printk("%pU: block_group offset=%llu size=%llu "
635 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
636 "create=%d", __entry->fsid,
Josef Bacikc83f8ef2016-03-25 13:25:52 -0400637 (unsigned long long)__entry->offset,
638 (unsigned long long)__entry->size,
639 (unsigned long long)__entry->flags,
640 __print_flags((unsigned long)__entry->flags, "|",
641 BTRFS_GROUP_FLAGS),
642 (unsigned long long)__entry->bytes_used,
643 (unsigned long long)__entry->bytes_super, __entry->create)
644);
645
liubo1abe9b82011-03-24 11:18:59 +0000646#define show_ref_action(action) \
647 __print_symbolic(action, \
648 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
649 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
650 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
651 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
652
653
Liu Bo599c75e2013-07-16 19:03:36 +0800654DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
liubo1abe9b82011-03-24 11:18:59 +0000655
Jeff Mahoneybc074522016-06-09 17:27:55 -0400656 TP_PROTO(struct btrfs_fs_info *fs_info,
657 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000658 struct btrfs_delayed_tree_ref *full_ref,
659 int action),
660
Jeff Mahoneybc074522016-06-09 17:27:55 -0400661 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000662
Jeff Mahoneybc074522016-06-09 17:27:55 -0400663 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000664 __field( u64, bytenr )
665 __field( u64, num_bytes )
666 __field( int, action )
667 __field( u64, parent )
668 __field( u64, ref_root )
669 __field( int, level )
670 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600671 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000672 ),
673
Jeff Mahoneybc074522016-06-09 17:27:55 -0400674 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000675 __entry->bytenr = ref->bytenr;
676 __entry->num_bytes = ref->num_bytes;
677 __entry->action = action;
678 __entry->parent = full_ref->parent;
679 __entry->ref_root = full_ref->root;
680 __entry->level = full_ref->level;
681 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600682 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000683 ),
684
David Sterba562a7a02017-01-06 15:51:36 +0100685 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
686 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
687 "type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000688 (unsigned long long)__entry->bytenr,
689 (unsigned long long)__entry->num_bytes,
690 show_ref_action(__entry->action),
691 show_root_type(__entry->parent),
692 show_root_type(__entry->ref_root),
Liu Bodea7d762012-09-07 20:01:27 -0600693 __entry->level, show_ref_type(__entry->type),
694 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000695);
696
Liu Bo599c75e2013-07-16 19:03:36 +0800697DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
698
Jeff Mahoneybc074522016-06-09 17:27:55 -0400699 TP_PROTO(struct btrfs_fs_info *fs_info,
700 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800701 struct btrfs_delayed_tree_ref *full_ref,
702 int action),
703
Jeff Mahoneybc074522016-06-09 17:27:55 -0400704 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800705);
706
707DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
708
Jeff Mahoneybc074522016-06-09 17:27:55 -0400709 TP_PROTO(struct btrfs_fs_info *fs_info,
710 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800711 struct btrfs_delayed_tree_ref *full_ref,
712 int action),
713
Jeff Mahoneybc074522016-06-09 17:27:55 -0400714 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800715);
716
717DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
liubo1abe9b82011-03-24 11:18:59 +0000718
Jeff Mahoneybc074522016-06-09 17:27:55 -0400719 TP_PROTO(struct btrfs_fs_info *fs_info,
720 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000721 struct btrfs_delayed_data_ref *full_ref,
722 int action),
723
Jeff Mahoneybc074522016-06-09 17:27:55 -0400724 TP_ARGS(fs_info, ref, full_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000725
Jeff Mahoneybc074522016-06-09 17:27:55 -0400726 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000727 __field( u64, bytenr )
728 __field( u64, num_bytes )
729 __field( int, action )
730 __field( u64, parent )
731 __field( u64, ref_root )
732 __field( u64, owner )
733 __field( u64, offset )
734 __field( int, type )
Liu Bodea7d762012-09-07 20:01:27 -0600735 __field( u64, seq )
liubo1abe9b82011-03-24 11:18:59 +0000736 ),
737
Jeff Mahoneybc074522016-06-09 17:27:55 -0400738 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000739 __entry->bytenr = ref->bytenr;
740 __entry->num_bytes = ref->num_bytes;
741 __entry->action = action;
742 __entry->parent = full_ref->parent;
743 __entry->ref_root = full_ref->root;
744 __entry->owner = full_ref->objectid;
745 __entry->offset = full_ref->offset;
746 __entry->type = ref->type;
Liu Bodea7d762012-09-07 20:01:27 -0600747 __entry->seq = ref->seq;
liubo1abe9b82011-03-24 11:18:59 +0000748 ),
749
David Sterba562a7a02017-01-06 15:51:36 +0100750 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
751 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
752 "offset=%llu type=%s seq=%llu",
liubo1abe9b82011-03-24 11:18:59 +0000753 (unsigned long long)__entry->bytenr,
754 (unsigned long long)__entry->num_bytes,
755 show_ref_action(__entry->action),
756 show_root_type(__entry->parent),
757 show_root_type(__entry->ref_root),
758 (unsigned long long)__entry->owner,
759 (unsigned long long)__entry->offset,
Liu Bodea7d762012-09-07 20:01:27 -0600760 show_ref_type(__entry->type),
761 (unsigned long long)__entry->seq)
liubo1abe9b82011-03-24 11:18:59 +0000762);
763
Liu Bo599c75e2013-07-16 19:03:36 +0800764DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
765
Jeff Mahoneybc074522016-06-09 17:27:55 -0400766 TP_PROTO(struct btrfs_fs_info *fs_info,
767 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800768 struct btrfs_delayed_data_ref *full_ref,
769 int action),
770
Jeff Mahoneybc074522016-06-09 17:27:55 -0400771 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800772);
773
774DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
775
Jeff Mahoneybc074522016-06-09 17:27:55 -0400776 TP_PROTO(struct btrfs_fs_info *fs_info,
777 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800778 struct btrfs_delayed_data_ref *full_ref,
779 int action),
780
Jeff Mahoneybc074522016-06-09 17:27:55 -0400781 TP_ARGS(fs_info, ref, full_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800782);
783
784DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
liubo1abe9b82011-03-24 11:18:59 +0000785
Jeff Mahoneybc074522016-06-09 17:27:55 -0400786 TP_PROTO(struct btrfs_fs_info *fs_info,
787 struct btrfs_delayed_ref_node *ref,
liubo1abe9b82011-03-24 11:18:59 +0000788 struct btrfs_delayed_ref_head *head_ref,
789 int action),
790
Jeff Mahoneybc074522016-06-09 17:27:55 -0400791 TP_ARGS(fs_info, ref, head_ref, action),
liubo1abe9b82011-03-24 11:18:59 +0000792
Jeff Mahoneybc074522016-06-09 17:27:55 -0400793 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000794 __field( u64, bytenr )
795 __field( u64, num_bytes )
796 __field( int, action )
797 __field( int, is_data )
798 ),
799
Jeff Mahoneybc074522016-06-09 17:27:55 -0400800 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000801 __entry->bytenr = ref->bytenr;
802 __entry->num_bytes = ref->num_bytes;
803 __entry->action = action;
804 __entry->is_data = head_ref->is_data;
805 ),
806
David Sterba562a7a02017-01-06 15:51:36 +0100807 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
liubo1abe9b82011-03-24 11:18:59 +0000808 (unsigned long long)__entry->bytenr,
809 (unsigned long long)__entry->num_bytes,
810 show_ref_action(__entry->action),
811 __entry->is_data)
812);
813
Liu Bo599c75e2013-07-16 19:03:36 +0800814DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
815
Jeff Mahoneybc074522016-06-09 17:27:55 -0400816 TP_PROTO(struct btrfs_fs_info *fs_info,
817 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800818 struct btrfs_delayed_ref_head *head_ref,
819 int action),
820
Jeff Mahoneybc074522016-06-09 17:27:55 -0400821 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800822);
823
824DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
825
Jeff Mahoneybc074522016-06-09 17:27:55 -0400826 TP_PROTO(struct btrfs_fs_info *fs_info,
827 struct btrfs_delayed_ref_node *ref,
Liu Bo599c75e2013-07-16 19:03:36 +0800828 struct btrfs_delayed_ref_head *head_ref,
829 int action),
830
Jeff Mahoneybc074522016-06-09 17:27:55 -0400831 TP_ARGS(fs_info, ref, head_ref, action)
Liu Bo599c75e2013-07-16 19:03:36 +0800832);
833
liubo1abe9b82011-03-24 11:18:59 +0000834#define show_chunk_type(type) \
835 __print_flags(type, "|", \
836 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
837 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
838 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
839 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
840 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
841 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
Liu Boe112e2b2013-05-26 13:50:28 +0000842 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \
843 { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \
844 { BTRFS_BLOCK_GROUP_RAID6, "RAID6" })
liubo1abe9b82011-03-24 11:18:59 +0000845
846DECLARE_EVENT_CLASS(btrfs__chunk,
847
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400848 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000849 u64 offset, u64 size),
850
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400851 TP_ARGS(fs_info, map, offset, size),
liubo1abe9b82011-03-24 11:18:59 +0000852
Jeff Mahoneybc074522016-06-09 17:27:55 -0400853 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000854 __field( int, num_stripes )
855 __field( u64, type )
856 __field( int, sub_stripes )
857 __field( u64, offset )
858 __field( u64, size )
859 __field( u64, root_objectid )
860 ),
861
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400862 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000863 __entry->num_stripes = map->num_stripes;
864 __entry->type = map->type;
865 __entry->sub_stripes = map->sub_stripes;
866 __entry->offset = offset;
867 __entry->size = size;
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400868 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
liubo1abe9b82011-03-24 11:18:59 +0000869 ),
870
David Sterba562a7a02017-01-06 15:51:36 +0100871 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
872 "num_stripes=%d sub_stripes=%d type=%s",
liubo1abe9b82011-03-24 11:18:59 +0000873 show_root_type(__entry->root_objectid),
874 (unsigned long long)__entry->offset,
875 (unsigned long long)__entry->size,
876 __entry->num_stripes, __entry->sub_stripes,
877 show_chunk_type(__entry->type))
878);
879
880DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
881
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400882 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000883 u64 offset, u64 size),
884
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400885 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000886);
887
888DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
889
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400890 TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
liubo1abe9b82011-03-24 11:18:59 +0000891 u64 offset, u64 size),
892
Jeff Mahoney6bccf3a2016-06-21 21:16:51 -0400893 TP_ARGS(fs_info, map, offset, size)
liubo1abe9b82011-03-24 11:18:59 +0000894);
895
896TRACE_EVENT(btrfs_cow_block,
897
898 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
899 struct extent_buffer *cow),
900
901 TP_ARGS(root, buf, cow),
902
Jeff Mahoneybc074522016-06-09 17:27:55 -0400903 TP_STRUCT__entry_btrfs(
liubo1abe9b82011-03-24 11:18:59 +0000904 __field( u64, root_objectid )
905 __field( u64, buf_start )
906 __field( int, refs )
907 __field( u64, cow_start )
908 __field( int, buf_level )
909 __field( int, cow_level )
910 ),
911
Jeff Mahoneybc074522016-06-09 17:27:55 -0400912 TP_fast_assign_btrfs(root->fs_info,
liubo1abe9b82011-03-24 11:18:59 +0000913 __entry->root_objectid = root->root_key.objectid;
914 __entry->buf_start = buf->start;
915 __entry->refs = atomic_read(&buf->refs);
916 __entry->cow_start = cow->start;
917 __entry->buf_level = btrfs_header_level(buf);
918 __entry->cow_level = btrfs_header_level(cow);
919 ),
920
David Sterba562a7a02017-01-06 15:51:36 +0100921 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
922 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
liubo1abe9b82011-03-24 11:18:59 +0000923 show_root_type(__entry->root_objectid),
924 __entry->refs,
925 (unsigned long long)__entry->buf_start,
926 __entry->buf_level,
927 (unsigned long long)__entry->cow_start,
928 __entry->cow_level)
929);
930
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500931TRACE_EVENT(btrfs_space_reservation,
932
933 TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
934 u64 bytes, int reserve),
935
936 TP_ARGS(fs_info, type, val, bytes, reserve),
937
Jeff Mahoneybc074522016-06-09 17:27:55 -0400938 TP_STRUCT__entry_btrfs(
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500939 __string( type, type )
940 __field( u64, val )
941 __field( u64, bytes )
942 __field( int, reserve )
943 ),
944
Jeff Mahoneybc074522016-06-09 17:27:55 -0400945 TP_fast_assign_btrfs(fs_info,
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500946 __assign_str(type, type);
947 __entry->val = val;
948 __entry->bytes = bytes;
949 __entry->reserve = reserve;
950 ),
951
Jeff Mahoneybc074522016-06-09 17:27:55 -0400952 TP_printk_btrfs("%s: %Lu %s %Lu", __get_str(type), __entry->val,
953 __entry->reserve ? "reserve" : "release",
954 __entry->bytes)
Josef Bacik8c2a3ca2012-01-10 10:31:31 -0500955);
956
Josef Bacikf376df22016-03-25 13:25:56 -0400957#define show_flush_action(action) \
958 __print_symbolic(action, \
959 { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \
960 { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \
961 { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"})
962
963TRACE_EVENT(btrfs_trigger_flush,
964
965 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
966 int flush, char *reason),
967
968 TP_ARGS(fs_info, flags, bytes, flush, reason),
969
970 TP_STRUCT__entry(
971 __array( u8, fsid, BTRFS_UUID_SIZE )
972 __field( u64, flags )
973 __field( u64, bytes )
974 __field( int, flush )
975 __string( reason, reason )
976 ),
977
978 TP_fast_assign(
979 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
980 __entry->flags = flags;
981 __entry->bytes = bytes;
982 __entry->flush = flush;
983 __assign_str(reason, reason)
984 ),
985
David Sterba562a7a02017-01-06 15:51:36 +0100986 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
Josef Bacikf376df22016-03-25 13:25:56 -0400987 __entry->fsid, __get_str(reason), __entry->flush,
988 show_flush_action(__entry->flush),
989 (unsigned long long)__entry->flags,
990 __print_flags((unsigned long)__entry->flags, "|",
991 BTRFS_GROUP_FLAGS),
992 (unsigned long long)__entry->bytes)
993);
994
995#define show_flush_state(state) \
996 __print_symbolic(state, \
997 { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \
998 { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \
999 { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \
1000 { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \
1001 { ALLOC_CHUNK, "ALLOC_CHUNK"}, \
1002 { COMMIT_TRANS, "COMMIT_TRANS"})
1003
1004TRACE_EVENT(btrfs_flush_space,
1005
1006 TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
1007 u64 orig_bytes, int state, int ret),
1008
1009 TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret),
1010
1011 TP_STRUCT__entry(
1012 __array( u8, fsid, BTRFS_UUID_SIZE )
1013 __field( u64, flags )
1014 __field( u64, num_bytes )
1015 __field( u64, orig_bytes )
1016 __field( int, state )
1017 __field( int, ret )
1018 ),
1019
1020 TP_fast_assign(
1021 memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
1022 __entry->flags = flags;
1023 __entry->num_bytes = num_bytes;
1024 __entry->orig_bytes = orig_bytes;
1025 __entry->state = state;
1026 __entry->ret = ret;
1027 ),
1028
David Sterba562a7a02017-01-06 15:51:36 +01001029 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu "
1030 "orig_bytes=%llu ret=%d", __entry->fsid, __entry->state,
Josef Bacikf376df22016-03-25 13:25:56 -04001031 show_flush_state(__entry->state),
1032 (unsigned long long)__entry->flags,
1033 __print_flags((unsigned long)__entry->flags, "|",
1034 BTRFS_GROUP_FLAGS),
1035 (unsigned long long)__entry->num_bytes,
1036 (unsigned long long)__entry->orig_bytes, __entry->ret)
1037);
1038
liubo1abe9b82011-03-24 11:18:59 +00001039DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1040
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001041 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001042
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001043 TP_ARGS(fs_info, start, len),
liubo1abe9b82011-03-24 11:18:59 +00001044
Jeff Mahoneybc074522016-06-09 17:27:55 -04001045 TP_STRUCT__entry_btrfs(
Jeff Mahoneybc074522016-06-09 17:27:55 -04001046 __field( u64, start )
1047 __field( u64, len )
liubo1abe9b82011-03-24 11:18:59 +00001048 ),
1049
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001050 TP_fast_assign_btrfs(fs_info,
liubo1abe9b82011-03-24 11:18:59 +00001051 __entry->start = start;
1052 __entry->len = len;
1053 ),
1054
David Sterba562a7a02017-01-06 15:51:36 +01001055 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001056 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
liubo1abe9b82011-03-24 11:18:59 +00001057 (unsigned long long)__entry->start,
1058 (unsigned long long)__entry->len)
1059);
1060
1061DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
1062
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001063 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001064
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001065 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001066);
1067
1068DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
1069
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001070 TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len),
liubo1abe9b82011-03-24 11:18:59 +00001071
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001072 TP_ARGS(fs_info, start, len)
liubo1abe9b82011-03-24 11:18:59 +00001073);
1074
Josef Bacik3f7de032011-11-10 08:29:20 -05001075TRACE_EVENT(find_free_extent,
1076
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001077 TP_PROTO(struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size,
Josef Bacik3f7de032011-11-10 08:29:20 -05001078 u64 data),
1079
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001080 TP_ARGS(fs_info, num_bytes, empty_size, data),
Josef Bacik3f7de032011-11-10 08:29:20 -05001081
Jeff Mahoneybc074522016-06-09 17:27:55 -04001082 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001083 __field( u64, num_bytes )
1084 __field( u64, empty_size )
1085 __field( u64, data )
1086 ),
1087
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001088 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001089 __entry->num_bytes = num_bytes;
1090 __entry->empty_size = empty_size;
1091 __entry->data = data;
1092 ),
1093
David Sterba562a7a02017-01-06 15:51:36 +01001094 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001095 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
Josef Bacik3f7de032011-11-10 08:29:20 -05001096 __entry->num_bytes, __entry->empty_size, __entry->data,
1097 __print_flags((unsigned long)__entry->data, "|",
1098 BTRFS_GROUP_FLAGS))
1099);
1100
1101DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1102
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001103 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001104 struct btrfs_block_group_cache *block_group, u64 start,
1105 u64 len),
1106
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001107 TP_ARGS(fs_info, block_group, start, len),
Josef Bacik3f7de032011-11-10 08:29:20 -05001108
Jeff Mahoneybc074522016-06-09 17:27:55 -04001109 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001110 __field( u64, bg_objectid )
1111 __field( u64, flags )
1112 __field( u64, start )
1113 __field( u64, len )
1114 ),
1115
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001116 TP_fast_assign_btrfs(fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001117 __entry->bg_objectid = block_group->key.objectid;
1118 __entry->flags = block_group->flags;
1119 __entry->start = start;
1120 __entry->len = len;
1121 ),
1122
David Sterba562a7a02017-01-06 15:51:36 +01001123 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
1124 "start=%Lu len=%Lu",
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001125 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1126 __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001127 __entry->flags, __print_flags((unsigned long)__entry->flags,
1128 "|", BTRFS_GROUP_FLAGS),
1129 __entry->start, __entry->len)
1130);
1131
1132DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1133
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001134 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001135 struct btrfs_block_group_cache *block_group, u64 start,
1136 u64 len),
1137
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001138 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001139);
1140
1141DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1142
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001143 TP_PROTO(struct btrfs_fs_info *fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001144 struct btrfs_block_group_cache *block_group, u64 start,
1145 u64 len),
1146
Jeff Mahoney71ff6432016-09-06 16:00:42 -04001147 TP_ARGS(fs_info, block_group, start, len)
Josef Bacik3f7de032011-11-10 08:29:20 -05001148);
1149
1150TRACE_EVENT(btrfs_find_cluster,
1151
1152 TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
1153 u64 bytes, u64 empty_size, u64 min_bytes),
1154
1155 TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1156
Jeff Mahoneybc074522016-06-09 17:27:55 -04001157 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001158 __field( u64, bg_objectid )
1159 __field( u64, flags )
1160 __field( u64, start )
1161 __field( u64, bytes )
1162 __field( u64, empty_size )
1163 __field( u64, min_bytes )
1164 ),
1165
Jeff Mahoneybc074522016-06-09 17:27:55 -04001166 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001167 __entry->bg_objectid = block_group->key.objectid;
1168 __entry->flags = block_group->flags;
1169 __entry->start = start;
1170 __entry->bytes = bytes;
1171 __entry->empty_size = empty_size;
1172 __entry->min_bytes = min_bytes;
1173 ),
1174
David Sterba562a7a02017-01-06 15:51:36 +01001175 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1176 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
Josef Bacik3f7de032011-11-10 08:29:20 -05001177 __entry->flags,
1178 __print_flags((unsigned long)__entry->flags, "|",
1179 BTRFS_GROUP_FLAGS), __entry->start,
1180 __entry->bytes, __entry->empty_size, __entry->min_bytes)
1181);
1182
1183TRACE_EVENT(btrfs_failed_cluster_setup,
1184
1185 TP_PROTO(struct btrfs_block_group_cache *block_group),
1186
1187 TP_ARGS(block_group),
1188
Jeff Mahoneybc074522016-06-09 17:27:55 -04001189 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001190 __field( u64, bg_objectid )
1191 ),
1192
Jeff Mahoneybc074522016-06-09 17:27:55 -04001193 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001194 __entry->bg_objectid = block_group->key.objectid;
1195 ),
1196
David Sterba562a7a02017-01-06 15:51:36 +01001197 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
Josef Bacik3f7de032011-11-10 08:29:20 -05001198);
1199
1200TRACE_EVENT(btrfs_setup_cluster,
1201
1202 TP_PROTO(struct btrfs_block_group_cache *block_group,
1203 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
1204
1205 TP_ARGS(block_group, cluster, size, bitmap),
1206
Jeff Mahoneybc074522016-06-09 17:27:55 -04001207 TP_STRUCT__entry_btrfs(
Josef Bacik3f7de032011-11-10 08:29:20 -05001208 __field( u64, bg_objectid )
1209 __field( u64, flags )
1210 __field( u64, start )
1211 __field( u64, max_size )
1212 __field( u64, size )
1213 __field( int, bitmap )
1214 ),
1215
Jeff Mahoneybc074522016-06-09 17:27:55 -04001216 TP_fast_assign_btrfs(block_group->fs_info,
Josef Bacik3f7de032011-11-10 08:29:20 -05001217 __entry->bg_objectid = block_group->key.objectid;
1218 __entry->flags = block_group->flags;
1219 __entry->start = cluster->window_start;
1220 __entry->max_size = cluster->max_size;
1221 __entry->size = size;
1222 __entry->bitmap = bitmap;
1223 ),
1224
David Sterba562a7a02017-01-06 15:51:36 +01001225 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1226 "size=%Lu max_size=%Lu bitmap=%d",
Josef Bacik3f7de032011-11-10 08:29:20 -05001227 __entry->bg_objectid,
1228 __entry->flags,
1229 __print_flags((unsigned long)__entry->flags, "|",
1230 BTRFS_GROUP_FLAGS), __entry->start,
1231 __entry->size, __entry->max_size, __entry->bitmap)
1232);
1233
Jeff Mahoney143bede2012-03-01 14:56:26 +01001234struct extent_state;
1235TRACE_EVENT(alloc_extent_state,
1236
1237 TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
1238
1239 TP_ARGS(state, mask, IP),
1240
1241 TP_STRUCT__entry(
1242 __field(struct extent_state *, state)
1243 __field(gfp_t, mask)
1244 __field(unsigned long, ip)
1245 ),
1246
1247 TP_fast_assign(
1248 __entry->state = state,
1249 __entry->mask = mask,
1250 __entry->ip = IP
1251 ),
1252
David Sterba562a7a02017-01-06 15:51:36 +01001253 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
Jeff Mahoney143bede2012-03-01 14:56:26 +01001254 show_gfp_flags(__entry->mask), (void *)__entry->ip)
1255);
1256
1257TRACE_EVENT(free_extent_state,
1258
1259 TP_PROTO(struct extent_state *state, unsigned long IP),
1260
1261 TP_ARGS(state, IP),
1262
1263 TP_STRUCT__entry(
1264 __field(struct extent_state *, state)
1265 __field(unsigned long, ip)
1266 ),
1267
1268 TP_fast_assign(
1269 __entry->state = state,
1270 __entry->ip = IP
1271 ),
1272
David Sterba562a7a02017-01-06 15:51:36 +01001273 TP_printk("state=%p caller=%pS", __entry->state,
Jeff Mahoney143bede2012-03-01 14:56:26 +01001274 (void *)__entry->ip)
1275);
1276
Qu Wenruo52483bc2014-03-06 04:19:50 +00001277DECLARE_EVENT_CLASS(btrfs__work,
1278
1279 TP_PROTO(struct btrfs_work *work),
1280
1281 TP_ARGS(work),
1282
Jeff Mahoneybc074522016-06-09 17:27:55 -04001283 TP_STRUCT__entry_btrfs(
Qu Wenruo52483bc2014-03-06 04:19:50 +00001284 __field( void *, work )
1285 __field( void *, wq )
1286 __field( void *, func )
1287 __field( void *, ordered_func )
1288 __field( void *, ordered_free )
Liu Bob38a6252014-08-12 16:33:17 +08001289 __field( void *, normal_work )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001290 ),
1291
Jeff Mahoneybc074522016-06-09 17:27:55 -04001292 TP_fast_assign_btrfs(btrfs_work_owner(work),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001293 __entry->work = work;
1294 __entry->wq = work->wq;
1295 __entry->func = work->func;
1296 __entry->ordered_func = work->ordered_func;
1297 __entry->ordered_free = work->ordered_free;
Liu Bob38a6252014-08-12 16:33:17 +08001298 __entry->normal_work = &work->normal_work;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001299 ),
1300
David Sterba562a7a02017-01-06 15:51:36 +01001301 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1302 "ordered_free=%p",
Liu Bob38a6252014-08-12 16:33:17 +08001303 __entry->work, __entry->normal_work, __entry->wq,
1304 __entry->func, __entry->ordered_func, __entry->ordered_free)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001305);
1306
David Sterbaac0c7cf2017-01-06 14:12:51 +01001307/*
1308 * For situiations when the work is freed, we pass fs_info and a tag that that
1309 * matches address of the work structure so it can be paired with the
1310 * scheduling event.
1311 */
Qu Wenruo52483bc2014-03-06 04:19:50 +00001312DECLARE_EVENT_CLASS(btrfs__work__done,
1313
David Sterbaac0c7cf2017-01-06 14:12:51 +01001314 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001315
David Sterbaac0c7cf2017-01-06 14:12:51 +01001316 TP_ARGS(fs_info, wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001317
Jeff Mahoneybc074522016-06-09 17:27:55 -04001318 TP_STRUCT__entry_btrfs(
David Sterbaac0c7cf2017-01-06 14:12:51 +01001319 __field( void *, wtag )
Qu Wenruo52483bc2014-03-06 04:19:50 +00001320 ),
1321
David Sterbaac0c7cf2017-01-06 14:12:51 +01001322 TP_fast_assign_btrfs(fs_info,
1323 __entry->wtag = wtag;
Qu Wenruo52483bc2014-03-06 04:19:50 +00001324 ),
1325
David Sterbaac0c7cf2017-01-06 14:12:51 +01001326 TP_printk_btrfs("work->%p", __entry->wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001327);
1328
1329DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1330
1331 TP_PROTO(struct btrfs_work *work),
1332
1333 TP_ARGS(work)
1334);
1335
1336DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1337
1338 TP_PROTO(struct btrfs_work *work),
1339
1340 TP_ARGS(work)
1341);
1342
Qu Wenruo52483bc2014-03-06 04:19:50 +00001343DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1344
David Sterbaac0c7cf2017-01-06 14:12:51 +01001345 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
Qu Wenruo52483bc2014-03-06 04:19:50 +00001346
David Sterbaac0c7cf2017-01-06 14:12:51 +01001347 TP_ARGS(fs_info, wtag)
Qu Wenruo52483bc2014-03-06 04:19:50 +00001348);
1349
1350DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1351
1352 TP_PROTO(struct btrfs_work *work),
1353
1354 TP_ARGS(work)
1355);
1356
Qu Wenruoc3a46892014-03-12 08:05:33 +00001357DECLARE_EVENT_CLASS(btrfs__workqueue,
1358
1359 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1360
1361 TP_ARGS(wq, name, high),
1362
Jeff Mahoneybc074522016-06-09 17:27:55 -04001363 TP_STRUCT__entry_btrfs(
Qu Wenruoc3a46892014-03-12 08:05:33 +00001364 __field( void *, wq )
1365 __string( name, name )
1366 __field( int , high )
1367 ),
1368
Jeff Mahoneybc074522016-06-09 17:27:55 -04001369 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001370 __entry->wq = wq;
1371 __assign_str(name, name);
1372 __entry->high = high;
1373 ),
1374
David Sterba562a7a02017-01-06 15:51:36 +01001375 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001376 __print_flags(__entry->high, "",
1377 {(WQ_HIGHPRI), "-high"}),
1378 __entry->wq)
1379);
1380
1381DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1382
1383 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1384
1385 TP_ARGS(wq, name, high)
1386);
1387
1388DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1389
1390 TP_PROTO(struct __btrfs_workqueue *wq),
1391
1392 TP_ARGS(wq),
1393
Jeff Mahoneybc074522016-06-09 17:27:55 -04001394 TP_STRUCT__entry_btrfs(
Qu Wenruoc3a46892014-03-12 08:05:33 +00001395 __field( void *, wq )
1396 ),
1397
Jeff Mahoneybc074522016-06-09 17:27:55 -04001398 TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
Qu Wenruoc3a46892014-03-12 08:05:33 +00001399 __entry->wq = wq;
1400 ),
1401
Jeff Mahoneybc074522016-06-09 17:27:55 -04001402 TP_printk_btrfs("wq=%p", __entry->wq)
Qu Wenruoc3a46892014-03-12 08:05:33 +00001403);
1404
1405DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1406
1407 TP_PROTO(struct __btrfs_workqueue *wq),
1408
1409 TP_ARGS(wq)
1410);
Qu Wenruo52483bc2014-03-06 04:19:50 +00001411
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001412DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1413
1414 TP_PROTO(struct inode *inode, u64 free_reserved),
1415
1416 TP_ARGS(inode, free_reserved),
1417
Jeff Mahoneybc074522016-06-09 17:27:55 -04001418 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001419 __field( u64, rootid )
1420 __field( unsigned long, ino )
1421 __field( u64, free_reserved )
1422 ),
1423
Jeff Mahoneybc074522016-06-09 17:27:55 -04001424 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001425 __entry->rootid = BTRFS_I(inode)->root->objectid;
1426 __entry->ino = inode->i_ino;
1427 __entry->free_reserved = free_reserved;
1428 ),
1429
David Sterba562a7a02017-01-06 15:51:36 +01001430 TP_printk_btrfs("rootid=%llu ino=%lu free_reserved=%llu",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001431 __entry->rootid, __entry->ino, __entry->free_reserved)
1432);
1433
1434DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
1435
1436 TP_PROTO(struct inode *inode, u64 free_reserved),
1437
1438 TP_ARGS(inode, free_reserved)
1439);
1440
1441DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
1442
1443 TP_PROTO(struct inode *inode, u64 free_reserved),
1444
1445 TP_ARGS(inode, free_reserved)
1446);
1447
1448#define BTRFS_QGROUP_OPERATIONS \
1449 { QGROUP_RESERVE, "reserve" }, \
1450 { QGROUP_RELEASE, "release" }, \
1451 { QGROUP_FREE, "free" }
1452
1453DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1454
1455 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1456
1457 TP_ARGS(inode, start, len, reserved, op),
1458
Jeff Mahoneybc074522016-06-09 17:27:55 -04001459 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001460 __field( u64, rootid )
1461 __field( unsigned long, ino )
1462 __field( u64, start )
1463 __field( u64, len )
1464 __field( u64, reserved )
1465 __field( int, op )
1466 ),
1467
Jeff Mahoneybc074522016-06-09 17:27:55 -04001468 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001469 __entry->rootid = BTRFS_I(inode)->root->objectid;
1470 __entry->ino = inode->i_ino;
1471 __entry->start = start;
1472 __entry->len = len;
1473 __entry->reserved = reserved;
1474 __entry->op = op;
1475 ),
1476
David Sterba562a7a02017-01-06 15:51:36 +01001477 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001478 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1479 __entry->reserved,
1480 __print_flags((unsigned long)__entry->op, "",
1481 BTRFS_QGROUP_OPERATIONS)
1482 )
1483);
1484
1485DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1486
1487 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1488
1489 TP_ARGS(inode, start, len, reserved, op)
1490);
1491
1492DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1493
1494 TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1495
1496 TP_ARGS(inode, start, len, reserved, op)
1497);
1498
1499DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1500
Jeff Mahoneybc074522016-06-09 17:27:55 -04001501 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001502
Jeff Mahoneybc074522016-06-09 17:27:55 -04001503 TP_ARGS(fs_info, ref_root, reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001504
Jeff Mahoneybc074522016-06-09 17:27:55 -04001505 TP_STRUCT__entry_btrfs(
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001506 __field( u64, ref_root )
1507 __field( u64, reserved )
1508 ),
1509
Jeff Mahoneybc074522016-06-09 17:27:55 -04001510 TP_fast_assign_btrfs(fs_info,
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001511 __entry->ref_root = ref_root;
1512 __entry->reserved = reserved;
1513 ),
1514
David Sterba562a7a02017-01-06 15:51:36 +01001515 TP_printk_btrfs("root=%llu reserved=%llu op=free",
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001516 __entry->ref_root, __entry->reserved)
1517);
1518
1519DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1520
Jeff Mahoneybc074522016-06-09 17:27:55 -04001521 TP_PROTO(struct btrfs_fs_info *fs_info, u64 ref_root, u64 reserved),
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001522
Jeff Mahoneybc074522016-06-09 17:27:55 -04001523 TP_ARGS(fs_info, ref_root, reserved)
Qu Wenruo81fb6f72015-09-28 16:57:53 +08001524);
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001525
1526DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
Jeff Mahoneybc074522016-06-09 17:27:55 -04001527 TP_PROTO(struct btrfs_fs_info *fs_info,
1528 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001529
Jeff Mahoneybc074522016-06-09 17:27:55 -04001530 TP_ARGS(fs_info, rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001531
Jeff Mahoneybc074522016-06-09 17:27:55 -04001532 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001533 __field( u64, bytenr )
1534 __field( u64, num_bytes )
1535 ),
1536
Jeff Mahoneybc074522016-06-09 17:27:55 -04001537 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001538 __entry->bytenr = rec->bytenr,
1539 __entry->num_bytes = rec->num_bytes;
1540 ),
1541
David Sterba562a7a02017-01-06 15:51:36 +01001542 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001543 (unsigned long long)__entry->bytenr,
1544 (unsigned long long)__entry->num_bytes)
1545);
1546
1547DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1548
Jeff Mahoneybc074522016-06-09 17:27:55 -04001549 TP_PROTO(struct btrfs_fs_info *fs_info,
1550 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001551
Jeff Mahoneybc074522016-06-09 17:27:55 -04001552 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001553);
1554
Qu Wenruo50b3e042016-10-18 09:31:27 +08001555DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001556
Jeff Mahoneybc074522016-06-09 17:27:55 -04001557 TP_PROTO(struct btrfs_fs_info *fs_info,
1558 struct btrfs_qgroup_extent_record *rec),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001559
Jeff Mahoneybc074522016-06-09 17:27:55 -04001560 TP_ARGS(fs_info, rec)
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001561);
1562
1563TRACE_EVENT(btrfs_qgroup_account_extent,
1564
Jeff Mahoneybc074522016-06-09 17:27:55 -04001565 TP_PROTO(struct btrfs_fs_info *fs_info, u64 bytenr,
1566 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001567
Jeff Mahoneybc074522016-06-09 17:27:55 -04001568 TP_ARGS(fs_info, bytenr, num_bytes, nr_old_roots, nr_new_roots),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001569
Jeff Mahoneybc074522016-06-09 17:27:55 -04001570 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001571 __field( u64, bytenr )
1572 __field( u64, num_bytes )
1573 __field( u64, nr_old_roots )
1574 __field( u64, nr_new_roots )
1575 ),
1576
Jeff Mahoneybc074522016-06-09 17:27:55 -04001577 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001578 __entry->bytenr = bytenr;
1579 __entry->num_bytes = num_bytes;
1580 __entry->nr_old_roots = nr_old_roots;
1581 __entry->nr_new_roots = nr_new_roots;
1582 ),
1583
David Sterba562a7a02017-01-06 15:51:36 +01001584 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1585 "nr_new_roots=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001586 __entry->bytenr,
1587 __entry->num_bytes,
1588 __entry->nr_old_roots,
1589 __entry->nr_new_roots)
1590);
1591
1592TRACE_EVENT(qgroup_update_counters,
1593
Jeff Mahoneybc074522016-06-09 17:27:55 -04001594 TP_PROTO(struct btrfs_fs_info *fs_info, u64 qgid,
1595 u64 cur_old_count, u64 cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001596
Jeff Mahoneybc074522016-06-09 17:27:55 -04001597 TP_ARGS(fs_info, qgid, cur_old_count, cur_new_count),
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001598
Jeff Mahoneybc074522016-06-09 17:27:55 -04001599 TP_STRUCT__entry_btrfs(
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001600 __field( u64, qgid )
1601 __field( u64, cur_old_count )
1602 __field( u64, cur_new_count )
1603 ),
1604
Jeff Mahoneybc074522016-06-09 17:27:55 -04001605 TP_fast_assign_btrfs(fs_info,
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001606 __entry->qgid = qgid;
1607 __entry->cur_old_count = cur_old_count;
1608 __entry->cur_new_count = cur_new_count;
1609 ),
1610
David Sterba562a7a02017-01-06 15:51:36 +01001611 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
Mark Fasheh0f5dcf82016-03-29 17:19:55 -07001612 __entry->qgid,
1613 __entry->cur_old_count,
1614 __entry->cur_new_count)
1615);
1616
liubo1abe9b82011-03-24 11:18:59 +00001617#endif /* _TRACE_BTRFS_H */
1618
1619/* This part must be outside protection */
1620#include <trace/define_trace.h>