xref: /openbmc/linux/include/trace/events/btrfs.h (revision 8197766d)
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;
2232da5386SDavid Sterba struct btrfs_block_group;
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;
30a1d19847SQu Wenruo struct extent_io_tree;
3100142756SJeff Mahoney struct prelim_ref;
32480b9b4dSQu Wenruo struct btrfs_space_info;
331abe9b8aSliubo 
341abe9b8aSliubo #define show_ref_type(type)						\
351abe9b8aSliubo 	__print_symbolic(type,						\
361abe9b8aSliubo 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
371abe9b8aSliubo 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
381abe9b8aSliubo 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
391abe9b8aSliubo 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
401abe9b8aSliubo 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
411abe9b8aSliubo 
421abe9b8aSliubo #define __show_root_type(obj)						\
437f34b746Sliubo 	__print_symbolic_u64(obj,					\
441abe9b8aSliubo 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
451abe9b8aSliubo 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
461abe9b8aSliubo 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
471abe9b8aSliubo 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
481abe9b8aSliubo 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
491abe9b8aSliubo 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
501abe9b8aSliubo 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
511abe9b8aSliubo 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
52e112e2b4SLiu Bo 		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
531abe9b8aSliubo 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
54208acb8cSOmar Sandoval 		{ BTRFS_UUID_TREE_OBJECTID,	"UUID_TREE"	},	\
55208acb8cSOmar Sandoval 		{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },	\
561abe9b8aSliubo 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
571abe9b8aSliubo 
581abe9b8aSliubo #define show_root_type(obj)						\
591abe9b8aSliubo 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
60fb57dc81SLiu Bo 	      (obj >= BTRFS_ROOT_TREE_OBJECTID &&			\
61e112e2b4SLiu Bo 	       obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
621abe9b8aSliubo 
635bca2c95SNikolay Borisov #define FLUSH_ACTIONS								\
645bca2c95SNikolay Borisov 	EM( BTRFS_RESERVE_NO_FLUSH,		"BTRFS_RESERVE_NO_FLUSH")	\
655bca2c95SNikolay Borisov 	EM( BTRFS_RESERVE_FLUSH_LIMIT,		"BTRFS_RESERVE_FLUSH_LIMIT")	\
665bca2c95SNikolay Borisov 	EM( BTRFS_RESERVE_FLUSH_ALL,		"BTRFS_RESERVE_FLUSH_ALL")	\
675bca2c95SNikolay Borisov 	EMe(BTRFS_RESERVE_FLUSH_ALL_STEAL,	"BTRFS_RESERVE_FLUSH_ALL_STEAL")
685bca2c95SNikolay Borisov 
690840dd28SNikolay Borisov #define FI_TYPES							\
700840dd28SNikolay Borisov 	EM( BTRFS_FILE_EXTENT_INLINE,		"INLINE")		\
710840dd28SNikolay Borisov 	EM( BTRFS_FILE_EXTENT_REG,		"REG")			\
720840dd28SNikolay Borisov 	EMe(BTRFS_FILE_EXTENT_PREALLOC,		"PREALLOC")
730840dd28SNikolay Borisov 
741cb1f0b2SNikolay Borisov #define QGROUP_RSV_TYPES						\
751cb1f0b2SNikolay Borisov 	EM( BTRFS_QGROUP_RSV_DATA,		"DATA")			\
761cb1f0b2SNikolay Borisov 	EM( BTRFS_QGROUP_RSV_META_PERTRANS,	"META_PERTRANS")	\
771cb1f0b2SNikolay Borisov 	EMe(BTRFS_QGROUP_RSV_META_PREALLOC,	"META_PREALLOC")
781cb1f0b2SNikolay Borisov 
79c92bb304SNikolay Borisov #define IO_TREE_OWNER						    \
80c92bb304SNikolay Borisov 	EM( IO_TREE_FS_PINNED_EXTENTS, 	  "PINNED_EXTENTS")	    \
81c92bb304SNikolay Borisov 	EM( IO_TREE_FS_EXCLUDED_EXTENTS,  "EXCLUDED_EXTENTS")	    \
822c53a14dSQu Wenruo 	EM( IO_TREE_BTREE_INODE_IO,	  "BTREE_INODE_IO")	    \
83c92bb304SNikolay Borisov 	EM( IO_TREE_INODE_IO,		  "INODE_IO")		    \
84c92bb304SNikolay Borisov 	EM( IO_TREE_INODE_IO_FAILURE,	  "INODE_IO_FAILURE")	    \
85c92bb304SNikolay Borisov 	EM( IO_TREE_RELOC_BLOCKS,	  "RELOC_BLOCKS")	    \
86c92bb304SNikolay Borisov 	EM( IO_TREE_TRANS_DIRTY_PAGES,	  "TRANS_DIRTY_PAGES")      \
87c92bb304SNikolay Borisov 	EM( IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES")   \
88c92bb304SNikolay Borisov 	EM( IO_TREE_INODE_FILE_EXTENT,	  "INODE_FILE_EXTENT")      \
89c92bb304SNikolay Borisov 	EM( IO_TREE_LOG_CSUM_RANGE,	  "LOG_CSUM_RANGE")         \
90c92bb304SNikolay Borisov 	EMe(IO_TREE_SELFTEST,		  "SELFTEST")
91c92bb304SNikolay Borisov 
92f0cdd15cSNikolay Borisov #define FLUSH_STATES							\
93f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_ITEMS_NR,	"FLUSH_DELAYED_ITEMS_NR")	\
94f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_ITEMS,	"FLUSH_DELAYED_ITEMS")		\
95f0cdd15cSNikolay Borisov 	EM( FLUSH_DELALLOC,		"FLUSH_DELALLOC")		\
96f0cdd15cSNikolay Borisov 	EM( FLUSH_DELALLOC_WAIT,	"FLUSH_DELALLOC_WAIT")		\
97f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_REFS_NR,	"FLUSH_DELAYED_REFS_NR")	\
98f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_REFS,		"FLUSH_ELAYED_REFS")		\
99f0cdd15cSNikolay Borisov 	EM( ALLOC_CHUNK,		"ALLOC_CHUNK")			\
100f0cdd15cSNikolay Borisov 	EM( ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE")		\
101f0cdd15cSNikolay Borisov 	EM( RUN_DELAYED_IPUTS,		"RUN_DELAYED_IPUTS")		\
102c416a30cSJosef Bacik 	EMe(COMMIT_TRANS,		"COMMIT_TRANS")
103f0cdd15cSNikolay Borisov 
1045bca2c95SNikolay Borisov /*
1055bca2c95SNikolay Borisov  * First define the enums in the above macros to be exported to userspace via
1065bca2c95SNikolay Borisov  * TRACE_DEFINE_ENUM().
1075bca2c95SNikolay Borisov  */
1085bca2c95SNikolay Borisov 
1090840dd28SNikolay Borisov #undef EM
1100840dd28SNikolay Borisov #undef EMe
1110840dd28SNikolay Borisov #define EM(a, b)	TRACE_DEFINE_ENUM(a);
1120840dd28SNikolay Borisov #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
1130840dd28SNikolay Borisov 
1145bca2c95SNikolay Borisov FLUSH_ACTIONS
1150840dd28SNikolay Borisov FI_TYPES
1161cb1f0b2SNikolay Borisov QGROUP_RSV_TYPES
117c92bb304SNikolay Borisov IO_TREE_OWNER
118f0cdd15cSNikolay Borisov FLUSH_STATES
1190840dd28SNikolay Borisov 
1205bca2c95SNikolay Borisov /*
1215bca2c95SNikolay Borisov  * Now redefine the EM and EMe macros to map the enums to the strings that will
1225bca2c95SNikolay Borisov  * be printed in the output
1235bca2c95SNikolay Borisov  */
1245bca2c95SNikolay Borisov 
1250840dd28SNikolay Borisov #undef EM
1260840dd28SNikolay Borisov #undef EMe
1270840dd28SNikolay Borisov #define EM(a, b)        {a, b},
1280840dd28SNikolay Borisov #define EMe(a, b)       {a, b}
12909ed2f16SLiu Bo 
130a1d19847SQu Wenruo 
1313f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS	\
1323f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
1333f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
1343f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
1353f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
1363f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
1373f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
138e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
139e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
140e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
1413f7de037SJosef Bacik 
142a1d19847SQu Wenruo #define EXTENT_FLAGS						\
143a1d19847SQu Wenruo 	{ EXTENT_DIRTY,			"DIRTY"},		\
144a1d19847SQu Wenruo 	{ EXTENT_UPTODATE,		"UPTODATE"},		\
145a1d19847SQu Wenruo 	{ EXTENT_LOCKED,		"LOCKED"},		\
146a1d19847SQu Wenruo 	{ EXTENT_NEW,			"NEW"},			\
147a1d19847SQu Wenruo 	{ EXTENT_DELALLOC,		"DELALLOC"},		\
148a1d19847SQu Wenruo 	{ EXTENT_DEFRAG,		"DEFRAG"},		\
149a1d19847SQu Wenruo 	{ EXTENT_BOUNDARY,		"BOUNDARY"},		\
150a1d19847SQu Wenruo 	{ EXTENT_NODATASUM,		"NODATASUM"},		\
151a1d19847SQu Wenruo 	{ EXTENT_CLEAR_META_RESV,	"CLEAR_META_RESV"},	\
152a1d19847SQu Wenruo 	{ EXTENT_NEED_WAIT,		"NEED_WAIT"},		\
153a1d19847SQu Wenruo 	{ EXTENT_DAMAGED,		"DAMAGED"},		\
154a1d19847SQu Wenruo 	{ EXTENT_NORESERVE,		"NORESERVE"},		\
155a1d19847SQu Wenruo 	{ EXTENT_QGROUP_RESERVED,	"QGROUP_RESERVED"},	\
156a1d19847SQu Wenruo 	{ EXTENT_CLEAR_DATA_RESV,	"CLEAR_DATA_RESV"},	\
157a1d19847SQu Wenruo 	{ EXTENT_DELALLOC_NEW,		"DELALLOC_NEW"}
158a1d19847SQu Wenruo 
159b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16
160b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
161bc074524SJeff Mahoney 
162bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info)					\
163a1d19847SQu Wenruo ({									\
164a1d19847SQu Wenruo 	if (fs_info)							\
165a1d19847SQu Wenruo 		memcpy(__entry->fsid, fs_info->fs_devices->fsid,	\
166a1d19847SQu Wenruo 		       BTRFS_FSID_SIZE);				\
167a1d19847SQu Wenruo 	else								\
168a1d19847SQu Wenruo 		memset(__entry->fsid, 0, BTRFS_FSID_SIZE);		\
169a1d19847SQu Wenruo })
170bc074524SJeff Mahoney 
171bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...)					\
172bc074524SJeff Mahoney 	TP_STRUCT__entry(						\
173bc074524SJeff Mahoney 		TP_STRUCT__entry_fsid					\
174bc074524SJeff Mahoney 		args)
175bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...)				\
176bc074524SJeff Mahoney 	TP_fast_assign(							\
177bc074524SJeff Mahoney 		TP_fast_assign_fsid(fs_info);				\
178bc074524SJeff Mahoney 		args)
179bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \
180bc074524SJeff Mahoney 	TP_printk("%pU: " fmt, __entry->fsid, args)
1818c2a3ca2SJosef Bacik 
1821abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit,
1831abe9b8aSliubo 
1849a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root),
1851abe9b8aSliubo 
1861abe9b8aSliubo 	TP_ARGS(root),
1871abe9b8aSliubo 
188bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1891abe9b8aSliubo 		__field(	u64,  generation		)
1901abe9b8aSliubo 		__field(	u64,  root_objectid		)
1911abe9b8aSliubo 	),
1921abe9b8aSliubo 
193bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
1941abe9b8aSliubo 		__entry->generation	= root->fs_info->generation;
1951abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
1961abe9b8aSliubo 	),
1971abe9b8aSliubo 
19879bcb71aSDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu",
1991abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2008eec8463SDavid Sterba 		  __entry->generation)
2011abe9b8aSliubo );
2021abe9b8aSliubo 
2031abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode,
2041abe9b8aSliubo 
2059a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2061abe9b8aSliubo 
2071abe9b8aSliubo 	TP_ARGS(inode),
2081abe9b8aSliubo 
209bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
210f8f8e189SDavid Sterba 		__field(	u64,  ino			)
21194c3f6c6SDavid Sterba 		__field(	u64,  blocks			)
2121abe9b8aSliubo 		__field(	u64,  disk_i_size		)
2131abe9b8aSliubo 		__field(	u64,  generation		)
2141abe9b8aSliubo 		__field(	u64,  last_trans		)
2151abe9b8aSliubo 		__field(	u64,  logged_trans		)
2161abe9b8aSliubo 		__field(	u64,  root_objectid		)
2171abe9b8aSliubo 	),
2181abe9b8aSliubo 
219bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
220f8f8e189SDavid Sterba 		__entry->ino	= btrfs_ino(BTRFS_I(inode));
2211abe9b8aSliubo 		__entry->blocks	= inode->i_blocks;
2221abe9b8aSliubo 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
2231abe9b8aSliubo 		__entry->generation = BTRFS_I(inode)->generation;
2241abe9b8aSliubo 		__entry->last_trans = BTRFS_I(inode)->last_trans;
2251abe9b8aSliubo 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
2261abe9b8aSliubo 		__entry->root_objectid =
2271abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
2281abe9b8aSliubo 	),
2291abe9b8aSliubo 
230f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
231562a7a07SDavid Sterba 		  "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
2321abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2338eec8463SDavid Sterba 		  __entry->generation,
2348eec8463SDavid Sterba 		  __entry->ino,
23594c3f6c6SDavid Sterba 		  __entry->blocks,
2368eec8463SDavid Sterba 		  __entry->disk_i_size,
2378eec8463SDavid Sterba 		  __entry->last_trans,
2388eec8463SDavid Sterba 		  __entry->logged_trans)
2391abe9b8aSliubo );
2401abe9b8aSliubo 
2411abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
2421abe9b8aSliubo 
2439a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2441abe9b8aSliubo 
2451abe9b8aSliubo 	TP_ARGS(inode)
2461abe9b8aSliubo );
2471abe9b8aSliubo 
2481abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
2491abe9b8aSliubo 
2509a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2511abe9b8aSliubo 
2521abe9b8aSliubo 	TP_ARGS(inode)
2531abe9b8aSliubo );
2541abe9b8aSliubo 
2551abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
2561abe9b8aSliubo 
2579a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2581abe9b8aSliubo 
2591abe9b8aSliubo 	TP_ARGS(inode)
2601abe9b8aSliubo );
2611abe9b8aSliubo 
2621abe9b8aSliubo #define __show_map_type(type)						\
2637f34b746Sliubo 	__print_symbolic_u64(type,					\
2641abe9b8aSliubo 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
2651abe9b8aSliubo 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
2661abe9b8aSliubo 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
2671abe9b8aSliubo 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
2681abe9b8aSliubo 
2691abe9b8aSliubo #define show_map_type(type)			\
2701abe9b8aSliubo 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
2711abe9b8aSliubo 
2721abe9b8aSliubo #define show_map_flags(flag)						\
2731abe9b8aSliubo 	__print_flags(flag, "|",					\
274254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
275254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
276254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
277254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
278254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
279254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
2801abe9b8aSliubo 
2814cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent,
2821abe9b8aSliubo 
2839a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
2849a35b637SJeff Mahoney 		 const struct extent_map *map),
2851abe9b8aSliubo 
28692a1bf76SLiu Bo 	TP_ARGS(root, inode, map),
2871abe9b8aSliubo 
2884cd8587cSSteven Rostedt 	TP_CONDITION(map),
2894cd8587cSSteven Rostedt 
290bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
2911abe9b8aSliubo 		__field(	u64,  root_objectid	)
29292a1bf76SLiu Bo 		__field(	u64,  ino		)
2931abe9b8aSliubo 		__field(	u64,  start		)
2941abe9b8aSliubo 		__field(	u64,  len		)
2951abe9b8aSliubo 		__field(	u64,  orig_start	)
2961abe9b8aSliubo 		__field(	u64,  block_start	)
2971abe9b8aSliubo 		__field(	u64,  block_len		)
2981abe9b8aSliubo 		__field(	unsigned long,  flags	)
2991abe9b8aSliubo 		__field(	int,  refs		)
3001abe9b8aSliubo 		__field(	unsigned int,  compress_type	)
3011abe9b8aSliubo 	),
3021abe9b8aSliubo 
303bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
3041abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
30592a1bf76SLiu Bo 		__entry->ino		= btrfs_ino(inode);
3061abe9b8aSliubo 		__entry->start		= map->start;
3071abe9b8aSliubo 		__entry->len		= map->len;
3081abe9b8aSliubo 		__entry->orig_start	= map->orig_start;
3091abe9b8aSliubo 		__entry->block_start	= map->block_start;
3101abe9b8aSliubo 		__entry->block_len	= map->block_len;
3111abe9b8aSliubo 		__entry->flags		= map->flags;
312490b54d6SElena Reshetova 		__entry->refs		= refcount_read(&map->refs);
3131abe9b8aSliubo 		__entry->compress_type	= map->compress_type;
3141abe9b8aSliubo 	),
3151abe9b8aSliubo 
316562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
317562a7a07SDavid Sterba 		  "orig_start=%llu block_start=%llu(%s) "
318562a7a07SDavid Sterba 		  "block_len=%llu flags=%s refs=%u "
3191abe9b8aSliubo 		  "compress_type=%u",
3201abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3218eec8463SDavid Sterba 		  __entry->ino,
3228eec8463SDavid Sterba 		  __entry->start,
3238eec8463SDavid Sterba 		  __entry->len,
3248eec8463SDavid Sterba 		  __entry->orig_start,
3251abe9b8aSliubo 		  show_map_type(__entry->block_start),
3268eec8463SDavid Sterba 		  __entry->block_len,
3271abe9b8aSliubo 		  show_map_flags(__entry->flags),
3281abe9b8aSliubo 		  __entry->refs, __entry->compress_type)
3291abe9b8aSliubo );
3301abe9b8aSliubo 
331393da918SLiu Bo TRACE_EVENT(btrfs_handle_em_exist,
332393da918SLiu Bo 
3331d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
334f46b24c9SDavid Sterba 		const struct extent_map *existing, const struct extent_map *map,
335f46b24c9SDavid Sterba 		u64 start, u64 len),
336393da918SLiu Bo 
337f46b24c9SDavid Sterba 	TP_ARGS(fs_info, existing, map, start, len),
338393da918SLiu Bo 
339f46b24c9SDavid Sterba 	TP_STRUCT__entry_btrfs(
340393da918SLiu Bo 		__field(	u64,  e_start		)
341393da918SLiu Bo 		__field(	u64,  e_len		)
342393da918SLiu Bo 		__field(	u64,  map_start		)
343393da918SLiu Bo 		__field(	u64,  map_len		)
344393da918SLiu Bo 		__field(	u64,  start		)
345393da918SLiu Bo 		__field(	u64,  len		)
346393da918SLiu Bo 	),
347393da918SLiu Bo 
348f46b24c9SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
349393da918SLiu Bo 		__entry->e_start	= existing->start;
350393da918SLiu Bo 		__entry->e_len		= existing->len;
351393da918SLiu Bo 		__entry->map_start	= map->start;
352393da918SLiu Bo 		__entry->map_len	= map->len;
353393da918SLiu Bo 		__entry->start		= start;
354393da918SLiu Bo 		__entry->len		= len;
355393da918SLiu Bo 	),
356393da918SLiu Bo 
357f46b24c9SDavid Sterba 	TP_printk_btrfs("start=%llu len=%llu "
358393da918SLiu Bo 		  "existing(start=%llu len=%llu) "
359393da918SLiu Bo 		  "em(start=%llu len=%llu)",
3608eec8463SDavid Sterba 		  __entry->start,
3618eec8463SDavid Sterba 		  __entry->len,
3628eec8463SDavid Sterba 		  __entry->e_start,
3638eec8463SDavid Sterba 		  __entry->e_len,
3648eec8463SDavid Sterba 		  __entry->map_start,
3658eec8463SDavid Sterba 		  __entry->map_len)
366393da918SLiu Bo );
367393da918SLiu Bo 
36809ed2f16SLiu Bo /* file extent item */
36909ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
37009ed2f16SLiu Bo 
3711d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
3721d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
37309ed2f16SLiu Bo 
37409ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start),
37509ed2f16SLiu Bo 
37609ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
37709ed2f16SLiu Bo 		__field(	u64,	root_obj	)
37809ed2f16SLiu Bo 		__field(	u64,	ino		)
37909ed2f16SLiu Bo 		__field(	loff_t,	isize		)
38009ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
38109ed2f16SLiu Bo 		__field(	u64,	num_bytes	)
38209ed2f16SLiu Bo 		__field(	u64,	ram_bytes	)
38309ed2f16SLiu Bo 		__field(	u64,	disk_bytenr	)
38409ed2f16SLiu Bo 		__field(	u64,	disk_num_bytes	)
38509ed2f16SLiu Bo 		__field(	u64,	extent_offset	)
38609ed2f16SLiu Bo 		__field(	u8,	extent_type	)
38709ed2f16SLiu Bo 		__field(	u8,	compression	)
38809ed2f16SLiu Bo 		__field(	u64,	extent_start	)
38909ed2f16SLiu Bo 		__field(	u64,	extent_end	)
39009ed2f16SLiu Bo 	),
39109ed2f16SLiu Bo 
39209ed2f16SLiu Bo 	TP_fast_assign_btrfs(bi->root->fs_info,
3934fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
39409ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
39509ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
39609ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
39709ed2f16SLiu Bo 		__entry->num_bytes	= btrfs_file_extent_num_bytes(l, fi);
39809ed2f16SLiu Bo 		__entry->ram_bytes	= btrfs_file_extent_ram_bytes(l, fi);
39909ed2f16SLiu Bo 		__entry->disk_bytenr	= btrfs_file_extent_disk_bytenr(l, fi);
40009ed2f16SLiu Bo 		__entry->disk_num_bytes	= btrfs_file_extent_disk_num_bytes(l, fi);
40109ed2f16SLiu Bo 		__entry->extent_offset	= btrfs_file_extent_offset(l, fi);
40209ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
40309ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
40409ed2f16SLiu Bo 		__entry->extent_start	= start;
40509ed2f16SLiu Bo 		__entry->extent_end	= (start + __entry->num_bytes);
40609ed2f16SLiu Bo 	),
40709ed2f16SLiu Bo 
40809ed2f16SLiu Bo 	TP_printk_btrfs(
40909ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
41009ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
41109ed2f16SLiu Bo 		"(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
41209ed2f16SLiu Bo 		"disk_num_bytes=%llu extent_offset=%llu type=%s "
41309ed2f16SLiu Bo 		"compression=%u",
41409ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino,
41509ed2f16SLiu Bo 		__entry->isize,
41609ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
41709ed2f16SLiu Bo 		__entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
41809ed2f16SLiu Bo 		__entry->disk_bytenr, __entry->disk_num_bytes,
4190840dd28SNikolay Borisov 		__entry->extent_offset, __print_symbolic(__entry->extent_type, FI_TYPES),
42009ed2f16SLiu Bo 		__entry->compression)
42109ed2f16SLiu Bo );
42209ed2f16SLiu Bo 
42309ed2f16SLiu Bo DECLARE_EVENT_CLASS(
42409ed2f16SLiu Bo 	btrfs__file_extent_item_inline,
42509ed2f16SLiu Bo 
4261d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4271d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
42809ed2f16SLiu Bo 
42909ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot,  start),
43009ed2f16SLiu Bo 
43109ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
43209ed2f16SLiu Bo 		__field(	u64,	root_obj	)
43309ed2f16SLiu Bo 		__field(	u64,	ino		)
43409ed2f16SLiu Bo 		__field(	loff_t,	isize		)
43509ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
43609ed2f16SLiu Bo 		__field(	u8,	extent_type	)
43709ed2f16SLiu Bo 		__field(	u8,	compression	)
43809ed2f16SLiu Bo 		__field(	u64,	extent_start	)
43909ed2f16SLiu Bo 		__field(	u64,	extent_end	)
44009ed2f16SLiu Bo 	),
44109ed2f16SLiu Bo 
44209ed2f16SLiu Bo 	TP_fast_assign_btrfs(
44309ed2f16SLiu Bo 		bi->root->fs_info,
4444fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
44509ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
44609ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
44709ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
44809ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
44909ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
45009ed2f16SLiu Bo 		__entry->extent_start	= start;
451e41ca589SQu Wenruo 		__entry->extent_end	= (start + btrfs_file_extent_ram_bytes(l, fi));
45209ed2f16SLiu Bo 	),
45309ed2f16SLiu Bo 
45409ed2f16SLiu Bo 	TP_printk_btrfs(
45509ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
45609ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
45709ed2f16SLiu Bo 		"extent_type=%s compression=%u",
45809ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
45909ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
4600840dd28SNikolay Borisov 		__entry->extent_end, __print_symbolic(__entry->extent_type, FI_TYPES),
46109ed2f16SLiu Bo 		__entry->compression)
46209ed2f16SLiu Bo );
46309ed2f16SLiu Bo 
46409ed2f16SLiu Bo DEFINE_EVENT(
46509ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
46609ed2f16SLiu Bo 
4671d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4681d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
46909ed2f16SLiu Bo 
47009ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
47109ed2f16SLiu Bo );
47209ed2f16SLiu Bo 
47309ed2f16SLiu Bo DEFINE_EVENT(
47409ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
47509ed2f16SLiu Bo 
4761d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4771d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
47809ed2f16SLiu Bo 
47909ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
48009ed2f16SLiu Bo );
48109ed2f16SLiu Bo 
48209ed2f16SLiu Bo DEFINE_EVENT(
48309ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
48409ed2f16SLiu Bo 
4851d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4861d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
48709ed2f16SLiu Bo 
48809ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
48909ed2f16SLiu Bo );
49009ed2f16SLiu Bo 
49109ed2f16SLiu Bo DEFINE_EVENT(
49209ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
49309ed2f16SLiu Bo 
4941d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4951d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
49609ed2f16SLiu Bo 
49709ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
49809ed2f16SLiu Bo );
49909ed2f16SLiu Bo 
5001abe9b8aSliubo #define show_ordered_flags(flags)					   \
5019d04a8ceSLiu Bo 	__print_flags(flags, "|",					   \
5023c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_REGULAR), 	"REGULAR" 	}, \
5033c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_NOCOW), 		"NOCOW" 	}, \
5043c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_PREALLOC), 	"PREALLOC" 	}, \
5053c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_COMPRESSED), 	"COMPRESSED" 	}, \
5063c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_DIRECT),	 	"DIRECT" 	}, \
5079d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IO_DONE), 	"IO_DONE" 	}, \
5089d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_COMPLETE), 	"COMPLETE" 	}, \
5099d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IOERR), 		"IOERR" 	}, \
510792ddef0SLiu Bo 		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
511e112e2b4SLiu Bo 
5121abe9b8aSliubo 
5131abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent,
5141abe9b8aSliubo 
515acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5169a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5171abe9b8aSliubo 
5181abe9b8aSliubo 	TP_ARGS(inode, ordered),
5191abe9b8aSliubo 
520bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
521f8f8e189SDavid Sterba 		__field(	u64,  ino		)
5221abe9b8aSliubo 		__field(	u64,  file_offset	)
5231abe9b8aSliubo 		__field(	u64,  start		)
5241abe9b8aSliubo 		__field(	u64,  len		)
5251abe9b8aSliubo 		__field(	u64,  disk_len		)
5261abe9b8aSliubo 		__field(	u64,  bytes_left	)
5271abe9b8aSliubo 		__field(	unsigned long,  flags	)
5281abe9b8aSliubo 		__field(	int,  compress_type	)
5291abe9b8aSliubo 		__field(	int,  refs		)
5301abe9b8aSliubo 		__field(	u64,  root_objectid	)
53178566548SLiu Bo 		__field(	u64,  truncated_len	)
5321abe9b8aSliubo 	),
5331abe9b8aSliubo 
534acbf1dd0SNikolay Borisov 	TP_fast_assign_btrfs(inode->root->fs_info,
535acbf1dd0SNikolay Borisov 		__entry->ino 		= btrfs_ino(inode);
5361abe9b8aSliubo 		__entry->file_offset	= ordered->file_offset;
537bffe633eSOmar Sandoval 		__entry->start		= ordered->disk_bytenr;
538bffe633eSOmar Sandoval 		__entry->len		= ordered->num_bytes;
539bffe633eSOmar Sandoval 		__entry->disk_len	= ordered->disk_num_bytes;
5401abe9b8aSliubo 		__entry->bytes_left	= ordered->bytes_left;
5411abe9b8aSliubo 		__entry->flags		= ordered->flags;
5421abe9b8aSliubo 		__entry->compress_type	= ordered->compress_type;
543e76edab7SElena Reshetova 		__entry->refs		= refcount_read(&ordered->refs);
544acbf1dd0SNikolay Borisov 		__entry->root_objectid	= inode->root->root_key.objectid;
54578566548SLiu Bo 		__entry->truncated_len	= ordered->truncated_len;
5461abe9b8aSliubo 	),
5471abe9b8aSliubo 
548562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
549562a7a07SDavid Sterba 		  "start=%llu len=%llu disk_len=%llu "
550562a7a07SDavid Sterba 		  "truncated_len=%llu "
551562a7a07SDavid Sterba 		  "bytes_left=%llu flags=%s compress_type=%d "
5521abe9b8aSliubo 		  "refs=%d",
5531abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
5548eec8463SDavid Sterba 		  __entry->ino,
5558eec8463SDavid Sterba 		  __entry->file_offset,
5568eec8463SDavid Sterba 		  __entry->start,
5578eec8463SDavid Sterba 		  __entry->len,
5588eec8463SDavid Sterba 		  __entry->disk_len,
5598eec8463SDavid Sterba 		  __entry->truncated_len,
5608eec8463SDavid Sterba 		  __entry->bytes_left,
5611abe9b8aSliubo 		  show_ordered_flags(__entry->flags),
5621abe9b8aSliubo 		  __entry->compress_type, __entry->refs)
5631abe9b8aSliubo );
5641abe9b8aSliubo 
5651abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
5661abe9b8aSliubo 
567acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5689a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5691abe9b8aSliubo 
5701abe9b8aSliubo 	TP_ARGS(inode, ordered)
5711abe9b8aSliubo );
5721abe9b8aSliubo 
5731abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
5741abe9b8aSliubo 
575acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5769a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5771abe9b8aSliubo 
5781abe9b8aSliubo 	TP_ARGS(inode, ordered)
5791abe9b8aSliubo );
5801abe9b8aSliubo 
5811abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
5821abe9b8aSliubo 
583acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5849a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5851abe9b8aSliubo 
5861abe9b8aSliubo 	TP_ARGS(inode, ordered)
5871abe9b8aSliubo );
5881abe9b8aSliubo 
5891abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
5901abe9b8aSliubo 
591acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5929a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5931abe9b8aSliubo 
5941abe9b8aSliubo 	TP_ARGS(inode, ordered)
5951abe9b8aSliubo );
5961abe9b8aSliubo 
5971abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage,
5981abe9b8aSliubo 
5999a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
6009a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
6011abe9b8aSliubo 
6021abe9b8aSliubo 	TP_ARGS(page, inode, wbc),
6031abe9b8aSliubo 
604bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
605f8f8e189SDavid Sterba 		__field(	u64,	ino			)
6061abe9b8aSliubo 		__field(	pgoff_t,  index			)
6071abe9b8aSliubo 		__field(	long,   nr_to_write		)
6081abe9b8aSliubo 		__field(	long,   pages_skipped		)
6091abe9b8aSliubo 		__field(	loff_t, range_start		)
6101abe9b8aSliubo 		__field(	loff_t, range_end		)
6111abe9b8aSliubo 		__field(	char,   for_kupdate		)
6121abe9b8aSliubo 		__field(	char,   for_reclaim		)
6131abe9b8aSliubo 		__field(	char,   range_cyclic		)
61494c3f6c6SDavid Sterba 		__field(	unsigned long,  writeback_index	)
6151abe9b8aSliubo 		__field(	u64,    root_objectid		)
6161abe9b8aSliubo 	),
6171abe9b8aSliubo 
618bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
619f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
6201abe9b8aSliubo 		__entry->index		= page->index;
6211abe9b8aSliubo 		__entry->nr_to_write	= wbc->nr_to_write;
6221abe9b8aSliubo 		__entry->pages_skipped	= wbc->pages_skipped;
6231abe9b8aSliubo 		__entry->range_start	= wbc->range_start;
6241abe9b8aSliubo 		__entry->range_end	= wbc->range_end;
6251abe9b8aSliubo 		__entry->for_kupdate	= wbc->for_kupdate;
6261abe9b8aSliubo 		__entry->for_reclaim	= wbc->for_reclaim;
6271abe9b8aSliubo 		__entry->range_cyclic	= wbc->range_cyclic;
6281abe9b8aSliubo 		__entry->writeback_index = inode->i_mapping->writeback_index;
6291abe9b8aSliubo 		__entry->root_objectid	=
6301abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
6311abe9b8aSliubo 	),
6321abe9b8aSliubo 
633f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
634562a7a07SDavid Sterba 		  "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
635562a7a07SDavid Sterba 		  "range_end=%llu for_kupdate=%d "
636562a7a07SDavid Sterba 		  "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
6371abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
6388eec8463SDavid Sterba 		  __entry->ino, __entry->index,
6391abe9b8aSliubo 		  __entry->nr_to_write, __entry->pages_skipped,
6401abe9b8aSliubo 		  __entry->range_start, __entry->range_end,
641846d5a09SWu Fengguang 		  __entry->for_kupdate,
6421abe9b8aSliubo 		  __entry->for_reclaim, __entry->range_cyclic,
64394c3f6c6SDavid Sterba 		  __entry->writeback_index)
6441abe9b8aSliubo );
6451abe9b8aSliubo 
6461abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage,
6471abe9b8aSliubo 
6489a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
6499a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
6501abe9b8aSliubo 
6511abe9b8aSliubo 	TP_ARGS(page, inode, wbc)
6521abe9b8aSliubo );
6531abe9b8aSliubo 
6541abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook,
6551abe9b8aSliubo 
65638a39ac7SQu Wenruo 	TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 end,
65738a39ac7SQu Wenruo 		 int uptodate),
6581abe9b8aSliubo 
65938a39ac7SQu Wenruo 	TP_ARGS(inode, start, end, uptodate),
6601abe9b8aSliubo 
661bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
662f8f8e189SDavid Sterba 		__field(	u64,	 ino		)
6631abe9b8aSliubo 		__field(	u64,	 start		)
6641abe9b8aSliubo 		__field(	u64,	 end		)
6651abe9b8aSliubo 		__field(	int,	 uptodate	)
6661abe9b8aSliubo 		__field(	u64,    root_objectid	)
6671abe9b8aSliubo 	),
6681abe9b8aSliubo 
66938a39ac7SQu Wenruo 	TP_fast_assign_btrfs(inode->root->fs_info,
67038a39ac7SQu Wenruo 		__entry->ino	= btrfs_ino(inode);
6711abe9b8aSliubo 		__entry->start	= start;
6721abe9b8aSliubo 		__entry->end	= end;
6731abe9b8aSliubo 		__entry->uptodate = uptodate;
67438a39ac7SQu Wenruo 		__entry->root_objectid = inode->root->root_key.objectid;
6751abe9b8aSliubo 	),
6761abe9b8aSliubo 
67738a39ac7SQu Wenruo 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu end=%llu uptodate=%d",
6781abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
67938a39ac7SQu Wenruo 		  __entry->ino, __entry->start,
6808eec8463SDavid Sterba 		  __entry->end, __entry->uptodate)
6811abe9b8aSliubo );
6821abe9b8aSliubo 
6831abe9b8aSliubo TRACE_EVENT(btrfs_sync_file,
6841abe9b8aSliubo 
6859a35b637SJeff Mahoney 	TP_PROTO(const struct file *file, int datasync),
6861abe9b8aSliubo 
6871abe9b8aSliubo 	TP_ARGS(file, datasync),
6881abe9b8aSliubo 
689bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
690f8f8e189SDavid Sterba 		__field(	u64,	ino		)
691f8f8e189SDavid Sterba 		__field(	u64,	parent		)
6921abe9b8aSliubo 		__field(	int,    datasync	)
6931abe9b8aSliubo 		__field(	u64,    root_objectid	)
6941abe9b8aSliubo 	),
6951abe9b8aSliubo 
6961abe9b8aSliubo 	TP_fast_assign(
6979a35b637SJeff Mahoney 		const struct dentry *dentry = file->f_path.dentry;
6989a35b637SJeff Mahoney 		const struct inode *inode = d_inode(dentry);
6991abe9b8aSliubo 
700bc074524SJeff Mahoney 		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
701f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
702f8f8e189SDavid Sterba 		__entry->parent		= btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
7031abe9b8aSliubo 		__entry->datasync	= datasync;
7041abe9b8aSliubo 		__entry->root_objectid	=
7051abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
7061abe9b8aSliubo 	),
7071abe9b8aSliubo 
708f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
7091abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
7108eec8463SDavid Sterba 		  __entry->ino,
7118eec8463SDavid Sterba 		  __entry->parent,
7121abe9b8aSliubo 		  __entry->datasync)
7131abe9b8aSliubo );
7141abe9b8aSliubo 
7151abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs,
7161abe9b8aSliubo 
7179a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
7181abe9b8aSliubo 
719bc074524SJeff Mahoney 	TP_ARGS(fs_info, wait),
7201abe9b8aSliubo 
721bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
7221abe9b8aSliubo 		__field(	int,  wait		)
7231abe9b8aSliubo 	),
7241abe9b8aSliubo 
725bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
7261abe9b8aSliubo 		__entry->wait	= wait;
7271abe9b8aSliubo 	),
7281abe9b8aSliubo 
729bc074524SJeff Mahoney 	TP_printk_btrfs("wait=%d", __entry->wait)
7301abe9b8aSliubo );
7311abe9b8aSliubo 
732c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group,
733c83f8effSJosef Bacik 
7349a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
73532da5386SDavid Sterba 		 const struct btrfs_block_group *block_group, int create),
736c83f8effSJosef Bacik 
737c83f8effSJosef Bacik 	TP_ARGS(fs_info, block_group, create),
738c83f8effSJosef Bacik 
7392e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
740c83f8effSJosef Bacik 		__field(	u64,	offset			)
741c83f8effSJosef Bacik 		__field(	u64,	size			)
742c83f8effSJosef Bacik 		__field(	u64,	flags			)
743c83f8effSJosef Bacik 		__field(	u64,	bytes_used		)
744c83f8effSJosef Bacik 		__field(	u64,	bytes_super		)
745c83f8effSJosef Bacik 		__field(	int,	create			)
746c83f8effSJosef Bacik 	),
747c83f8effSJosef Bacik 
7482e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
749b3470b5dSDavid Sterba 		__entry->offset		= block_group->start;
750b3470b5dSDavid Sterba 		__entry->size		= block_group->length;
751c83f8effSJosef Bacik 		__entry->flags		= block_group->flags;
752bf38be65SDavid Sterba 		__entry->bytes_used	= block_group->used;
753c83f8effSJosef Bacik 		__entry->bytes_super	= block_group->bytes_super;
754c83f8effSJosef Bacik 		__entry->create		= create;
755c83f8effSJosef Bacik 	),
756c83f8effSJosef Bacik 
7572e63e62dSDavid Sterba 	TP_printk_btrfs("block_group offset=%llu size=%llu "
758562a7a07SDavid Sterba 		  "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
7592e63e62dSDavid Sterba 		  "create=%d",
7608eec8463SDavid Sterba 		  __entry->offset,
7618eec8463SDavid Sterba 		  __entry->size,
7628eec8463SDavid Sterba 		  __entry->flags,
763c83f8effSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
764c83f8effSJosef Bacik 				BTRFS_GROUP_FLAGS),
7658eec8463SDavid Sterba 		  __entry->bytes_used,
7668eec8463SDavid Sterba 		  __entry->bytes_super, __entry->create)
767c83f8effSJosef Bacik );
768c83f8effSJosef Bacik 
7691abe9b8aSliubo #define show_ref_action(action)						\
7701abe9b8aSliubo 	__print_symbolic(action,					\
7711abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
7721abe9b8aSliubo 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
7731abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
7741abe9b8aSliubo 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
7751abe9b8aSliubo 
7761abe9b8aSliubo 
777599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
7781abe9b8aSliubo 
7799a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
7809a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
7819a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
7821abe9b8aSliubo 		 int action),
7831abe9b8aSliubo 
784bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
7851abe9b8aSliubo 
786bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
7871abe9b8aSliubo 		__field(	u64,  bytenr		)
7881abe9b8aSliubo 		__field(	u64,  num_bytes		)
7891abe9b8aSliubo 		__field(	int,  action		)
7901abe9b8aSliubo 		__field(	u64,  parent		)
7911abe9b8aSliubo 		__field(	u64,  ref_root		)
7921abe9b8aSliubo 		__field(	int,  level		)
7931abe9b8aSliubo 		__field(	int,  type		)
794dea7d76eSLiu Bo 		__field(	u64,  seq		)
7951abe9b8aSliubo 	),
7961abe9b8aSliubo 
797bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
7981abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
7991abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
8001abe9b8aSliubo 		__entry->action		= action;
8011abe9b8aSliubo 		__entry->parent		= full_ref->parent;
8021abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
8031abe9b8aSliubo 		__entry->level		= full_ref->level;
8041abe9b8aSliubo 		__entry->type		= ref->type;
805dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
8061abe9b8aSliubo 	),
8071abe9b8aSliubo 
808562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
809562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) level=%d "
810562a7a07SDavid Sterba 		  "type=%s seq=%llu",
8118eec8463SDavid Sterba 		  __entry->bytenr,
8128eec8463SDavid Sterba 		  __entry->num_bytes,
8131abe9b8aSliubo 		  show_ref_action(__entry->action),
8141abe9b8aSliubo 		  show_root_type(__entry->parent),
8151abe9b8aSliubo 		  show_root_type(__entry->ref_root),
816dea7d76eSLiu Bo 		  __entry->level, show_ref_type(__entry->type),
8178eec8463SDavid Sterba 		  __entry->seq)
8181abe9b8aSliubo );
8191abe9b8aSliubo 
820599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
821599c75ecSLiu Bo 
8229a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8239a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8249a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
825599c75ecSLiu Bo 		 int action),
826599c75ecSLiu Bo 
827bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
828599c75ecSLiu Bo );
829599c75ecSLiu Bo 
830599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
831599c75ecSLiu Bo 
8329a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8339a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8349a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
835599c75ecSLiu Bo 		 int action),
836599c75ecSLiu Bo 
837bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
838599c75ecSLiu Bo );
839599c75ecSLiu Bo 
840599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
8411abe9b8aSliubo 
8429a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8439a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8449a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
8451abe9b8aSliubo 		 int action),
8461abe9b8aSliubo 
847bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
8481abe9b8aSliubo 
849bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
8501abe9b8aSliubo 		__field(	u64,  bytenr		)
8511abe9b8aSliubo 		__field(	u64,  num_bytes		)
8521abe9b8aSliubo 		__field(	int,  action		)
8531abe9b8aSliubo 		__field(	u64,  parent		)
8541abe9b8aSliubo 		__field(	u64,  ref_root		)
8551abe9b8aSliubo 		__field(	u64,  owner		)
8561abe9b8aSliubo 		__field(	u64,  offset		)
8571abe9b8aSliubo 		__field(	int,  type		)
858dea7d76eSLiu Bo 		__field(	u64,  seq		)
8591abe9b8aSliubo 	),
8601abe9b8aSliubo 
861bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
8621abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
8631abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
8641abe9b8aSliubo 		__entry->action		= action;
8651abe9b8aSliubo 		__entry->parent		= full_ref->parent;
8661abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
8671abe9b8aSliubo 		__entry->owner		= full_ref->objectid;
8681abe9b8aSliubo 		__entry->offset		= full_ref->offset;
8691abe9b8aSliubo 		__entry->type		= ref->type;
870dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
8711abe9b8aSliubo 	),
8721abe9b8aSliubo 
873562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
874562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
875562a7a07SDavid Sterba 		  "offset=%llu type=%s seq=%llu",
8768eec8463SDavid Sterba 		  __entry->bytenr,
8778eec8463SDavid Sterba 		  __entry->num_bytes,
8781abe9b8aSliubo 		  show_ref_action(__entry->action),
8791abe9b8aSliubo 		  show_root_type(__entry->parent),
8801abe9b8aSliubo 		  show_root_type(__entry->ref_root),
8818eec8463SDavid Sterba 		  __entry->owner,
8828eec8463SDavid Sterba 		  __entry->offset,
883dea7d76eSLiu Bo 		  show_ref_type(__entry->type),
8848eec8463SDavid Sterba 		  __entry->seq)
8851abe9b8aSliubo );
8861abe9b8aSliubo 
887599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
888599c75ecSLiu Bo 
8899a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8909a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8919a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
892599c75ecSLiu Bo 		 int action),
893599c75ecSLiu Bo 
894bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
895599c75ecSLiu Bo );
896599c75ecSLiu Bo 
897599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
898599c75ecSLiu Bo 
8999a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9009a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9019a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
902599c75ecSLiu Bo 		 int action),
903599c75ecSLiu Bo 
904bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
905599c75ecSLiu Bo );
906599c75ecSLiu Bo 
907599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
9081abe9b8aSliubo 
9099a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9109a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
9111abe9b8aSliubo 		 int action),
9121abe9b8aSliubo 
913d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action),
9141abe9b8aSliubo 
915bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9161abe9b8aSliubo 		__field(	u64,  bytenr		)
9171abe9b8aSliubo 		__field(	u64,  num_bytes		)
9181abe9b8aSliubo 		__field(	int,  action		)
9191abe9b8aSliubo 		__field(	int,  is_data		)
9201abe9b8aSliubo 	),
9211abe9b8aSliubo 
922bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
923d278850eSJosef Bacik 		__entry->bytenr		= head_ref->bytenr;
924d278850eSJosef Bacik 		__entry->num_bytes	= head_ref->num_bytes;
9251abe9b8aSliubo 		__entry->action		= action;
9261abe9b8aSliubo 		__entry->is_data	= head_ref->is_data;
9271abe9b8aSliubo 	),
9281abe9b8aSliubo 
929562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
9308eec8463SDavid Sterba 		  __entry->bytenr,
9318eec8463SDavid Sterba 		  __entry->num_bytes,
9321abe9b8aSliubo 		  show_ref_action(__entry->action),
9331abe9b8aSliubo 		  __entry->is_data)
9341abe9b8aSliubo );
9351abe9b8aSliubo 
936599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
937599c75ecSLiu Bo 
9389a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9399a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
940599c75ecSLiu Bo 		 int action),
941599c75ecSLiu Bo 
942d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
943599c75ecSLiu Bo );
944599c75ecSLiu Bo 
945599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
946599c75ecSLiu Bo 
9479a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9489a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
949599c75ecSLiu Bo 		 int action),
950599c75ecSLiu Bo 
951d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
952599c75ecSLiu Bo );
953599c75ecSLiu Bo 
9541abe9b8aSliubo #define show_chunk_type(type)					\
9551abe9b8aSliubo 	__print_flags(type, "|",				\
9561abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
9571abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
9581abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
9591abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
9601abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
9611abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
962e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
963e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
964e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
9651abe9b8aSliubo 
9661abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk,
9671abe9b8aSliubo 
9689a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9699a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
9701abe9b8aSliubo 
9716bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size),
9721abe9b8aSliubo 
973bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9741abe9b8aSliubo 		__field(	int,  num_stripes		)
9751abe9b8aSliubo 		__field(	u64,  type			)
9761abe9b8aSliubo 		__field(	int,  sub_stripes		)
9771abe9b8aSliubo 		__field(	u64,  offset			)
9781abe9b8aSliubo 		__field(	u64,  size			)
9791abe9b8aSliubo 		__field(	u64,  root_objectid		)
9801abe9b8aSliubo 	),
9811abe9b8aSliubo 
9826bccf3abSJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
9831abe9b8aSliubo 		__entry->num_stripes	= map->num_stripes;
9841abe9b8aSliubo 		__entry->type		= map->type;
9851abe9b8aSliubo 		__entry->sub_stripes	= map->sub_stripes;
9861abe9b8aSliubo 		__entry->offset		= offset;
9871abe9b8aSliubo 		__entry->size		= size;
9886bccf3abSJeff Mahoney 		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
9891abe9b8aSliubo 	),
9901abe9b8aSliubo 
991562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
992562a7a07SDavid Sterba 		  "num_stripes=%d sub_stripes=%d type=%s",
9931abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
9948eec8463SDavid Sterba 		  __entry->offset,
9958eec8463SDavid Sterba 		  __entry->size,
9961abe9b8aSliubo 		  __entry->num_stripes, __entry->sub_stripes,
9971abe9b8aSliubo 		  show_chunk_type(__entry->type))
9981abe9b8aSliubo );
9991abe9b8aSliubo 
10001abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
10011abe9b8aSliubo 
10029a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10039a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10041abe9b8aSliubo 
10056bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
10061abe9b8aSliubo );
10071abe9b8aSliubo 
10081abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
10091abe9b8aSliubo 
10109a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10119a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10121abe9b8aSliubo 
10136bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
10141abe9b8aSliubo );
10151abe9b8aSliubo 
10161abe9b8aSliubo TRACE_EVENT(btrfs_cow_block,
10171abe9b8aSliubo 
10189a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
10199a35b637SJeff Mahoney 		 const struct extent_buffer *cow),
10201abe9b8aSliubo 
10211abe9b8aSliubo 	TP_ARGS(root, buf, cow),
10221abe9b8aSliubo 
1023bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10241abe9b8aSliubo 		__field(	u64,  root_objectid		)
10251abe9b8aSliubo 		__field(	u64,  buf_start			)
10261abe9b8aSliubo 		__field(	int,  refs			)
10271abe9b8aSliubo 		__field(	u64,  cow_start			)
10281abe9b8aSliubo 		__field(	int,  buf_level			)
10291abe9b8aSliubo 		__field(	int,  cow_level			)
10301abe9b8aSliubo 	),
10311abe9b8aSliubo 
1032bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
10331abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
10341abe9b8aSliubo 		__entry->buf_start	= buf->start;
10351abe9b8aSliubo 		__entry->refs		= atomic_read(&buf->refs);
10361abe9b8aSliubo 		__entry->cow_start	= cow->start;
10371abe9b8aSliubo 		__entry->buf_level	= btrfs_header_level(buf);
10381abe9b8aSliubo 		__entry->cow_level	= btrfs_header_level(cow);
10391abe9b8aSliubo 	),
10401abe9b8aSliubo 
1041562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
1042562a7a07SDavid Sterba 		  "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
10431abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
10441abe9b8aSliubo 		  __entry->refs,
10458eec8463SDavid Sterba 		  __entry->buf_start,
10461abe9b8aSliubo 		  __entry->buf_level,
10478eec8463SDavid Sterba 		  __entry->cow_start,
10481abe9b8aSliubo 		  __entry->cow_level)
10491abe9b8aSliubo );
10501abe9b8aSliubo 
10518c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation,
10528c2a3ca2SJosef Bacik 
10531d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val,
10548c2a3ca2SJosef Bacik 		 u64 bytes, int reserve),
10558c2a3ca2SJosef Bacik 
10568c2a3ca2SJosef Bacik 	TP_ARGS(fs_info, type, val, bytes, reserve),
10578c2a3ca2SJosef Bacik 
1058bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10598c2a3ca2SJosef Bacik 		__string(	type,	type			)
10608c2a3ca2SJosef Bacik 		__field(	u64,	val			)
10618c2a3ca2SJosef Bacik 		__field(	u64,	bytes			)
10628c2a3ca2SJosef Bacik 		__field(	int,	reserve			)
10638c2a3ca2SJosef Bacik 	),
10648c2a3ca2SJosef Bacik 
1065bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
10668c2a3ca2SJosef Bacik 		__assign_str(type, type);
10678c2a3ca2SJosef Bacik 		__entry->val		= val;
10688c2a3ca2SJosef Bacik 		__entry->bytes		= bytes;
10698c2a3ca2SJosef Bacik 		__entry->reserve	= reserve;
10708c2a3ca2SJosef Bacik 	),
10718c2a3ca2SJosef Bacik 
10725439c7f5SDavid Sterba 	TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
1073bc074524SJeff Mahoney 			__entry->reserve ? "reserve" : "release",
10748c2a3ca2SJosef Bacik 			__entry->bytes)
10758c2a3ca2SJosef Bacik );
10768c2a3ca2SJosef Bacik 
1077f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush,
1078f376df2bSJosef Bacik 
10799a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
10801d2e7c7cSDavid Sterba 		 int flush, const char *reason),
1081f376df2bSJosef Bacik 
1082f376df2bSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, flush, reason),
1083f376df2bSJosef Bacik 
10842e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1085f376df2bSJosef Bacik 		__field(	u64,	flags			)
1086f376df2bSJosef Bacik 		__field(	u64,	bytes			)
1087f376df2bSJosef Bacik 		__field(	int,	flush			)
1088f376df2bSJosef Bacik 		__string(	reason,	reason			)
1089f376df2bSJosef Bacik 	),
1090f376df2bSJosef Bacik 
10912e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1092f376df2bSJosef Bacik 		__entry->flags	= flags;
1093f376df2bSJosef Bacik 		__entry->bytes	= bytes;
1094f376df2bSJosef Bacik 		__entry->flush	= flush;
109578c14b38SJoe Perches 		__assign_str(reason, reason);
1096f376df2bSJosef Bacik 	),
1097f376df2bSJosef Bacik 
10982e63e62dSDavid Sterba 	TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
10992e63e62dSDavid Sterba 		  __get_str(reason), __entry->flush,
110045e31869SNikolay Borisov 		  __print_symbolic(__entry->flush, FLUSH_ACTIONS),
11018eec8463SDavid Sterba 		  __entry->flags,
1102f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1103f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
11048eec8463SDavid Sterba 		  __entry->bytes)
1105f376df2bSJosef Bacik );
1106f376df2bSJosef Bacik 
1107f376df2bSJosef Bacik 
1108f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space,
1109f376df2bSJosef Bacik 
11109a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
11114b02b00fSJosef Bacik 		 int state, int ret, bool for_preempt),
1112f376df2bSJosef Bacik 
11134b02b00fSJosef Bacik 	TP_ARGS(fs_info, flags, num_bytes, state, ret, for_preempt),
1114f376df2bSJosef Bacik 
11152e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1116f376df2bSJosef Bacik 		__field(	u64,	flags			)
1117f376df2bSJosef Bacik 		__field(	u64,	num_bytes		)
1118f376df2bSJosef Bacik 		__field(	int,	state			)
1119f376df2bSJosef Bacik 		__field(	int,	ret			)
11204b02b00fSJosef Bacik 		__field(       bool,	for_preempt		)
1121f376df2bSJosef Bacik 	),
1122f376df2bSJosef Bacik 
11232e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1124f376df2bSJosef Bacik 		__entry->flags		=	flags;
1125f376df2bSJosef Bacik 		__entry->num_bytes	=	num_bytes;
1126f376df2bSJosef Bacik 		__entry->state		=	state;
1127f376df2bSJosef Bacik 		__entry->ret		=	ret;
11284b02b00fSJosef Bacik 		__entry->for_preempt	=	for_preempt;
1129f376df2bSJosef Bacik 	),
1130f376df2bSJosef Bacik 
11314b02b00fSJosef Bacik 	TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d for_preempt=%d",
11322e63e62dSDavid Sterba 		  __entry->state,
1133f0cdd15cSNikolay Borisov 		  __print_symbolic(__entry->state, FLUSH_STATES),
11348eec8463SDavid Sterba 		  __entry->flags,
1135f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1136f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
11374b02b00fSJosef Bacik 		  __entry->num_bytes, __entry->ret, __entry->for_preempt)
1138f376df2bSJosef Bacik );
1139f376df2bSJosef Bacik 
11401abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent,
11411abe9b8aSliubo 
11429a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
11431abe9b8aSliubo 
114471ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len),
11451abe9b8aSliubo 
1146bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
11471abe9b8aSliubo 		__field(	u64,  start			)
11481abe9b8aSliubo 		__field(	u64,  len			)
11491abe9b8aSliubo 	),
11501abe9b8aSliubo 
115171ff6437SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
11521abe9b8aSliubo 		__entry->start		= start;
11531abe9b8aSliubo 		__entry->len		= len;
11541abe9b8aSliubo 	),
11551abe9b8aSliubo 
1156562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
115771ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
11588eec8463SDavid Sterba 		  __entry->start,
11598eec8463SDavid Sterba 		  __entry->len)
11601abe9b8aSliubo );
11611abe9b8aSliubo 
11621abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
11631abe9b8aSliubo 
11649a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
11651abe9b8aSliubo 
116671ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
11671abe9b8aSliubo );
11681abe9b8aSliubo 
11691abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
11701abe9b8aSliubo 
11719a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
11721abe9b8aSliubo 
117371ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
11741abe9b8aSliubo );
11751abe9b8aSliubo 
11763f7de037SJosef Bacik TRACE_EVENT(find_free_extent,
11773f7de037SJosef Bacik 
1178437490feSQu Wenruo 	TP_PROTO(const struct btrfs_root *root, u64 num_bytes,
11799a35b637SJeff Mahoney 		 u64 empty_size, u64 data),
11803f7de037SJosef Bacik 
1181437490feSQu Wenruo 	TP_ARGS(root, num_bytes, empty_size, data),
11823f7de037SJosef Bacik 
1183bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1184437490feSQu Wenruo 		__field(	u64,	root_objectid		)
11853f7de037SJosef Bacik 		__field(	u64,	num_bytes		)
11863f7de037SJosef Bacik 		__field(	u64,	empty_size		)
11873f7de037SJosef Bacik 		__field(	u64,	data			)
11883f7de037SJosef Bacik 	),
11893f7de037SJosef Bacik 
1190437490feSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
1191437490feSQu Wenruo 		__entry->root_objectid	= root->root_key.objectid;
11923f7de037SJosef Bacik 		__entry->num_bytes	= num_bytes;
11933f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
11943f7de037SJosef Bacik 		__entry->data		= data;
11953f7de037SJosef Bacik 	),
11963f7de037SJosef Bacik 
11975439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
1198437490feSQu Wenruo 		  show_root_type(__entry->root_objectid),
11993f7de037SJosef Bacik 		  __entry->num_bytes, __entry->empty_size, __entry->data,
12003f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->data, "|",
12013f7de037SJosef Bacik 				 BTRFS_GROUP_FLAGS))
12023f7de037SJosef Bacik );
12033f7de037SJosef Bacik 
12043f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent,
12053f7de037SJosef Bacik 
120632da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
12073f7de037SJosef Bacik 		 u64 len),
12083f7de037SJosef Bacik 
12093dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len),
12103f7de037SJosef Bacik 
1211bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12123f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12133f7de037SJosef Bacik 		__field(	u64,	flags			)
12143f7de037SJosef Bacik 		__field(	u64,	start			)
12153f7de037SJosef Bacik 		__field(	u64,	len			)
12163f7de037SJosef Bacik 	),
12173f7de037SJosef Bacik 
12183dca5c94SQu Wenruo 	TP_fast_assign_btrfs(block_group->fs_info,
1219b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
12203f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
12213f7de037SJosef Bacik 		__entry->start		= start;
12223f7de037SJosef Bacik 		__entry->len		= len;
12233f7de037SJosef Bacik 	),
12243f7de037SJosef Bacik 
12255439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
12265439c7f5SDavid Sterba 		  "start=%llu len=%llu",
122771ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
122871ff6437SJeff Mahoney 		  __entry->bg_objectid,
12293f7de037SJosef Bacik 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
12303f7de037SJosef Bacik 						"|", BTRFS_GROUP_FLAGS),
12313f7de037SJosef Bacik 		  __entry->start, __entry->len)
12323f7de037SJosef Bacik );
12333f7de037SJosef Bacik 
12343f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
12353f7de037SJosef Bacik 
123632da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
12373f7de037SJosef Bacik 		 u64 len),
12383f7de037SJosef Bacik 
12393dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len)
12403f7de037SJosef Bacik );
12413f7de037SJosef Bacik 
12423f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
12433f7de037SJosef Bacik 
124432da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
12453f7de037SJosef Bacik 		 u64 len),
12463f7de037SJosef Bacik 
12473dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len)
12483f7de037SJosef Bacik );
12493f7de037SJosef Bacik 
12503f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster,
12513f7de037SJosef Bacik 
125232da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
12533f7de037SJosef Bacik 		 u64 bytes, u64 empty_size, u64 min_bytes),
12543f7de037SJosef Bacik 
12553f7de037SJosef Bacik 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
12563f7de037SJosef Bacik 
1257bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12583f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12593f7de037SJosef Bacik 		__field(	u64,	flags			)
12603f7de037SJosef Bacik 		__field(	u64,	start			)
12613f7de037SJosef Bacik 		__field(	u64,	bytes			)
12623f7de037SJosef Bacik 		__field(	u64,	empty_size		)
12633f7de037SJosef Bacik 		__field(	u64,	min_bytes		)
12643f7de037SJosef Bacik 	),
12653f7de037SJosef Bacik 
1266bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1267b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
12683f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
12693f7de037SJosef Bacik 		__entry->start		= start;
12703f7de037SJosef Bacik 		__entry->bytes		= bytes;
12713f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
12723f7de037SJosef Bacik 		__entry->min_bytes	= min_bytes;
12733f7de037SJosef Bacik 	),
12743f7de037SJosef Bacik 
12755439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
12765439c7f5SDavid Sterba 		  "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
12773f7de037SJosef Bacik 		  __entry->flags,
12783f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
12793f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
12803f7de037SJosef Bacik 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
12813f7de037SJosef Bacik );
12823f7de037SJosef Bacik 
12833f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup,
12843f7de037SJosef Bacik 
128532da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group),
12863f7de037SJosef Bacik 
12873f7de037SJosef Bacik 	TP_ARGS(block_group),
12883f7de037SJosef Bacik 
1289bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12903f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12913f7de037SJosef Bacik 	),
12923f7de037SJosef Bacik 
1293bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1294b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
12953f7de037SJosef Bacik 	),
12963f7de037SJosef Bacik 
12975439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
12983f7de037SJosef Bacik );
12993f7de037SJosef Bacik 
13003f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster,
13013f7de037SJosef Bacik 
130232da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group,
13039a35b637SJeff Mahoney 		 const struct btrfs_free_cluster *cluster,
13049a35b637SJeff Mahoney 		 u64 size, int bitmap),
13053f7de037SJosef Bacik 
13063f7de037SJosef Bacik 	TP_ARGS(block_group, cluster, size, bitmap),
13073f7de037SJosef Bacik 
1308bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13093f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
13103f7de037SJosef Bacik 		__field(	u64,	flags			)
13113f7de037SJosef Bacik 		__field(	u64,	start			)
13123f7de037SJosef Bacik 		__field(	u64,	max_size		)
13133f7de037SJosef Bacik 		__field(	u64,	size			)
13143f7de037SJosef Bacik 		__field(	int,	bitmap			)
13153f7de037SJosef Bacik 	),
13163f7de037SJosef Bacik 
1317bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1318b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
13193f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
13203f7de037SJosef Bacik 		__entry->start		= cluster->window_start;
13213f7de037SJosef Bacik 		__entry->max_size	= cluster->max_size;
13223f7de037SJosef Bacik 		__entry->size		= size;
13233f7de037SJosef Bacik 		__entry->bitmap		= bitmap;
13243f7de037SJosef Bacik 	),
13253f7de037SJosef Bacik 
13265439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
13275439c7f5SDavid Sterba 		  "size=%llu max_size=%llu bitmap=%d",
13283f7de037SJosef Bacik 		  __entry->bg_objectid,
13293f7de037SJosef Bacik 		  __entry->flags,
13303f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
13313f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
13323f7de037SJosef Bacik 		  __entry->size, __entry->max_size, __entry->bitmap)
13333f7de037SJosef Bacik );
13343f7de037SJosef Bacik 
1335143bede5SJeff Mahoney struct extent_state;
1336143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state,
1337143bede5SJeff Mahoney 
13389a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state,
13399a35b637SJeff Mahoney 		 gfp_t mask, unsigned long IP),
1340143bede5SJeff Mahoney 
1341143bede5SJeff Mahoney 	TP_ARGS(state, mask, IP),
1342143bede5SJeff Mahoney 
1343143bede5SJeff Mahoney 	TP_STRUCT__entry(
13449a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
1345143bede5SJeff Mahoney 		__field(gfp_t, mask)
134694c3f6c6SDavid Sterba 		__field(const void*, ip)
1347143bede5SJeff Mahoney 	),
1348143bede5SJeff Mahoney 
1349143bede5SJeff Mahoney 	TP_fast_assign(
1350143bede5SJeff Mahoney 		__entry->state	= state,
1351143bede5SJeff Mahoney 		__entry->mask	= mask,
135294c3f6c6SDavid Sterba 		__entry->ip	= (const void *)IP
1353143bede5SJeff Mahoney 	),
1354143bede5SJeff Mahoney 
1355562a7a07SDavid Sterba 	TP_printk("state=%p mask=%s caller=%pS", __entry->state,
135694c3f6c6SDavid Sterba 		  show_gfp_flags(__entry->mask), __entry->ip)
1357143bede5SJeff Mahoney );
1358143bede5SJeff Mahoney 
1359143bede5SJeff Mahoney TRACE_EVENT(free_extent_state,
1360143bede5SJeff Mahoney 
13619a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state, unsigned long IP),
1362143bede5SJeff Mahoney 
1363143bede5SJeff Mahoney 	TP_ARGS(state, IP),
1364143bede5SJeff Mahoney 
1365143bede5SJeff Mahoney 	TP_STRUCT__entry(
13669a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
136794c3f6c6SDavid Sterba 		__field(const void*, ip)
1368143bede5SJeff Mahoney 	),
1369143bede5SJeff Mahoney 
1370143bede5SJeff Mahoney 	TP_fast_assign(
1371143bede5SJeff Mahoney 		__entry->state	= state,
137294c3f6c6SDavid Sterba 		__entry->ip = (const void *)IP
1373143bede5SJeff Mahoney 	),
1374143bede5SJeff Mahoney 
137594c3f6c6SDavid Sterba 	TP_printk("state=%p caller=%pS", __entry->state, __entry->ip)
1376143bede5SJeff Mahoney );
1377143bede5SJeff Mahoney 
137852483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work,
137952483bc2SQu Wenruo 
13809a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
138152483bc2SQu Wenruo 
138252483bc2SQu Wenruo 	TP_ARGS(work),
138352483bc2SQu Wenruo 
1384bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13859a35b637SJeff Mahoney 		__field(	const void *,	work			)
13869a35b637SJeff Mahoney 		__field(	const void *,	wq			)
13879a35b637SJeff Mahoney 		__field(	const void *,	func			)
13889a35b637SJeff Mahoney 		__field(	const void *,	ordered_func		)
13899a35b637SJeff Mahoney 		__field(	const void *,	ordered_free		)
13909a35b637SJeff Mahoney 		__field(	const void *,	normal_work		)
139152483bc2SQu Wenruo 	),
139252483bc2SQu Wenruo 
1393bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_work_owner(work),
139452483bc2SQu Wenruo 		__entry->work		= work;
139552483bc2SQu Wenruo 		__entry->wq		= work->wq;
139652483bc2SQu Wenruo 		__entry->func		= work->func;
139752483bc2SQu Wenruo 		__entry->ordered_func	= work->ordered_func;
139852483bc2SQu Wenruo 		__entry->ordered_free	= work->ordered_free;
1399b38a6258SLiu Bo 		__entry->normal_work	= &work->normal_work;
140052483bc2SQu Wenruo 	),
140152483bc2SQu Wenruo 
1402d75f773cSSakari Ailus 	TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
1403b38a6258SLiu Bo 		  "ordered_free=%p",
1404b38a6258SLiu Bo 		  __entry->work, __entry->normal_work, __entry->wq,
1405b38a6258SLiu Bo 		   __entry->func, __entry->ordered_func, __entry->ordered_free)
140652483bc2SQu Wenruo );
140752483bc2SQu Wenruo 
1408ac0c7cf8SDavid Sterba /*
1409c9eb55dbSOmar Sandoval  * For situations when the work is freed, we pass fs_info and a tag that matches
1410c9eb55dbSOmar Sandoval  * the address of the work structure so it can be paired with the scheduling
1411c9eb55dbSOmar Sandoval  * event. DO NOT add anything here that dereferences wtag.
1412ac0c7cf8SDavid Sterba  */
141352483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done,
141452483bc2SQu Wenruo 
14159a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
141652483bc2SQu Wenruo 
1417ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag),
141852483bc2SQu Wenruo 
1419bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14209a35b637SJeff Mahoney 		__field(	const void *,	wtag			)
142152483bc2SQu Wenruo 	),
142252483bc2SQu Wenruo 
1423ac0c7cf8SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1424ac0c7cf8SDavid Sterba 		__entry->wtag		= wtag;
142552483bc2SQu Wenruo 	),
142652483bc2SQu Wenruo 
1427ac0c7cf8SDavid Sterba 	TP_printk_btrfs("work->%p", __entry->wtag)
142852483bc2SQu Wenruo );
142952483bc2SQu Wenruo 
143052483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued,
143152483bc2SQu Wenruo 
14329a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
143352483bc2SQu Wenruo 
143452483bc2SQu Wenruo 	TP_ARGS(work)
143552483bc2SQu Wenruo );
143652483bc2SQu Wenruo 
143752483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched,
143852483bc2SQu Wenruo 
14399a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
144052483bc2SQu Wenruo 
144152483bc2SQu Wenruo 	TP_ARGS(work)
144252483bc2SQu Wenruo );
144352483bc2SQu Wenruo 
144452483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
144552483bc2SQu Wenruo 
14469a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
144752483bc2SQu Wenruo 
1448ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag)
144952483bc2SQu Wenruo );
145052483bc2SQu Wenruo 
145152483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
145252483bc2SQu Wenruo 
14539a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
145452483bc2SQu Wenruo 
145552483bc2SQu Wenruo 	TP_ARGS(work)
145652483bc2SQu Wenruo );
145752483bc2SQu Wenruo 
1458c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue,
1459c3a46891SQu Wenruo 
14609a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq,
14619a35b637SJeff Mahoney 		 const char *name, int high),
1462c3a46891SQu Wenruo 
1463c3a46891SQu Wenruo 	TP_ARGS(wq, name, high),
1464c3a46891SQu Wenruo 
1465bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14669a35b637SJeff Mahoney 		__field(	const void *,	wq			)
1467c3a46891SQu Wenruo 		__string(	name,	name			)
1468c3a46891SQu Wenruo 		__field(	int ,	high			)
1469c3a46891SQu Wenruo 	),
1470c3a46891SQu Wenruo 
1471bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1472c3a46891SQu Wenruo 		__entry->wq		= wq;
1473c3a46891SQu Wenruo 		__assign_str(name, name);
1474c3a46891SQu Wenruo 		__entry->high		= high;
1475c3a46891SQu Wenruo 	),
1476c3a46891SQu Wenruo 
1477562a7a07SDavid Sterba 	TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1478c3a46891SQu Wenruo 		  __print_flags(__entry->high, "",
1479c3a46891SQu Wenruo 				{(WQ_HIGHPRI),	"-high"}),
1480c3a46891SQu Wenruo 		  __entry->wq)
1481c3a46891SQu Wenruo );
1482c3a46891SQu Wenruo 
1483c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1484c3a46891SQu Wenruo 
14859a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq,
14869a35b637SJeff Mahoney 		 const char *name, int high),
1487c3a46891SQu Wenruo 
1488c3a46891SQu Wenruo 	TP_ARGS(wq, name, high)
1489c3a46891SQu Wenruo );
1490c3a46891SQu Wenruo 
1491c3a46891SQu Wenruo DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1492c3a46891SQu Wenruo 
14939a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq),
1494c3a46891SQu Wenruo 
1495c3a46891SQu Wenruo 	TP_ARGS(wq),
1496c3a46891SQu Wenruo 
1497bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14989a35b637SJeff Mahoney 		__field(	const void *,	wq		)
1499c3a46891SQu Wenruo 	),
1500c3a46891SQu Wenruo 
1501bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1502c3a46891SQu Wenruo 		__entry->wq		= wq;
1503c3a46891SQu Wenruo 	),
1504c3a46891SQu Wenruo 
1505bc074524SJeff Mahoney 	TP_printk_btrfs("wq=%p", __entry->wq)
1506c3a46891SQu Wenruo );
1507c3a46891SQu Wenruo 
1508c3a46891SQu Wenruo DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1509c3a46891SQu Wenruo 
15109a35b637SJeff Mahoney 	TP_PROTO(const struct __btrfs_workqueue *wq),
1511c3a46891SQu Wenruo 
1512c3a46891SQu Wenruo 	TP_ARGS(wq)
1513c3a46891SQu Wenruo );
151452483bc2SQu Wenruo 
151581fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS				\
151681fb6f77SQu Wenruo 	{ QGROUP_RESERVE,	"reserve"	},	\
151781fb6f77SQu Wenruo 	{ QGROUP_RELEASE,	"release"	},	\
151881fb6f77SQu Wenruo 	{ QGROUP_FREE,		"free"		}
151981fb6f77SQu Wenruo 
152081fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
152181fb6f77SQu Wenruo 
15229a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
15239a35b637SJeff Mahoney 		 u64 reserved, int op),
152481fb6f77SQu Wenruo 
152581fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op),
152681fb6f77SQu Wenruo 
1527bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
152881fb6f77SQu Wenruo 		__field(	u64,		rootid		)
1529f8f8e189SDavid Sterba 		__field(	u64,		ino		)
153081fb6f77SQu Wenruo 		__field(	u64,		start		)
153181fb6f77SQu Wenruo 		__field(	u64,		len		)
153281fb6f77SQu Wenruo 		__field(	u64,		reserved	)
153381fb6f77SQu Wenruo 		__field(	int,		op		)
153481fb6f77SQu Wenruo 	),
153581fb6f77SQu Wenruo 
1536bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
15374fd786e6SMisono Tomohiro 		__entry->rootid		=
15384fd786e6SMisono Tomohiro 			BTRFS_I(inode)->root->root_key.objectid;
1539f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
154081fb6f77SQu Wenruo 		__entry->start		= start;
154181fb6f77SQu Wenruo 		__entry->len		= len;
154281fb6f77SQu Wenruo 		__entry->reserved	= reserved;
154381fb6f77SQu Wenruo 		__entry->op		= op;
154481fb6f77SQu Wenruo 	),
154581fb6f77SQu Wenruo 
1546f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
154781fb6f77SQu Wenruo 		  __entry->rootid, __entry->ino, __entry->start, __entry->len,
154881fb6f77SQu Wenruo 		  __entry->reserved,
154981fb6f77SQu Wenruo 		  __print_flags((unsigned long)__entry->op, "",
155081fb6f77SQu Wenruo 				BTRFS_QGROUP_OPERATIONS)
155181fb6f77SQu Wenruo 	)
155281fb6f77SQu Wenruo );
155381fb6f77SQu Wenruo 
155481fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
155581fb6f77SQu Wenruo 
15569a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
15579a35b637SJeff Mahoney 		 u64 reserved, int op),
155881fb6f77SQu Wenruo 
155981fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
156081fb6f77SQu Wenruo );
156181fb6f77SQu Wenruo 
156281fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
156381fb6f77SQu Wenruo 
15649a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
15659a35b637SJeff Mahoney 		 u64 reserved, int op),
156681fb6f77SQu Wenruo 
156781fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
156881fb6f77SQu Wenruo );
156981fb6f77SQu Wenruo 
15700f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
15719a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
15729a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
15730f5dcf8dSMark Fasheh 
1574bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec),
15750f5dcf8dSMark Fasheh 
1576bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
15770f5dcf8dSMark Fasheh 		__field(	u64,  bytenr		)
15780f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes		)
15790f5dcf8dSMark Fasheh 	),
15800f5dcf8dSMark Fasheh 
1581bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
15820f5dcf8dSMark Fasheh 		__entry->bytenr		= rec->bytenr,
15830f5dcf8dSMark Fasheh 		__entry->num_bytes	= rec->num_bytes;
15840f5dcf8dSMark Fasheh 	),
15850f5dcf8dSMark Fasheh 
1586562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
158794c3f6c6SDavid Sterba 		  __entry->bytenr, __entry->num_bytes)
15880f5dcf8dSMark Fasheh );
15890f5dcf8dSMark Fasheh 
15900f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
15910f5dcf8dSMark Fasheh 
15929a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
15939a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
15940f5dcf8dSMark Fasheh 
1595bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
15960f5dcf8dSMark Fasheh );
15970f5dcf8dSMark Fasheh 
159850b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
15990f5dcf8dSMark Fasheh 
16009a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
16019a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
16020f5dcf8dSMark Fasheh 
1603bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
16040f5dcf8dSMark Fasheh );
16050f5dcf8dSMark Fasheh 
1606c337e7b0SQu Wenruo TRACE_EVENT(qgroup_num_dirty_extents,
1607c337e7b0SQu Wenruo 
1608c337e7b0SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1609c337e7b0SQu Wenruo 		 u64 num_dirty_extents),
1610c337e7b0SQu Wenruo 
1611c337e7b0SQu Wenruo 	TP_ARGS(fs_info, transid, num_dirty_extents),
1612c337e7b0SQu Wenruo 
1613c337e7b0SQu Wenruo 	TP_STRUCT__entry_btrfs(
1614c337e7b0SQu Wenruo 		__field(	u64, transid			)
1615c337e7b0SQu Wenruo 		__field(	u64, num_dirty_extents		)
1616c337e7b0SQu Wenruo 	),
1617c337e7b0SQu Wenruo 
1618c337e7b0SQu Wenruo 	TP_fast_assign_btrfs(fs_info,
1619c337e7b0SQu Wenruo 		__entry->transid	   = transid;
1620c337e7b0SQu Wenruo 		__entry->num_dirty_extents = num_dirty_extents;
1621c337e7b0SQu Wenruo 	),
1622c337e7b0SQu Wenruo 
1623c337e7b0SQu Wenruo 	TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1624c337e7b0SQu Wenruo 		__entry->transid, __entry->num_dirty_extents)
1625c337e7b0SQu Wenruo );
1626c337e7b0SQu Wenruo 
16270f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent,
16280f5dcf8dSMark Fasheh 
1629c9f6f3cdSQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
1630bc074524SJeff Mahoney 		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
16310f5dcf8dSMark Fasheh 
1632c9f6f3cdSQu Wenruo 	TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1633c9f6f3cdSQu Wenruo 		nr_new_roots),
16340f5dcf8dSMark Fasheh 
1635bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1636c9f6f3cdSQu Wenruo 		__field(	u64,  transid			)
16370f5dcf8dSMark Fasheh 		__field(	u64,  bytenr			)
16380f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes			)
16390f5dcf8dSMark Fasheh 		__field(	u64,  nr_old_roots		)
16400f5dcf8dSMark Fasheh 		__field(	u64,  nr_new_roots		)
16410f5dcf8dSMark Fasheh 	),
16420f5dcf8dSMark Fasheh 
1643bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
1644c9f6f3cdSQu Wenruo 		__entry->transid	= transid;
16450f5dcf8dSMark Fasheh 		__entry->bytenr		= bytenr;
16460f5dcf8dSMark Fasheh 		__entry->num_bytes	= num_bytes;
16470f5dcf8dSMark Fasheh 		__entry->nr_old_roots	= nr_old_roots;
16480f5dcf8dSMark Fasheh 		__entry->nr_new_roots	= nr_new_roots;
16490f5dcf8dSMark Fasheh 	),
16500f5dcf8dSMark Fasheh 
1651c9f6f3cdSQu Wenruo 	TP_printk_btrfs(
1652c9f6f3cdSQu Wenruo "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1653c9f6f3cdSQu Wenruo 		__entry->transid,
16540f5dcf8dSMark Fasheh 		__entry->bytenr,
16550f5dcf8dSMark Fasheh 		__entry->num_bytes,
16560f5dcf8dSMark Fasheh 		__entry->nr_old_roots,
16570f5dcf8dSMark Fasheh 		__entry->nr_new_roots)
16580f5dcf8dSMark Fasheh );
16590f5dcf8dSMark Fasheh 
16600f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters,
16610f5dcf8dSMark Fasheh 
16628b317901SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info,
16631d2e7c7cSDavid Sterba 		 const struct btrfs_qgroup *qgroup,
1664bc074524SJeff Mahoney 		 u64 cur_old_count, u64 cur_new_count),
16650f5dcf8dSMark Fasheh 
16668b317901SQu Wenruo 	TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
16670f5dcf8dSMark Fasheh 
1668bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
16690f5dcf8dSMark Fasheh 		__field(	u64,  qgid			)
16708b317901SQu Wenruo 		__field(	u64,  old_rfer			)
16718b317901SQu Wenruo 		__field(	u64,  old_excl			)
16720f5dcf8dSMark Fasheh 		__field(	u64,  cur_old_count		)
16730f5dcf8dSMark Fasheh 		__field(	u64,  cur_new_count		)
16740f5dcf8dSMark Fasheh 	),
16750f5dcf8dSMark Fasheh 
1676bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
16778b317901SQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
16788b317901SQu Wenruo 		__entry->old_rfer	= qgroup->rfer;
16798b317901SQu Wenruo 		__entry->old_excl	= qgroup->excl;
16800f5dcf8dSMark Fasheh 		__entry->cur_old_count	= cur_old_count;
16810f5dcf8dSMark Fasheh 		__entry->cur_new_count	= cur_new_count;
16820f5dcf8dSMark Fasheh 	),
16830f5dcf8dSMark Fasheh 
16848b317901SQu Wenruo 	TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
16858b317901SQu Wenruo 		  __entry->qgid, __entry->old_rfer, __entry->old_excl,
16868b317901SQu Wenruo 		  __entry->cur_old_count, __entry->cur_new_count)
16870f5dcf8dSMark Fasheh );
16880f5dcf8dSMark Fasheh 
16893159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve,
16903159fe7bSQu Wenruo 
16913159fe7bSQu Wenruo 	TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
169264ee4e75SQu Wenruo 		 s64 diff, int type),
16933159fe7bSQu Wenruo 
169464ee4e75SQu Wenruo 	TP_ARGS(fs_info, qgroup, diff, type),
16953159fe7bSQu Wenruo 
16963159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
16973159fe7bSQu Wenruo 		__field(	u64,	qgid			)
16983159fe7bSQu Wenruo 		__field(	u64,	cur_reserved		)
16993159fe7bSQu Wenruo 		__field(	s64,	diff			)
170064ee4e75SQu Wenruo 		__field(	int,	type			)
17013159fe7bSQu Wenruo 	),
17023159fe7bSQu Wenruo 
17033159fe7bSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
17043159fe7bSQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
170564ee4e75SQu Wenruo 		__entry->cur_reserved	= qgroup->rsv.values[type];
17063159fe7bSQu Wenruo 		__entry->diff		= diff;
17071b2442b4SQu Wenruo 		__entry->type		= type;
17083159fe7bSQu Wenruo 	),
17093159fe7bSQu Wenruo 
171064ee4e75SQu Wenruo 	TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
17111cb1f0b2SNikolay Borisov 		__entry->qgid, __print_symbolic(__entry->type, QGROUP_RSV_TYPES),
171264ee4e75SQu Wenruo 		__entry->cur_reserved, __entry->diff)
17133159fe7bSQu Wenruo );
17143159fe7bSQu Wenruo 
17153159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve,
17163159fe7bSQu Wenruo 
17174ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff, int type),
17183159fe7bSQu Wenruo 
17194ee0d883SQu Wenruo 	TP_ARGS(root, diff, type),
17203159fe7bSQu Wenruo 
17213159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
17223159fe7bSQu Wenruo 		__field(	u64,	refroot			)
17233159fe7bSQu Wenruo 		__field(	s64,	diff			)
17244ee0d883SQu Wenruo 		__field(	int,	type			)
17253159fe7bSQu Wenruo 	),
17263159fe7bSQu Wenruo 
17273159fe7bSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
17284fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
17293159fe7bSQu Wenruo 		__entry->diff		= diff;
17301b2442b4SQu Wenruo 		__entry->type		= type;
17313159fe7bSQu Wenruo 	),
17323159fe7bSQu Wenruo 
17334ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
17344ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
17351cb1f0b2SNikolay Borisov 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
17364ee0d883SQu Wenruo );
17374ee0d883SQu Wenruo 
17384ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_convert,
17394ee0d883SQu Wenruo 
17404ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff),
17414ee0d883SQu Wenruo 
17424ee0d883SQu Wenruo 	TP_ARGS(root, diff),
17434ee0d883SQu Wenruo 
17444ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
17454ee0d883SQu Wenruo 		__field(	u64,	refroot			)
17464ee0d883SQu Wenruo 		__field(	s64,	diff			)
17474ee0d883SQu Wenruo 	),
17484ee0d883SQu Wenruo 
17494ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
17504fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
17514ee0d883SQu Wenruo 		__entry->diff		= diff;
17524ee0d883SQu Wenruo 	),
17534ee0d883SQu Wenruo 
17544ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
17554ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
17561cb1f0b2SNikolay Borisov 		__print_symbolic(BTRFS_QGROUP_RSV_META_PREALLOC, QGROUP_RSV_TYPES),
17571cb1f0b2SNikolay Borisov 		__print_symbolic(BTRFS_QGROUP_RSV_META_PERTRANS, QGROUP_RSV_TYPES),
17584ee0d883SQu Wenruo 		__entry->diff)
17594ee0d883SQu Wenruo );
17604ee0d883SQu Wenruo 
17614ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_free_all_pertrans,
17624ee0d883SQu Wenruo 
17634ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root),
17644ee0d883SQu Wenruo 
17654ee0d883SQu Wenruo 	TP_ARGS(root),
17664ee0d883SQu Wenruo 
17674ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
17684ee0d883SQu Wenruo 		__field(	u64,	refroot			)
17694ee0d883SQu Wenruo 		__field(	s64,	diff			)
17704ee0d883SQu Wenruo 		__field(	int,	type			)
17714ee0d883SQu Wenruo 	),
17724ee0d883SQu Wenruo 
17734ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
17744fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
17754ee0d883SQu Wenruo 		spin_lock(&root->qgroup_meta_rsv_lock);
17764ee0d883SQu Wenruo 		__entry->diff		= -(s64)root->qgroup_meta_rsv_pertrans;
17774ee0d883SQu Wenruo 		spin_unlock(&root->qgroup_meta_rsv_lock);
17784ee0d883SQu Wenruo 		__entry->type		= BTRFS_QGROUP_RSV_META_PERTRANS;
17794ee0d883SQu Wenruo 	),
17804ee0d883SQu Wenruo 
17814ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
17824ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
17831cb1f0b2SNikolay Borisov 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
17843159fe7bSQu Wenruo );
17853159fe7bSQu Wenruo 
178600142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref,
178700142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
178800142756SJeff Mahoney 		 const struct prelim_ref *oldref,
178900142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
179000142756SJeff Mahoney 	TP_ARGS(fs_info, newref, oldref, tree_size),
179100142756SJeff Mahoney 
179200142756SJeff Mahoney 	TP_STRUCT__entry_btrfs(
179300142756SJeff Mahoney 		__field(	u64,  root_id		)
179400142756SJeff Mahoney 		__field(	u64,  objectid		)
179500142756SJeff Mahoney 		__field(	 u8,  type		)
179600142756SJeff Mahoney 		__field(	u64,  offset		)
179700142756SJeff Mahoney 		__field(	int,  level		)
179800142756SJeff Mahoney 		__field(	int,  old_count		)
179900142756SJeff Mahoney 		__field(	u64,  parent		)
180000142756SJeff Mahoney 		__field(	u64,  bytenr		)
180100142756SJeff Mahoney 		__field(	int,  mod_count		)
180200142756SJeff Mahoney 		__field(	u64,  tree_size		)
180300142756SJeff Mahoney 	),
180400142756SJeff Mahoney 
180500142756SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
180600142756SJeff Mahoney 		__entry->root_id	= oldref->root_id;
180700142756SJeff Mahoney 		__entry->objectid	= oldref->key_for_search.objectid;
180800142756SJeff Mahoney 		__entry->type		= oldref->key_for_search.type;
180900142756SJeff Mahoney 		__entry->offset		= oldref->key_for_search.offset;
181000142756SJeff Mahoney 		__entry->level		= oldref->level;
181100142756SJeff Mahoney 		__entry->old_count	= oldref->count;
181200142756SJeff Mahoney 		__entry->parent		= oldref->parent;
181300142756SJeff Mahoney 		__entry->bytenr		= oldref->wanted_disk_byte;
181400142756SJeff Mahoney 		__entry->mod_count	= newref ? newref->count : 0;
181500142756SJeff Mahoney 		__entry->tree_size	= tree_size;
181600142756SJeff Mahoney 	),
181700142756SJeff Mahoney 
181800142756SJeff 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",
18198eec8463SDavid Sterba 			__entry->root_id,
18208eec8463SDavid Sterba 			__entry->objectid, __entry->type,
18218eec8463SDavid Sterba 			__entry->offset, __entry->level,
182200142756SJeff Mahoney 			__entry->old_count, __entry->mod_count,
182300142756SJeff Mahoney 			__entry->old_count + __entry->mod_count,
18248eec8463SDavid Sterba 			__entry->parent,
18258eec8463SDavid Sterba 			__entry->bytenr,
18268eec8463SDavid Sterba 			__entry->tree_size)
182700142756SJeff Mahoney );
182800142756SJeff Mahoney 
182900142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
183000142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
183100142756SJeff Mahoney 		 const struct prelim_ref *oldref,
183200142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
183300142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
183400142756SJeff Mahoney );
183500142756SJeff Mahoney 
183600142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
183700142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
183800142756SJeff Mahoney 		 const struct prelim_ref *oldref,
183900142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
184000142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
184100142756SJeff Mahoney );
184200142756SJeff Mahoney 
1843dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
18441d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_root *root, u64 ino, int mod),
1845dd48d407SJosef Bacik 
1846dd48d407SJosef Bacik 	TP_ARGS(root, ino, mod),
1847dd48d407SJosef Bacik 
1848dd48d407SJosef Bacik 	TP_STRUCT__entry_btrfs(
1849dd48d407SJosef Bacik 		__field(	u64, root_objectid	)
1850dd48d407SJosef Bacik 		__field(	u64, ino		)
1851dd48d407SJosef Bacik 		__field(	int, mod		)
1852dd48d407SJosef Bacik 	),
1853dd48d407SJosef Bacik 
1854dd48d407SJosef Bacik 	TP_fast_assign_btrfs(root->fs_info,
18554fd786e6SMisono Tomohiro 		__entry->root_objectid	= root->root_key.objectid;
1856dd48d407SJosef Bacik 		__entry->ino		= ino;
1857dd48d407SJosef Bacik 		__entry->mod		= mod;
1858dd48d407SJosef Bacik 	),
1859dd48d407SJosef Bacik 
1860dd48d407SJosef Bacik 	TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1861dd48d407SJosef Bacik 			show_root_type(__entry->root_objectid),
18628eec8463SDavid Sterba 			__entry->ino, __entry->mod)
1863dd48d407SJosef Bacik );
18643dca5c94SQu Wenruo 
18654ed0a7a3SQu Wenruo DECLARE_EVENT_CLASS(btrfs__block_group,
186632da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
18674ed0a7a3SQu Wenruo 
18684ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache),
18694ed0a7a3SQu Wenruo 
18704ed0a7a3SQu Wenruo 	TP_STRUCT__entry_btrfs(
18714ed0a7a3SQu Wenruo 		__field(	u64,	bytenr		)
18724ed0a7a3SQu Wenruo 		__field(	u64,	len		)
18734ed0a7a3SQu Wenruo 		__field(	u64,	used		)
18744ed0a7a3SQu Wenruo 		__field(	u64,	flags		)
18754ed0a7a3SQu Wenruo 	),
18764ed0a7a3SQu Wenruo 
18774ed0a7a3SQu Wenruo 	TP_fast_assign_btrfs(bg_cache->fs_info,
1878b3470b5dSDavid Sterba 		__entry->bytenr = bg_cache->start,
1879b3470b5dSDavid Sterba 		__entry->len	= bg_cache->length,
1880bf38be65SDavid Sterba 		__entry->used	= bg_cache->used;
18814ed0a7a3SQu Wenruo 		__entry->flags	= bg_cache->flags;
18824ed0a7a3SQu Wenruo 	),
18834ed0a7a3SQu Wenruo 
18844ed0a7a3SQu Wenruo 	TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
18854ed0a7a3SQu Wenruo 		__entry->bytenr, __entry->len, __entry->used, __entry->flags,
18864ed0a7a3SQu Wenruo 		__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
18874ed0a7a3SQu Wenruo );
18884ed0a7a3SQu Wenruo 
18894ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
189032da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
18914ed0a7a3SQu Wenruo 
18924ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
18934ed0a7a3SQu Wenruo );
18944ed0a7a3SQu Wenruo 
18954ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
189632da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
18974ed0a7a3SQu Wenruo 
18984ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
18994ed0a7a3SQu Wenruo );
19004ed0a7a3SQu Wenruo 
190118bb8bbfSJohannes Thumshirn DEFINE_EVENT(btrfs__block_group, btrfs_add_reclaim_block_group,
190218bb8bbfSJohannes Thumshirn 	TP_PROTO(const struct btrfs_block_group *bg_cache),
190318bb8bbfSJohannes Thumshirn 
190418bb8bbfSJohannes Thumshirn 	TP_ARGS(bg_cache)
190518bb8bbfSJohannes Thumshirn );
190618bb8bbfSJohannes Thumshirn 
190718bb8bbfSJohannes Thumshirn DEFINE_EVENT(btrfs__block_group, btrfs_reclaim_block_group,
190818bb8bbfSJohannes Thumshirn 	TP_PROTO(const struct btrfs_block_group *bg_cache),
190918bb8bbfSJohannes Thumshirn 
191018bb8bbfSJohannes Thumshirn 	TP_ARGS(bg_cache)
191118bb8bbfSJohannes Thumshirn );
191218bb8bbfSJohannes Thumshirn 
19134ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
191432da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
19154ed0a7a3SQu Wenruo 
19164ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
19174ed0a7a3SQu Wenruo );
19184ed0a7a3SQu Wenruo 
1919a1d19847SQu Wenruo TRACE_EVENT(btrfs_set_extent_bit,
1920a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
1921a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned set_bits),
1922a1d19847SQu Wenruo 
1923a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, set_bits),
1924a1d19847SQu Wenruo 
1925a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
1926a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
1927a1d19847SQu Wenruo 		__field(	u64,		ino	)
1928a1d19847SQu Wenruo 		__field(	u64,		rootid	)
1929a1d19847SQu Wenruo 		__field(	u64,		start	)
1930a1d19847SQu Wenruo 		__field(	u64,		len	)
1931a1d19847SQu Wenruo 		__field(	unsigned,	set_bits)
1932a1d19847SQu Wenruo 	),
1933a1d19847SQu Wenruo 
1934a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
1935a1d19847SQu Wenruo 		__entry->owner = tree->owner;
1936a1d19847SQu Wenruo 		if (tree->private_data) {
19371d2e7c7cSDavid Sterba 			const struct inode *inode = tree->private_data;
1938a1d19847SQu Wenruo 
1939a1d19847SQu Wenruo 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
1940a1d19847SQu Wenruo 			__entry->rootid	=
1941a1d19847SQu Wenruo 				BTRFS_I(inode)->root->root_key.objectid;
1942a1d19847SQu Wenruo 		} else {
1943a1d19847SQu Wenruo 			__entry->ino	= 0;
1944a1d19847SQu Wenruo 			__entry->rootid	= 0;
1945a1d19847SQu Wenruo 		}
1946a1d19847SQu Wenruo 		__entry->start		= start;
1947a1d19847SQu Wenruo 		__entry->len		= len;
1948a1d19847SQu Wenruo 		__entry->set_bits	= set_bits;
1949a1d19847SQu Wenruo 	),
1950a1d19847SQu Wenruo 
1951a1d19847SQu Wenruo 	TP_printk_btrfs(
1952a1d19847SQu Wenruo 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s",
1953c92bb304SNikolay Borisov 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
1954a1d19847SQu Wenruo 		__entry->rootid, __entry->start, __entry->len,
1955a1d19847SQu Wenruo 		__print_flags(__entry->set_bits, "|", EXTENT_FLAGS))
1956a1d19847SQu Wenruo );
1957a1d19847SQu Wenruo 
1958a1d19847SQu Wenruo TRACE_EVENT(btrfs_clear_extent_bit,
1959a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
1960a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned clear_bits),
1961a1d19847SQu Wenruo 
1962a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, clear_bits),
1963a1d19847SQu Wenruo 
1964a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
1965a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
1966a1d19847SQu Wenruo 		__field(	u64,		ino	)
1967a1d19847SQu Wenruo 		__field(	u64,		rootid	)
1968a1d19847SQu Wenruo 		__field(	u64,		start	)
1969a1d19847SQu Wenruo 		__field(	u64,		len	)
1970a1d19847SQu Wenruo 		__field(	unsigned,	clear_bits)
1971a1d19847SQu Wenruo 	),
1972a1d19847SQu Wenruo 
1973a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
1974a1d19847SQu Wenruo 		__entry->owner = tree->owner;
1975a1d19847SQu Wenruo 		if (tree->private_data) {
19761d2e7c7cSDavid Sterba 			const struct inode *inode = tree->private_data;
1977a1d19847SQu Wenruo 
1978a1d19847SQu Wenruo 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
1979a1d19847SQu Wenruo 			__entry->rootid	=
1980a1d19847SQu Wenruo 				BTRFS_I(inode)->root->root_key.objectid;
1981a1d19847SQu Wenruo 		} else {
1982a1d19847SQu Wenruo 			__entry->ino	= 0;
1983a1d19847SQu Wenruo 			__entry->rootid	= 0;
1984a1d19847SQu Wenruo 		}
1985a1d19847SQu Wenruo 		__entry->start		= start;
1986a1d19847SQu Wenruo 		__entry->len		= len;
1987a1d19847SQu Wenruo 		__entry->clear_bits	= clear_bits;
1988a1d19847SQu Wenruo 	),
1989a1d19847SQu Wenruo 
1990a1d19847SQu Wenruo 	TP_printk_btrfs(
1991a1d19847SQu Wenruo 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s",
1992c92bb304SNikolay Borisov 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
1993a1d19847SQu Wenruo 		__entry->rootid, __entry->start, __entry->len,
1994a1d19847SQu Wenruo 		__print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
1995a1d19847SQu Wenruo );
1996a1d19847SQu Wenruo 
1997a1d19847SQu Wenruo TRACE_EVENT(btrfs_convert_extent_bit,
1998a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
1999a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned set_bits, unsigned clear_bits),
2000a1d19847SQu Wenruo 
2001a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, set_bits, clear_bits),
2002a1d19847SQu Wenruo 
2003a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
2004a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
2005a1d19847SQu Wenruo 		__field(	u64,		ino	)
2006a1d19847SQu Wenruo 		__field(	u64,		rootid	)
2007a1d19847SQu Wenruo 		__field(	u64,		start	)
2008a1d19847SQu Wenruo 		__field(	u64,		len	)
2009a1d19847SQu Wenruo 		__field(	unsigned,	set_bits)
2010a1d19847SQu Wenruo 		__field(	unsigned,	clear_bits)
2011a1d19847SQu Wenruo 	),
2012a1d19847SQu Wenruo 
2013a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
2014a1d19847SQu Wenruo 		__entry->owner = tree->owner;
2015a1d19847SQu Wenruo 		if (tree->private_data) {
20161d2e7c7cSDavid Sterba 			const struct inode *inode = tree->private_data;
2017a1d19847SQu Wenruo 
2018a1d19847SQu Wenruo 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
2019a1d19847SQu Wenruo 			__entry->rootid	=
2020a1d19847SQu Wenruo 				BTRFS_I(inode)->root->root_key.objectid;
2021a1d19847SQu Wenruo 		} else {
2022a1d19847SQu Wenruo 			__entry->ino	= 0;
2023a1d19847SQu Wenruo 			__entry->rootid	= 0;
2024a1d19847SQu Wenruo 		}
2025a1d19847SQu Wenruo 		__entry->start		= start;
2026a1d19847SQu Wenruo 		__entry->len		= len;
2027a1d19847SQu Wenruo 		__entry->set_bits	= set_bits;
2028a1d19847SQu Wenruo 		__entry->clear_bits	= clear_bits;
2029a1d19847SQu Wenruo 	),
2030a1d19847SQu Wenruo 
2031a1d19847SQu Wenruo 	TP_printk_btrfs(
2032a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s",
2033c92bb304SNikolay Borisov 		  __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2034a1d19847SQu Wenruo 		  __entry->rootid, __entry->start, __entry->len,
2035a1d19847SQu Wenruo 		  __print_flags(__entry->set_bits , "|", EXTENT_FLAGS),
2036a1d19847SQu Wenruo 		  __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2037a1d19847SQu Wenruo );
2038a1d19847SQu Wenruo 
2039e5ad49e2SJosef Bacik DECLARE_EVENT_CLASS(btrfs_dump_space_info,
2040*8197766dSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2041e5ad49e2SJosef Bacik 		 const struct btrfs_space_info *sinfo),
2042e5ad49e2SJosef Bacik 
2043e5ad49e2SJosef Bacik 	TP_ARGS(fs_info, sinfo),
2044e5ad49e2SJosef Bacik 
2045e5ad49e2SJosef Bacik 	TP_STRUCT__entry_btrfs(
2046e5ad49e2SJosef Bacik 		__field(	u64,	flags			)
2047e5ad49e2SJosef Bacik 		__field(	u64,	total_bytes		)
2048e5ad49e2SJosef Bacik 		__field(	u64,	bytes_used		)
2049e5ad49e2SJosef Bacik 		__field(	u64,	bytes_pinned		)
2050e5ad49e2SJosef Bacik 		__field(	u64,	bytes_reserved		)
2051e5ad49e2SJosef Bacik 		__field(	u64,	bytes_may_use		)
2052e5ad49e2SJosef Bacik 		__field(	u64,	bytes_readonly		)
2053e5ad49e2SJosef Bacik 		__field(	u64,	reclaim_size		)
2054e5ad49e2SJosef Bacik 		__field(	int,	clamp			)
2055e5ad49e2SJosef Bacik 		__field(	u64,	global_reserved		)
2056e5ad49e2SJosef Bacik 		__field(	u64,	trans_reserved		)
2057e5ad49e2SJosef Bacik 		__field(	u64,	delayed_refs_reserved	)
2058e5ad49e2SJosef Bacik 		__field(	u64,	delayed_reserved	)
2059e5ad49e2SJosef Bacik 		__field(	u64,	free_chunk_space	)
2060*8197766dSJosef Bacik 		__field(	u64,	delalloc_bytes		)
2061*8197766dSJosef Bacik 		__field(	u64,	ordered_bytes		)
2062e5ad49e2SJosef Bacik 	),
2063e5ad49e2SJosef Bacik 
2064e5ad49e2SJosef Bacik 	TP_fast_assign_btrfs(fs_info,
2065e5ad49e2SJosef Bacik 		__entry->flags			=	sinfo->flags;
2066e5ad49e2SJosef Bacik 		__entry->total_bytes		=	sinfo->total_bytes;
2067e5ad49e2SJosef Bacik 		__entry->bytes_used		=	sinfo->bytes_used;
2068e5ad49e2SJosef Bacik 		__entry->bytes_pinned		=	sinfo->bytes_pinned;
2069e5ad49e2SJosef Bacik 		__entry->bytes_reserved		=	sinfo->bytes_reserved;
2070e5ad49e2SJosef Bacik 		__entry->bytes_may_use		=	sinfo->bytes_may_use;
2071e5ad49e2SJosef Bacik 		__entry->bytes_readonly		=	sinfo->bytes_readonly;
2072e5ad49e2SJosef Bacik 		__entry->reclaim_size		=	sinfo->reclaim_size;
2073e5ad49e2SJosef Bacik 		__entry->clamp			=	sinfo->clamp;
2074e5ad49e2SJosef Bacik 		__entry->global_reserved	=	fs_info->global_block_rsv.reserved;
2075e5ad49e2SJosef Bacik 		__entry->trans_reserved		=	fs_info->trans_block_rsv.reserved;
2076e5ad49e2SJosef Bacik 		__entry->delayed_refs_reserved	=	fs_info->delayed_refs_rsv.reserved;
2077e5ad49e2SJosef Bacik 		__entry->delayed_reserved	=	fs_info->delayed_block_rsv.reserved;
2078e5ad49e2SJosef Bacik 		__entry->free_chunk_space	=	atomic64_read(&fs_info->free_chunk_space);
2079*8197766dSJosef Bacik 		__entry->delalloc_bytes		=	percpu_counter_sum_positive(&fs_info->delalloc_bytes);
2080*8197766dSJosef Bacik 		__entry->ordered_bytes		=	percpu_counter_sum_positive(&fs_info->ordered_bytes);
2081e5ad49e2SJosef Bacik 	),
2082e5ad49e2SJosef Bacik 
2083e5ad49e2SJosef Bacik 	TP_printk_btrfs("flags=%s total_bytes=%llu bytes_used=%llu "
2084e5ad49e2SJosef Bacik 			"bytes_pinned=%llu bytes_reserved=%llu "
2085e5ad49e2SJosef Bacik 			"bytes_may_use=%llu bytes_readonly=%llu "
2086e5ad49e2SJosef Bacik 			"reclaim_size=%llu clamp=%d global_reserved=%llu "
2087e5ad49e2SJosef Bacik 			"trans_reserved=%llu delayed_refs_reserved=%llu "
2088*8197766dSJosef Bacik 			"delayed_reserved=%llu chunk_free_space=%llu "
2089*8197766dSJosef Bacik 			"delalloc_bytes=%llu ordered_bytes=%llu",
2090e5ad49e2SJosef Bacik 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2091e5ad49e2SJosef Bacik 			__entry->total_bytes, __entry->bytes_used,
2092e5ad49e2SJosef Bacik 			__entry->bytes_pinned, __entry->bytes_reserved,
2093e5ad49e2SJosef Bacik 			__entry->bytes_may_use, __entry->bytes_readonly,
2094e5ad49e2SJosef Bacik 			__entry->reclaim_size, __entry->clamp,
2095e5ad49e2SJosef Bacik 			__entry->global_reserved, __entry->trans_reserved,
2096e5ad49e2SJosef Bacik 			__entry->delayed_refs_reserved,
2097*8197766dSJosef Bacik 			__entry->delayed_reserved, __entry->free_chunk_space,
2098*8197766dSJosef Bacik 			__entry->delalloc_bytes, __entry->ordered_bytes)
2099e5ad49e2SJosef Bacik );
2100e5ad49e2SJosef Bacik 
2101e5ad49e2SJosef Bacik DEFINE_EVENT(btrfs_dump_space_info, btrfs_done_preemptive_reclaim,
2102*8197766dSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2103e5ad49e2SJosef Bacik 		 const struct btrfs_space_info *sinfo),
2104e5ad49e2SJosef Bacik 	TP_ARGS(fs_info, sinfo)
2105e5ad49e2SJosef Bacik );
2106e5ad49e2SJosef Bacik 
2107ac1ea10eSJosef Bacik TRACE_EVENT(btrfs_reserve_ticket,
2108ac1ea10eSJosef Bacik 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
2109ac1ea10eSJosef Bacik 		 u64 start_ns, int flush, int error),
2110ac1ea10eSJosef Bacik 
2111ac1ea10eSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, start_ns, flush, error),
2112ac1ea10eSJosef Bacik 
2113ac1ea10eSJosef Bacik 	TP_STRUCT__entry_btrfs(
2114ac1ea10eSJosef Bacik 		__field(	u64,	flags		)
2115ac1ea10eSJosef Bacik 		__field(	u64,	bytes		)
2116ac1ea10eSJosef Bacik 		__field(	u64,	start_ns	)
2117ac1ea10eSJosef Bacik 		__field(	int,	flush		)
2118ac1ea10eSJosef Bacik 		__field(	int,	error		)
2119ac1ea10eSJosef Bacik 	),
2120ac1ea10eSJosef Bacik 
2121ac1ea10eSJosef Bacik 	TP_fast_assign_btrfs(fs_info,
2122ac1ea10eSJosef Bacik 		__entry->flags		= flags;
2123ac1ea10eSJosef Bacik 		__entry->bytes		= bytes;
2124ac1ea10eSJosef Bacik 		__entry->start_ns	= start_ns;
2125ac1ea10eSJosef Bacik 		__entry->flush		= flush;
2126ac1ea10eSJosef Bacik 		__entry->error		= error;
2127ac1ea10eSJosef Bacik 	),
2128ac1ea10eSJosef Bacik 
2129ac1ea10eSJosef Bacik 	TP_printk_btrfs("flags=%s bytes=%llu start_ns=%llu flush=%s error=%d",
2130ac1ea10eSJosef Bacik 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2131ac1ea10eSJosef Bacik 			__entry->bytes, __entry->start_ns,
2132ac1ea10eSJosef Bacik 			__print_symbolic(__entry->flush, FLUSH_ACTIONS),
2133ac1ea10eSJosef Bacik 			__entry->error)
2134ac1ea10eSJosef Bacik );
2135ac1ea10eSJosef Bacik 
213634e73cc9SQu Wenruo DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock,
213734e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
213834e73cc9SQu Wenruo 
213934e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns),
214034e73cc9SQu Wenruo 
214134e73cc9SQu Wenruo 	TP_STRUCT__entry_btrfs(
214234e73cc9SQu Wenruo 		__field(	u64,	block		)
214334e73cc9SQu Wenruo 		__field(	u64,	generation	)
214434e73cc9SQu Wenruo 		__field(	u64,	start_ns	)
214534e73cc9SQu Wenruo 		__field(	u64,	end_ns		)
214634e73cc9SQu Wenruo 		__field(	u64,	diff_ns		)
214734e73cc9SQu Wenruo 		__field(	u64,	owner		)
214834e73cc9SQu Wenruo 		__field(	int,	is_log_tree	)
214934e73cc9SQu Wenruo 	),
215034e73cc9SQu Wenruo 
215134e73cc9SQu Wenruo 	TP_fast_assign_btrfs(eb->fs_info,
215234e73cc9SQu Wenruo 		__entry->block		= eb->start;
215334e73cc9SQu Wenruo 		__entry->generation	= btrfs_header_generation(eb);
215434e73cc9SQu Wenruo 		__entry->start_ns	= start_ns;
215534e73cc9SQu Wenruo 		__entry->end_ns		= ktime_get_ns();
215634e73cc9SQu Wenruo 		__entry->diff_ns	= __entry->end_ns - start_ns;
215734e73cc9SQu Wenruo 		__entry->owner		= btrfs_header_owner(eb);
215834e73cc9SQu Wenruo 		__entry->is_log_tree	= (eb->log_index >= 0);
215934e73cc9SQu Wenruo 	),
216034e73cc9SQu Wenruo 
216134e73cc9SQu Wenruo 	TP_printk_btrfs(
216234e73cc9SQu Wenruo "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d",
216334e73cc9SQu Wenruo 		__entry->block, __entry->generation,
216434e73cc9SQu Wenruo 		__entry->start_ns, __entry->end_ns, __entry->diff_ns,
216534e73cc9SQu Wenruo 		__entry->owner, __entry->is_log_tree)
216634e73cc9SQu Wenruo );
216734e73cc9SQu Wenruo 
216834e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock,
216934e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
217034e73cc9SQu Wenruo 
217134e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns)
217234e73cc9SQu Wenruo );
217334e73cc9SQu Wenruo 
217434e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock,
217534e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
217634e73cc9SQu Wenruo 
217734e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns)
217834e73cc9SQu Wenruo );
217934e73cc9SQu Wenruo 
218031aab402SQu Wenruo DECLARE_EVENT_CLASS(btrfs_locking_events,
218131aab402SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb),
218231aab402SQu Wenruo 
218331aab402SQu Wenruo 	TP_ARGS(eb),
218431aab402SQu Wenruo 
218531aab402SQu Wenruo 	TP_STRUCT__entry_btrfs(
218631aab402SQu Wenruo 		__field(	u64,	block		)
218731aab402SQu Wenruo 		__field(	u64,	generation	)
218831aab402SQu Wenruo 		__field(	u64,	owner		)
218931aab402SQu Wenruo 		__field(	int,	is_log_tree	)
219031aab402SQu Wenruo 	),
219131aab402SQu Wenruo 
219231aab402SQu Wenruo 	TP_fast_assign_btrfs(eb->fs_info,
219331aab402SQu Wenruo 		__entry->block		= eb->start;
219431aab402SQu Wenruo 		__entry->generation	= btrfs_header_generation(eb);
219531aab402SQu Wenruo 		__entry->owner		= btrfs_header_owner(eb);
219631aab402SQu Wenruo 		__entry->is_log_tree	= (eb->log_index >= 0);
219731aab402SQu Wenruo 	),
219831aab402SQu Wenruo 
219931aab402SQu Wenruo 	TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d",
220031aab402SQu Wenruo 		__entry->block, __entry->generation,
220131aab402SQu Wenruo 		__entry->owner, __entry->is_log_tree)
220231aab402SQu Wenruo );
220331aab402SQu Wenruo 
220431aab402SQu Wenruo #define DEFINE_BTRFS_LOCK_EVENT(name)				\
220531aab402SQu Wenruo DEFINE_EVENT(btrfs_locking_events, name,			\
220631aab402SQu Wenruo 		TP_PROTO(const struct extent_buffer *eb),	\
220731aab402SQu Wenruo 								\
220831aab402SQu Wenruo 		TP_ARGS(eb)					\
220931aab402SQu Wenruo )
221031aab402SQu Wenruo 
221131aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock);
221231aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock);
221331aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking);
221431aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read);
221531aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write);
221631aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock);
221731aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock);
221831aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic);
221931aab402SQu Wenruo 
2220480b9b4dSQu Wenruo DECLARE_EVENT_CLASS(btrfs__space_info_update,
2221480b9b4dSQu Wenruo 
22221d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
22231d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2224480b9b4dSQu Wenruo 
2225480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff),
2226480b9b4dSQu Wenruo 
2227480b9b4dSQu Wenruo 	TP_STRUCT__entry_btrfs(
2228480b9b4dSQu Wenruo 		__field(	u64,	type		)
2229480b9b4dSQu Wenruo 		__field(	u64,	old		)
2230480b9b4dSQu Wenruo 		__field(	s64,	diff		)
2231480b9b4dSQu Wenruo 	),
2232480b9b4dSQu Wenruo 
2233480b9b4dSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
2234480b9b4dSQu Wenruo 		__entry->type	= sinfo->flags;
2235480b9b4dSQu Wenruo 		__entry->old	= old;
2236480b9b4dSQu Wenruo 		__entry->diff	= diff;
2237480b9b4dSQu Wenruo 	),
2238480b9b4dSQu Wenruo 	TP_printk_btrfs("type=%s old=%llu diff=%lld",
2239480b9b4dSQu Wenruo 		__print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS),
2240480b9b4dSQu Wenruo 		__entry->old, __entry->diff)
2241480b9b4dSQu Wenruo );
2242480b9b4dSQu Wenruo 
2243480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use,
2244480b9b4dSQu Wenruo 
22451d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
22461d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2247480b9b4dSQu Wenruo 
2248480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff)
2249480b9b4dSQu Wenruo );
2250480b9b4dSQu Wenruo 
2251480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned,
2252480b9b4dSQu Wenruo 
22531d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
22541d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2255480b9b4dSQu Wenruo 
2256480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff)
2257480b9b4dSQu Wenruo );
2258480b9b4dSQu Wenruo 
22591abe9b8aSliubo #endif /* _TRACE_BTRFS_H */
22601abe9b8aSliubo 
22611abe9b8aSliubo /* This part must be outside protection */
22621abe9b8aSliubo #include <trace/define_trace.h>
2263