xref: /openbmc/linux/include/trace/events/btrfs.h (revision d75f773c)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21abe9b8aSliubo #undef TRACE_SYSTEM
31abe9b8aSliubo #define TRACE_SYSTEM btrfs
41abe9b8aSliubo 
51abe9b8aSliubo #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
61abe9b8aSliubo #define _TRACE_BTRFS_H
71abe9b8aSliubo 
81abe9b8aSliubo #include <linux/writeback.h>
91abe9b8aSliubo #include <linux/tracepoint.h>
10420adbe9SVlastimil Babka #include <trace/events/mmflags.h>
111abe9b8aSliubo 
121abe9b8aSliubo struct btrfs_root;
131abe9b8aSliubo struct btrfs_fs_info;
141abe9b8aSliubo struct btrfs_inode;
151abe9b8aSliubo struct extent_map;
1609ed2f16SLiu Bo struct btrfs_file_extent_item;
171abe9b8aSliubo struct btrfs_ordered_extent;
181abe9b8aSliubo struct btrfs_delayed_ref_node;
191abe9b8aSliubo struct btrfs_delayed_tree_ref;
201abe9b8aSliubo struct btrfs_delayed_data_ref;
211abe9b8aSliubo struct btrfs_delayed_ref_head;
223f7de037SJosef Bacik struct btrfs_block_group_cache;
233f7de037SJosef Bacik struct btrfs_free_cluster;
241abe9b8aSliubo struct map_lookup;
251abe9b8aSliubo struct extent_buffer;
2652483bc2SQu Wenruo struct btrfs_work;
27c3a46891SQu Wenruo struct __btrfs_workqueue;
280f5dcf8dSMark Fasheh struct btrfs_qgroup_extent_record;
293159fe7bSQu Wenruo struct btrfs_qgroup;
3000142756SJeff Mahoney struct prelim_ref;
311abe9b8aSliubo 
32012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
33012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
34012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
35012e513eSAnand Jain TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
36012e513eSAnand Jain TRACE_DEFINE_ENUM(ALLOC_CHUNK);
37012e513eSAnand Jain TRACE_DEFINE_ENUM(COMMIT_TRANS);
38012e513eSAnand Jain 
391abe9b8aSliubo #define show_ref_type(type)						\
401abe9b8aSliubo 	__print_symbolic(type,						\
411abe9b8aSliubo 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
421abe9b8aSliubo 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
431abe9b8aSliubo 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
441abe9b8aSliubo 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
451abe9b8aSliubo 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
461abe9b8aSliubo 
471abe9b8aSliubo #define __show_root_type(obj)						\
487f34b746Sliubo 	__print_symbolic_u64(obj,					\
491abe9b8aSliubo 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
501abe9b8aSliubo 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
511abe9b8aSliubo 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
521abe9b8aSliubo 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
531abe9b8aSliubo 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
541abe9b8aSliubo 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
551abe9b8aSliubo 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
561abe9b8aSliubo 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
57e112e2b4SLiu Bo 		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
581abe9b8aSliubo 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
59208acb8cSOmar Sandoval 		{ BTRFS_UUID_TREE_OBJECTID,	"UUID_TREE"	},	\
60208acb8cSOmar Sandoval 		{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },	\
611abe9b8aSliubo 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
621abe9b8aSliubo 
631abe9b8aSliubo #define show_root_type(obj)						\
641abe9b8aSliubo 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
65fb57dc81SLiu Bo 	      (obj >= BTRFS_ROOT_TREE_OBJECTID &&			\
66e112e2b4SLiu Bo 	       obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
671abe9b8aSliubo 
6809ed2f16SLiu Bo #define show_fi_type(type)						\
6909ed2f16SLiu Bo 	__print_symbolic(type,						\
7009ed2f16SLiu Bo 		 { BTRFS_FILE_EXTENT_INLINE,	"INLINE" },		\
7109ed2f16SLiu Bo 		 { BTRFS_FILE_EXTENT_REG,	"REG"	 },		\
7209ed2f16SLiu Bo 		 { BTRFS_FILE_EXTENT_PREALLOC,	"PREALLOC"})
7309ed2f16SLiu Bo 
7464ee4e75SQu Wenruo #define show_qgroup_rsv_type(type)					\
7564ee4e75SQu Wenruo 	__print_symbolic(type,						\
7664ee4e75SQu Wenruo 		{ BTRFS_QGROUP_RSV_DATA,	  "DATA"	},	\
77733e03a0SQu Wenruo 		{ BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS" },	\
78733e03a0SQu Wenruo 		{ BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC" })
7964ee4e75SQu Wenruo 
803f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS	\
813f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
823f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
833f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
843f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
853f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
863f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
87e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
88e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
89e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
903f7de037SJosef Bacik 
91b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16
92b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
93bc074524SJeff Mahoney 
94bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info)					\
95de37aa51SNikolay Borisov 	memcpy(__entry->fsid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE)
96bc074524SJeff Mahoney 
97bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...)					\
98bc074524SJeff Mahoney 	TP_STRUCT__entry(						\
99bc074524SJeff Mahoney 		TP_STRUCT__entry_fsid					\
100bc074524SJeff Mahoney 		args)
101bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...)				\
102bc074524SJeff Mahoney 	TP_fast_assign(							\
103bc074524SJeff Mahoney 		TP_fast_assign_fsid(fs_info);				\
104bc074524SJeff Mahoney 		args)
105bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \
106bc074524SJeff Mahoney 	TP_printk("%pU: " fmt, __entry->fsid, args)
1078c2a3ca2SJosef Bacik 
1081abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit,
1091abe9b8aSliubo 
1109a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root),
1111abe9b8aSliubo 
1121abe9b8aSliubo 	TP_ARGS(root),
1131abe9b8aSliubo 
114bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1151abe9b8aSliubo 		__field(	u64,  generation		)
1161abe9b8aSliubo 		__field(	u64,  root_objectid		)
1171abe9b8aSliubo 	),
1181abe9b8aSliubo 
119bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
1201abe9b8aSliubo 		__entry->generation	= root->fs_info->generation;
1211abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
1221abe9b8aSliubo 	),
1231abe9b8aSliubo 
12479bcb71aSDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu",
1251abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
1268eec8463SDavid Sterba 		  __entry->generation)
1271abe9b8aSliubo );
1281abe9b8aSliubo 
1291abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode,
1301abe9b8aSliubo 
1319a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
1321abe9b8aSliubo 
1331abe9b8aSliubo 	TP_ARGS(inode),
1341abe9b8aSliubo 
135bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
136f8f8e189SDavid Sterba 		__field(	u64,  ino			)
1371abe9b8aSliubo 		__field(	blkcnt_t,  blocks		)
1381abe9b8aSliubo 		__field(	u64,  disk_i_size		)
1391abe9b8aSliubo 		__field(	u64,  generation		)
1401abe9b8aSliubo 		__field(	u64,  last_trans		)
1411abe9b8aSliubo 		__field(	u64,  logged_trans		)
1421abe9b8aSliubo 		__field(	u64,  root_objectid		)
1431abe9b8aSliubo 	),
1441abe9b8aSliubo 
145bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
146f8f8e189SDavid Sterba 		__entry->ino	= btrfs_ino(BTRFS_I(inode));
1471abe9b8aSliubo 		__entry->blocks	= inode->i_blocks;
1481abe9b8aSliubo 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
1491abe9b8aSliubo 		__entry->generation = BTRFS_I(inode)->generation;
1501abe9b8aSliubo 		__entry->last_trans = BTRFS_I(inode)->last_trans;
1511abe9b8aSliubo 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
1521abe9b8aSliubo 		__entry->root_objectid =
1531abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
1541abe9b8aSliubo 	),
1551abe9b8aSliubo 
156f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
157562a7a07SDavid Sterba 		  "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
1581abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
1598eec8463SDavid Sterba 		  __entry->generation,
1608eec8463SDavid Sterba 		  __entry->ino,
1611abe9b8aSliubo 		  (unsigned long long)__entry->blocks,
1628eec8463SDavid Sterba 		  __entry->disk_i_size,
1638eec8463SDavid Sterba 		  __entry->last_trans,
1648eec8463SDavid Sterba 		  __entry->logged_trans)
1651abe9b8aSliubo );
1661abe9b8aSliubo 
1671abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
1681abe9b8aSliubo 
1699a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
1701abe9b8aSliubo 
1711abe9b8aSliubo 	TP_ARGS(inode)
1721abe9b8aSliubo );
1731abe9b8aSliubo 
1741abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
1751abe9b8aSliubo 
1769a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
1771abe9b8aSliubo 
1781abe9b8aSliubo 	TP_ARGS(inode)
1791abe9b8aSliubo );
1801abe9b8aSliubo 
1811abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
1821abe9b8aSliubo 
1839a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
1841abe9b8aSliubo 
1851abe9b8aSliubo 	TP_ARGS(inode)
1861abe9b8aSliubo );
1871abe9b8aSliubo 
1881abe9b8aSliubo #define __show_map_type(type)						\
1897f34b746Sliubo 	__print_symbolic_u64(type,					\
1901abe9b8aSliubo 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
1911abe9b8aSliubo 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
1921abe9b8aSliubo 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
1931abe9b8aSliubo 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
1941abe9b8aSliubo 
1951abe9b8aSliubo #define show_map_type(type)			\
1961abe9b8aSliubo 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
1971abe9b8aSliubo 
1981abe9b8aSliubo #define show_map_flags(flag)						\
1991abe9b8aSliubo 	__print_flags(flag, "|",					\
200254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
201254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
202254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
203254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
204254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
205254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
2061abe9b8aSliubo 
2074cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent,
2081abe9b8aSliubo 
2099a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
2109a35b637SJeff Mahoney 		 const struct extent_map *map),
2111abe9b8aSliubo 
21292a1bf76SLiu Bo 	TP_ARGS(root, inode, map),
2131abe9b8aSliubo 
2144cd8587cSSteven Rostedt 	TP_CONDITION(map),
2154cd8587cSSteven Rostedt 
216bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
2171abe9b8aSliubo 		__field(	u64,  root_objectid	)
21892a1bf76SLiu Bo 		__field(	u64,  ino		)
2191abe9b8aSliubo 		__field(	u64,  start		)
2201abe9b8aSliubo 		__field(	u64,  len		)
2211abe9b8aSliubo 		__field(	u64,  orig_start	)
2221abe9b8aSliubo 		__field(	u64,  block_start	)
2231abe9b8aSliubo 		__field(	u64,  block_len		)
2241abe9b8aSliubo 		__field(	unsigned long,  flags	)
2251abe9b8aSliubo 		__field(	int,  refs		)
2261abe9b8aSliubo 		__field(	unsigned int,  compress_type	)
2271abe9b8aSliubo 	),
2281abe9b8aSliubo 
229bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
2301abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
23192a1bf76SLiu Bo 		__entry->ino		= btrfs_ino(inode);
2321abe9b8aSliubo 		__entry->start		= map->start;
2331abe9b8aSliubo 		__entry->len		= map->len;
2341abe9b8aSliubo 		__entry->orig_start	= map->orig_start;
2351abe9b8aSliubo 		__entry->block_start	= map->block_start;
2361abe9b8aSliubo 		__entry->block_len	= map->block_len;
2371abe9b8aSliubo 		__entry->flags		= map->flags;
238490b54d6SElena Reshetova 		__entry->refs		= refcount_read(&map->refs);
2391abe9b8aSliubo 		__entry->compress_type	= map->compress_type;
2401abe9b8aSliubo 	),
2411abe9b8aSliubo 
242562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
243562a7a07SDavid Sterba 		  "orig_start=%llu block_start=%llu(%s) "
244562a7a07SDavid Sterba 		  "block_len=%llu flags=%s refs=%u "
2451abe9b8aSliubo 		  "compress_type=%u",
2461abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2478eec8463SDavid Sterba 		  __entry->ino,
2488eec8463SDavid Sterba 		  __entry->start,
2498eec8463SDavid Sterba 		  __entry->len,
2508eec8463SDavid Sterba 		  __entry->orig_start,
2511abe9b8aSliubo 		  show_map_type(__entry->block_start),
2528eec8463SDavid Sterba 		  __entry->block_len,
2531abe9b8aSliubo 		  show_map_flags(__entry->flags),
2541abe9b8aSliubo 		  __entry->refs, __entry->compress_type)
2551abe9b8aSliubo );
2561abe9b8aSliubo 
257393da918SLiu Bo TRACE_EVENT(btrfs_handle_em_exist,
258393da918SLiu Bo 
259f46b24c9SDavid Sterba 	TP_PROTO(struct btrfs_fs_info *fs_info,
260f46b24c9SDavid Sterba 		const struct extent_map *existing, const struct extent_map *map,
261f46b24c9SDavid Sterba 		u64 start, u64 len),
262393da918SLiu Bo 
263f46b24c9SDavid Sterba 	TP_ARGS(fs_info, existing, map, start, len),
264393da918SLiu Bo 
265f46b24c9SDavid Sterba 	TP_STRUCT__entry_btrfs(
266393da918SLiu Bo 		__field(	u64,  e_start		)
267393da918SLiu Bo 		__field(	u64,  e_len		)
268393da918SLiu Bo 		__field(	u64,  map_start		)
269393da918SLiu Bo 		__field(	u64,  map_len		)
270393da918SLiu Bo 		__field(	u64,  start		)
271393da918SLiu Bo 		__field(	u64,  len		)
272393da918SLiu Bo 	),
273393da918SLiu Bo 
274f46b24c9SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
275393da918SLiu Bo 		__entry->e_start	= existing->start;
276393da918SLiu Bo 		__entry->e_len		= existing->len;
277393da918SLiu Bo 		__entry->map_start	= map->start;
278393da918SLiu Bo 		__entry->map_len	= map->len;
279393da918SLiu Bo 		__entry->start		= start;
280393da918SLiu Bo 		__entry->len		= len;
281393da918SLiu Bo 	),
282393da918SLiu Bo 
283f46b24c9SDavid Sterba 	TP_printk_btrfs("start=%llu len=%llu "
284393da918SLiu Bo 		  "existing(start=%llu len=%llu) "
285393da918SLiu Bo 		  "em(start=%llu len=%llu)",
2868eec8463SDavid Sterba 		  __entry->start,
2878eec8463SDavid Sterba 		  __entry->len,
2888eec8463SDavid Sterba 		  __entry->e_start,
2898eec8463SDavid Sterba 		  __entry->e_len,
2908eec8463SDavid Sterba 		  __entry->map_start,
2918eec8463SDavid Sterba 		  __entry->map_len)
292393da918SLiu Bo );
293393da918SLiu Bo 
29409ed2f16SLiu Bo /* file extent item */
29509ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
29609ed2f16SLiu Bo 
29709ed2f16SLiu Bo 	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
29809ed2f16SLiu Bo 		 struct btrfs_file_extent_item *fi, u64 start),
29909ed2f16SLiu Bo 
30009ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start),
30109ed2f16SLiu Bo 
30209ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
30309ed2f16SLiu Bo 		__field(	u64,	root_obj	)
30409ed2f16SLiu Bo 		__field(	u64,	ino		)
30509ed2f16SLiu Bo 		__field(	loff_t,	isize		)
30609ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
30709ed2f16SLiu Bo 		__field(	u64,	num_bytes	)
30809ed2f16SLiu Bo 		__field(	u64,	ram_bytes	)
30909ed2f16SLiu Bo 		__field(	u64,	disk_bytenr	)
31009ed2f16SLiu Bo 		__field(	u64,	disk_num_bytes	)
31109ed2f16SLiu Bo 		__field(	u64,	extent_offset	)
31209ed2f16SLiu Bo 		__field(	u8,	extent_type	)
31309ed2f16SLiu Bo 		__field(	u8,	compression	)
31409ed2f16SLiu Bo 		__field(	u64,	extent_start	)
31509ed2f16SLiu Bo 		__field(	u64,	extent_end	)
31609ed2f16SLiu Bo 	),
31709ed2f16SLiu Bo 
31809ed2f16SLiu Bo 	TP_fast_assign_btrfs(bi->root->fs_info,
3194fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
32009ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
32109ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
32209ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
32309ed2f16SLiu Bo 		__entry->num_bytes	= btrfs_file_extent_num_bytes(l, fi);
32409ed2f16SLiu Bo 		__entry->ram_bytes	= btrfs_file_extent_ram_bytes(l, fi);
32509ed2f16SLiu Bo 		__entry->disk_bytenr	= btrfs_file_extent_disk_bytenr(l, fi);
32609ed2f16SLiu Bo 		__entry->disk_num_bytes	= btrfs_file_extent_disk_num_bytes(l, fi);
32709ed2f16SLiu Bo 		__entry->extent_offset	= btrfs_file_extent_offset(l, fi);
32809ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
32909ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
33009ed2f16SLiu Bo 		__entry->extent_start	= start;
33109ed2f16SLiu Bo 		__entry->extent_end	= (start + __entry->num_bytes);
33209ed2f16SLiu Bo 	),
33309ed2f16SLiu Bo 
33409ed2f16SLiu Bo 	TP_printk_btrfs(
33509ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
33609ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
33709ed2f16SLiu Bo 		"(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
33809ed2f16SLiu Bo 		"disk_num_bytes=%llu extent_offset=%llu type=%s "
33909ed2f16SLiu Bo 		"compression=%u",
34009ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino,
34109ed2f16SLiu Bo 		__entry->isize,
34209ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
34309ed2f16SLiu Bo 		__entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
34409ed2f16SLiu Bo 		__entry->disk_bytenr, __entry->disk_num_bytes,
34509ed2f16SLiu Bo 		__entry->extent_offset, show_fi_type(__entry->extent_type),
34609ed2f16SLiu Bo 		__entry->compression)
34709ed2f16SLiu Bo );
34809ed2f16SLiu Bo 
34909ed2f16SLiu Bo DECLARE_EVENT_CLASS(
35009ed2f16SLiu Bo 	btrfs__file_extent_item_inline,
35109ed2f16SLiu Bo 
35209ed2f16SLiu Bo 	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
35309ed2f16SLiu Bo 		 struct btrfs_file_extent_item *fi, int slot, u64 start),
35409ed2f16SLiu Bo 
35509ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot,  start),
35609ed2f16SLiu Bo 
35709ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
35809ed2f16SLiu Bo 		__field(	u64,	root_obj	)
35909ed2f16SLiu Bo 		__field(	u64,	ino		)
36009ed2f16SLiu Bo 		__field(	loff_t,	isize		)
36109ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
36209ed2f16SLiu Bo 		__field(	u8,	extent_type	)
36309ed2f16SLiu Bo 		__field(	u8,	compression	)
36409ed2f16SLiu Bo 		__field(	u64,	extent_start	)
36509ed2f16SLiu Bo 		__field(	u64,	extent_end	)
36609ed2f16SLiu Bo 	),
36709ed2f16SLiu Bo 
36809ed2f16SLiu Bo 	TP_fast_assign_btrfs(
36909ed2f16SLiu Bo 		bi->root->fs_info,
3704fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
37109ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
37209ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
37309ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
37409ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
37509ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
37609ed2f16SLiu Bo 		__entry->extent_start	= start;
377e41ca589SQu Wenruo 		__entry->extent_end	= (start + btrfs_file_extent_ram_bytes(l, fi));
37809ed2f16SLiu Bo 	),
37909ed2f16SLiu Bo 
38009ed2f16SLiu Bo 	TP_printk_btrfs(
38109ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
38209ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
38309ed2f16SLiu Bo 		"extent_type=%s compression=%u",
38409ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
38509ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
38609ed2f16SLiu Bo 		__entry->extent_end, show_fi_type(__entry->extent_type),
38709ed2f16SLiu Bo 		__entry->compression)
38809ed2f16SLiu Bo );
38909ed2f16SLiu Bo 
39009ed2f16SLiu Bo DEFINE_EVENT(
39109ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
39209ed2f16SLiu Bo 
39309ed2f16SLiu Bo 	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
39409ed2f16SLiu Bo 		 struct btrfs_file_extent_item *fi, u64 start),
39509ed2f16SLiu Bo 
39609ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
39709ed2f16SLiu Bo );
39809ed2f16SLiu Bo 
39909ed2f16SLiu Bo DEFINE_EVENT(
40009ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
40109ed2f16SLiu Bo 
40209ed2f16SLiu Bo 	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
40309ed2f16SLiu Bo 		 struct btrfs_file_extent_item *fi, u64 start),
40409ed2f16SLiu Bo 
40509ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
40609ed2f16SLiu Bo );
40709ed2f16SLiu Bo 
40809ed2f16SLiu Bo DEFINE_EVENT(
40909ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
41009ed2f16SLiu Bo 
41109ed2f16SLiu Bo 	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
41209ed2f16SLiu Bo 		 struct btrfs_file_extent_item *fi, int slot, u64 start),
41309ed2f16SLiu Bo 
41409ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
41509ed2f16SLiu Bo );
41609ed2f16SLiu Bo 
41709ed2f16SLiu Bo DEFINE_EVENT(
41809ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
41909ed2f16SLiu Bo 
42009ed2f16SLiu Bo 	TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
42109ed2f16SLiu Bo 		 struct btrfs_file_extent_item *fi, int slot, u64 start),
42209ed2f16SLiu Bo 
42309ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
42409ed2f16SLiu Bo );
42509ed2f16SLiu Bo 
4261abe9b8aSliubo #define show_ordered_flags(flags)					   \
4279d04a8ceSLiu Bo 	__print_flags(flags, "|",					   \
4289d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IO_DONE), 	"IO_DONE" 	}, \
4299d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_COMPLETE), 	"COMPLETE" 	}, \
4309d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_NOCOW), 		"NOCOW" 	}, \
4319d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_COMPRESSED), 	"COMPRESSED" 	}, \
4329d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_PREALLOC), 	"PREALLOC" 	}, \
4339d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_DIRECT),	 	"DIRECT" 	}, \
4349d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IOERR), 		"IOERR" 	}, \
4359d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_UPDATED_ISIZE), 	"UPDATED_ISIZE"	}, \
436792ddef0SLiu Bo 		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
437e112e2b4SLiu Bo 
4381abe9b8aSliubo 
4391abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent,
4401abe9b8aSliubo 
4419a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode,
4429a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
4431abe9b8aSliubo 
4441abe9b8aSliubo 	TP_ARGS(inode, ordered),
4451abe9b8aSliubo 
446bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
447f8f8e189SDavid Sterba 		__field(	u64,  ino		)
4481abe9b8aSliubo 		__field(	u64,  file_offset	)
4491abe9b8aSliubo 		__field(	u64,  start		)
4501abe9b8aSliubo 		__field(	u64,  len		)
4511abe9b8aSliubo 		__field(	u64,  disk_len		)
4521abe9b8aSliubo 		__field(	u64,  bytes_left	)
4531abe9b8aSliubo 		__field(	unsigned long,  flags	)
4541abe9b8aSliubo 		__field(	int,  compress_type	)
4551abe9b8aSliubo 		__field(	int,  refs		)
4561abe9b8aSliubo 		__field(	u64,  root_objectid	)
45778566548SLiu Bo 		__field(	u64,  truncated_len	)
4581abe9b8aSliubo 	),
4591abe9b8aSliubo 
460bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
461f8f8e189SDavid Sterba 		__entry->ino 		= btrfs_ino(BTRFS_I(inode));
4621abe9b8aSliubo 		__entry->file_offset	= ordered->file_offset;
4631abe9b8aSliubo 		__entry->start		= ordered->start;
4641abe9b8aSliubo 		__entry->len		= ordered->len;
4651abe9b8aSliubo 		__entry->disk_len	= ordered->disk_len;
4661abe9b8aSliubo 		__entry->bytes_left	= ordered->bytes_left;
4671abe9b8aSliubo 		__entry->flags		= ordered->flags;
4681abe9b8aSliubo 		__entry->compress_type	= ordered->compress_type;
469e76edab7SElena Reshetova 		__entry->refs		= refcount_read(&ordered->refs);
4701abe9b8aSliubo 		__entry->root_objectid	=
4711abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
47278566548SLiu Bo 		__entry->truncated_len	= ordered->truncated_len;
4731abe9b8aSliubo 	),
4741abe9b8aSliubo 
475562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
476562a7a07SDavid Sterba 		  "start=%llu len=%llu disk_len=%llu "
477562a7a07SDavid Sterba 		  "truncated_len=%llu "
478562a7a07SDavid Sterba 		  "bytes_left=%llu flags=%s compress_type=%d "
4791abe9b8aSliubo 		  "refs=%d",
4801abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
4818eec8463SDavid Sterba 		  __entry->ino,
4828eec8463SDavid Sterba 		  __entry->file_offset,
4838eec8463SDavid Sterba 		  __entry->start,
4848eec8463SDavid Sterba 		  __entry->len,
4858eec8463SDavid Sterba 		  __entry->disk_len,
4868eec8463SDavid Sterba 		  __entry->truncated_len,
4878eec8463SDavid Sterba 		  __entry->bytes_left,
4881abe9b8aSliubo 		  show_ordered_flags(__entry->flags),
4891abe9b8aSliubo 		  __entry->compress_type, __entry->refs)
4901abe9b8aSliubo );
4911abe9b8aSliubo 
4921abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
4931abe9b8aSliubo 
4949a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode,
4959a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
4961abe9b8aSliubo 
4971abe9b8aSliubo 	TP_ARGS(inode, ordered)
4981abe9b8aSliubo );
4991abe9b8aSliubo 
5001abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
5011abe9b8aSliubo 
5029a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode,
5039a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5041abe9b8aSliubo 
5051abe9b8aSliubo 	TP_ARGS(inode, ordered)
5061abe9b8aSliubo );
5071abe9b8aSliubo 
5081abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
5091abe9b8aSliubo 
5109a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode,
5119a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5121abe9b8aSliubo 
5131abe9b8aSliubo 	TP_ARGS(inode, ordered)
5141abe9b8aSliubo );
5151abe9b8aSliubo 
5161abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
5171abe9b8aSliubo 
5189a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode,
5199a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5201abe9b8aSliubo 
5211abe9b8aSliubo 	TP_ARGS(inode, ordered)
5221abe9b8aSliubo );
5231abe9b8aSliubo 
5241abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage,
5251abe9b8aSliubo 
5269a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
5279a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
5281abe9b8aSliubo 
5291abe9b8aSliubo 	TP_ARGS(page, inode, wbc),
5301abe9b8aSliubo 
531bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
532f8f8e189SDavid Sterba 		__field(	u64,	ino			)
5331abe9b8aSliubo 		__field(	pgoff_t,  index			)
5341abe9b8aSliubo 		__field(	long,   nr_to_write		)
5351abe9b8aSliubo 		__field(	long,   pages_skipped		)
5361abe9b8aSliubo 		__field(	loff_t, range_start		)
5371abe9b8aSliubo 		__field(	loff_t, range_end		)
5381abe9b8aSliubo 		__field(	char,   for_kupdate		)
5391abe9b8aSliubo 		__field(	char,   for_reclaim		)
5401abe9b8aSliubo 		__field(	char,   range_cyclic		)
5411abe9b8aSliubo 		__field(	pgoff_t,  writeback_index	)
5421abe9b8aSliubo 		__field(	u64,    root_objectid		)
5431abe9b8aSliubo 	),
5441abe9b8aSliubo 
545bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
546f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
5471abe9b8aSliubo 		__entry->index		= page->index;
5481abe9b8aSliubo 		__entry->nr_to_write	= wbc->nr_to_write;
5491abe9b8aSliubo 		__entry->pages_skipped	= wbc->pages_skipped;
5501abe9b8aSliubo 		__entry->range_start	= wbc->range_start;
5511abe9b8aSliubo 		__entry->range_end	= wbc->range_end;
5521abe9b8aSliubo 		__entry->for_kupdate	= wbc->for_kupdate;
5531abe9b8aSliubo 		__entry->for_reclaim	= wbc->for_reclaim;
5541abe9b8aSliubo 		__entry->range_cyclic	= wbc->range_cyclic;
5551abe9b8aSliubo 		__entry->writeback_index = inode->i_mapping->writeback_index;
5561abe9b8aSliubo 		__entry->root_objectid	=
5571abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
5581abe9b8aSliubo 	),
5591abe9b8aSliubo 
560f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
561562a7a07SDavid Sterba 		  "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
562562a7a07SDavid Sterba 		  "range_end=%llu for_kupdate=%d "
563562a7a07SDavid Sterba 		  "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
5641abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
5658eec8463SDavid Sterba 		  __entry->ino, __entry->index,
5661abe9b8aSliubo 		  __entry->nr_to_write, __entry->pages_skipped,
5671abe9b8aSliubo 		  __entry->range_start, __entry->range_end,
568846d5a09SWu Fengguang 		  __entry->for_kupdate,
5691abe9b8aSliubo 		  __entry->for_reclaim, __entry->range_cyclic,
5701abe9b8aSliubo 		  (unsigned long)__entry->writeback_index)
5711abe9b8aSliubo );
5721abe9b8aSliubo 
5731abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage,
5741abe9b8aSliubo 
5759a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
5769a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
5771abe9b8aSliubo 
5781abe9b8aSliubo 	TP_ARGS(page, inode, wbc)
5791abe9b8aSliubo );
5801abe9b8aSliubo 
5811abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook,
5821abe9b8aSliubo 
5839a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
5841abe9b8aSliubo 
5851abe9b8aSliubo 	TP_ARGS(page, start, end, uptodate),
5861abe9b8aSliubo 
587bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
588f8f8e189SDavid Sterba 		__field(	u64,	 ino		)
5891abe9b8aSliubo 		__field(	pgoff_t, index		)
5901abe9b8aSliubo 		__field(	u64,	 start		)
5911abe9b8aSliubo 		__field(	u64,	 end		)
5921abe9b8aSliubo 		__field(	int,	 uptodate	)
5931abe9b8aSliubo 		__field(	u64,    root_objectid	)
5941abe9b8aSliubo 	),
5951abe9b8aSliubo 
596bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
597f8f8e189SDavid Sterba 		__entry->ino	= btrfs_ino(BTRFS_I(page->mapping->host));
5981abe9b8aSliubo 		__entry->index	= page->index;
5991abe9b8aSliubo 		__entry->start	= start;
6001abe9b8aSliubo 		__entry->end	= end;
6011abe9b8aSliubo 		__entry->uptodate = uptodate;
6021abe9b8aSliubo 		__entry->root_objectid	=
6031abe9b8aSliubo 			 BTRFS_I(page->mapping->host)->root->root_key.objectid;
6041abe9b8aSliubo 	),
6051abe9b8aSliubo 
606f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu "
607562a7a07SDavid Sterba 		  "end=%llu uptodate=%d",
6081abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
6098eec8463SDavid Sterba 		  __entry->ino, (unsigned long)__entry->index,
6108eec8463SDavid Sterba 		  __entry->start,
6118eec8463SDavid Sterba 		  __entry->end, __entry->uptodate)
6121abe9b8aSliubo );
6131abe9b8aSliubo 
6141abe9b8aSliubo TRACE_EVENT(btrfs_sync_file,
6151abe9b8aSliubo 
6169a35b637SJeff Mahoney 	TP_PROTO(const struct file *file, int datasync),
6171abe9b8aSliubo 
6181abe9b8aSliubo 	TP_ARGS(file, datasync),
6191abe9b8aSliubo 
620bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
621f8f8e189SDavid Sterba 		__field(	u64,	ino		)
622f8f8e189SDavid Sterba 		__field(	u64,	parent		)
6231abe9b8aSliubo 		__field(	int,    datasync	)
6241abe9b8aSliubo 		__field(	u64,    root_objectid	)
6251abe9b8aSliubo 	),
6261abe9b8aSliubo 
6271abe9b8aSliubo 	TP_fast_assign(
6289a35b637SJeff Mahoney 		const struct dentry *dentry = file->f_path.dentry;
6299a35b637SJeff Mahoney 		const struct inode *inode = d_inode(dentry);
6301abe9b8aSliubo 
631bc074524SJeff Mahoney 		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
632f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
633f8f8e189SDavid Sterba 		__entry->parent		= btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
6341abe9b8aSliubo 		__entry->datasync	= datasync;
6351abe9b8aSliubo 		__entry->root_objectid	=
6361abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
6371abe9b8aSliubo 	),
6381abe9b8aSliubo 
639f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
6401abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
6418eec8463SDavid Sterba 		  __entry->ino,
6428eec8463SDavid Sterba 		  __entry->parent,
6431abe9b8aSliubo 		  __entry->datasync)
6441abe9b8aSliubo );
6451abe9b8aSliubo 
6461abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs,
6471abe9b8aSliubo 
6489a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
6491abe9b8aSliubo 
650bc074524SJeff Mahoney 	TP_ARGS(fs_info, wait),
6511abe9b8aSliubo 
652bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
6531abe9b8aSliubo 		__field(	int,  wait		)
6541abe9b8aSliubo 	),
6551abe9b8aSliubo 
656bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
6571abe9b8aSliubo 		__entry->wait	= wait;
6581abe9b8aSliubo 	),
6591abe9b8aSliubo 
660bc074524SJeff Mahoney 	TP_printk_btrfs("wait=%d", __entry->wait)
6611abe9b8aSliubo );
6621abe9b8aSliubo 
663c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group,
664c83f8effSJosef Bacik 
6659a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
6669a35b637SJeff Mahoney 		 const struct btrfs_block_group_cache *block_group, int create),
667c83f8effSJosef Bacik 
668c83f8effSJosef Bacik 	TP_ARGS(fs_info, block_group, create),
669c83f8effSJosef Bacik 
6702e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
671c83f8effSJosef Bacik 		__field(	u64,	offset			)
672c83f8effSJosef Bacik 		__field(	u64,	size			)
673c83f8effSJosef Bacik 		__field(	u64,	flags			)
674c83f8effSJosef Bacik 		__field(	u64,	bytes_used		)
675c83f8effSJosef Bacik 		__field(	u64,	bytes_super		)
676c83f8effSJosef Bacik 		__field(	int,	create			)
677c83f8effSJosef Bacik 	),
678c83f8effSJosef Bacik 
6792e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
680c83f8effSJosef Bacik 		__entry->offset		= block_group->key.objectid;
681c83f8effSJosef Bacik 		__entry->size		= block_group->key.offset;
682c83f8effSJosef Bacik 		__entry->flags		= block_group->flags;
683c83f8effSJosef Bacik 		__entry->bytes_used	=
684c83f8effSJosef Bacik 			btrfs_block_group_used(&block_group->item);
685c83f8effSJosef Bacik 		__entry->bytes_super	= block_group->bytes_super;
686c83f8effSJosef Bacik 		__entry->create		= create;
687c83f8effSJosef Bacik 	),
688c83f8effSJosef Bacik 
6892e63e62dSDavid Sterba 	TP_printk_btrfs("block_group offset=%llu size=%llu "
690562a7a07SDavid Sterba 		  "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
6912e63e62dSDavid Sterba 		  "create=%d",
6928eec8463SDavid Sterba 		  __entry->offset,
6938eec8463SDavid Sterba 		  __entry->size,
6948eec8463SDavid Sterba 		  __entry->flags,
695c83f8effSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
696c83f8effSJosef Bacik 				BTRFS_GROUP_FLAGS),
6978eec8463SDavid Sterba 		  __entry->bytes_used,
6988eec8463SDavid Sterba 		  __entry->bytes_super, __entry->create)
699c83f8effSJosef Bacik );
700c83f8effSJosef Bacik 
7011abe9b8aSliubo #define show_ref_action(action)						\
7021abe9b8aSliubo 	__print_symbolic(action,					\
7031abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
7041abe9b8aSliubo 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
7051abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
7061abe9b8aSliubo 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
7071abe9b8aSliubo 
7081abe9b8aSliubo 
709599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
7101abe9b8aSliubo 
7119a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
7129a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
7139a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
7141abe9b8aSliubo 		 int action),
7151abe9b8aSliubo 
716bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
7171abe9b8aSliubo 
718bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
7191abe9b8aSliubo 		__field(	u64,  bytenr		)
7201abe9b8aSliubo 		__field(	u64,  num_bytes		)
7211abe9b8aSliubo 		__field(	int,  action		)
7221abe9b8aSliubo 		__field(	u64,  parent		)
7231abe9b8aSliubo 		__field(	u64,  ref_root		)
7241abe9b8aSliubo 		__field(	int,  level		)
7251abe9b8aSliubo 		__field(	int,  type		)
726dea7d76eSLiu Bo 		__field(	u64,  seq		)
7271abe9b8aSliubo 	),
7281abe9b8aSliubo 
729bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
7301abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
7311abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
7321abe9b8aSliubo 		__entry->action		= action;
7331abe9b8aSliubo 		__entry->parent		= full_ref->parent;
7341abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
7351abe9b8aSliubo 		__entry->level		= full_ref->level;
7361abe9b8aSliubo 		__entry->type		= ref->type;
737dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
7381abe9b8aSliubo 	),
7391abe9b8aSliubo 
740562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
741562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) level=%d "
742562a7a07SDavid Sterba 		  "type=%s seq=%llu",
7438eec8463SDavid Sterba 		  __entry->bytenr,
7448eec8463SDavid Sterba 		  __entry->num_bytes,
7451abe9b8aSliubo 		  show_ref_action(__entry->action),
7461abe9b8aSliubo 		  show_root_type(__entry->parent),
7471abe9b8aSliubo 		  show_root_type(__entry->ref_root),
748dea7d76eSLiu Bo 		  __entry->level, show_ref_type(__entry->type),
7498eec8463SDavid Sterba 		  __entry->seq)
7501abe9b8aSliubo );
7511abe9b8aSliubo 
752599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
753599c75ecSLiu Bo 
7549a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
7559a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
7569a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
757599c75ecSLiu Bo 		 int action),
758599c75ecSLiu Bo 
759bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
760599c75ecSLiu Bo );
761599c75ecSLiu Bo 
762599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
763599c75ecSLiu Bo 
7649a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
7659a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
7669a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
767599c75ecSLiu Bo 		 int action),
768599c75ecSLiu Bo 
769bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
770599c75ecSLiu Bo );
771599c75ecSLiu Bo 
772599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
7731abe9b8aSliubo 
7749a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
7759a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
7769a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
7771abe9b8aSliubo 		 int action),
7781abe9b8aSliubo 
779bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
7801abe9b8aSliubo 
781bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
7821abe9b8aSliubo 		__field(	u64,  bytenr		)
7831abe9b8aSliubo 		__field(	u64,  num_bytes		)
7841abe9b8aSliubo 		__field(	int,  action		)
7851abe9b8aSliubo 		__field(	u64,  parent		)
7861abe9b8aSliubo 		__field(	u64,  ref_root		)
7871abe9b8aSliubo 		__field(	u64,  owner		)
7881abe9b8aSliubo 		__field(	u64,  offset		)
7891abe9b8aSliubo 		__field(	int,  type		)
790dea7d76eSLiu Bo 		__field(	u64,  seq		)
7911abe9b8aSliubo 	),
7921abe9b8aSliubo 
793bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
7941abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
7951abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
7961abe9b8aSliubo 		__entry->action		= action;
7971abe9b8aSliubo 		__entry->parent		= full_ref->parent;
7981abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
7991abe9b8aSliubo 		__entry->owner		= full_ref->objectid;
8001abe9b8aSliubo 		__entry->offset		= full_ref->offset;
8011abe9b8aSliubo 		__entry->type		= ref->type;
802dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
8031abe9b8aSliubo 	),
8041abe9b8aSliubo 
805562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
806562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
807562a7a07SDavid Sterba 		  "offset=%llu type=%s seq=%llu",
8088eec8463SDavid Sterba 		  __entry->bytenr,
8098eec8463SDavid Sterba 		  __entry->num_bytes,
8101abe9b8aSliubo 		  show_ref_action(__entry->action),
8111abe9b8aSliubo 		  show_root_type(__entry->parent),
8121abe9b8aSliubo 		  show_root_type(__entry->ref_root),
8138eec8463SDavid Sterba 		  __entry->owner,
8148eec8463SDavid Sterba 		  __entry->offset,
815dea7d76eSLiu Bo 		  show_ref_type(__entry->type),
8168eec8463SDavid Sterba 		  __entry->seq)
8171abe9b8aSliubo );
8181abe9b8aSliubo 
819599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
820599c75ecSLiu Bo 
8219a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8229a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8239a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
824599c75ecSLiu Bo 		 int action),
825599c75ecSLiu Bo 
826bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
827599c75ecSLiu Bo );
828599c75ecSLiu Bo 
829599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
830599c75ecSLiu Bo 
8319a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8329a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8339a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
834599c75ecSLiu Bo 		 int action),
835599c75ecSLiu Bo 
836bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
837599c75ecSLiu Bo );
838599c75ecSLiu Bo 
839599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
8401abe9b8aSliubo 
8419a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8429a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
8431abe9b8aSliubo 		 int action),
8441abe9b8aSliubo 
845d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action),
8461abe9b8aSliubo 
847bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
8481abe9b8aSliubo 		__field(	u64,  bytenr		)
8491abe9b8aSliubo 		__field(	u64,  num_bytes		)
8501abe9b8aSliubo 		__field(	int,  action		)
8511abe9b8aSliubo 		__field(	int,  is_data		)
8521abe9b8aSliubo 	),
8531abe9b8aSliubo 
854bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
855d278850eSJosef Bacik 		__entry->bytenr		= head_ref->bytenr;
856d278850eSJosef Bacik 		__entry->num_bytes	= head_ref->num_bytes;
8571abe9b8aSliubo 		__entry->action		= action;
8581abe9b8aSliubo 		__entry->is_data	= head_ref->is_data;
8591abe9b8aSliubo 	),
8601abe9b8aSliubo 
861562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
8628eec8463SDavid Sterba 		  __entry->bytenr,
8638eec8463SDavid Sterba 		  __entry->num_bytes,
8641abe9b8aSliubo 		  show_ref_action(__entry->action),
8651abe9b8aSliubo 		  __entry->is_data)
8661abe9b8aSliubo );
8671abe9b8aSliubo 
868599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
869599c75ecSLiu Bo 
8709a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8719a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
872599c75ecSLiu Bo 		 int action),
873599c75ecSLiu Bo 
874d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
875599c75ecSLiu Bo );
876599c75ecSLiu Bo 
877599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
878599c75ecSLiu Bo 
8799a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8809a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
881599c75ecSLiu Bo 		 int action),
882599c75ecSLiu Bo 
883d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
884599c75ecSLiu Bo );
885599c75ecSLiu Bo 
8861abe9b8aSliubo #define show_chunk_type(type)					\
8871abe9b8aSliubo 	__print_flags(type, "|",				\
8881abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
8891abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
8901abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
8911abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
8921abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
8931abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
894e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
895e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
896e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
8971abe9b8aSliubo 
8981abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk,
8991abe9b8aSliubo 
9009a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9019a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
9021abe9b8aSliubo 
9036bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size),
9041abe9b8aSliubo 
905bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9061abe9b8aSliubo 		__field(	int,  num_stripes		)
9071abe9b8aSliubo 		__field(	u64,  type			)
9081abe9b8aSliubo 		__field(	int,  sub_stripes		)
9091abe9b8aSliubo 		__field(	u64,  offset			)
9101abe9b8aSliubo 		__field(	u64,  size			)
9111abe9b8aSliubo 		__field(	u64,  root_objectid		)
9121abe9b8aSliubo 	),
9131abe9b8aSliubo 
9146bccf3abSJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
9151abe9b8aSliubo 		__entry->num_stripes	= map->num_stripes;
9161abe9b8aSliubo 		__entry->type		= map->type;
9171abe9b8aSliubo 		__entry->sub_stripes	= map->sub_stripes;
9181abe9b8aSliubo 		__entry->offset		= offset;
9191abe9b8aSliubo 		__entry->size		= size;
9206bccf3abSJeff Mahoney 		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
9211abe9b8aSliubo 	),
9221abe9b8aSliubo 
923562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
924562a7a07SDavid Sterba 		  "num_stripes=%d sub_stripes=%d type=%s",
9251abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
9268eec8463SDavid Sterba 		  __entry->offset,
9278eec8463SDavid Sterba 		  __entry->size,
9281abe9b8aSliubo 		  __entry->num_stripes, __entry->sub_stripes,
9291abe9b8aSliubo 		  show_chunk_type(__entry->type))
9301abe9b8aSliubo );
9311abe9b8aSliubo 
9321abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
9331abe9b8aSliubo 
9349a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9359a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
9361abe9b8aSliubo 
9376bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
9381abe9b8aSliubo );
9391abe9b8aSliubo 
9401abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
9411abe9b8aSliubo 
9429a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9439a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
9441abe9b8aSliubo 
9456bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
9461abe9b8aSliubo );
9471abe9b8aSliubo 
9481abe9b8aSliubo TRACE_EVENT(btrfs_cow_block,
9491abe9b8aSliubo 
9509a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
9519a35b637SJeff Mahoney 		 const struct extent_buffer *cow),
9521abe9b8aSliubo 
9531abe9b8aSliubo 	TP_ARGS(root, buf, cow),
9541abe9b8aSliubo 
955bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9561abe9b8aSliubo 		__field(	u64,  root_objectid		)
9571abe9b8aSliubo 		__field(	u64,  buf_start			)
9581abe9b8aSliubo 		__field(	int,  refs			)
9591abe9b8aSliubo 		__field(	u64,  cow_start			)
9601abe9b8aSliubo 		__field(	int,  buf_level			)
9611abe9b8aSliubo 		__field(	int,  cow_level			)
9621abe9b8aSliubo 	),
9631abe9b8aSliubo 
964bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
9651abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
9661abe9b8aSliubo 		__entry->buf_start	= buf->start;
9671abe9b8aSliubo 		__entry->refs		= atomic_read(&buf->refs);
9681abe9b8aSliubo 		__entry->cow_start	= cow->start;
9691abe9b8aSliubo 		__entry->buf_level	= btrfs_header_level(buf);
9701abe9b8aSliubo 		__entry->cow_level	= btrfs_header_level(cow);
9711abe9b8aSliubo 	),
9721abe9b8aSliubo 
973562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
974562a7a07SDavid Sterba 		  "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
9751abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
9761abe9b8aSliubo 		  __entry->refs,
9778eec8463SDavid Sterba 		  __entry->buf_start,
9781abe9b8aSliubo 		  __entry->buf_level,
9798eec8463SDavid Sterba 		  __entry->cow_start,
9801abe9b8aSliubo 		  __entry->cow_level)
9811abe9b8aSliubo );
9821abe9b8aSliubo 
9838c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation,
9848c2a3ca2SJosef Bacik 
9859a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
9868c2a3ca2SJosef Bacik 		 u64 bytes, int reserve),
9878c2a3ca2SJosef Bacik 
9888c2a3ca2SJosef Bacik 	TP_ARGS(fs_info, type, val, bytes, reserve),
9898c2a3ca2SJosef Bacik 
990bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9918c2a3ca2SJosef Bacik 		__string(	type,	type			)
9928c2a3ca2SJosef Bacik 		__field(	u64,	val			)
9938c2a3ca2SJosef Bacik 		__field(	u64,	bytes			)
9948c2a3ca2SJosef Bacik 		__field(	int,	reserve			)
9958c2a3ca2SJosef Bacik 	),
9968c2a3ca2SJosef Bacik 
997bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
9988c2a3ca2SJosef Bacik 		__assign_str(type, type);
9998c2a3ca2SJosef Bacik 		__entry->val		= val;
10008c2a3ca2SJosef Bacik 		__entry->bytes		= bytes;
10018c2a3ca2SJosef Bacik 		__entry->reserve	= reserve;
10028c2a3ca2SJosef Bacik 	),
10038c2a3ca2SJosef Bacik 
10045439c7f5SDavid Sterba 	TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
1005bc074524SJeff Mahoney 			__entry->reserve ? "reserve" : "release",
10068c2a3ca2SJosef Bacik 			__entry->bytes)
10078c2a3ca2SJosef Bacik );
10088c2a3ca2SJosef Bacik 
1009f376df2bSJosef Bacik #define show_flush_action(action)						\
1010f376df2bSJosef Bacik 	__print_symbolic(action,						\
1011f376df2bSJosef Bacik 		{ BTRFS_RESERVE_NO_FLUSH,	"BTRFS_RESERVE_NO_FLUSH"},	\
1012f376df2bSJosef Bacik 		{ BTRFS_RESERVE_FLUSH_LIMIT,	"BTRFS_RESERVE_FLUSH_LIMIT"},	\
1013f376df2bSJosef Bacik 		{ BTRFS_RESERVE_FLUSH_ALL,	"BTRFS_RESERVE_FLUSH_ALL"})
1014f376df2bSJosef Bacik 
1015f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush,
1016f376df2bSJosef Bacik 
10179a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
1018f376df2bSJosef Bacik 		 int flush, char *reason),
1019f376df2bSJosef Bacik 
1020f376df2bSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, flush, reason),
1021f376df2bSJosef Bacik 
10222e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1023f376df2bSJosef Bacik 		__field(	u64,	flags			)
1024f376df2bSJosef Bacik 		__field(	u64,	bytes			)
1025f376df2bSJosef Bacik 		__field(	int,	flush			)
1026f376df2bSJosef Bacik 		__string(	reason,	reason			)
1027f376df2bSJosef Bacik 	),
1028f376df2bSJosef Bacik 
10292e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1030f376df2bSJosef Bacik 		__entry->flags	= flags;
1031f376df2bSJosef Bacik 		__entry->bytes	= bytes;
1032f376df2bSJosef Bacik 		__entry->flush	= flush;
1033f376df2bSJosef Bacik 		__assign_str(reason, reason)
1034f376df2bSJosef Bacik 	),
1035f376df2bSJosef Bacik 
10362e63e62dSDavid Sterba 	TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
10372e63e62dSDavid Sterba 		  __get_str(reason), __entry->flush,
1038f376df2bSJosef Bacik 		  show_flush_action(__entry->flush),
10398eec8463SDavid Sterba 		  __entry->flags,
1040f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1041f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
10428eec8463SDavid Sterba 		  __entry->bytes)
1043f376df2bSJosef Bacik );
1044f376df2bSJosef Bacik 
1045f376df2bSJosef Bacik #define show_flush_state(state)							\
1046f376df2bSJosef Bacik 	__print_symbolic(state,							\
1047f376df2bSJosef Bacik 		{ FLUSH_DELAYED_ITEMS_NR,	"FLUSH_DELAYED_ITEMS_NR"},	\
1048f376df2bSJosef Bacik 		{ FLUSH_DELAYED_ITEMS,		"FLUSH_DELAYED_ITEMS"},		\
1049f376df2bSJosef Bacik 		{ FLUSH_DELALLOC,		"FLUSH_DELALLOC"},		\
1050f376df2bSJosef Bacik 		{ FLUSH_DELALLOC_WAIT,		"FLUSH_DELALLOC_WAIT"},		\
1051413df725SJosef Bacik 		{ FLUSH_DELAYED_REFS_NR,	"FLUSH_DELAYED_REFS_NR"},	\
1052413df725SJosef Bacik 		{ FLUSH_DELAYED_REFS,		"FLUSH_ELAYED_REFS"},		\
1053f376df2bSJosef Bacik 		{ ALLOC_CHUNK,			"ALLOC_CHUNK"},			\
1054450114fcSJosef Bacik 		{ ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE"},		\
1055f376df2bSJosef Bacik 		{ COMMIT_TRANS,			"COMMIT_TRANS"})
1056f376df2bSJosef Bacik 
1057f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space,
1058f376df2bSJosef Bacik 
10599a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
10607bdd6277SNikolay Borisov 		 int state, int ret),
1061f376df2bSJosef Bacik 
10627bdd6277SNikolay Borisov 	TP_ARGS(fs_info, flags, num_bytes, state, ret),
1063f376df2bSJosef Bacik 
10642e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1065f376df2bSJosef Bacik 		__field(	u64,	flags			)
1066f376df2bSJosef Bacik 		__field(	u64,	num_bytes		)
1067f376df2bSJosef Bacik 		__field(	int,	state			)
1068f376df2bSJosef Bacik 		__field(	int,	ret			)
1069f376df2bSJosef Bacik 	),
1070f376df2bSJosef Bacik 
10712e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1072f376df2bSJosef Bacik 		__entry->flags		=	flags;
1073f376df2bSJosef Bacik 		__entry->num_bytes	=	num_bytes;
1074f376df2bSJosef Bacik 		__entry->state		=	state;
1075f376df2bSJosef Bacik 		__entry->ret		=	ret;
1076f376df2bSJosef Bacik 	),
1077f376df2bSJosef Bacik 
10782e63e62dSDavid Sterba 	TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
10792e63e62dSDavid Sterba 		  __entry->state,
1080f376df2bSJosef Bacik 		  show_flush_state(__entry->state),
10818eec8463SDavid Sterba 		  __entry->flags,
1082f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1083f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
10848eec8463SDavid Sterba 		  __entry->num_bytes, __entry->ret)
1085f376df2bSJosef Bacik );
1086f376df2bSJosef Bacik 
10871abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent,
10881abe9b8aSliubo 
10899a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
10901abe9b8aSliubo 
109171ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len),
10921abe9b8aSliubo 
1093bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10941abe9b8aSliubo 		__field(	u64,  start			)
10951abe9b8aSliubo 		__field(	u64,  len			)
10961abe9b8aSliubo 	),
10971abe9b8aSliubo 
109871ff6437SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
10991abe9b8aSliubo 		__entry->start		= start;
11001abe9b8aSliubo 		__entry->len		= len;
11011abe9b8aSliubo 	),
11021abe9b8aSliubo 
1103562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
110471ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
11058eec8463SDavid Sterba 		  __entry->start,
11068eec8463SDavid Sterba 		  __entry->len)
11071abe9b8aSliubo );
11081abe9b8aSliubo 
11091abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
11101abe9b8aSliubo 
11119a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
11121abe9b8aSliubo 
111371ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
11141abe9b8aSliubo );
11151abe9b8aSliubo 
11161abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
11171abe9b8aSliubo 
11189a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
11191abe9b8aSliubo 
112071ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
11211abe9b8aSliubo );
11221abe9b8aSliubo 
11233f7de037SJosef Bacik TRACE_EVENT(find_free_extent,
11243f7de037SJosef Bacik 
11259a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
11269a35b637SJeff Mahoney 		 u64 empty_size, u64 data),
11273f7de037SJosef Bacik 
112871ff6437SJeff Mahoney 	TP_ARGS(fs_info, num_bytes, empty_size, data),
11293f7de037SJosef Bacik 
1130bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
11313f7de037SJosef Bacik 		__field(	u64,	num_bytes		)
11323f7de037SJosef Bacik 		__field(	u64,	empty_size		)
11333f7de037SJosef Bacik 		__field(	u64,	data			)
11343f7de037SJosef Bacik 	),
11353f7de037SJosef Bacik 
113671ff6437SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
11373f7de037SJosef Bacik 		__entry->num_bytes	= num_bytes;
11383f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
11393f7de037SJosef Bacik 		__entry->data		= data;
11403f7de037SJosef Bacik 	),
11413f7de037SJosef Bacik 
11425439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
114371ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
11443f7de037SJosef Bacik 		  __entry->num_bytes, __entry->empty_size, __entry->data,
11453f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->data, "|",
11463f7de037SJosef Bacik 				 BTRFS_GROUP_FLAGS))
11473f7de037SJosef Bacik );
11483f7de037SJosef Bacik 
11493f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent,
11503f7de037SJosef Bacik 
11513dca5c94SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
11523f7de037SJosef Bacik 		 u64 len),
11533f7de037SJosef Bacik 
11543dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len),
11553f7de037SJosef Bacik 
1156bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
11573f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
11583f7de037SJosef Bacik 		__field(	u64,	flags			)
11593f7de037SJosef Bacik 		__field(	u64,	start			)
11603f7de037SJosef Bacik 		__field(	u64,	len			)
11613f7de037SJosef Bacik 	),
11623f7de037SJosef Bacik 
11633dca5c94SQu Wenruo 	TP_fast_assign_btrfs(block_group->fs_info,
11643f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
11653f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
11663f7de037SJosef Bacik 		__entry->start		= start;
11673f7de037SJosef Bacik 		__entry->len		= len;
11683f7de037SJosef Bacik 	),
11693f7de037SJosef Bacik 
11705439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
11715439c7f5SDavid Sterba 		  "start=%llu len=%llu",
117271ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
117371ff6437SJeff Mahoney 		  __entry->bg_objectid,
11743f7de037SJosef Bacik 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
11753f7de037SJosef Bacik 						"|", BTRFS_GROUP_FLAGS),
11763f7de037SJosef Bacik 		  __entry->start, __entry->len)
11773f7de037SJosef Bacik );
11783f7de037SJosef Bacik 
11793f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
11803f7de037SJosef Bacik 
11813dca5c94SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
11823f7de037SJosef Bacik 		 u64 len),
11833f7de037SJosef Bacik 
11843dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len)
11853f7de037SJosef Bacik );
11863f7de037SJosef Bacik 
11873f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
11883f7de037SJosef Bacik 
11893dca5c94SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
11903f7de037SJosef Bacik 		 u64 len),
11913f7de037SJosef Bacik 
11923dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len)
11933f7de037SJosef Bacik );
11943f7de037SJosef Bacik 
11953f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster,
11963f7de037SJosef Bacik 
11979a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
11983f7de037SJosef Bacik 		 u64 bytes, u64 empty_size, u64 min_bytes),
11993f7de037SJosef Bacik 
12003f7de037SJosef Bacik 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
12013f7de037SJosef Bacik 
1202bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12033f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12043f7de037SJosef Bacik 		__field(	u64,	flags			)
12053f7de037SJosef Bacik 		__field(	u64,	start			)
12063f7de037SJosef Bacik 		__field(	u64,	bytes			)
12073f7de037SJosef Bacik 		__field(	u64,	empty_size		)
12083f7de037SJosef Bacik 		__field(	u64,	min_bytes		)
12093f7de037SJosef Bacik 	),
12103f7de037SJosef Bacik 
1211bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
12123f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
12133f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
12143f7de037SJosef Bacik 		__entry->start		= start;
12153f7de037SJosef Bacik 		__entry->bytes		= bytes;
12163f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
12173f7de037SJosef Bacik 		__entry->min_bytes	= min_bytes;
12183f7de037SJosef Bacik 	),
12193f7de037SJosef Bacik 
12205439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
12215439c7f5SDavid Sterba 		  "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
12223f7de037SJosef Bacik 		  __entry->flags,
12233f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
12243f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
12253f7de037SJosef Bacik 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
12263f7de037SJosef Bacik );
12273f7de037SJosef Bacik 
12283f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup,
12293f7de037SJosef Bacik 
12309a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_block_group_cache *block_group),
12313f7de037SJosef Bacik 
12323f7de037SJosef Bacik 	TP_ARGS(block_group),
12333f7de037SJosef Bacik 
1234bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12353f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12363f7de037SJosef Bacik 	),
12373f7de037SJosef Bacik 
1238bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
12393f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
12403f7de037SJosef Bacik 	),
12413f7de037SJosef Bacik 
12425439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
12433f7de037SJosef Bacik );
12443f7de037SJosef Bacik 
12453f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster,
12463f7de037SJosef Bacik 
12479a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_block_group_cache *block_group,
12489a35b637SJeff Mahoney 		 const struct btrfs_free_cluster *cluster,
12499a35b637SJeff Mahoney 		 u64 size, int bitmap),
12503f7de037SJosef Bacik 
12513f7de037SJosef Bacik 	TP_ARGS(block_group, cluster, size, bitmap),
12523f7de037SJosef Bacik 
1253bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12543f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12553f7de037SJosef Bacik 		__field(	u64,	flags			)
12563f7de037SJosef Bacik 		__field(	u64,	start			)
12573f7de037SJosef Bacik 		__field(	u64,	max_size		)
12583f7de037SJosef Bacik 		__field(	u64,	size			)
12593f7de037SJosef Bacik 		__field(	int,	bitmap			)
12603f7de037SJosef Bacik 	),
12613f7de037SJosef Bacik 
1262bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
12633f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
12643f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
12653f7de037SJosef Bacik 		__entry->start		= cluster->window_start;
12663f7de037SJosef Bacik 		__entry->max_size	= cluster->max_size;
12673f7de037SJosef Bacik 		__entry->size		= size;
12683f7de037SJosef Bacik 		__entry->bitmap		= bitmap;
12693f7de037SJosef Bacik 	),
12703f7de037SJosef Bacik 
12715439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
12725439c7f5SDavid Sterba 		  "size=%llu max_size=%llu bitmap=%d",
12733f7de037SJosef Bacik 		  __entry->bg_objectid,
12743f7de037SJosef Bacik 		  __entry->flags,
12753f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
12763f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
12773f7de037SJosef Bacik 		  __entry->size, __entry->max_size, __entry->bitmap)
12783f7de037SJosef Bacik );
12793f7de037SJosef Bacik 
1280143bede5SJeff Mahoney struct extent_state;
1281143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state,
1282143bede5SJeff Mahoney 
12839a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state,
12849a35b637SJeff Mahoney 		 gfp_t mask, unsigned long IP),
1285143bede5SJeff Mahoney 
1286143bede5SJeff Mahoney 	TP_ARGS(state, mask, IP),
1287143bede5SJeff Mahoney 
1288143bede5SJeff Mahoney 	TP_STRUCT__entry(
12899a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
1290143bede5SJeff Mahoney 		__field(gfp_t, mask)
1291143bede5SJeff Mahoney 		__field(unsigned long, ip)
1292143bede5SJeff Mahoney 	),
1293143bede5SJeff Mahoney 
1294143bede5SJeff Mahoney 	TP_fast_assign(
1295143bede5SJeff Mahoney 		__entry->state	= state,
1296143bede5SJeff Mahoney 		__entry->mask	= mask,
1297143bede5SJeff Mahoney 		__entry->ip	= IP
1298143bede5SJeff Mahoney 	),
1299143bede5SJeff Mahoney 
1300562a7a07SDavid Sterba 	TP_printk("state=%p mask=%s caller=%pS", __entry->state,
13019a35b637SJeff Mahoney 		  show_gfp_flags(__entry->mask), (const void *)__entry->ip)
1302143bede5SJeff Mahoney );
1303143bede5SJeff Mahoney 
1304143bede5SJeff Mahoney TRACE_EVENT(free_extent_state,
1305143bede5SJeff Mahoney 
13069a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state, unsigned long IP),
1307143bede5SJeff Mahoney 
1308143bede5SJeff Mahoney 	TP_ARGS(state, IP),
1309143bede5SJeff Mahoney 
1310143bede5SJeff Mahoney 	TP_STRUCT__entry(
13119a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
1312143bede5SJeff Mahoney 		__field(unsigned long, ip)
1313143bede5SJeff Mahoney 	),
1314143bede5SJeff Mahoney 
1315143bede5SJeff Mahoney 	TP_fast_assign(
1316143bede5SJeff Mahoney 		__entry->state	= state,
1317143bede5SJeff Mahoney 		__entry->ip = IP
1318143bede5SJeff Mahoney 	),
1319143bede5SJeff Mahoney 
1320562a7a07SDavid Sterba 	TP_printk("state=%p caller=%pS", __entry->state,
13219a35b637SJeff Mahoney 		  (const void *)__entry->ip)
1322143bede5SJeff Mahoney );
1323143bede5SJeff Mahoney 
132452483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work,
132552483bc2SQu Wenruo 
13269a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
132752483bc2SQu Wenruo 
132852483bc2SQu Wenruo 	TP_ARGS(work),
132952483bc2SQu Wenruo 
1330bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13319a35b637SJeff Mahoney 		__field(	const void *,	work			)
13329a35b637SJeff Mahoney 		__field(	const void *,	wq			)
13339a35b637SJeff Mahoney 		__field(	const void *,	func			)
13349a35b637SJeff Mahoney 		__field(	const void *,	ordered_func		)
13359a35b637SJeff Mahoney 		__field(	const void *,	ordered_free		)
13369a35b637SJeff Mahoney 		__field(	const void *,	normal_work		)
133752483bc2SQu Wenruo 	),
133852483bc2SQu Wenruo 
1339bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_work_owner(work),
134052483bc2SQu Wenruo 		__entry->work		= work;
134152483bc2SQu Wenruo 		__entry->wq		= work->wq;
134252483bc2SQu Wenruo 		__entry->func		= work->func;
134352483bc2SQu Wenruo 		__entry->ordered_func	= work->ordered_func;
134452483bc2SQu Wenruo 		__entry->ordered_free	= work->ordered_free;
1345b38a6258SLiu Bo 		__entry->normal_work	= &work->normal_work;
134652483bc2SQu Wenruo 	),
134752483bc2SQu Wenruo 
1348d75f773cSSakari Ailus 	TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
1349b38a6258SLiu Bo 		  "ordered_free=%p",
1350b38a6258SLiu Bo 		  __entry->work, __entry->normal_work, __entry->wq,
1351b38a6258SLiu Bo 		   __entry->func, __entry->ordered_func, __entry->ordered_free)
135252483bc2SQu Wenruo );
135352483bc2SQu Wenruo 
1354ac0c7cf8SDavid Sterba /*
1355ac0c7cf8SDavid Sterba  * For situiations when the work is freed, we pass fs_info and a tag that that
1356ac0c7cf8SDavid Sterba  * matches address of the work structure so it can be paired with the
1357ac0c7cf8SDavid Sterba  * scheduling event.
1358ac0c7cf8SDavid Sterba  */
135952483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done,
136052483bc2SQu Wenruo 
13619a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
136252483bc2SQu Wenruo 
1363ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag),
136452483bc2SQu Wenruo 
1365bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13669a35b637SJeff Mahoney 		__field(	const void *,	wtag			)
136752483bc2SQu Wenruo 	),
136852483bc2SQu Wenruo 
1369ac0c7cf8SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1370ac0c7cf8SDavid Sterba 		__entry->wtag		= wtag;
137152483bc2SQu Wenruo 	),
137252483bc2SQu Wenruo 
1373ac0c7cf8SDavid Sterba 	TP_printk_btrfs("work->%p", __entry->wtag)
137452483bc2SQu Wenruo );
137552483bc2SQu Wenruo 
137652483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued,
137752483bc2SQu Wenruo 
13789a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
137952483bc2SQu Wenruo 
138052483bc2SQu Wenruo 	TP_ARGS(work)
138152483bc2SQu Wenruo );
138252483bc2SQu Wenruo 
138352483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched,
138452483bc2SQu Wenruo 
13859a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
138652483bc2SQu Wenruo 
138752483bc2SQu Wenruo 	TP_ARGS(work)
138852483bc2SQu Wenruo );
138952483bc2SQu Wenruo 
139052483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
139152483bc2SQu Wenruo 
13929a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
139352483bc2SQu Wenruo 
1394ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag)
139552483bc2SQu Wenruo );
139652483bc2SQu Wenruo 
139752483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
139852483bc2SQu Wenruo 
13999a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
140052483bc2SQu Wenruo 
140152483bc2SQu Wenruo 	TP_ARGS(work)
140252483bc2SQu Wenruo );
140352483bc2SQu Wenruo 
1404c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue,
1405c3a46891SQu Wenruo 
14069a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq,
14079a35b637SJeff Mahoney 		 const char *name, int high),
1408c3a46891SQu Wenruo 
1409c3a46891SQu Wenruo 	TP_ARGS(wq, name, high),
1410c3a46891SQu Wenruo 
1411bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14129a35b637SJeff Mahoney 		__field(	const void *,	wq			)
1413c3a46891SQu Wenruo 		__string(	name,	name			)
1414c3a46891SQu Wenruo 		__field(	int ,	high			)
1415c3a46891SQu Wenruo 	),
1416c3a46891SQu Wenruo 
1417bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1418c3a46891SQu Wenruo 		__entry->wq		= wq;
1419c3a46891SQu Wenruo 		__assign_str(name, name);
1420c3a46891SQu Wenruo 		__entry->high		= high;
1421c3a46891SQu Wenruo 	),
1422c3a46891SQu Wenruo 
1423562a7a07SDavid Sterba 	TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1424c3a46891SQu Wenruo 		  __print_flags(__entry->high, "",
1425c3a46891SQu Wenruo 				{(WQ_HIGHPRI),	"-high"}),
1426c3a46891SQu Wenruo 		  __entry->wq)
1427c3a46891SQu Wenruo );
1428c3a46891SQu Wenruo 
1429c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1430c3a46891SQu Wenruo 
14319a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq,
14329a35b637SJeff Mahoney 		 const char *name, int high),
1433c3a46891SQu Wenruo 
1434c3a46891SQu Wenruo 	TP_ARGS(wq, name, high)
1435c3a46891SQu Wenruo );
1436c3a46891SQu Wenruo 
1437c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1438c3a46891SQu Wenruo 
14399a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq),
1440c3a46891SQu Wenruo 
1441c3a46891SQu Wenruo 	TP_ARGS(wq),
1442c3a46891SQu Wenruo 
1443bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14449a35b637SJeff Mahoney 		__field(	const void *,	wq		)
1445c3a46891SQu Wenruo 	),
1446c3a46891SQu Wenruo 
1447bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1448c3a46891SQu Wenruo 		__entry->wq		= wq;
1449c3a46891SQu Wenruo 	),
1450c3a46891SQu Wenruo 
1451bc074524SJeff Mahoney 	TP_printk_btrfs("wq=%p", __entry->wq)
1452c3a46891SQu Wenruo );
1453c3a46891SQu Wenruo 
1454c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1455c3a46891SQu Wenruo 
14569a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq),
1457c3a46891SQu Wenruo 
1458c3a46891SQu Wenruo 	TP_ARGS(wq)
1459c3a46891SQu Wenruo );
146052483bc2SQu Wenruo 
146181fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS				\
146281fb6f77SQu Wenruo 	{ QGROUP_RESERVE,	"reserve"	},	\
146381fb6f77SQu Wenruo 	{ QGROUP_RELEASE,	"release"	},	\
146481fb6f77SQu Wenruo 	{ QGROUP_FREE,		"free"		}
146581fb6f77SQu Wenruo 
146681fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
146781fb6f77SQu Wenruo 
14689a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
14699a35b637SJeff Mahoney 		 u64 reserved, int op),
147081fb6f77SQu Wenruo 
147181fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op),
147281fb6f77SQu Wenruo 
1473bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
147481fb6f77SQu Wenruo 		__field(	u64,		rootid		)
1475f8f8e189SDavid Sterba 		__field(	u64,		ino		)
147681fb6f77SQu Wenruo 		__field(	u64,		start		)
147781fb6f77SQu Wenruo 		__field(	u64,		len		)
147881fb6f77SQu Wenruo 		__field(	u64,		reserved	)
147981fb6f77SQu Wenruo 		__field(	int,		op		)
148081fb6f77SQu Wenruo 	),
148181fb6f77SQu Wenruo 
1482bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
14834fd786e6SMisono Tomohiro 		__entry->rootid		=
14844fd786e6SMisono Tomohiro 			BTRFS_I(inode)->root->root_key.objectid;
1485f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
148681fb6f77SQu Wenruo 		__entry->start		= start;
148781fb6f77SQu Wenruo 		__entry->len		= len;
148881fb6f77SQu Wenruo 		__entry->reserved	= reserved;
148981fb6f77SQu Wenruo 		__entry->op		= op;
149081fb6f77SQu Wenruo 	),
149181fb6f77SQu Wenruo 
1492f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
149381fb6f77SQu Wenruo 		  __entry->rootid, __entry->ino, __entry->start, __entry->len,
149481fb6f77SQu Wenruo 		  __entry->reserved,
149581fb6f77SQu Wenruo 		  __print_flags((unsigned long)__entry->op, "",
149681fb6f77SQu Wenruo 				BTRFS_QGROUP_OPERATIONS)
149781fb6f77SQu Wenruo 	)
149881fb6f77SQu Wenruo );
149981fb6f77SQu Wenruo 
150081fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
150181fb6f77SQu Wenruo 
15029a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
15039a35b637SJeff Mahoney 		 u64 reserved, int op),
150481fb6f77SQu Wenruo 
150581fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
150681fb6f77SQu Wenruo );
150781fb6f77SQu Wenruo 
150881fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
150981fb6f77SQu Wenruo 
15109a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
15119a35b637SJeff Mahoney 		 u64 reserved, int op),
151281fb6f77SQu Wenruo 
151381fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
151481fb6f77SQu Wenruo );
151581fb6f77SQu Wenruo 
15160f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
15179a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
15189a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
15190f5dcf8dSMark Fasheh 
1520bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec),
15210f5dcf8dSMark Fasheh 
1522bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
15230f5dcf8dSMark Fasheh 		__field(	u64,  bytenr		)
15240f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes		)
15250f5dcf8dSMark Fasheh 	),
15260f5dcf8dSMark Fasheh 
1527bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
15280f5dcf8dSMark Fasheh 		__entry->bytenr		= rec->bytenr,
15290f5dcf8dSMark Fasheh 		__entry->num_bytes	= rec->num_bytes;
15300f5dcf8dSMark Fasheh 	),
15310f5dcf8dSMark Fasheh 
1532562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
15330f5dcf8dSMark Fasheh 		  (unsigned long long)__entry->bytenr,
15340f5dcf8dSMark Fasheh 		  (unsigned long long)__entry->num_bytes)
15350f5dcf8dSMark Fasheh );
15360f5dcf8dSMark Fasheh 
15370f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
15380f5dcf8dSMark Fasheh 
15399a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
15409a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
15410f5dcf8dSMark Fasheh 
1542bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
15430f5dcf8dSMark Fasheh );
15440f5dcf8dSMark Fasheh 
154550b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
15460f5dcf8dSMark Fasheh 
15479a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
15489a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
15490f5dcf8dSMark Fasheh 
1550bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
15510f5dcf8dSMark Fasheh );
15520f5dcf8dSMark Fasheh 
1553c337e7b0SQu Wenruo TRACE_EVENT(qgroup_num_dirty_extents,
1554c337e7b0SQu Wenruo 
1555c337e7b0SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1556c337e7b0SQu Wenruo 		 u64 num_dirty_extents),
1557c337e7b0SQu Wenruo 
1558c337e7b0SQu Wenruo 	TP_ARGS(fs_info, transid, num_dirty_extents),
1559c337e7b0SQu Wenruo 
1560c337e7b0SQu Wenruo 	TP_STRUCT__entry_btrfs(
1561c337e7b0SQu Wenruo 		__field(	u64, transid			)
1562c337e7b0SQu Wenruo 		__field(	u64, num_dirty_extents		)
1563c337e7b0SQu Wenruo 	),
1564c337e7b0SQu Wenruo 
1565c337e7b0SQu Wenruo 	TP_fast_assign_btrfs(fs_info,
1566c337e7b0SQu Wenruo 		__entry->transid	   = transid;
1567c337e7b0SQu Wenruo 		__entry->num_dirty_extents = num_dirty_extents;
1568c337e7b0SQu Wenruo 	),
1569c337e7b0SQu Wenruo 
1570c337e7b0SQu Wenruo 	TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1571c337e7b0SQu Wenruo 		__entry->transid, __entry->num_dirty_extents)
1572c337e7b0SQu Wenruo );
1573c337e7b0SQu Wenruo 
15740f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent,
15750f5dcf8dSMark Fasheh 
1576c9f6f3cdSQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
1577bc074524SJeff Mahoney 		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
15780f5dcf8dSMark Fasheh 
1579c9f6f3cdSQu Wenruo 	TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1580c9f6f3cdSQu Wenruo 		nr_new_roots),
15810f5dcf8dSMark Fasheh 
1582bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1583c9f6f3cdSQu Wenruo 		__field(	u64,  transid			)
15840f5dcf8dSMark Fasheh 		__field(	u64,  bytenr			)
15850f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes			)
15860f5dcf8dSMark Fasheh 		__field(	u64,  nr_old_roots		)
15870f5dcf8dSMark Fasheh 		__field(	u64,  nr_new_roots		)
15880f5dcf8dSMark Fasheh 	),
15890f5dcf8dSMark Fasheh 
1590bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
1591c9f6f3cdSQu Wenruo 		__entry->transid	= transid;
15920f5dcf8dSMark Fasheh 		__entry->bytenr		= bytenr;
15930f5dcf8dSMark Fasheh 		__entry->num_bytes	= num_bytes;
15940f5dcf8dSMark Fasheh 		__entry->nr_old_roots	= nr_old_roots;
15950f5dcf8dSMark Fasheh 		__entry->nr_new_roots	= nr_new_roots;
15960f5dcf8dSMark Fasheh 	),
15970f5dcf8dSMark Fasheh 
1598c9f6f3cdSQu Wenruo 	TP_printk_btrfs(
1599c9f6f3cdSQu Wenruo "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1600c9f6f3cdSQu Wenruo 		__entry->transid,
16010f5dcf8dSMark Fasheh 		__entry->bytenr,
16020f5dcf8dSMark Fasheh 		__entry->num_bytes,
16030f5dcf8dSMark Fasheh 		__entry->nr_old_roots,
16040f5dcf8dSMark Fasheh 		__entry->nr_new_roots)
16050f5dcf8dSMark Fasheh );
16060f5dcf8dSMark Fasheh 
16070f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters,
16080f5dcf8dSMark Fasheh 
16098b317901SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info,
16108b317901SQu Wenruo 		 struct btrfs_qgroup *qgroup,
1611bc074524SJeff Mahoney 		 u64 cur_old_count, u64 cur_new_count),
16120f5dcf8dSMark Fasheh 
16138b317901SQu Wenruo 	TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
16140f5dcf8dSMark Fasheh 
1615bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
16160f5dcf8dSMark Fasheh 		__field(	u64,  qgid			)
16178b317901SQu Wenruo 		__field(	u64,  old_rfer			)
16188b317901SQu Wenruo 		__field(	u64,  old_excl			)
16190f5dcf8dSMark Fasheh 		__field(	u64,  cur_old_count		)
16200f5dcf8dSMark Fasheh 		__field(	u64,  cur_new_count		)
16210f5dcf8dSMark Fasheh 	),
16220f5dcf8dSMark Fasheh 
1623bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
16248b317901SQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
16258b317901SQu Wenruo 		__entry->old_rfer	= qgroup->rfer;
16268b317901SQu Wenruo 		__entry->old_excl	= qgroup->excl;
16270f5dcf8dSMark Fasheh 		__entry->cur_old_count	= cur_old_count;
16280f5dcf8dSMark Fasheh 		__entry->cur_new_count	= cur_new_count;
16290f5dcf8dSMark Fasheh 	),
16300f5dcf8dSMark Fasheh 
16318b317901SQu Wenruo 	TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
16328b317901SQu Wenruo 		  __entry->qgid, __entry->old_rfer, __entry->old_excl,
16338b317901SQu Wenruo 		  __entry->cur_old_count, __entry->cur_new_count)
16340f5dcf8dSMark Fasheh );
16350f5dcf8dSMark Fasheh 
16363159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve,
16373159fe7bSQu Wenruo 
16383159fe7bSQu Wenruo 	TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
163964ee4e75SQu Wenruo 		 s64 diff, int type),
16403159fe7bSQu Wenruo 
164164ee4e75SQu Wenruo 	TP_ARGS(fs_info, qgroup, diff, type),
16423159fe7bSQu Wenruo 
16433159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
16443159fe7bSQu Wenruo 		__field(	u64,	qgid			)
16453159fe7bSQu Wenruo 		__field(	u64,	cur_reserved		)
16463159fe7bSQu Wenruo 		__field(	s64,	diff			)
164764ee4e75SQu Wenruo 		__field(	int,	type			)
16483159fe7bSQu Wenruo 	),
16493159fe7bSQu Wenruo 
16503159fe7bSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
16513159fe7bSQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
165264ee4e75SQu Wenruo 		__entry->cur_reserved	= qgroup->rsv.values[type];
16533159fe7bSQu Wenruo 		__entry->diff		= diff;
16543159fe7bSQu Wenruo 	),
16553159fe7bSQu Wenruo 
165664ee4e75SQu Wenruo 	TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
165764ee4e75SQu Wenruo 		__entry->qgid, show_qgroup_rsv_type(__entry->type),
165864ee4e75SQu Wenruo 		__entry->cur_reserved, __entry->diff)
16593159fe7bSQu Wenruo );
16603159fe7bSQu Wenruo 
16613159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve,
16623159fe7bSQu Wenruo 
16634ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff, int type),
16643159fe7bSQu Wenruo 
16654ee0d883SQu Wenruo 	TP_ARGS(root, diff, type),
16663159fe7bSQu Wenruo 
16673159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
16683159fe7bSQu Wenruo 		__field(	u64,	refroot			)
16693159fe7bSQu Wenruo 		__field(	s64,	diff			)
16704ee0d883SQu Wenruo 		__field(	int,	type			)
16713159fe7bSQu Wenruo 	),
16723159fe7bSQu Wenruo 
16733159fe7bSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
16744fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
16753159fe7bSQu Wenruo 		__entry->diff		= diff;
16763159fe7bSQu Wenruo 	),
16773159fe7bSQu Wenruo 
16784ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
16794ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
16804ee0d883SQu Wenruo 		show_qgroup_rsv_type(__entry->type), __entry->diff)
16814ee0d883SQu Wenruo );
16824ee0d883SQu Wenruo 
16834ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_convert,
16844ee0d883SQu Wenruo 
16854ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff),
16864ee0d883SQu Wenruo 
16874ee0d883SQu Wenruo 	TP_ARGS(root, diff),
16884ee0d883SQu Wenruo 
16894ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
16904ee0d883SQu Wenruo 		__field(	u64,	refroot			)
16914ee0d883SQu Wenruo 		__field(	s64,	diff			)
16924ee0d883SQu Wenruo 		__field(	int,	type			)
16934ee0d883SQu Wenruo 	),
16944ee0d883SQu Wenruo 
16954ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
16964fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
16974ee0d883SQu Wenruo 		__entry->diff		= diff;
16984ee0d883SQu Wenruo 	),
16994ee0d883SQu Wenruo 
17004ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
17014ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
17024ee0d883SQu Wenruo 		show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC),
17034ee0d883SQu Wenruo 		show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS),
17044ee0d883SQu Wenruo 		__entry->diff)
17054ee0d883SQu Wenruo );
17064ee0d883SQu Wenruo 
17074ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_free_all_pertrans,
17084ee0d883SQu Wenruo 
17094ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root),
17104ee0d883SQu Wenruo 
17114ee0d883SQu Wenruo 	TP_ARGS(root),
17124ee0d883SQu Wenruo 
17134ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
17144ee0d883SQu Wenruo 		__field(	u64,	refroot			)
17154ee0d883SQu Wenruo 		__field(	s64,	diff			)
17164ee0d883SQu Wenruo 		__field(	int,	type			)
17174ee0d883SQu Wenruo 	),
17184ee0d883SQu Wenruo 
17194ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
17204fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
17214ee0d883SQu Wenruo 		spin_lock(&root->qgroup_meta_rsv_lock);
17224ee0d883SQu Wenruo 		__entry->diff		= -(s64)root->qgroup_meta_rsv_pertrans;
17234ee0d883SQu Wenruo 		spin_unlock(&root->qgroup_meta_rsv_lock);
17244ee0d883SQu Wenruo 		__entry->type		= BTRFS_QGROUP_RSV_META_PERTRANS;
17254ee0d883SQu Wenruo 	),
17264ee0d883SQu Wenruo 
17274ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
17284ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
17294ee0d883SQu Wenruo 		show_qgroup_rsv_type(__entry->type), __entry->diff)
17303159fe7bSQu Wenruo );
17313159fe7bSQu Wenruo 
173200142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref,
173300142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
173400142756SJeff Mahoney 		 const struct prelim_ref *oldref,
173500142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
173600142756SJeff Mahoney 	TP_ARGS(fs_info, newref, oldref, tree_size),
173700142756SJeff Mahoney 
173800142756SJeff Mahoney 	TP_STRUCT__entry_btrfs(
173900142756SJeff Mahoney 		__field(	u64,  root_id		)
174000142756SJeff Mahoney 		__field(	u64,  objectid		)
174100142756SJeff Mahoney 		__field(	 u8,  type		)
174200142756SJeff Mahoney 		__field(	u64,  offset		)
174300142756SJeff Mahoney 		__field(	int,  level		)
174400142756SJeff Mahoney 		__field(	int,  old_count		)
174500142756SJeff Mahoney 		__field(	u64,  parent		)
174600142756SJeff Mahoney 		__field(	u64,  bytenr		)
174700142756SJeff Mahoney 		__field(	int,  mod_count		)
174800142756SJeff Mahoney 		__field(	u64,  tree_size		)
174900142756SJeff Mahoney 	),
175000142756SJeff Mahoney 
175100142756SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
175200142756SJeff Mahoney 		__entry->root_id	= oldref->root_id;
175300142756SJeff Mahoney 		__entry->objectid	= oldref->key_for_search.objectid;
175400142756SJeff Mahoney 		__entry->type		= oldref->key_for_search.type;
175500142756SJeff Mahoney 		__entry->offset		= oldref->key_for_search.offset;
175600142756SJeff Mahoney 		__entry->level		= oldref->level;
175700142756SJeff Mahoney 		__entry->old_count	= oldref->count;
175800142756SJeff Mahoney 		__entry->parent		= oldref->parent;
175900142756SJeff Mahoney 		__entry->bytenr		= oldref->wanted_disk_byte;
176000142756SJeff Mahoney 		__entry->mod_count	= newref ? newref->count : 0;
176100142756SJeff Mahoney 		__entry->tree_size	= tree_size;
176200142756SJeff Mahoney 	),
176300142756SJeff Mahoney 
176400142756SJeff Mahoney 	TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
17658eec8463SDavid Sterba 			__entry->root_id,
17668eec8463SDavid Sterba 			__entry->objectid, __entry->type,
17678eec8463SDavid Sterba 			__entry->offset, __entry->level,
176800142756SJeff Mahoney 			__entry->old_count, __entry->mod_count,
176900142756SJeff Mahoney 			__entry->old_count + __entry->mod_count,
17708eec8463SDavid Sterba 			__entry->parent,
17718eec8463SDavid Sterba 			__entry->bytenr,
17728eec8463SDavid Sterba 			__entry->tree_size)
177300142756SJeff Mahoney );
177400142756SJeff Mahoney 
177500142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
177600142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
177700142756SJeff Mahoney 		 const struct prelim_ref *oldref,
177800142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
177900142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
178000142756SJeff Mahoney );
178100142756SJeff Mahoney 
178200142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
178300142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
178400142756SJeff Mahoney 		 const struct prelim_ref *oldref,
178500142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
178600142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
178700142756SJeff Mahoney );
178800142756SJeff Mahoney 
1789dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
1790dd48d407SJosef Bacik 	TP_PROTO(struct btrfs_root *root, u64 ino, int mod),
1791dd48d407SJosef Bacik 
1792dd48d407SJosef Bacik 	TP_ARGS(root, ino, mod),
1793dd48d407SJosef Bacik 
1794dd48d407SJosef Bacik 	TP_STRUCT__entry_btrfs(
1795dd48d407SJosef Bacik 		__field(	u64, root_objectid	)
1796dd48d407SJosef Bacik 		__field(	u64, ino		)
1797dd48d407SJosef Bacik 		__field(	int, mod		)
1798dd48d407SJosef Bacik 	),
1799dd48d407SJosef Bacik 
1800dd48d407SJosef Bacik 	TP_fast_assign_btrfs(root->fs_info,
18014fd786e6SMisono Tomohiro 		__entry->root_objectid	= root->root_key.objectid;
1802dd48d407SJosef Bacik 		__entry->ino		= ino;
1803dd48d407SJosef Bacik 		__entry->mod		= mod;
1804dd48d407SJosef Bacik 	),
1805dd48d407SJosef Bacik 
1806dd48d407SJosef Bacik 	TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1807dd48d407SJosef Bacik 			show_root_type(__entry->root_objectid),
18088eec8463SDavid Sterba 			__entry->ino, __entry->mod)
1809dd48d407SJosef Bacik );
18103dca5c94SQu Wenruo 
18114ed0a7a3SQu Wenruo DECLARE_EVENT_CLASS(btrfs__block_group,
18124ed0a7a3SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
18134ed0a7a3SQu Wenruo 
18144ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache),
18154ed0a7a3SQu Wenruo 
18164ed0a7a3SQu Wenruo 	TP_STRUCT__entry_btrfs(
18174ed0a7a3SQu Wenruo 		__field(	u64,	bytenr		)
18184ed0a7a3SQu Wenruo 		__field(	u64,	len		)
18194ed0a7a3SQu Wenruo 		__field(	u64,	used		)
18204ed0a7a3SQu Wenruo 		__field(	u64,	flags		)
18214ed0a7a3SQu Wenruo 	),
18224ed0a7a3SQu Wenruo 
18234ed0a7a3SQu Wenruo 	TP_fast_assign_btrfs(bg_cache->fs_info,
18244ed0a7a3SQu Wenruo 		__entry->bytenr = bg_cache->key.objectid,
18254ed0a7a3SQu Wenruo 		__entry->len	= bg_cache->key.offset,
18264ed0a7a3SQu Wenruo 		__entry->used	= btrfs_block_group_used(&bg_cache->item);
18274ed0a7a3SQu Wenruo 		__entry->flags	= bg_cache->flags;
18284ed0a7a3SQu Wenruo 	),
18294ed0a7a3SQu Wenruo 
18304ed0a7a3SQu Wenruo 	TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
18314ed0a7a3SQu Wenruo 		__entry->bytenr, __entry->len, __entry->used, __entry->flags,
18324ed0a7a3SQu Wenruo 		__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
18334ed0a7a3SQu Wenruo );
18344ed0a7a3SQu Wenruo 
18354ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
18364ed0a7a3SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
18374ed0a7a3SQu Wenruo 
18384ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
18394ed0a7a3SQu Wenruo );
18404ed0a7a3SQu Wenruo 
18414ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
18424ed0a7a3SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
18434ed0a7a3SQu Wenruo 
18444ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
18454ed0a7a3SQu Wenruo );
18464ed0a7a3SQu Wenruo 
18474ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
18484ed0a7a3SQu Wenruo 	TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
18494ed0a7a3SQu Wenruo 
18504ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
18514ed0a7a3SQu Wenruo );
18524ed0a7a3SQu Wenruo 
18531abe9b8aSliubo #endif /* _TRACE_BTRFS_H */
18541abe9b8aSliubo 
18551abe9b8aSliubo /* This part must be outside protection */
18561abe9b8aSliubo #include <trace/define_trace.h>
1857