xref: /openbmc/linux/include/trace/events/btrfs.h (revision 182741d2)
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;
27a31b4a43SChristoph Hellwig 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;
33b8bea09aSQu Wenruo struct btrfs_raid_bio;
34b8bea09aSQu Wenruo struct raid56_bio_trace_info;
35cfc2de0fSBoris Burkov struct find_free_extent_ctl;
361abe9b8aSliubo 
371abe9b8aSliubo #define show_ref_type(type)						\
381abe9b8aSliubo 	__print_symbolic(type,						\
391abe9b8aSliubo 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
401abe9b8aSliubo 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
411abe9b8aSliubo 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
421abe9b8aSliubo 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
431abe9b8aSliubo 
441abe9b8aSliubo #define __show_root_type(obj)						\
457f34b746Sliubo 	__print_symbolic_u64(obj,					\
461abe9b8aSliubo 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
471abe9b8aSliubo 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
481abe9b8aSliubo 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
491abe9b8aSliubo 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
501abe9b8aSliubo 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
511abe9b8aSliubo 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
521abe9b8aSliubo 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
531abe9b8aSliubo 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
54e112e2b4SLiu Bo 		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
551abe9b8aSliubo 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
56208acb8cSOmar Sandoval 		{ BTRFS_UUID_TREE_OBJECTID,	"UUID_TREE"	},	\
57208acb8cSOmar Sandoval 		{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },	\
589c54e80dSJosef Bacik 		{ BTRFS_BLOCK_GROUP_TREE_OBJECTID, "BLOCK_GROUP_TREE" },\
591abe9b8aSliubo 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
601abe9b8aSliubo 
611abe9b8aSliubo #define show_root_type(obj)						\
621abe9b8aSliubo 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
63fb57dc81SLiu Bo 	      (obj >= BTRFS_ROOT_TREE_OBJECTID &&			\
64e112e2b4SLiu Bo 	       obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
651abe9b8aSliubo 
665bca2c95SNikolay Borisov #define FLUSH_ACTIONS								\
675bca2c95SNikolay Borisov 	EM( BTRFS_RESERVE_NO_FLUSH,		"BTRFS_RESERVE_NO_FLUSH")	\
685bca2c95SNikolay Borisov 	EM( BTRFS_RESERVE_FLUSH_LIMIT,		"BTRFS_RESERVE_FLUSH_LIMIT")	\
695bca2c95SNikolay Borisov 	EM( BTRFS_RESERVE_FLUSH_ALL,		"BTRFS_RESERVE_FLUSH_ALL")	\
705bca2c95SNikolay Borisov 	EMe(BTRFS_RESERVE_FLUSH_ALL_STEAL,	"BTRFS_RESERVE_FLUSH_ALL_STEAL")
715bca2c95SNikolay Borisov 
720840dd28SNikolay Borisov #define FI_TYPES							\
730840dd28SNikolay Borisov 	EM( BTRFS_FILE_EXTENT_INLINE,		"INLINE")		\
740840dd28SNikolay Borisov 	EM( BTRFS_FILE_EXTENT_REG,		"REG")			\
750840dd28SNikolay Borisov 	EMe(BTRFS_FILE_EXTENT_PREALLOC,		"PREALLOC")
760840dd28SNikolay Borisov 
771cb1f0b2SNikolay Borisov #define QGROUP_RSV_TYPES						\
781cb1f0b2SNikolay Borisov 	EM( BTRFS_QGROUP_RSV_DATA,		"DATA")			\
791cb1f0b2SNikolay Borisov 	EM( BTRFS_QGROUP_RSV_META_PERTRANS,	"META_PERTRANS")	\
801cb1f0b2SNikolay Borisov 	EMe(BTRFS_QGROUP_RSV_META_PREALLOC,	"META_PREALLOC")
811cb1f0b2SNikolay Borisov 
82c92bb304SNikolay Borisov #define IO_TREE_OWNER						    \
83c92bb304SNikolay Borisov 	EM( IO_TREE_FS_PINNED_EXTENTS, 	  "PINNED_EXTENTS")	    \
84c92bb304SNikolay Borisov 	EM( IO_TREE_FS_EXCLUDED_EXTENTS,  "EXCLUDED_EXTENTS")	    \
852c53a14dSQu Wenruo 	EM( IO_TREE_BTREE_INODE_IO,	  "BTREE_INODE_IO")	    \
86c92bb304SNikolay Borisov 	EM( IO_TREE_INODE_IO,		  "INODE_IO")		    \
87c92bb304SNikolay Borisov 	EM( IO_TREE_RELOC_BLOCKS,	  "RELOC_BLOCKS")	    \
88c92bb304SNikolay Borisov 	EM( IO_TREE_TRANS_DIRTY_PAGES,	  "TRANS_DIRTY_PAGES")      \
89c92bb304SNikolay Borisov 	EM( IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES")   \
90c92bb304SNikolay Borisov 	EM( IO_TREE_INODE_FILE_EXTENT,	  "INODE_FILE_EXTENT")      \
91c92bb304SNikolay Borisov 	EM( IO_TREE_LOG_CSUM_RANGE,	  "LOG_CSUM_RANGE")         \
92c92bb304SNikolay Borisov 	EMe(IO_TREE_SELFTEST,		  "SELFTEST")
93c92bb304SNikolay Borisov 
94f0cdd15cSNikolay Borisov #define FLUSH_STATES							\
95f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_ITEMS_NR,	"FLUSH_DELAYED_ITEMS_NR")	\
96f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_ITEMS,	"FLUSH_DELAYED_ITEMS")		\
97f0cdd15cSNikolay Borisov 	EM( FLUSH_DELALLOC,		"FLUSH_DELALLOC")		\
98f0cdd15cSNikolay Borisov 	EM( FLUSH_DELALLOC_WAIT,	"FLUSH_DELALLOC_WAIT")		\
9903fe78ccSJosef Bacik 	EM( FLUSH_DELALLOC_FULL,	"FLUSH_DELALLOC_FULL")		\
100f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_REFS_NR,	"FLUSH_DELAYED_REFS_NR")	\
1010a3212deSNaohiro Aota 	EM( FLUSH_DELAYED_REFS,		"FLUSH_DELAYED_REFS")		\
102f0cdd15cSNikolay Borisov 	EM( ALLOC_CHUNK,		"ALLOC_CHUNK")			\
103f0cdd15cSNikolay Borisov 	EM( ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE")		\
104f0cdd15cSNikolay Borisov 	EM( RUN_DELAYED_IPUTS,		"RUN_DELAYED_IPUTS")		\
105c416a30cSJosef Bacik 	EMe(COMMIT_TRANS,		"COMMIT_TRANS")
106f0cdd15cSNikolay Borisov 
1075bca2c95SNikolay Borisov /*
1085bca2c95SNikolay Borisov  * First define the enums in the above macros to be exported to userspace via
1095bca2c95SNikolay Borisov  * TRACE_DEFINE_ENUM().
1105bca2c95SNikolay Borisov  */
1115bca2c95SNikolay Borisov 
1120840dd28SNikolay Borisov #undef EM
1130840dd28SNikolay Borisov #undef EMe
1140840dd28SNikolay Borisov #define EM(a, b)	TRACE_DEFINE_ENUM(a);
1150840dd28SNikolay Borisov #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
1160840dd28SNikolay Borisov 
1175bca2c95SNikolay Borisov FLUSH_ACTIONS
1180840dd28SNikolay Borisov FI_TYPES
1191cb1f0b2SNikolay Borisov QGROUP_RSV_TYPES
120c92bb304SNikolay Borisov IO_TREE_OWNER
121f0cdd15cSNikolay Borisov FLUSH_STATES
1220840dd28SNikolay Borisov 
1235bca2c95SNikolay Borisov /*
1245bca2c95SNikolay Borisov  * Now redefine the EM and EMe macros to map the enums to the strings that will
1255bca2c95SNikolay Borisov  * be printed in the output
1265bca2c95SNikolay Borisov  */
1275bca2c95SNikolay Borisov 
1280840dd28SNikolay Borisov #undef EM
1290840dd28SNikolay Borisov #undef EMe
1300840dd28SNikolay Borisov #define EM(a, b)        {a, b},
1310840dd28SNikolay Borisov #define EMe(a, b)       {a, b}
13209ed2f16SLiu Bo 
133a1d19847SQu Wenruo 
1343f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS	\
1353f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
1363f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
1373f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
1383f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
1393f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
1403f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
141e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
142e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
143e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
1443f7de037SJosef Bacik 
145a1d19847SQu Wenruo #define EXTENT_FLAGS						\
146a1d19847SQu Wenruo 	{ EXTENT_DIRTY,			"DIRTY"},		\
147a1d19847SQu Wenruo 	{ EXTENT_UPTODATE,		"UPTODATE"},		\
148a1d19847SQu Wenruo 	{ EXTENT_LOCKED,		"LOCKED"},		\
149a1d19847SQu Wenruo 	{ EXTENT_NEW,			"NEW"},			\
150a1d19847SQu Wenruo 	{ EXTENT_DELALLOC,		"DELALLOC"},		\
151a1d19847SQu Wenruo 	{ EXTENT_DEFRAG,		"DEFRAG"},		\
152a1d19847SQu Wenruo 	{ EXTENT_BOUNDARY,		"BOUNDARY"},		\
153a1d19847SQu Wenruo 	{ EXTENT_NODATASUM,		"NODATASUM"},		\
154a1d19847SQu Wenruo 	{ EXTENT_CLEAR_META_RESV,	"CLEAR_META_RESV"},	\
155a1d19847SQu Wenruo 	{ EXTENT_NEED_WAIT,		"NEED_WAIT"},		\
156a1d19847SQu Wenruo 	{ EXTENT_NORESERVE,		"NORESERVE"},		\
157a1d19847SQu Wenruo 	{ EXTENT_QGROUP_RESERVED,	"QGROUP_RESERVED"},	\
158a1d19847SQu Wenruo 	{ EXTENT_CLEAR_DATA_RESV,	"CLEAR_DATA_RESV"},	\
159a1d19847SQu Wenruo 	{ EXTENT_DELALLOC_NEW,		"DELALLOC_NEW"}
160a1d19847SQu Wenruo 
161b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16
162b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
163bc074524SJeff Mahoney 
164bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info)					\
165a1d19847SQu Wenruo ({									\
166a1d19847SQu Wenruo 	if (fs_info)							\
167a1d19847SQu Wenruo 		memcpy(__entry->fsid, fs_info->fs_devices->fsid,	\
168a1d19847SQu Wenruo 		       BTRFS_FSID_SIZE);				\
169a1d19847SQu Wenruo 	else								\
170a1d19847SQu Wenruo 		memset(__entry->fsid, 0, BTRFS_FSID_SIZE);		\
171a1d19847SQu Wenruo })
172bc074524SJeff Mahoney 
173bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...)					\
174bc074524SJeff Mahoney 	TP_STRUCT__entry(						\
175bc074524SJeff Mahoney 		TP_STRUCT__entry_fsid					\
176bc074524SJeff Mahoney 		args)
177bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...)				\
178bc074524SJeff Mahoney 	TP_fast_assign(							\
179bc074524SJeff Mahoney 		TP_fast_assign_fsid(fs_info);				\
180bc074524SJeff Mahoney 		args)
181bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \
182bc074524SJeff Mahoney 	TP_printk("%pU: " fmt, __entry->fsid, args)
1838c2a3ca2SJosef Bacik 
1841abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit,
1851abe9b8aSliubo 
1862e4e97abSJosef Bacik 	TP_PROTO(const struct btrfs_fs_info *fs_info),
1871abe9b8aSliubo 
1882e4e97abSJosef Bacik 	TP_ARGS(fs_info),
1891abe9b8aSliubo 
190bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1911abe9b8aSliubo 		__field(	u64,  generation		)
1921abe9b8aSliubo 		__field(	u64,  root_objectid		)
1931abe9b8aSliubo 	),
1941abe9b8aSliubo 
1952e4e97abSJosef Bacik 	TP_fast_assign_btrfs(fs_info,
1962e4e97abSJosef Bacik 		__entry->generation	= fs_info->generation;
1972e4e97abSJosef Bacik 		__entry->root_objectid	= BTRFS_ROOT_TREE_OBJECTID;
1981abe9b8aSliubo 	),
1991abe9b8aSliubo 
20079bcb71aSDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu",
2011abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2028eec8463SDavid Sterba 		  __entry->generation)
2031abe9b8aSliubo );
2041abe9b8aSliubo 
2051abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode,
2061abe9b8aSliubo 
2079a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2081abe9b8aSliubo 
2091abe9b8aSliubo 	TP_ARGS(inode),
2101abe9b8aSliubo 
211bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
212f8f8e189SDavid Sterba 		__field(	u64,  ino			)
21394c3f6c6SDavid Sterba 		__field(	u64,  blocks			)
2141abe9b8aSliubo 		__field(	u64,  disk_i_size		)
2151abe9b8aSliubo 		__field(	u64,  generation		)
2161abe9b8aSliubo 		__field(	u64,  last_trans		)
2171abe9b8aSliubo 		__field(	u64,  logged_trans		)
2181abe9b8aSliubo 		__field(	u64,  root_objectid		)
2191abe9b8aSliubo 	),
2201abe9b8aSliubo 
221bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
222f8f8e189SDavid Sterba 		__entry->ino	= btrfs_ino(BTRFS_I(inode));
2231abe9b8aSliubo 		__entry->blocks	= inode->i_blocks;
2241abe9b8aSliubo 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
2251abe9b8aSliubo 		__entry->generation = BTRFS_I(inode)->generation;
2261abe9b8aSliubo 		__entry->last_trans = BTRFS_I(inode)->last_trans;
2271abe9b8aSliubo 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
2281abe9b8aSliubo 		__entry->root_objectid =
2291abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
2301abe9b8aSliubo 	),
2311abe9b8aSliubo 
232f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
233562a7a07SDavid Sterba 		  "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
2341abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2358eec8463SDavid Sterba 		  __entry->generation,
2368eec8463SDavid Sterba 		  __entry->ino,
23794c3f6c6SDavid Sterba 		  __entry->blocks,
2388eec8463SDavid Sterba 		  __entry->disk_i_size,
2398eec8463SDavid Sterba 		  __entry->last_trans,
2408eec8463SDavid Sterba 		  __entry->logged_trans)
2411abe9b8aSliubo );
2421abe9b8aSliubo 
2431abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
2441abe9b8aSliubo 
2459a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2461abe9b8aSliubo 
2471abe9b8aSliubo 	TP_ARGS(inode)
2481abe9b8aSliubo );
2491abe9b8aSliubo 
2501abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
2511abe9b8aSliubo 
2529a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2531abe9b8aSliubo 
2541abe9b8aSliubo 	TP_ARGS(inode)
2551abe9b8aSliubo );
2561abe9b8aSliubo 
2571abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
2581abe9b8aSliubo 
2599a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2601abe9b8aSliubo 
2611abe9b8aSliubo 	TP_ARGS(inode)
2621abe9b8aSliubo );
2631abe9b8aSliubo 
2641abe9b8aSliubo #define __show_map_type(type)						\
2657f34b746Sliubo 	__print_symbolic_u64(type,					\
2661abe9b8aSliubo 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
2671abe9b8aSliubo 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
2681abe9b8aSliubo 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
2691abe9b8aSliubo 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
2701abe9b8aSliubo 
2711abe9b8aSliubo #define show_map_type(type)			\
2721abe9b8aSliubo 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
2731abe9b8aSliubo 
2741abe9b8aSliubo #define show_map_flags(flag)						\
2751abe9b8aSliubo 	__print_flags(flag, "|",					\
276254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
277254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
278254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
279254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
280254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
281254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
2821abe9b8aSliubo 
2834cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent,
2841abe9b8aSliubo 
2859a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
2869a35b637SJeff Mahoney 		 const struct extent_map *map),
2871abe9b8aSliubo 
28892a1bf76SLiu Bo 	TP_ARGS(root, inode, map),
2891abe9b8aSliubo 
2904cd8587cSSteven Rostedt 	TP_CONDITION(map),
2914cd8587cSSteven Rostedt 
292bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
2931abe9b8aSliubo 		__field(	u64,  root_objectid	)
29492a1bf76SLiu Bo 		__field(	u64,  ino		)
2951abe9b8aSliubo 		__field(	u64,  start		)
2961abe9b8aSliubo 		__field(	u64,  len		)
2971abe9b8aSliubo 		__field(	u64,  orig_start	)
2981abe9b8aSliubo 		__field(	u64,  block_start	)
2991abe9b8aSliubo 		__field(	u64,  block_len		)
3001abe9b8aSliubo 		__field(	unsigned long,  flags	)
3011abe9b8aSliubo 		__field(	int,  refs		)
3021abe9b8aSliubo 		__field(	unsigned int,  compress_type	)
3031abe9b8aSliubo 	),
3041abe9b8aSliubo 
305bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
3061abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
30792a1bf76SLiu Bo 		__entry->ino		= btrfs_ino(inode);
3081abe9b8aSliubo 		__entry->start		= map->start;
3091abe9b8aSliubo 		__entry->len		= map->len;
3101abe9b8aSliubo 		__entry->orig_start	= map->orig_start;
3111abe9b8aSliubo 		__entry->block_start	= map->block_start;
3121abe9b8aSliubo 		__entry->block_len	= map->block_len;
3131abe9b8aSliubo 		__entry->flags		= map->flags;
314490b54d6SElena Reshetova 		__entry->refs		= refcount_read(&map->refs);
3151abe9b8aSliubo 		__entry->compress_type	= map->compress_type;
3161abe9b8aSliubo 	),
3171abe9b8aSliubo 
318562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
319562a7a07SDavid Sterba 		  "orig_start=%llu block_start=%llu(%s) "
320562a7a07SDavid Sterba 		  "block_len=%llu flags=%s refs=%u "
3211abe9b8aSliubo 		  "compress_type=%u",
3221abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3238eec8463SDavid Sterba 		  __entry->ino,
3248eec8463SDavid Sterba 		  __entry->start,
3258eec8463SDavid Sterba 		  __entry->len,
3268eec8463SDavid Sterba 		  __entry->orig_start,
3271abe9b8aSliubo 		  show_map_type(__entry->block_start),
3288eec8463SDavid Sterba 		  __entry->block_len,
3291abe9b8aSliubo 		  show_map_flags(__entry->flags),
3301abe9b8aSliubo 		  __entry->refs, __entry->compress_type)
3311abe9b8aSliubo );
3321abe9b8aSliubo 
333393da918SLiu Bo TRACE_EVENT(btrfs_handle_em_exist,
334393da918SLiu Bo 
3351d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
336f46b24c9SDavid Sterba 		const struct extent_map *existing, const struct extent_map *map,
337f46b24c9SDavid Sterba 		u64 start, u64 len),
338393da918SLiu Bo 
339f46b24c9SDavid Sterba 	TP_ARGS(fs_info, existing, map, start, len),
340393da918SLiu Bo 
341f46b24c9SDavid Sterba 	TP_STRUCT__entry_btrfs(
342393da918SLiu Bo 		__field(	u64,  e_start		)
343393da918SLiu Bo 		__field(	u64,  e_len		)
344393da918SLiu Bo 		__field(	u64,  map_start		)
345393da918SLiu Bo 		__field(	u64,  map_len		)
346393da918SLiu Bo 		__field(	u64,  start		)
347393da918SLiu Bo 		__field(	u64,  len		)
348393da918SLiu Bo 	),
349393da918SLiu Bo 
350f46b24c9SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
351393da918SLiu Bo 		__entry->e_start	= existing->start;
352393da918SLiu Bo 		__entry->e_len		= existing->len;
353393da918SLiu Bo 		__entry->map_start	= map->start;
354393da918SLiu Bo 		__entry->map_len	= map->len;
355393da918SLiu Bo 		__entry->start		= start;
356393da918SLiu Bo 		__entry->len		= len;
357393da918SLiu Bo 	),
358393da918SLiu Bo 
359f46b24c9SDavid Sterba 	TP_printk_btrfs("start=%llu len=%llu "
360393da918SLiu Bo 		  "existing(start=%llu len=%llu) "
361393da918SLiu Bo 		  "em(start=%llu len=%llu)",
3628eec8463SDavid Sterba 		  __entry->start,
3638eec8463SDavid Sterba 		  __entry->len,
3648eec8463SDavid Sterba 		  __entry->e_start,
3658eec8463SDavid Sterba 		  __entry->e_len,
3668eec8463SDavid Sterba 		  __entry->map_start,
3678eec8463SDavid Sterba 		  __entry->map_len)
368393da918SLiu Bo );
369393da918SLiu Bo 
37009ed2f16SLiu Bo /* file extent item */
37109ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
37209ed2f16SLiu Bo 
3731d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
3741d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
37509ed2f16SLiu Bo 
37609ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start),
37709ed2f16SLiu Bo 
37809ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
37909ed2f16SLiu Bo 		__field(	u64,	root_obj	)
38009ed2f16SLiu Bo 		__field(	u64,	ino		)
38109ed2f16SLiu Bo 		__field(	loff_t,	isize		)
38209ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
38309ed2f16SLiu Bo 		__field(	u64,	num_bytes	)
38409ed2f16SLiu Bo 		__field(	u64,	ram_bytes	)
38509ed2f16SLiu Bo 		__field(	u64,	disk_bytenr	)
38609ed2f16SLiu Bo 		__field(	u64,	disk_num_bytes	)
38709ed2f16SLiu Bo 		__field(	u64,	extent_offset	)
38809ed2f16SLiu Bo 		__field(	u8,	extent_type	)
38909ed2f16SLiu Bo 		__field(	u8,	compression	)
39009ed2f16SLiu Bo 		__field(	u64,	extent_start	)
39109ed2f16SLiu Bo 		__field(	u64,	extent_end	)
39209ed2f16SLiu Bo 	),
39309ed2f16SLiu Bo 
39409ed2f16SLiu Bo 	TP_fast_assign_btrfs(bi->root->fs_info,
3954fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
39609ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
39709ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
39809ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
39909ed2f16SLiu Bo 		__entry->num_bytes	= btrfs_file_extent_num_bytes(l, fi);
40009ed2f16SLiu Bo 		__entry->ram_bytes	= btrfs_file_extent_ram_bytes(l, fi);
40109ed2f16SLiu Bo 		__entry->disk_bytenr	= btrfs_file_extent_disk_bytenr(l, fi);
40209ed2f16SLiu Bo 		__entry->disk_num_bytes	= btrfs_file_extent_disk_num_bytes(l, fi);
40309ed2f16SLiu Bo 		__entry->extent_offset	= btrfs_file_extent_offset(l, fi);
40409ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
40509ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
40609ed2f16SLiu Bo 		__entry->extent_start	= start;
40709ed2f16SLiu Bo 		__entry->extent_end	= (start + __entry->num_bytes);
40809ed2f16SLiu Bo 	),
40909ed2f16SLiu Bo 
41009ed2f16SLiu Bo 	TP_printk_btrfs(
41109ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
41209ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
41309ed2f16SLiu Bo 		"(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
41409ed2f16SLiu Bo 		"disk_num_bytes=%llu extent_offset=%llu type=%s "
41509ed2f16SLiu Bo 		"compression=%u",
41609ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino,
41709ed2f16SLiu Bo 		__entry->isize,
41809ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
41909ed2f16SLiu Bo 		__entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
42009ed2f16SLiu Bo 		__entry->disk_bytenr, __entry->disk_num_bytes,
4210840dd28SNikolay Borisov 		__entry->extent_offset, __print_symbolic(__entry->extent_type, FI_TYPES),
42209ed2f16SLiu Bo 		__entry->compression)
42309ed2f16SLiu Bo );
42409ed2f16SLiu Bo 
42509ed2f16SLiu Bo DECLARE_EVENT_CLASS(
42609ed2f16SLiu Bo 	btrfs__file_extent_item_inline,
42709ed2f16SLiu Bo 
4281d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4291d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
43009ed2f16SLiu Bo 
43109ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot,  start),
43209ed2f16SLiu Bo 
43309ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
43409ed2f16SLiu Bo 		__field(	u64,	root_obj	)
43509ed2f16SLiu Bo 		__field(	u64,	ino		)
43609ed2f16SLiu Bo 		__field(	loff_t,	isize		)
43709ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
43809ed2f16SLiu Bo 		__field(	u8,	extent_type	)
43909ed2f16SLiu Bo 		__field(	u8,	compression	)
44009ed2f16SLiu Bo 		__field(	u64,	extent_start	)
44109ed2f16SLiu Bo 		__field(	u64,	extent_end	)
44209ed2f16SLiu Bo 	),
44309ed2f16SLiu Bo 
44409ed2f16SLiu Bo 	TP_fast_assign_btrfs(
44509ed2f16SLiu Bo 		bi->root->fs_info,
4464fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
44709ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
44809ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
44909ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
45009ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
45109ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
45209ed2f16SLiu Bo 		__entry->extent_start	= start;
453e41ca589SQu Wenruo 		__entry->extent_end	= (start + btrfs_file_extent_ram_bytes(l, fi));
45409ed2f16SLiu Bo 	),
45509ed2f16SLiu Bo 
45609ed2f16SLiu Bo 	TP_printk_btrfs(
45709ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
45809ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
45909ed2f16SLiu Bo 		"extent_type=%s compression=%u",
46009ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
46109ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
4620840dd28SNikolay Borisov 		__entry->extent_end, __print_symbolic(__entry->extent_type, FI_TYPES),
46309ed2f16SLiu Bo 		__entry->compression)
46409ed2f16SLiu Bo );
46509ed2f16SLiu Bo 
46609ed2f16SLiu Bo DEFINE_EVENT(
46709ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
46809ed2f16SLiu Bo 
4691d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4701d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
47109ed2f16SLiu Bo 
47209ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
47309ed2f16SLiu Bo );
47409ed2f16SLiu Bo 
47509ed2f16SLiu Bo DEFINE_EVENT(
47609ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
47709ed2f16SLiu Bo 
4781d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4791d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
48009ed2f16SLiu Bo 
48109ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
48209ed2f16SLiu Bo );
48309ed2f16SLiu Bo 
48409ed2f16SLiu Bo DEFINE_EVENT(
48509ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
48609ed2f16SLiu Bo 
4871d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4881d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
48909ed2f16SLiu Bo 
49009ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
49109ed2f16SLiu Bo );
49209ed2f16SLiu Bo 
49309ed2f16SLiu Bo DEFINE_EVENT(
49409ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
49509ed2f16SLiu Bo 
4961d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4971d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
49809ed2f16SLiu Bo 
49909ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
50009ed2f16SLiu Bo );
50109ed2f16SLiu Bo 
5021abe9b8aSliubo #define show_ordered_flags(flags)					   \
5039d04a8ceSLiu Bo 	__print_flags(flags, "|",					   \
5043c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_REGULAR), 	"REGULAR" 	}, \
5053c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_NOCOW), 		"NOCOW" 	}, \
5063c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_PREALLOC), 	"PREALLOC" 	}, \
5073c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_COMPRESSED), 	"COMPRESSED" 	}, \
5083c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_DIRECT),	 	"DIRECT" 	}, \
5099d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IO_DONE), 	"IO_DONE" 	}, \
5109d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_COMPLETE), 	"COMPLETE" 	}, \
5119d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IOERR), 		"IOERR" 	}, \
512792ddef0SLiu Bo 		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
513e112e2b4SLiu Bo 
5141abe9b8aSliubo 
5151abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent,
5161abe9b8aSliubo 
517acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5189a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5191abe9b8aSliubo 
5201abe9b8aSliubo 	TP_ARGS(inode, ordered),
5211abe9b8aSliubo 
522bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
523f8f8e189SDavid Sterba 		__field(	u64,  ino		)
5241abe9b8aSliubo 		__field(	u64,  file_offset	)
5251abe9b8aSliubo 		__field(	u64,  start		)
5261abe9b8aSliubo 		__field(	u64,  len		)
5271abe9b8aSliubo 		__field(	u64,  disk_len		)
5281abe9b8aSliubo 		__field(	u64,  bytes_left	)
5291abe9b8aSliubo 		__field(	unsigned long,  flags	)
5301abe9b8aSliubo 		__field(	int,  compress_type	)
5311abe9b8aSliubo 		__field(	int,  refs		)
5321abe9b8aSliubo 		__field(	u64,  root_objectid	)
53378566548SLiu Bo 		__field(	u64,  truncated_len	)
5341abe9b8aSliubo 	),
5351abe9b8aSliubo 
536acbf1dd0SNikolay Borisov 	TP_fast_assign_btrfs(inode->root->fs_info,
537acbf1dd0SNikolay Borisov 		__entry->ino 		= btrfs_ino(inode);
5381abe9b8aSliubo 		__entry->file_offset	= ordered->file_offset;
539bffe633eSOmar Sandoval 		__entry->start		= ordered->disk_bytenr;
540bffe633eSOmar Sandoval 		__entry->len		= ordered->num_bytes;
541bffe633eSOmar Sandoval 		__entry->disk_len	= ordered->disk_num_bytes;
5421abe9b8aSliubo 		__entry->bytes_left	= ordered->bytes_left;
5431abe9b8aSliubo 		__entry->flags		= ordered->flags;
5441abe9b8aSliubo 		__entry->compress_type	= ordered->compress_type;
545e76edab7SElena Reshetova 		__entry->refs		= refcount_read(&ordered->refs);
546acbf1dd0SNikolay Borisov 		__entry->root_objectid	= inode->root->root_key.objectid;
54778566548SLiu Bo 		__entry->truncated_len	= ordered->truncated_len;
5481abe9b8aSliubo 	),
5491abe9b8aSliubo 
550562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
551562a7a07SDavid Sterba 		  "start=%llu len=%llu disk_len=%llu "
552562a7a07SDavid Sterba 		  "truncated_len=%llu "
553562a7a07SDavid Sterba 		  "bytes_left=%llu flags=%s compress_type=%d "
5541abe9b8aSliubo 		  "refs=%d",
5551abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
5568eec8463SDavid Sterba 		  __entry->ino,
5578eec8463SDavid Sterba 		  __entry->file_offset,
5588eec8463SDavid Sterba 		  __entry->start,
5598eec8463SDavid Sterba 		  __entry->len,
5608eec8463SDavid Sterba 		  __entry->disk_len,
5618eec8463SDavid Sterba 		  __entry->truncated_len,
5628eec8463SDavid Sterba 		  __entry->bytes_left,
5631abe9b8aSliubo 		  show_ordered_flags(__entry->flags),
5641abe9b8aSliubo 		  __entry->compress_type, __entry->refs)
5651abe9b8aSliubo );
5661abe9b8aSliubo 
5671abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
5681abe9b8aSliubo 
569acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5709a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5711abe9b8aSliubo 
5721abe9b8aSliubo 	TP_ARGS(inode, ordered)
5731abe9b8aSliubo );
5741abe9b8aSliubo 
5751abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
5761abe9b8aSliubo 
577acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5789a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5791abe9b8aSliubo 
5801abe9b8aSliubo 	TP_ARGS(inode, ordered)
5811abe9b8aSliubo );
5821abe9b8aSliubo 
5831abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
5841abe9b8aSliubo 
585acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5869a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5871abe9b8aSliubo 
5881abe9b8aSliubo 	TP_ARGS(inode, ordered)
5891abe9b8aSliubo );
5901abe9b8aSliubo 
5911abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
5921abe9b8aSliubo 
593acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5949a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5951abe9b8aSliubo 
5961abe9b8aSliubo 	TP_ARGS(inode, ordered)
5971abe9b8aSliubo );
5981abe9b8aSliubo 
5995bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup,
6005bea2508SJohannes Thumshirn 
6015bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6025bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6035bea2508SJohannes Thumshirn 
6045bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6055bea2508SJohannes Thumshirn );
6065bea2508SJohannes Thumshirn 
6075bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_range,
6085bea2508SJohannes Thumshirn 
6095bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6105bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6115bea2508SJohannes Thumshirn 
6125bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6135bea2508SJohannes Thumshirn );
6145bea2508SJohannes Thumshirn 
6155bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_first_range,
6165bea2508SJohannes Thumshirn 
6175bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6185bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6195bea2508SJohannes Thumshirn 
6205bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6215bea2508SJohannes Thumshirn );
6225bea2508SJohannes Thumshirn 
6235bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_for_logging,
6245bea2508SJohannes Thumshirn 
6255bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6265bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6275bea2508SJohannes Thumshirn 
6285bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6295bea2508SJohannes Thumshirn );
6305bea2508SJohannes Thumshirn 
6315bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_first,
6325bea2508SJohannes Thumshirn 
6335bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6345bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6355bea2508SJohannes Thumshirn 
6365bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6375bea2508SJohannes Thumshirn );
6385bea2508SJohannes Thumshirn 
6395bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_split,
6405bea2508SJohannes Thumshirn 
6415bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6425bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6435bea2508SJohannes Thumshirn 
6445bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6455bea2508SJohannes Thumshirn );
6465bea2508SJohannes Thumshirn 
6475bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_dec_test_pending,
6485bea2508SJohannes Thumshirn 
6495bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6505bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6515bea2508SJohannes Thumshirn 
6525bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6535bea2508SJohannes Thumshirn );
6545bea2508SJohannes Thumshirn 
6555bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_mark_finished,
6565bea2508SJohannes Thumshirn 
6575bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
6585bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
6595bea2508SJohannes Thumshirn 
6605bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
6615bea2508SJohannes Thumshirn );
6625bea2508SJohannes Thumshirn 
663122e9edeSChristoph Hellwig TRACE_EVENT(btrfs_finish_ordered_extent,
664122e9edeSChristoph Hellwig 
665122e9edeSChristoph Hellwig 	TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 len,
666122e9edeSChristoph Hellwig 		 bool uptodate),
667122e9edeSChristoph Hellwig 
668122e9edeSChristoph Hellwig 	TP_ARGS(inode, start, len, uptodate),
669122e9edeSChristoph Hellwig 
670122e9edeSChristoph Hellwig 	TP_STRUCT__entry_btrfs(
671122e9edeSChristoph Hellwig 		__field(	u64,	 ino		)
672122e9edeSChristoph Hellwig 		__field(	u64,	 start		)
673122e9edeSChristoph Hellwig 		__field(	u64,	 len		)
674122e9edeSChristoph Hellwig 		__field(	bool,	 uptodate	)
675122e9edeSChristoph Hellwig 		__field(	u64,	 root_objectid	)
676122e9edeSChristoph Hellwig 	),
677122e9edeSChristoph Hellwig 
678122e9edeSChristoph Hellwig 	TP_fast_assign_btrfs(inode->root->fs_info,
679122e9edeSChristoph Hellwig 		__entry->ino	= btrfs_ino(inode);
680122e9edeSChristoph Hellwig 		__entry->start	= start;
681122e9edeSChristoph Hellwig 		__entry->len	= len;
682122e9edeSChristoph Hellwig 		__entry->uptodate = uptodate;
683122e9edeSChristoph Hellwig 		__entry->root_objectid = inode->root->root_key.objectid;
684122e9edeSChristoph Hellwig 	),
685122e9edeSChristoph Hellwig 
686122e9edeSChristoph Hellwig 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu uptodate=%d",
687122e9edeSChristoph Hellwig 		  show_root_type(__entry->root_objectid),
688122e9edeSChristoph Hellwig 		  __entry->ino, __entry->start,
689122e9edeSChristoph Hellwig 		  __entry->len, !!__entry->uptodate)
690122e9edeSChristoph Hellwig );
691122e9edeSChristoph Hellwig 
6921abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage,
6931abe9b8aSliubo 
6949a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
6959a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
6961abe9b8aSliubo 
6971abe9b8aSliubo 	TP_ARGS(page, inode, wbc),
6981abe9b8aSliubo 
699bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
700f8f8e189SDavid Sterba 		__field(	u64,	ino			)
7011abe9b8aSliubo 		__field(	pgoff_t,  index			)
7021abe9b8aSliubo 		__field(	long,   nr_to_write		)
7031abe9b8aSliubo 		__field(	long,   pages_skipped		)
7041abe9b8aSliubo 		__field(	loff_t, range_start		)
7051abe9b8aSliubo 		__field(	loff_t, range_end		)
7061abe9b8aSliubo 		__field(	char,   for_kupdate		)
7071abe9b8aSliubo 		__field(	char,   for_reclaim		)
7081abe9b8aSliubo 		__field(	char,   range_cyclic		)
70994c3f6c6SDavid Sterba 		__field(	unsigned long,  writeback_index	)
7101abe9b8aSliubo 		__field(	u64,    root_objectid		)
7111abe9b8aSliubo 	),
7121abe9b8aSliubo 
713bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
714f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
7151abe9b8aSliubo 		__entry->index		= page->index;
7161abe9b8aSliubo 		__entry->nr_to_write	= wbc->nr_to_write;
7171abe9b8aSliubo 		__entry->pages_skipped	= wbc->pages_skipped;
7181abe9b8aSliubo 		__entry->range_start	= wbc->range_start;
7191abe9b8aSliubo 		__entry->range_end	= wbc->range_end;
7201abe9b8aSliubo 		__entry->for_kupdate	= wbc->for_kupdate;
7211abe9b8aSliubo 		__entry->for_reclaim	= wbc->for_reclaim;
7221abe9b8aSliubo 		__entry->range_cyclic	= wbc->range_cyclic;
7231abe9b8aSliubo 		__entry->writeback_index = inode->i_mapping->writeback_index;
7241abe9b8aSliubo 		__entry->root_objectid	=
7251abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
7261abe9b8aSliubo 	),
7271abe9b8aSliubo 
728f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
729562a7a07SDavid Sterba 		  "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
730562a7a07SDavid Sterba 		  "range_end=%llu for_kupdate=%d "
731562a7a07SDavid Sterba 		  "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
7321abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
7338eec8463SDavid Sterba 		  __entry->ino, __entry->index,
7341abe9b8aSliubo 		  __entry->nr_to_write, __entry->pages_skipped,
7351abe9b8aSliubo 		  __entry->range_start, __entry->range_end,
736846d5a09SWu Fengguang 		  __entry->for_kupdate,
7371abe9b8aSliubo 		  __entry->for_reclaim, __entry->range_cyclic,
73894c3f6c6SDavid Sterba 		  __entry->writeback_index)
7391abe9b8aSliubo );
7401abe9b8aSliubo 
7411abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage,
7421abe9b8aSliubo 
7439a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
7449a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
7451abe9b8aSliubo 
7461abe9b8aSliubo 	TP_ARGS(page, inode, wbc)
7471abe9b8aSliubo );
7481abe9b8aSliubo 
7491abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook,
7501abe9b8aSliubo 
75138a39ac7SQu Wenruo 	TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 end,
75238a39ac7SQu Wenruo 		 int uptodate),
7531abe9b8aSliubo 
75438a39ac7SQu Wenruo 	TP_ARGS(inode, start, end, uptodate),
7551abe9b8aSliubo 
756bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
757f8f8e189SDavid Sterba 		__field(	u64,	 ino		)
7581abe9b8aSliubo 		__field(	u64,	 start		)
7591abe9b8aSliubo 		__field(	u64,	 end		)
7601abe9b8aSliubo 		__field(	int,	 uptodate	)
7611abe9b8aSliubo 		__field(	u64,    root_objectid	)
7621abe9b8aSliubo 	),
7631abe9b8aSliubo 
76438a39ac7SQu Wenruo 	TP_fast_assign_btrfs(inode->root->fs_info,
76538a39ac7SQu Wenruo 		__entry->ino	= btrfs_ino(inode);
7661abe9b8aSliubo 		__entry->start	= start;
7671abe9b8aSliubo 		__entry->end	= end;
7681abe9b8aSliubo 		__entry->uptodate = uptodate;
76938a39ac7SQu Wenruo 		__entry->root_objectid = inode->root->root_key.objectid;
7701abe9b8aSliubo 	),
7711abe9b8aSliubo 
77238a39ac7SQu Wenruo 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu end=%llu uptodate=%d",
7731abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
77438a39ac7SQu Wenruo 		  __entry->ino, __entry->start,
7758eec8463SDavid Sterba 		  __entry->end, __entry->uptodate)
7761abe9b8aSliubo );
7771abe9b8aSliubo 
7781abe9b8aSliubo TRACE_EVENT(btrfs_sync_file,
7791abe9b8aSliubo 
7809a35b637SJeff Mahoney 	TP_PROTO(const struct file *file, int datasync),
7811abe9b8aSliubo 
7821abe9b8aSliubo 	TP_ARGS(file, datasync),
7831abe9b8aSliubo 
784bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
785f8f8e189SDavid Sterba 		__field(	u64,	ino		)
786f8f8e189SDavid Sterba 		__field(	u64,	parent		)
7871abe9b8aSliubo 		__field(	int,    datasync	)
7881abe9b8aSliubo 		__field(	u64,    root_objectid	)
7891abe9b8aSliubo 	),
7901abe9b8aSliubo 
7911abe9b8aSliubo 	TP_fast_assign(
7929a35b637SJeff Mahoney 		const struct dentry *dentry = file->f_path.dentry;
7939a35b637SJeff Mahoney 		const struct inode *inode = d_inode(dentry);
7941abe9b8aSliubo 
795bc074524SJeff Mahoney 		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
796f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
797f8f8e189SDavid Sterba 		__entry->parent		= btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
7981abe9b8aSliubo 		__entry->datasync	= datasync;
7991abe9b8aSliubo 		__entry->root_objectid	=
8001abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
8011abe9b8aSliubo 	),
8021abe9b8aSliubo 
803f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
8041abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
8058eec8463SDavid Sterba 		  __entry->ino,
8068eec8463SDavid Sterba 		  __entry->parent,
8071abe9b8aSliubo 		  __entry->datasync)
8081abe9b8aSliubo );
8091abe9b8aSliubo 
8101abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs,
8111abe9b8aSliubo 
8129a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
8131abe9b8aSliubo 
814bc074524SJeff Mahoney 	TP_ARGS(fs_info, wait),
8151abe9b8aSliubo 
816bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
8171abe9b8aSliubo 		__field(	int,  wait		)
8181abe9b8aSliubo 	),
8191abe9b8aSliubo 
820bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
8211abe9b8aSliubo 		__entry->wait	= wait;
8221abe9b8aSliubo 	),
8231abe9b8aSliubo 
824bc074524SJeff Mahoney 	TP_printk_btrfs("wait=%d", __entry->wait)
8251abe9b8aSliubo );
8261abe9b8aSliubo 
827c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group,
828c83f8effSJosef Bacik 
8299a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
83032da5386SDavid Sterba 		 const struct btrfs_block_group *block_group, int create),
831c83f8effSJosef Bacik 
832c83f8effSJosef Bacik 	TP_ARGS(fs_info, block_group, create),
833c83f8effSJosef Bacik 
8342e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
835c83f8effSJosef Bacik 		__field(	u64,	offset			)
836c83f8effSJosef Bacik 		__field(	u64,	size			)
837c83f8effSJosef Bacik 		__field(	u64,	flags			)
838c83f8effSJosef Bacik 		__field(	u64,	bytes_used		)
839c83f8effSJosef Bacik 		__field(	u64,	bytes_super		)
840c83f8effSJosef Bacik 		__field(	int,	create			)
841c83f8effSJosef Bacik 	),
842c83f8effSJosef Bacik 
8432e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
844b3470b5dSDavid Sterba 		__entry->offset		= block_group->start;
845b3470b5dSDavid Sterba 		__entry->size		= block_group->length;
846c83f8effSJosef Bacik 		__entry->flags		= block_group->flags;
847bf38be65SDavid Sterba 		__entry->bytes_used	= block_group->used;
848c83f8effSJosef Bacik 		__entry->bytes_super	= block_group->bytes_super;
849c83f8effSJosef Bacik 		__entry->create		= create;
850c83f8effSJosef Bacik 	),
851c83f8effSJosef Bacik 
8522e63e62dSDavid Sterba 	TP_printk_btrfs("block_group offset=%llu size=%llu "
853562a7a07SDavid Sterba 		  "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
8542e63e62dSDavid Sterba 		  "create=%d",
8558eec8463SDavid Sterba 		  __entry->offset,
8568eec8463SDavid Sterba 		  __entry->size,
8578eec8463SDavid Sterba 		  __entry->flags,
858c83f8effSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
859c83f8effSJosef Bacik 				BTRFS_GROUP_FLAGS),
8608eec8463SDavid Sterba 		  __entry->bytes_used,
8618eec8463SDavid Sterba 		  __entry->bytes_super, __entry->create)
862c83f8effSJosef Bacik );
863c83f8effSJosef Bacik 
8641abe9b8aSliubo #define show_ref_action(action)						\
8651abe9b8aSliubo 	__print_symbolic(action,					\
8661abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
8671abe9b8aSliubo 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
8681abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
8691abe9b8aSliubo 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
8701abe9b8aSliubo 
8711abe9b8aSliubo 
872599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
8731abe9b8aSliubo 
8749a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8759a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8769a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
8771abe9b8aSliubo 		 int action),
8781abe9b8aSliubo 
879bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
8801abe9b8aSliubo 
881bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
8821abe9b8aSliubo 		__field(	u64,  bytenr		)
8831abe9b8aSliubo 		__field(	u64,  num_bytes		)
8841abe9b8aSliubo 		__field(	int,  action		)
8851abe9b8aSliubo 		__field(	u64,  parent		)
8861abe9b8aSliubo 		__field(	u64,  ref_root		)
8871abe9b8aSliubo 		__field(	int,  level		)
8881abe9b8aSliubo 		__field(	int,  type		)
889dea7d76eSLiu Bo 		__field(	u64,  seq		)
8901abe9b8aSliubo 	),
8911abe9b8aSliubo 
892bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
8931abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
8941abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
8951abe9b8aSliubo 		__entry->action		= action;
8961abe9b8aSliubo 		__entry->parent		= full_ref->parent;
8971abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
8981abe9b8aSliubo 		__entry->level		= full_ref->level;
8991abe9b8aSliubo 		__entry->type		= ref->type;
900dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
9011abe9b8aSliubo 	),
9021abe9b8aSliubo 
903562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
904562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) level=%d "
905562a7a07SDavid Sterba 		  "type=%s seq=%llu",
9068eec8463SDavid Sterba 		  __entry->bytenr,
9078eec8463SDavid Sterba 		  __entry->num_bytes,
9081abe9b8aSliubo 		  show_ref_action(__entry->action),
9091abe9b8aSliubo 		  show_root_type(__entry->parent),
9101abe9b8aSliubo 		  show_root_type(__entry->ref_root),
911dea7d76eSLiu Bo 		  __entry->level, show_ref_type(__entry->type),
9128eec8463SDavid Sterba 		  __entry->seq)
9131abe9b8aSliubo );
9141abe9b8aSliubo 
915599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
916599c75ecSLiu Bo 
9179a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9189a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9199a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
920599c75ecSLiu Bo 		 int action),
921599c75ecSLiu Bo 
922bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
923599c75ecSLiu Bo );
924599c75ecSLiu Bo 
925599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
926599c75ecSLiu Bo 
9279a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9289a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9299a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
930599c75ecSLiu Bo 		 int action),
931599c75ecSLiu Bo 
932bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
933599c75ecSLiu Bo );
934599c75ecSLiu Bo 
935599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
9361abe9b8aSliubo 
9379a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9389a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9399a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
9401abe9b8aSliubo 		 int action),
9411abe9b8aSliubo 
942bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
9431abe9b8aSliubo 
944bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9451abe9b8aSliubo 		__field(	u64,  bytenr		)
9461abe9b8aSliubo 		__field(	u64,  num_bytes		)
9471abe9b8aSliubo 		__field(	int,  action		)
9481abe9b8aSliubo 		__field(	u64,  parent		)
9491abe9b8aSliubo 		__field(	u64,  ref_root		)
9501abe9b8aSliubo 		__field(	u64,  owner		)
9511abe9b8aSliubo 		__field(	u64,  offset		)
9521abe9b8aSliubo 		__field(	int,  type		)
953dea7d76eSLiu Bo 		__field(	u64,  seq		)
9541abe9b8aSliubo 	),
9551abe9b8aSliubo 
956bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
9571abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
9581abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
9591abe9b8aSliubo 		__entry->action		= action;
9601abe9b8aSliubo 		__entry->parent		= full_ref->parent;
9611abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
9621abe9b8aSliubo 		__entry->owner		= full_ref->objectid;
9631abe9b8aSliubo 		__entry->offset		= full_ref->offset;
9641abe9b8aSliubo 		__entry->type		= ref->type;
965dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
9661abe9b8aSliubo 	),
9671abe9b8aSliubo 
968562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
969562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
970562a7a07SDavid Sterba 		  "offset=%llu type=%s seq=%llu",
9718eec8463SDavid Sterba 		  __entry->bytenr,
9728eec8463SDavid Sterba 		  __entry->num_bytes,
9731abe9b8aSliubo 		  show_ref_action(__entry->action),
9741abe9b8aSliubo 		  show_root_type(__entry->parent),
9751abe9b8aSliubo 		  show_root_type(__entry->ref_root),
9768eec8463SDavid Sterba 		  __entry->owner,
9778eec8463SDavid Sterba 		  __entry->offset,
978dea7d76eSLiu Bo 		  show_ref_type(__entry->type),
9798eec8463SDavid Sterba 		  __entry->seq)
9801abe9b8aSliubo );
9811abe9b8aSliubo 
982599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
983599c75ecSLiu Bo 
9849a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9859a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9869a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
987599c75ecSLiu Bo 		 int action),
988599c75ecSLiu Bo 
989bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
990599c75ecSLiu Bo );
991599c75ecSLiu Bo 
992599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
993599c75ecSLiu Bo 
9949a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9959a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9969a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
997599c75ecSLiu Bo 		 int action),
998599c75ecSLiu Bo 
999bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
1000599c75ecSLiu Bo );
1001599c75ecSLiu Bo 
1002599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
10031abe9b8aSliubo 
10049a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10059a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
10061abe9b8aSliubo 		 int action),
10071abe9b8aSliubo 
1008d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action),
10091abe9b8aSliubo 
1010bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10111abe9b8aSliubo 		__field(	u64,  bytenr		)
10121abe9b8aSliubo 		__field(	u64,  num_bytes		)
10131abe9b8aSliubo 		__field(	int,  action		)
10141abe9b8aSliubo 		__field(	int,  is_data		)
10151abe9b8aSliubo 	),
10161abe9b8aSliubo 
1017bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
1018d278850eSJosef Bacik 		__entry->bytenr		= head_ref->bytenr;
1019d278850eSJosef Bacik 		__entry->num_bytes	= head_ref->num_bytes;
10201abe9b8aSliubo 		__entry->action		= action;
10211abe9b8aSliubo 		__entry->is_data	= head_ref->is_data;
10221abe9b8aSliubo 	),
10231abe9b8aSliubo 
1024562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
10258eec8463SDavid Sterba 		  __entry->bytenr,
10268eec8463SDavid Sterba 		  __entry->num_bytes,
10271abe9b8aSliubo 		  show_ref_action(__entry->action),
10281abe9b8aSliubo 		  __entry->is_data)
10291abe9b8aSliubo );
10301abe9b8aSliubo 
1031599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
1032599c75ecSLiu Bo 
10339a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10349a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
1035599c75ecSLiu Bo 		 int action),
1036599c75ecSLiu Bo 
1037d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
1038599c75ecSLiu Bo );
1039599c75ecSLiu Bo 
1040599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
1041599c75ecSLiu Bo 
10429a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10439a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
1044599c75ecSLiu Bo 		 int action),
1045599c75ecSLiu Bo 
1046d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
1047599c75ecSLiu Bo );
1048599c75ecSLiu Bo 
10491abe9b8aSliubo #define show_chunk_type(type)					\
10501abe9b8aSliubo 	__print_flags(type, "|",				\
10511abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
10521abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
10531abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
10541abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
10551abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
10561abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
1057e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
1058e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
1059e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
10601abe9b8aSliubo 
10611abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk,
10621abe9b8aSliubo 
10639a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10649a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10651abe9b8aSliubo 
10666bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size),
10671abe9b8aSliubo 
1068bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10691abe9b8aSliubo 		__field(	int,  num_stripes		)
10701abe9b8aSliubo 		__field(	u64,  type			)
10711abe9b8aSliubo 		__field(	int,  sub_stripes		)
10721abe9b8aSliubo 		__field(	u64,  offset			)
10731abe9b8aSliubo 		__field(	u64,  size			)
10741abe9b8aSliubo 		__field(	u64,  root_objectid		)
10751abe9b8aSliubo 	),
10761abe9b8aSliubo 
10776bccf3abSJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
10781abe9b8aSliubo 		__entry->num_stripes	= map->num_stripes;
10791abe9b8aSliubo 		__entry->type		= map->type;
10801abe9b8aSliubo 		__entry->sub_stripes	= map->sub_stripes;
10811abe9b8aSliubo 		__entry->offset		= offset;
10821abe9b8aSliubo 		__entry->size		= size;
10836bccf3abSJeff Mahoney 		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
10841abe9b8aSliubo 	),
10851abe9b8aSliubo 
1086562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
1087562a7a07SDavid Sterba 		  "num_stripes=%d sub_stripes=%d type=%s",
10881abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
10898eec8463SDavid Sterba 		  __entry->offset,
10908eec8463SDavid Sterba 		  __entry->size,
10911abe9b8aSliubo 		  __entry->num_stripes, __entry->sub_stripes,
10921abe9b8aSliubo 		  show_chunk_type(__entry->type))
10931abe9b8aSliubo );
10941abe9b8aSliubo 
10951abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
10961abe9b8aSliubo 
10979a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10989a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10991abe9b8aSliubo 
11006bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
11011abe9b8aSliubo );
11021abe9b8aSliubo 
11031abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
11041abe9b8aSliubo 
11059a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
11069a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
11071abe9b8aSliubo 
11086bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
11091abe9b8aSliubo );
11101abe9b8aSliubo 
11111abe9b8aSliubo TRACE_EVENT(btrfs_cow_block,
11121abe9b8aSliubo 
11139a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
11149a35b637SJeff Mahoney 		 const struct extent_buffer *cow),
11151abe9b8aSliubo 
11161abe9b8aSliubo 	TP_ARGS(root, buf, cow),
11171abe9b8aSliubo 
1118bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
11191abe9b8aSliubo 		__field(	u64,  root_objectid		)
11201abe9b8aSliubo 		__field(	u64,  buf_start			)
11211abe9b8aSliubo 		__field(	int,  refs			)
11221abe9b8aSliubo 		__field(	u64,  cow_start			)
11231abe9b8aSliubo 		__field(	int,  buf_level			)
11241abe9b8aSliubo 		__field(	int,  cow_level			)
11251abe9b8aSliubo 	),
11261abe9b8aSliubo 
1127bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
11281abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
11291abe9b8aSliubo 		__entry->buf_start	= buf->start;
11301abe9b8aSliubo 		__entry->refs		= atomic_read(&buf->refs);
11311abe9b8aSliubo 		__entry->cow_start	= cow->start;
11321abe9b8aSliubo 		__entry->buf_level	= btrfs_header_level(buf);
11331abe9b8aSliubo 		__entry->cow_level	= btrfs_header_level(cow);
11341abe9b8aSliubo 	),
11351abe9b8aSliubo 
1136562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
1137562a7a07SDavid Sterba 		  "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
11381abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
11391abe9b8aSliubo 		  __entry->refs,
11408eec8463SDavid Sterba 		  __entry->buf_start,
11411abe9b8aSliubo 		  __entry->buf_level,
11428eec8463SDavid Sterba 		  __entry->cow_start,
11431abe9b8aSliubo 		  __entry->cow_level)
11441abe9b8aSliubo );
11451abe9b8aSliubo 
11468c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation,
11478c2a3ca2SJosef Bacik 
11481d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val,
11498c2a3ca2SJosef Bacik 		 u64 bytes, int reserve),
11508c2a3ca2SJosef Bacik 
11518c2a3ca2SJosef Bacik 	TP_ARGS(fs_info, type, val, bytes, reserve),
11528c2a3ca2SJosef Bacik 
1153bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
11548c2a3ca2SJosef Bacik 		__string(	type,	type			)
11558c2a3ca2SJosef Bacik 		__field(	u64,	val			)
11568c2a3ca2SJosef Bacik 		__field(	u64,	bytes			)
11578c2a3ca2SJosef Bacik 		__field(	int,	reserve			)
11588c2a3ca2SJosef Bacik 	),
11598c2a3ca2SJosef Bacik 
1160bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
11618c2a3ca2SJosef Bacik 		__assign_str(type, type);
11628c2a3ca2SJosef Bacik 		__entry->val		= val;
11638c2a3ca2SJosef Bacik 		__entry->bytes		= bytes;
11648c2a3ca2SJosef Bacik 		__entry->reserve	= reserve;
11658c2a3ca2SJosef Bacik 	),
11668c2a3ca2SJosef Bacik 
11675439c7f5SDavid Sterba 	TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
1168bc074524SJeff Mahoney 			__entry->reserve ? "reserve" : "release",
11698c2a3ca2SJosef Bacik 			__entry->bytes)
11708c2a3ca2SJosef Bacik );
11718c2a3ca2SJosef Bacik 
1172f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush,
1173f376df2bSJosef Bacik 
11749a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
11751d2e7c7cSDavid Sterba 		 int flush, const char *reason),
1176f376df2bSJosef Bacik 
1177f376df2bSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, flush, reason),
1178f376df2bSJosef Bacik 
11792e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1180f376df2bSJosef Bacik 		__field(	u64,	flags			)
1181f376df2bSJosef Bacik 		__field(	u64,	bytes			)
1182f376df2bSJosef Bacik 		__field(	int,	flush			)
1183f376df2bSJosef Bacik 		__string(	reason,	reason			)
1184f376df2bSJosef Bacik 	),
1185f376df2bSJosef Bacik 
11862e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1187f376df2bSJosef Bacik 		__entry->flags	= flags;
1188f376df2bSJosef Bacik 		__entry->bytes	= bytes;
1189f376df2bSJosef Bacik 		__entry->flush	= flush;
119078c14b38SJoe Perches 		__assign_str(reason, reason);
1191f376df2bSJosef Bacik 	),
1192f376df2bSJosef Bacik 
11932e63e62dSDavid Sterba 	TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
11942e63e62dSDavid Sterba 		  __get_str(reason), __entry->flush,
119545e31869SNikolay Borisov 		  __print_symbolic(__entry->flush, FLUSH_ACTIONS),
11968eec8463SDavid Sterba 		  __entry->flags,
1197f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1198f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
11998eec8463SDavid Sterba 		  __entry->bytes)
1200f376df2bSJosef Bacik );
1201f376df2bSJosef Bacik 
1202f376df2bSJosef Bacik 
1203f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space,
1204f376df2bSJosef Bacik 
12059a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
12064b02b00fSJosef Bacik 		 int state, int ret, bool for_preempt),
1207f376df2bSJosef Bacik 
12084b02b00fSJosef Bacik 	TP_ARGS(fs_info, flags, num_bytes, state, ret, for_preempt),
1209f376df2bSJosef Bacik 
12102e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1211f376df2bSJosef Bacik 		__field(	u64,	flags			)
1212f376df2bSJosef Bacik 		__field(	u64,	num_bytes		)
1213f376df2bSJosef Bacik 		__field(	int,	state			)
1214f376df2bSJosef Bacik 		__field(	int,	ret			)
12154b02b00fSJosef Bacik 		__field(       bool,	for_preempt		)
1216f376df2bSJosef Bacik 	),
1217f376df2bSJosef Bacik 
12182e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1219f376df2bSJosef Bacik 		__entry->flags		=	flags;
1220f376df2bSJosef Bacik 		__entry->num_bytes	=	num_bytes;
1221f376df2bSJosef Bacik 		__entry->state		=	state;
1222f376df2bSJosef Bacik 		__entry->ret		=	ret;
12234b02b00fSJosef Bacik 		__entry->for_preempt	=	for_preempt;
1224f376df2bSJosef Bacik 	),
1225f376df2bSJosef Bacik 
12264b02b00fSJosef Bacik 	TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d for_preempt=%d",
12272e63e62dSDavid Sterba 		  __entry->state,
1228f0cdd15cSNikolay Borisov 		  __print_symbolic(__entry->state, FLUSH_STATES),
12298eec8463SDavid Sterba 		  __entry->flags,
1230f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1231f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
12324b02b00fSJosef Bacik 		  __entry->num_bytes, __entry->ret, __entry->for_preempt)
1233f376df2bSJosef Bacik );
1234f376df2bSJosef Bacik 
12351abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent,
12361abe9b8aSliubo 
12379a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
12381abe9b8aSliubo 
123971ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len),
12401abe9b8aSliubo 
1241bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12421abe9b8aSliubo 		__field(	u64,  start			)
12431abe9b8aSliubo 		__field(	u64,  len			)
12441abe9b8aSliubo 	),
12451abe9b8aSliubo 
124671ff6437SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
12471abe9b8aSliubo 		__entry->start		= start;
12481abe9b8aSliubo 		__entry->len		= len;
12491abe9b8aSliubo 	),
12501abe9b8aSliubo 
1251562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
125271ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
12538eec8463SDavid Sterba 		  __entry->start,
12548eec8463SDavid Sterba 		  __entry->len)
12551abe9b8aSliubo );
12561abe9b8aSliubo 
12571abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
12581abe9b8aSliubo 
12599a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
12601abe9b8aSliubo 
126171ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
12621abe9b8aSliubo );
12631abe9b8aSliubo 
12641abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
12651abe9b8aSliubo 
12669a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
12671abe9b8aSliubo 
126871ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
12691abe9b8aSliubo );
12701abe9b8aSliubo 
12713f7de037SJosef Bacik TRACE_EVENT(find_free_extent,
12723f7de037SJosef Bacik 
1273cfc2de0fSBoris Burkov 	TP_PROTO(const struct btrfs_root *root,
1274cfc2de0fSBoris Burkov 		 const struct find_free_extent_ctl *ffe_ctl),
12753f7de037SJosef Bacik 
1276cfc2de0fSBoris Burkov 	TP_ARGS(root, ffe_ctl),
12773f7de037SJosef Bacik 
1278bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1279437490feSQu Wenruo 		__field(	u64,	root_objectid		)
12803f7de037SJosef Bacik 		__field(	u64,	num_bytes		)
12813f7de037SJosef Bacik 		__field(	u64,	empty_size		)
1282cfc2de0fSBoris Burkov 		__field(	u64,	flags			)
12833f7de037SJosef Bacik 	),
12843f7de037SJosef Bacik 
1285437490feSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
1286437490feSQu Wenruo 		__entry->root_objectid	= root->root_key.objectid;
1287cfc2de0fSBoris Burkov 		__entry->num_bytes	= ffe_ctl->num_bytes;
1288cfc2de0fSBoris Burkov 		__entry->empty_size	= ffe_ctl->empty_size;
1289cfc2de0fSBoris Burkov 		__entry->flags		= ffe_ctl->flags;
12903f7de037SJosef Bacik 	),
12913f7de037SJosef Bacik 
12925439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
1293437490feSQu Wenruo 		  show_root_type(__entry->root_objectid),
1294cfc2de0fSBoris Burkov 		  __entry->num_bytes, __entry->empty_size, __entry->flags,
1295cfc2de0fSBoris Burkov 		  __print_flags((unsigned long)__entry->flags, "|",
12963f7de037SJosef Bacik 				 BTRFS_GROUP_FLAGS))
12973f7de037SJosef Bacik );
12983f7de037SJosef Bacik 
1299854c2f36SBoris Burkov TRACE_EVENT(find_free_extent_search_loop,
1300854c2f36SBoris Burkov 
1301854c2f36SBoris Burkov 	TP_PROTO(const struct btrfs_root *root,
1302854c2f36SBoris Burkov 		 const struct find_free_extent_ctl *ffe_ctl),
1303854c2f36SBoris Burkov 
1304854c2f36SBoris Burkov 	TP_ARGS(root, ffe_ctl),
1305854c2f36SBoris Burkov 
1306854c2f36SBoris Burkov 	TP_STRUCT__entry_btrfs(
1307854c2f36SBoris Burkov 		__field(	u64,	root_objectid		)
1308854c2f36SBoris Burkov 		__field(	u64,	num_bytes		)
1309854c2f36SBoris Burkov 		__field(	u64,	empty_size		)
1310854c2f36SBoris Burkov 		__field(	u64,	flags			)
1311854c2f36SBoris Burkov 		__field(	u64,	loop			)
1312854c2f36SBoris Burkov 	),
1313854c2f36SBoris Burkov 
1314854c2f36SBoris Burkov 	TP_fast_assign_btrfs(root->fs_info,
1315854c2f36SBoris Burkov 		__entry->root_objectid	= root->root_key.objectid;
1316854c2f36SBoris Burkov 		__entry->num_bytes	= ffe_ctl->num_bytes;
1317854c2f36SBoris Burkov 		__entry->empty_size	= ffe_ctl->empty_size;
1318854c2f36SBoris Burkov 		__entry->flags		= ffe_ctl->flags;
1319854c2f36SBoris Burkov 		__entry->loop		= ffe_ctl->loop;
1320854c2f36SBoris Burkov 	),
1321854c2f36SBoris Burkov 
1322854c2f36SBoris Burkov 	TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s) loop=%llu",
1323854c2f36SBoris Burkov 		  show_root_type(__entry->root_objectid),
1324854c2f36SBoris Burkov 		  __entry->num_bytes, __entry->empty_size, __entry->flags,
1325854c2f36SBoris Burkov 		  __print_flags((unsigned long)__entry->flags, "|", BTRFS_GROUP_FLAGS),
1326854c2f36SBoris Burkov 		  __entry->loop)
1327854c2f36SBoris Burkov );
1328854c2f36SBoris Burkov 
1329854c2f36SBoris Burkov TRACE_EVENT(find_free_extent_have_block_group,
1330854c2f36SBoris Burkov 
1331854c2f36SBoris Burkov 	TP_PROTO(const struct btrfs_root *root,
1332854c2f36SBoris Burkov 		 const struct find_free_extent_ctl *ffe_ctl,
1333854c2f36SBoris Burkov 		 const struct btrfs_block_group *block_group),
1334854c2f36SBoris Burkov 
1335854c2f36SBoris Burkov 	TP_ARGS(root, ffe_ctl, block_group),
1336854c2f36SBoris Burkov 
1337854c2f36SBoris Burkov 	TP_STRUCT__entry_btrfs(
1338854c2f36SBoris Burkov 		__field(	u64,	root_objectid		)
1339854c2f36SBoris Burkov 		__field(	u64,	num_bytes		)
1340854c2f36SBoris Burkov 		__field(	u64,	empty_size		)
1341854c2f36SBoris Burkov 		__field(	u64,	flags			)
1342854c2f36SBoris Burkov 		__field(	u64,	loop			)
1343854c2f36SBoris Burkov 		__field(	bool,	hinted			)
1344854c2f36SBoris Burkov 		__field(	u64,	bg_start		)
1345854c2f36SBoris Burkov 		__field(	u64,	bg_flags		)
1346854c2f36SBoris Burkov 	),
1347854c2f36SBoris Burkov 
1348854c2f36SBoris Burkov 	TP_fast_assign_btrfs(root->fs_info,
1349854c2f36SBoris Burkov 		__entry->root_objectid	= root->root_key.objectid;
1350854c2f36SBoris Burkov 		__entry->num_bytes	= ffe_ctl->num_bytes;
1351854c2f36SBoris Burkov 		__entry->empty_size	= ffe_ctl->empty_size;
1352854c2f36SBoris Burkov 		__entry->flags		= ffe_ctl->flags;
1353854c2f36SBoris Burkov 		__entry->loop		= ffe_ctl->loop;
1354854c2f36SBoris Burkov 		__entry->hinted		= ffe_ctl->hinted;
1355854c2f36SBoris Burkov 		__entry->bg_start	= block_group->start;
1356854c2f36SBoris Burkov 		__entry->bg_flags	= block_group->flags;
1357854c2f36SBoris Burkov 	),
1358854c2f36SBoris Burkov 
1359854c2f36SBoris Burkov 	TP_printk_btrfs(
1360854c2f36SBoris Burkov "root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s) loop=%llu hinted=%d block_group=%llu bg_flags=%llu(%s)",
1361854c2f36SBoris Burkov 		  show_root_type(__entry->root_objectid),
1362854c2f36SBoris Burkov 		  __entry->num_bytes, __entry->empty_size, __entry->flags,
1363854c2f36SBoris Burkov 		  __print_flags((unsigned long)__entry->flags, "|", BTRFS_GROUP_FLAGS),
1364854c2f36SBoris Burkov 		  __entry->loop, __entry->hinted,
1365854c2f36SBoris Burkov 		  __entry->bg_start, __entry->bg_flags,
1366854c2f36SBoris Burkov 		  __print_flags((unsigned long)__entry->bg_flags, "|",
1367854c2f36SBoris Burkov 				 BTRFS_GROUP_FLAGS))
1368854c2f36SBoris Burkov );
1369854c2f36SBoris Burkov 
13703f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent,
13713f7de037SJosef Bacik 
1372cfc2de0fSBoris Burkov 	TP_PROTO(const struct btrfs_block_group *block_group,
1373cfc2de0fSBoris Burkov 		 const struct find_free_extent_ctl *ffe_ctl),
13743f7de037SJosef Bacik 
1375cfc2de0fSBoris Burkov 	TP_ARGS(block_group, ffe_ctl),
13763f7de037SJosef Bacik 
1377bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13783f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
13793f7de037SJosef Bacik 		__field(	u64,	flags			)
138052bb7a21SBoris Burkov 		__field(	int,	bg_size_class		)
13813f7de037SJosef Bacik 		__field(	u64,	start			)
13823f7de037SJosef Bacik 		__field(	u64,	len			)
1383854c2f36SBoris Burkov 		__field(	u64,	loop			)
1384854c2f36SBoris Burkov 		__field(	bool,	hinted			)
138552bb7a21SBoris Burkov 		__field(	int,	size_class		)
13863f7de037SJosef Bacik 	),
13873f7de037SJosef Bacik 
13883dca5c94SQu Wenruo 	TP_fast_assign_btrfs(block_group->fs_info,
1389b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
13903f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
139152bb7a21SBoris Burkov 		__entry->bg_size_class	= block_group->size_class;
1392cfc2de0fSBoris Burkov 		__entry->start		= ffe_ctl->search_start;
1393cfc2de0fSBoris Burkov 		__entry->len		= ffe_ctl->num_bytes;
1394854c2f36SBoris Burkov 		__entry->loop		= ffe_ctl->loop;
1395854c2f36SBoris Burkov 		__entry->hinted		= ffe_ctl->hinted;
139652bb7a21SBoris Burkov 		__entry->size_class	= ffe_ctl->size_class;
13973f7de037SJosef Bacik 	),
13983f7de037SJosef Bacik 
1399854c2f36SBoris Burkov 	TP_printk_btrfs(
140052bb7a21SBoris Burkov "root=%llu(%s) block_group=%llu flags=%llu(%s) bg_size_class=%d start=%llu len=%llu loop=%llu hinted=%d size_class=%d",
140171ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
140271ff6437SJeff Mahoney 		  __entry->bg_objectid,
14033f7de037SJosef Bacik 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
14043f7de037SJosef Bacik 						"|", BTRFS_GROUP_FLAGS),
140552bb7a21SBoris Burkov 		  __entry->bg_size_class, __entry->start, __entry->len,
140652bb7a21SBoris Burkov 		  __entry->loop, __entry->hinted, __entry->size_class)
14073f7de037SJosef Bacik );
14083f7de037SJosef Bacik 
14093f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
14103f7de037SJosef Bacik 
1411cfc2de0fSBoris Burkov 	TP_PROTO(const struct btrfs_block_group *block_group,
1412cfc2de0fSBoris Burkov 		 const struct find_free_extent_ctl *ffe_ctl),
14133f7de037SJosef Bacik 
1414cfc2de0fSBoris Burkov 	TP_ARGS(block_group, ffe_ctl)
14153f7de037SJosef Bacik );
14163f7de037SJosef Bacik 
14173f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
14183f7de037SJosef Bacik 
1419cfc2de0fSBoris Burkov 	TP_PROTO(const struct btrfs_block_group *block_group,
1420cfc2de0fSBoris Burkov 		 const struct find_free_extent_ctl *ffe_ctl),
14213f7de037SJosef Bacik 
1422cfc2de0fSBoris Burkov 	TP_ARGS(block_group, ffe_ctl)
14233f7de037SJosef Bacik );
14243f7de037SJosef Bacik 
14253f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster,
14263f7de037SJosef Bacik 
142732da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
14283f7de037SJosef Bacik 		 u64 bytes, u64 empty_size, u64 min_bytes),
14293f7de037SJosef Bacik 
14303f7de037SJosef Bacik 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
14313f7de037SJosef Bacik 
1432bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14333f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
14343f7de037SJosef Bacik 		__field(	u64,	flags			)
14353f7de037SJosef Bacik 		__field(	u64,	start			)
14363f7de037SJosef Bacik 		__field(	u64,	bytes			)
14373f7de037SJosef Bacik 		__field(	u64,	empty_size		)
14383f7de037SJosef Bacik 		__field(	u64,	min_bytes		)
14393f7de037SJosef Bacik 	),
14403f7de037SJosef Bacik 
1441bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1442b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
14433f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
14443f7de037SJosef Bacik 		__entry->start		= start;
14453f7de037SJosef Bacik 		__entry->bytes		= bytes;
14463f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
14473f7de037SJosef Bacik 		__entry->min_bytes	= min_bytes;
14483f7de037SJosef Bacik 	),
14493f7de037SJosef Bacik 
14505439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
14515439c7f5SDavid Sterba 		  "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
14523f7de037SJosef Bacik 		  __entry->flags,
14533f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
14543f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
14553f7de037SJosef Bacik 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
14563f7de037SJosef Bacik );
14573f7de037SJosef Bacik 
14583f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup,
14593f7de037SJosef Bacik 
146032da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group),
14613f7de037SJosef Bacik 
14623f7de037SJosef Bacik 	TP_ARGS(block_group),
14633f7de037SJosef Bacik 
1464bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14653f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
14663f7de037SJosef Bacik 	),
14673f7de037SJosef Bacik 
1468bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1469b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
14703f7de037SJosef Bacik 	),
14713f7de037SJosef Bacik 
14725439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
14733f7de037SJosef Bacik );
14743f7de037SJosef Bacik 
14753f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster,
14763f7de037SJosef Bacik 
147732da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group,
14789a35b637SJeff Mahoney 		 const struct btrfs_free_cluster *cluster,
14799a35b637SJeff Mahoney 		 u64 size, int bitmap),
14803f7de037SJosef Bacik 
14813f7de037SJosef Bacik 	TP_ARGS(block_group, cluster, size, bitmap),
14823f7de037SJosef Bacik 
1483bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14843f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
14853f7de037SJosef Bacik 		__field(	u64,	flags			)
14863f7de037SJosef Bacik 		__field(	u64,	start			)
14873f7de037SJosef Bacik 		__field(	u64,	max_size		)
14883f7de037SJosef Bacik 		__field(	u64,	size			)
14893f7de037SJosef Bacik 		__field(	int,	bitmap			)
14903f7de037SJosef Bacik 	),
14913f7de037SJosef Bacik 
1492bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1493b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
14943f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
14953f7de037SJosef Bacik 		__entry->start		= cluster->window_start;
14963f7de037SJosef Bacik 		__entry->max_size	= cluster->max_size;
14973f7de037SJosef Bacik 		__entry->size		= size;
14983f7de037SJosef Bacik 		__entry->bitmap		= bitmap;
14993f7de037SJosef Bacik 	),
15003f7de037SJosef Bacik 
15015439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
15025439c7f5SDavid Sterba 		  "size=%llu max_size=%llu bitmap=%d",
15033f7de037SJosef Bacik 		  __entry->bg_objectid,
15043f7de037SJosef Bacik 		  __entry->flags,
15053f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
15063f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
15073f7de037SJosef Bacik 		  __entry->size, __entry->max_size, __entry->bitmap)
15083f7de037SJosef Bacik );
15093f7de037SJosef Bacik 
1510143bede5SJeff Mahoney struct extent_state;
1511143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state,
1512143bede5SJeff Mahoney 
15139a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state,
15149a35b637SJeff Mahoney 		 gfp_t mask, unsigned long IP),
1515143bede5SJeff Mahoney 
1516143bede5SJeff Mahoney 	TP_ARGS(state, mask, IP),
1517143bede5SJeff Mahoney 
1518143bede5SJeff Mahoney 	TP_STRUCT__entry(
15199a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
1520fe573327SVasily Averin 		__field(unsigned long, mask)
152194c3f6c6SDavid Sterba 		__field(const void*, ip)
1522143bede5SJeff Mahoney 	),
1523143bede5SJeff Mahoney 
1524143bede5SJeff Mahoney 	TP_fast_assign(
1525143bede5SJeff Mahoney 		__entry->state	= state,
1526fe573327SVasily Averin 		__entry->mask	= (__force unsigned long)mask,
152794c3f6c6SDavid Sterba 		__entry->ip	= (const void *)IP
1528143bede5SJeff Mahoney 	),
1529143bede5SJeff Mahoney 
1530562a7a07SDavid Sterba 	TP_printk("state=%p mask=%s caller=%pS", __entry->state,
153194c3f6c6SDavid Sterba 		  show_gfp_flags(__entry->mask), __entry->ip)
1532143bede5SJeff Mahoney );
1533143bede5SJeff Mahoney 
1534143bede5SJeff Mahoney TRACE_EVENT(free_extent_state,
1535143bede5SJeff Mahoney 
15369a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state, unsigned long IP),
1537143bede5SJeff Mahoney 
1538143bede5SJeff Mahoney 	TP_ARGS(state, IP),
1539143bede5SJeff Mahoney 
1540143bede5SJeff Mahoney 	TP_STRUCT__entry(
15419a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
154294c3f6c6SDavid Sterba 		__field(const void*, ip)
1543143bede5SJeff Mahoney 	),
1544143bede5SJeff Mahoney 
1545143bede5SJeff Mahoney 	TP_fast_assign(
1546143bede5SJeff Mahoney 		__entry->state	= state,
154794c3f6c6SDavid Sterba 		__entry->ip = (const void *)IP
1548143bede5SJeff Mahoney 	),
1549143bede5SJeff Mahoney 
155094c3f6c6SDavid Sterba 	TP_printk("state=%p caller=%pS", __entry->state, __entry->ip)
1551143bede5SJeff Mahoney );
1552143bede5SJeff Mahoney 
155352483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work,
155452483bc2SQu Wenruo 
15559a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
155652483bc2SQu Wenruo 
155752483bc2SQu Wenruo 	TP_ARGS(work),
155852483bc2SQu Wenruo 
1559bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
15609a35b637SJeff Mahoney 		__field(	const void *,	work			)
15619a35b637SJeff Mahoney 		__field(	const void *,	wq			)
15629a35b637SJeff Mahoney 		__field(	const void *,	func			)
15639a35b637SJeff Mahoney 		__field(	const void *,	ordered_func		)
15649a35b637SJeff Mahoney 		__field(	const void *,	ordered_free		)
15659a35b637SJeff Mahoney 		__field(	const void *,	normal_work		)
156652483bc2SQu Wenruo 	),
156752483bc2SQu Wenruo 
1568bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_work_owner(work),
156952483bc2SQu Wenruo 		__entry->work		= work;
157052483bc2SQu Wenruo 		__entry->wq		= work->wq;
157152483bc2SQu Wenruo 		__entry->func		= work->func;
157252483bc2SQu Wenruo 		__entry->ordered_func	= work->ordered_func;
157352483bc2SQu Wenruo 		__entry->ordered_free	= work->ordered_free;
1574b38a6258SLiu Bo 		__entry->normal_work	= &work->normal_work;
157552483bc2SQu Wenruo 	),
157652483bc2SQu Wenruo 
1577d75f773cSSakari Ailus 	TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
1578b38a6258SLiu Bo 		  "ordered_free=%p",
1579b38a6258SLiu Bo 		  __entry->work, __entry->normal_work, __entry->wq,
1580b38a6258SLiu Bo 		   __entry->func, __entry->ordered_func, __entry->ordered_free)
158152483bc2SQu Wenruo );
158252483bc2SQu Wenruo 
1583ac0c7cf8SDavid Sterba /*
1584c9eb55dbSOmar Sandoval  * For situations when the work is freed, we pass fs_info and a tag that matches
1585c9eb55dbSOmar Sandoval  * the address of the work structure so it can be paired with the scheduling
1586c9eb55dbSOmar Sandoval  * event. DO NOT add anything here that dereferences wtag.
1587ac0c7cf8SDavid Sterba  */
158852483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done,
158952483bc2SQu Wenruo 
15909a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
159152483bc2SQu Wenruo 
1592ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag),
159352483bc2SQu Wenruo 
1594bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
15959a35b637SJeff Mahoney 		__field(	const void *,	wtag			)
159652483bc2SQu Wenruo 	),
159752483bc2SQu Wenruo 
1598ac0c7cf8SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1599ac0c7cf8SDavid Sterba 		__entry->wtag		= wtag;
160052483bc2SQu Wenruo 	),
160152483bc2SQu Wenruo 
1602ac0c7cf8SDavid Sterba 	TP_printk_btrfs("work->%p", __entry->wtag)
160352483bc2SQu Wenruo );
160452483bc2SQu Wenruo 
160552483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued,
160652483bc2SQu Wenruo 
16079a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
160852483bc2SQu Wenruo 
160952483bc2SQu Wenruo 	TP_ARGS(work)
161052483bc2SQu Wenruo );
161152483bc2SQu Wenruo 
161252483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched,
161352483bc2SQu Wenruo 
16149a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
161552483bc2SQu Wenruo 
161652483bc2SQu Wenruo 	TP_ARGS(work)
161752483bc2SQu Wenruo );
161852483bc2SQu Wenruo 
161952483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
162052483bc2SQu Wenruo 
16219a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
162252483bc2SQu Wenruo 
1623ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag)
162452483bc2SQu Wenruo );
162552483bc2SQu Wenruo 
162652483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
162752483bc2SQu Wenruo 
16289a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
162952483bc2SQu Wenruo 
163052483bc2SQu Wenruo 	TP_ARGS(work)
163152483bc2SQu Wenruo );
163252483bc2SQu Wenruo 
1633a31b4a43SChristoph Hellwig DECLARE_EVENT_CLASS(btrfs_workqueue,
1634c3a46891SQu Wenruo 
1635a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq, const char *name),
1636c3a46891SQu Wenruo 
1637a31b4a43SChristoph Hellwig 	TP_ARGS(wq, name),
1638c3a46891SQu Wenruo 
1639bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
16409a35b637SJeff Mahoney 		__field(	const void *,	wq			)
1641c3a46891SQu Wenruo 		__string(	name,	name			)
1642c3a46891SQu Wenruo 	),
1643c3a46891SQu Wenruo 
1644bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1645c3a46891SQu Wenruo 		__entry->wq		= wq;
1646c3a46891SQu Wenruo 		__assign_str(name, name);
1647c3a46891SQu Wenruo 	),
1648c3a46891SQu Wenruo 
1649a31b4a43SChristoph Hellwig 	TP_printk_btrfs("name=%s wq=%p", __get_str(name),
1650c3a46891SQu Wenruo 		  __entry->wq)
1651c3a46891SQu Wenruo );
1652c3a46891SQu Wenruo 
1653a31b4a43SChristoph Hellwig DEFINE_EVENT(btrfs_workqueue, btrfs_workqueue_alloc,
1654c3a46891SQu Wenruo 
1655a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq, const char *name),
1656c3a46891SQu Wenruo 
1657a31b4a43SChristoph Hellwig 	TP_ARGS(wq, name)
1658c3a46891SQu Wenruo );
1659c3a46891SQu Wenruo 
1660a31b4a43SChristoph Hellwig DECLARE_EVENT_CLASS(btrfs_workqueue_done,
1661c3a46891SQu Wenruo 
1662a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq),
1663c3a46891SQu Wenruo 
1664c3a46891SQu Wenruo 	TP_ARGS(wq),
1665c3a46891SQu Wenruo 
1666bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
16679a35b637SJeff Mahoney 		__field(	const void *,	wq		)
1668c3a46891SQu Wenruo 	),
1669c3a46891SQu Wenruo 
1670bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1671c3a46891SQu Wenruo 		__entry->wq		= wq;
1672c3a46891SQu Wenruo 	),
1673c3a46891SQu Wenruo 
1674bc074524SJeff Mahoney 	TP_printk_btrfs("wq=%p", __entry->wq)
1675c3a46891SQu Wenruo );
1676c3a46891SQu Wenruo 
1677a31b4a43SChristoph Hellwig DEFINE_EVENT(btrfs_workqueue_done, btrfs_workqueue_destroy,
1678c3a46891SQu Wenruo 
1679a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq),
1680c3a46891SQu Wenruo 
1681c3a46891SQu Wenruo 	TP_ARGS(wq)
1682c3a46891SQu Wenruo );
168352483bc2SQu Wenruo 
168481fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS				\
168581fb6f77SQu Wenruo 	{ QGROUP_RESERVE,	"reserve"	},	\
168681fb6f77SQu Wenruo 	{ QGROUP_RELEASE,	"release"	},	\
168781fb6f77SQu Wenruo 	{ QGROUP_FREE,		"free"		}
168881fb6f77SQu Wenruo 
168981fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
169081fb6f77SQu Wenruo 
16919a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
16929a35b637SJeff Mahoney 		 u64 reserved, int op),
169381fb6f77SQu Wenruo 
169481fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op),
169581fb6f77SQu Wenruo 
1696bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
169781fb6f77SQu Wenruo 		__field(	u64,		rootid		)
1698f8f8e189SDavid Sterba 		__field(	u64,		ino		)
169981fb6f77SQu Wenruo 		__field(	u64,		start		)
170081fb6f77SQu Wenruo 		__field(	u64,		len		)
170181fb6f77SQu Wenruo 		__field(	u64,		reserved	)
170281fb6f77SQu Wenruo 		__field(	int,		op		)
170381fb6f77SQu Wenruo 	),
170481fb6f77SQu Wenruo 
1705bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
17064fd786e6SMisono Tomohiro 		__entry->rootid		=
17074fd786e6SMisono Tomohiro 			BTRFS_I(inode)->root->root_key.objectid;
1708f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
170981fb6f77SQu Wenruo 		__entry->start		= start;
171081fb6f77SQu Wenruo 		__entry->len		= len;
171181fb6f77SQu Wenruo 		__entry->reserved	= reserved;
171281fb6f77SQu Wenruo 		__entry->op		= op;
171381fb6f77SQu Wenruo 	),
171481fb6f77SQu Wenruo 
1715f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
171681fb6f77SQu Wenruo 		  __entry->rootid, __entry->ino, __entry->start, __entry->len,
171781fb6f77SQu Wenruo 		  __entry->reserved,
171881fb6f77SQu Wenruo 		  __print_flags((unsigned long)__entry->op, "",
171981fb6f77SQu Wenruo 				BTRFS_QGROUP_OPERATIONS)
172081fb6f77SQu Wenruo 	)
172181fb6f77SQu Wenruo );
172281fb6f77SQu Wenruo 
172381fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
172481fb6f77SQu Wenruo 
17259a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
17269a35b637SJeff Mahoney 		 u64 reserved, int op),
172781fb6f77SQu Wenruo 
172881fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
172981fb6f77SQu Wenruo );
173081fb6f77SQu Wenruo 
173181fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
173281fb6f77SQu Wenruo 
17339a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
17349a35b637SJeff Mahoney 		 u64 reserved, int op),
173581fb6f77SQu Wenruo 
173681fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
173781fb6f77SQu Wenruo );
173881fb6f77SQu Wenruo 
17390f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
17409a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
17419a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
17420f5dcf8dSMark Fasheh 
1743bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec),
17440f5dcf8dSMark Fasheh 
1745bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
17460f5dcf8dSMark Fasheh 		__field(	u64,  bytenr		)
17470f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes		)
17480f5dcf8dSMark Fasheh 	),
17490f5dcf8dSMark Fasheh 
1750bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
17510f5dcf8dSMark Fasheh 		__entry->bytenr		= rec->bytenr,
17520f5dcf8dSMark Fasheh 		__entry->num_bytes	= rec->num_bytes;
17530f5dcf8dSMark Fasheh 	),
17540f5dcf8dSMark Fasheh 
1755562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
175694c3f6c6SDavid Sterba 		  __entry->bytenr, __entry->num_bytes)
17570f5dcf8dSMark Fasheh );
17580f5dcf8dSMark Fasheh 
17590f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
17600f5dcf8dSMark Fasheh 
17619a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
17629a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
17630f5dcf8dSMark Fasheh 
1764bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
17650f5dcf8dSMark Fasheh );
17660f5dcf8dSMark Fasheh 
176750b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
17680f5dcf8dSMark Fasheh 
17699a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
17709a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
17710f5dcf8dSMark Fasheh 
1772bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
17730f5dcf8dSMark Fasheh );
17740f5dcf8dSMark Fasheh 
1775c337e7b0SQu Wenruo TRACE_EVENT(qgroup_num_dirty_extents,
1776c337e7b0SQu Wenruo 
1777c337e7b0SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1778c337e7b0SQu Wenruo 		 u64 num_dirty_extents),
1779c337e7b0SQu Wenruo 
1780c337e7b0SQu Wenruo 	TP_ARGS(fs_info, transid, num_dirty_extents),
1781c337e7b0SQu Wenruo 
1782c337e7b0SQu Wenruo 	TP_STRUCT__entry_btrfs(
1783c337e7b0SQu Wenruo 		__field(	u64, transid			)
1784c337e7b0SQu Wenruo 		__field(	u64, num_dirty_extents		)
1785c337e7b0SQu Wenruo 	),
1786c337e7b0SQu Wenruo 
1787c337e7b0SQu Wenruo 	TP_fast_assign_btrfs(fs_info,
1788c337e7b0SQu Wenruo 		__entry->transid	   = transid;
1789c337e7b0SQu Wenruo 		__entry->num_dirty_extents = num_dirty_extents;
1790c337e7b0SQu Wenruo 	),
1791c337e7b0SQu Wenruo 
1792c337e7b0SQu Wenruo 	TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1793c337e7b0SQu Wenruo 		__entry->transid, __entry->num_dirty_extents)
1794c337e7b0SQu Wenruo );
1795c337e7b0SQu Wenruo 
17960f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent,
17970f5dcf8dSMark Fasheh 
1798c9f6f3cdSQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
1799bc074524SJeff Mahoney 		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
18000f5dcf8dSMark Fasheh 
1801c9f6f3cdSQu Wenruo 	TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1802c9f6f3cdSQu Wenruo 		nr_new_roots),
18030f5dcf8dSMark Fasheh 
1804bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1805c9f6f3cdSQu Wenruo 		__field(	u64,  transid			)
18060f5dcf8dSMark Fasheh 		__field(	u64,  bytenr			)
18070f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes			)
18080f5dcf8dSMark Fasheh 		__field(	u64,  nr_old_roots		)
18090f5dcf8dSMark Fasheh 		__field(	u64,  nr_new_roots		)
18100f5dcf8dSMark Fasheh 	),
18110f5dcf8dSMark Fasheh 
1812bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
1813c9f6f3cdSQu Wenruo 		__entry->transid	= transid;
18140f5dcf8dSMark Fasheh 		__entry->bytenr		= bytenr;
18150f5dcf8dSMark Fasheh 		__entry->num_bytes	= num_bytes;
18160f5dcf8dSMark Fasheh 		__entry->nr_old_roots	= nr_old_roots;
18170f5dcf8dSMark Fasheh 		__entry->nr_new_roots	= nr_new_roots;
18180f5dcf8dSMark Fasheh 	),
18190f5dcf8dSMark Fasheh 
1820c9f6f3cdSQu Wenruo 	TP_printk_btrfs(
1821c9f6f3cdSQu Wenruo "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1822c9f6f3cdSQu Wenruo 		__entry->transid,
18230f5dcf8dSMark Fasheh 		__entry->bytenr,
18240f5dcf8dSMark Fasheh 		__entry->num_bytes,
18250f5dcf8dSMark Fasheh 		__entry->nr_old_roots,
18260f5dcf8dSMark Fasheh 		__entry->nr_new_roots)
18270f5dcf8dSMark Fasheh );
18280f5dcf8dSMark Fasheh 
18290f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters,
18300f5dcf8dSMark Fasheh 
18318b317901SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info,
18321d2e7c7cSDavid Sterba 		 const struct btrfs_qgroup *qgroup,
1833bc074524SJeff Mahoney 		 u64 cur_old_count, u64 cur_new_count),
18340f5dcf8dSMark Fasheh 
18358b317901SQu Wenruo 	TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
18360f5dcf8dSMark Fasheh 
1837bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
18380f5dcf8dSMark Fasheh 		__field(	u64,  qgid			)
18398b317901SQu Wenruo 		__field(	u64,  old_rfer			)
18408b317901SQu Wenruo 		__field(	u64,  old_excl			)
18410f5dcf8dSMark Fasheh 		__field(	u64,  cur_old_count		)
18420f5dcf8dSMark Fasheh 		__field(	u64,  cur_new_count		)
18430f5dcf8dSMark Fasheh 	),
18440f5dcf8dSMark Fasheh 
1845bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
18468b317901SQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
18478b317901SQu Wenruo 		__entry->old_rfer	= qgroup->rfer;
18488b317901SQu Wenruo 		__entry->old_excl	= qgroup->excl;
18490f5dcf8dSMark Fasheh 		__entry->cur_old_count	= cur_old_count;
18500f5dcf8dSMark Fasheh 		__entry->cur_new_count	= cur_new_count;
18510f5dcf8dSMark Fasheh 	),
18520f5dcf8dSMark Fasheh 
18538b317901SQu Wenruo 	TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
18548b317901SQu Wenruo 		  __entry->qgid, __entry->old_rfer, __entry->old_excl,
18558b317901SQu Wenruo 		  __entry->cur_old_count, __entry->cur_new_count)
18560f5dcf8dSMark Fasheh );
18570f5dcf8dSMark Fasheh 
18583159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve,
18593159fe7bSQu Wenruo 
18603159fe7bSQu Wenruo 	TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
186164ee4e75SQu Wenruo 		 s64 diff, int type),
18623159fe7bSQu Wenruo 
186364ee4e75SQu Wenruo 	TP_ARGS(fs_info, qgroup, diff, type),
18643159fe7bSQu Wenruo 
18653159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
18663159fe7bSQu Wenruo 		__field(	u64,	qgid			)
18673159fe7bSQu Wenruo 		__field(	u64,	cur_reserved		)
18683159fe7bSQu Wenruo 		__field(	s64,	diff			)
186964ee4e75SQu Wenruo 		__field(	int,	type			)
18703159fe7bSQu Wenruo 	),
18713159fe7bSQu Wenruo 
18723159fe7bSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
18733159fe7bSQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
187464ee4e75SQu Wenruo 		__entry->cur_reserved	= qgroup->rsv.values[type];
18753159fe7bSQu Wenruo 		__entry->diff		= diff;
18761b2442b4SQu Wenruo 		__entry->type		= type;
18773159fe7bSQu Wenruo 	),
18783159fe7bSQu Wenruo 
187964ee4e75SQu Wenruo 	TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
18801cb1f0b2SNikolay Borisov 		__entry->qgid, __print_symbolic(__entry->type, QGROUP_RSV_TYPES),
188164ee4e75SQu Wenruo 		__entry->cur_reserved, __entry->diff)
18823159fe7bSQu Wenruo );
18833159fe7bSQu Wenruo 
18843159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve,
18853159fe7bSQu Wenruo 
18864ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff, int type),
18873159fe7bSQu Wenruo 
18884ee0d883SQu Wenruo 	TP_ARGS(root, diff, type),
18893159fe7bSQu Wenruo 
18903159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
18913159fe7bSQu Wenruo 		__field(	u64,	refroot			)
18923159fe7bSQu Wenruo 		__field(	s64,	diff			)
18934ee0d883SQu Wenruo 		__field(	int,	type			)
18943159fe7bSQu Wenruo 	),
18953159fe7bSQu Wenruo 
18963159fe7bSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
18974fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
18983159fe7bSQu Wenruo 		__entry->diff		= diff;
18991b2442b4SQu Wenruo 		__entry->type		= type;
19003159fe7bSQu Wenruo 	),
19013159fe7bSQu Wenruo 
19024ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
19034ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
19041cb1f0b2SNikolay Borisov 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
19054ee0d883SQu Wenruo );
19064ee0d883SQu Wenruo 
19074ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_convert,
19084ee0d883SQu Wenruo 
19094ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff),
19104ee0d883SQu Wenruo 
19114ee0d883SQu Wenruo 	TP_ARGS(root, diff),
19124ee0d883SQu Wenruo 
19134ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
19144ee0d883SQu Wenruo 		__field(	u64,	refroot			)
19154ee0d883SQu Wenruo 		__field(	s64,	diff			)
19164ee0d883SQu Wenruo 	),
19174ee0d883SQu Wenruo 
19184ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
19194fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
19204ee0d883SQu Wenruo 		__entry->diff		= diff;
19214ee0d883SQu Wenruo 	),
19224ee0d883SQu Wenruo 
19234ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
19244ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
19251cb1f0b2SNikolay Borisov 		__print_symbolic(BTRFS_QGROUP_RSV_META_PREALLOC, QGROUP_RSV_TYPES),
19261cb1f0b2SNikolay Borisov 		__print_symbolic(BTRFS_QGROUP_RSV_META_PERTRANS, QGROUP_RSV_TYPES),
19274ee0d883SQu Wenruo 		__entry->diff)
19284ee0d883SQu Wenruo );
19294ee0d883SQu Wenruo 
19304ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_free_all_pertrans,
19314ee0d883SQu Wenruo 
19324ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root),
19334ee0d883SQu Wenruo 
19344ee0d883SQu Wenruo 	TP_ARGS(root),
19354ee0d883SQu Wenruo 
19364ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
19374ee0d883SQu Wenruo 		__field(	u64,	refroot			)
19384ee0d883SQu Wenruo 		__field(	s64,	diff			)
19394ee0d883SQu Wenruo 		__field(	int,	type			)
19404ee0d883SQu Wenruo 	),
19414ee0d883SQu Wenruo 
19424ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
19434fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
19444ee0d883SQu Wenruo 		spin_lock(&root->qgroup_meta_rsv_lock);
19454ee0d883SQu Wenruo 		__entry->diff		= -(s64)root->qgroup_meta_rsv_pertrans;
19464ee0d883SQu Wenruo 		spin_unlock(&root->qgroup_meta_rsv_lock);
19474ee0d883SQu Wenruo 		__entry->type		= BTRFS_QGROUP_RSV_META_PERTRANS;
19484ee0d883SQu Wenruo 	),
19494ee0d883SQu Wenruo 
19504ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
19514ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
19521cb1f0b2SNikolay Borisov 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
19533159fe7bSQu Wenruo );
19543159fe7bSQu Wenruo 
195500142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref,
195600142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
195700142756SJeff Mahoney 		 const struct prelim_ref *oldref,
195800142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
195900142756SJeff Mahoney 	TP_ARGS(fs_info, newref, oldref, tree_size),
196000142756SJeff Mahoney 
196100142756SJeff Mahoney 	TP_STRUCT__entry_btrfs(
196200142756SJeff Mahoney 		__field(	u64,  root_id		)
196300142756SJeff Mahoney 		__field(	u64,  objectid		)
196400142756SJeff Mahoney 		__field(	 u8,  type		)
196500142756SJeff Mahoney 		__field(	u64,  offset		)
196600142756SJeff Mahoney 		__field(	int,  level		)
196700142756SJeff Mahoney 		__field(	int,  old_count		)
196800142756SJeff Mahoney 		__field(	u64,  parent		)
196900142756SJeff Mahoney 		__field(	u64,  bytenr		)
197000142756SJeff Mahoney 		__field(	int,  mod_count		)
197100142756SJeff Mahoney 		__field(	u64,  tree_size		)
197200142756SJeff Mahoney 	),
197300142756SJeff Mahoney 
197400142756SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
197500142756SJeff Mahoney 		__entry->root_id	= oldref->root_id;
197600142756SJeff Mahoney 		__entry->objectid	= oldref->key_for_search.objectid;
197700142756SJeff Mahoney 		__entry->type		= oldref->key_for_search.type;
197800142756SJeff Mahoney 		__entry->offset		= oldref->key_for_search.offset;
197900142756SJeff Mahoney 		__entry->level		= oldref->level;
198000142756SJeff Mahoney 		__entry->old_count	= oldref->count;
198100142756SJeff Mahoney 		__entry->parent		= oldref->parent;
198200142756SJeff Mahoney 		__entry->bytenr		= oldref->wanted_disk_byte;
198300142756SJeff Mahoney 		__entry->mod_count	= newref ? newref->count : 0;
198400142756SJeff Mahoney 		__entry->tree_size	= tree_size;
198500142756SJeff Mahoney 	),
198600142756SJeff Mahoney 
198700142756SJeff 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",
19888eec8463SDavid Sterba 			__entry->root_id,
19898eec8463SDavid Sterba 			__entry->objectid, __entry->type,
19908eec8463SDavid Sterba 			__entry->offset, __entry->level,
199100142756SJeff Mahoney 			__entry->old_count, __entry->mod_count,
199200142756SJeff Mahoney 			__entry->old_count + __entry->mod_count,
19938eec8463SDavid Sterba 			__entry->parent,
19948eec8463SDavid Sterba 			__entry->bytenr,
19958eec8463SDavid Sterba 			__entry->tree_size)
199600142756SJeff Mahoney );
199700142756SJeff Mahoney 
199800142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
199900142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
200000142756SJeff Mahoney 		 const struct prelim_ref *oldref,
200100142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
200200142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
200300142756SJeff Mahoney );
200400142756SJeff Mahoney 
200500142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
200600142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
200700142756SJeff Mahoney 		 const struct prelim_ref *oldref,
200800142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
200900142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
201000142756SJeff Mahoney );
201100142756SJeff Mahoney 
2012dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
201364425500SNaohiro Aota 	TP_PROTO(const struct btrfs_root *root, u64 ino, int mod, unsigned outstanding),
2014dd48d407SJosef Bacik 
201564425500SNaohiro Aota 	TP_ARGS(root, ino, mod, outstanding),
2016dd48d407SJosef Bacik 
2017dd48d407SJosef Bacik 	TP_STRUCT__entry_btrfs(
2018dd48d407SJosef Bacik 		__field(	u64, root_objectid	)
2019dd48d407SJosef Bacik 		__field(	u64, ino		)
2020dd48d407SJosef Bacik 		__field(	int, mod		)
202164425500SNaohiro Aota 		__field(	unsigned, outstanding	)
2022dd48d407SJosef Bacik 	),
2023dd48d407SJosef Bacik 
2024dd48d407SJosef Bacik 	TP_fast_assign_btrfs(root->fs_info,
20254fd786e6SMisono Tomohiro 		__entry->root_objectid	= root->root_key.objectid;
2026dd48d407SJosef Bacik 		__entry->ino		= ino;
2027dd48d407SJosef Bacik 		__entry->mod		= mod;
202864425500SNaohiro Aota 		__entry->outstanding    = outstanding;
2029dd48d407SJosef Bacik 	),
2030dd48d407SJosef Bacik 
203164425500SNaohiro Aota 	TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d outstanding=%u",
2032dd48d407SJosef Bacik 			show_root_type(__entry->root_objectid),
203364425500SNaohiro Aota 			__entry->ino, __entry->mod, __entry->outstanding)
2034dd48d407SJosef Bacik );
20353dca5c94SQu Wenruo 
20364ed0a7a3SQu Wenruo DECLARE_EVENT_CLASS(btrfs__block_group,
203732da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
20384ed0a7a3SQu Wenruo 
20394ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache),
20404ed0a7a3SQu Wenruo 
20414ed0a7a3SQu Wenruo 	TP_STRUCT__entry_btrfs(
20424ed0a7a3SQu Wenruo 		__field(	u64,	bytenr		)
20434ed0a7a3SQu Wenruo 		__field(	u64,	len		)
20444ed0a7a3SQu Wenruo 		__field(	u64,	used		)
20454ed0a7a3SQu Wenruo 		__field(	u64,	flags		)
20464ed0a7a3SQu Wenruo 	),
20474ed0a7a3SQu Wenruo 
20484ed0a7a3SQu Wenruo 	TP_fast_assign_btrfs(bg_cache->fs_info,
2049b3470b5dSDavid Sterba 		__entry->bytenr = bg_cache->start,
2050b3470b5dSDavid Sterba 		__entry->len	= bg_cache->length,
2051bf38be65SDavid Sterba 		__entry->used	= bg_cache->used;
20524ed0a7a3SQu Wenruo 		__entry->flags	= bg_cache->flags;
20534ed0a7a3SQu Wenruo 	),
20544ed0a7a3SQu Wenruo 
20554ed0a7a3SQu Wenruo 	TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
20564ed0a7a3SQu Wenruo 		__entry->bytenr, __entry->len, __entry->used, __entry->flags,
20574ed0a7a3SQu Wenruo 		__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
20584ed0a7a3SQu Wenruo );
20594ed0a7a3SQu Wenruo 
20604ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
206132da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
20624ed0a7a3SQu Wenruo 
20634ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
20644ed0a7a3SQu Wenruo );
20654ed0a7a3SQu Wenruo 
20664ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
206732da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
20684ed0a7a3SQu Wenruo 
20694ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
20704ed0a7a3SQu Wenruo );
20714ed0a7a3SQu Wenruo 
207218bb8bbfSJohannes Thumshirn DEFINE_EVENT(btrfs__block_group, btrfs_add_reclaim_block_group,
207318bb8bbfSJohannes Thumshirn 	TP_PROTO(const struct btrfs_block_group *bg_cache),
207418bb8bbfSJohannes Thumshirn 
207518bb8bbfSJohannes Thumshirn 	TP_ARGS(bg_cache)
207618bb8bbfSJohannes Thumshirn );
207718bb8bbfSJohannes Thumshirn 
207818bb8bbfSJohannes Thumshirn DEFINE_EVENT(btrfs__block_group, btrfs_reclaim_block_group,
207918bb8bbfSJohannes Thumshirn 	TP_PROTO(const struct btrfs_block_group *bg_cache),
208018bb8bbfSJohannes Thumshirn 
208118bb8bbfSJohannes Thumshirn 	TP_ARGS(bg_cache)
208218bb8bbfSJohannes Thumshirn );
208318bb8bbfSJohannes Thumshirn 
20844ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
208532da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
20864ed0a7a3SQu Wenruo 
20874ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
20884ed0a7a3SQu Wenruo );
20894ed0a7a3SQu Wenruo 
2090a1d19847SQu Wenruo TRACE_EVENT(btrfs_set_extent_bit,
2091a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
2092a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned set_bits),
2093a1d19847SQu Wenruo 
2094a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, set_bits),
2095a1d19847SQu Wenruo 
2096a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
2097a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
2098a1d19847SQu Wenruo 		__field(	u64,		ino	)
2099a1d19847SQu Wenruo 		__field(	u64,		rootid	)
2100a1d19847SQu Wenruo 		__field(	u64,		start	)
2101a1d19847SQu Wenruo 		__field(	u64,		len	)
2102a1d19847SQu Wenruo 		__field(	unsigned,	set_bits)
2103a1d19847SQu Wenruo 	),
2104a1d19847SQu Wenruo 
2105a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
2106a1d19847SQu Wenruo 		__entry->owner = tree->owner;
21070988fc7bSDavid Sterba 		if (tree->inode) {
21080988fc7bSDavid Sterba 			const struct btrfs_inode *inode = tree->inode;
2109a1d19847SQu Wenruo 
21100988fc7bSDavid Sterba 			__entry->ino	= btrfs_ino(inode);
21110988fc7bSDavid Sterba 			__entry->rootid	= inode->root->root_key.objectid;
2112a1d19847SQu Wenruo 		} else {
2113a1d19847SQu Wenruo 			__entry->ino	= 0;
2114a1d19847SQu Wenruo 			__entry->rootid	= 0;
2115a1d19847SQu Wenruo 		}
2116a1d19847SQu Wenruo 		__entry->start		= start;
2117a1d19847SQu Wenruo 		__entry->len		= len;
2118a1d19847SQu Wenruo 		__entry->set_bits	= set_bits;
2119a1d19847SQu Wenruo 	),
2120a1d19847SQu Wenruo 
2121a1d19847SQu Wenruo 	TP_printk_btrfs(
2122a1d19847SQu Wenruo 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s",
2123c92bb304SNikolay Borisov 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2124a1d19847SQu Wenruo 		__entry->rootid, __entry->start, __entry->len,
2125a1d19847SQu Wenruo 		__print_flags(__entry->set_bits, "|", EXTENT_FLAGS))
2126a1d19847SQu Wenruo );
2127a1d19847SQu Wenruo 
2128a1d19847SQu Wenruo TRACE_EVENT(btrfs_clear_extent_bit,
2129a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
2130a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned clear_bits),
2131a1d19847SQu Wenruo 
2132a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, clear_bits),
2133a1d19847SQu Wenruo 
2134a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
2135a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
2136a1d19847SQu Wenruo 		__field(	u64,		ino	)
2137a1d19847SQu Wenruo 		__field(	u64,		rootid	)
2138a1d19847SQu Wenruo 		__field(	u64,		start	)
2139a1d19847SQu Wenruo 		__field(	u64,		len	)
2140a1d19847SQu Wenruo 		__field(	unsigned,	clear_bits)
2141a1d19847SQu Wenruo 	),
2142a1d19847SQu Wenruo 
2143a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
2144a1d19847SQu Wenruo 		__entry->owner = tree->owner;
21450988fc7bSDavid Sterba 		if (tree->inode) {
21460988fc7bSDavid Sterba 			const struct btrfs_inode *inode = tree->inode;
2147a1d19847SQu Wenruo 
21480988fc7bSDavid Sterba 			__entry->ino	= btrfs_ino(inode);
21490988fc7bSDavid Sterba 			__entry->rootid	= inode->root->root_key.objectid;
2150a1d19847SQu Wenruo 		} else {
2151a1d19847SQu Wenruo 			__entry->ino	= 0;
2152a1d19847SQu Wenruo 			__entry->rootid	= 0;
2153a1d19847SQu Wenruo 		}
2154a1d19847SQu Wenruo 		__entry->start		= start;
2155a1d19847SQu Wenruo 		__entry->len		= len;
2156a1d19847SQu Wenruo 		__entry->clear_bits	= clear_bits;
2157a1d19847SQu Wenruo 	),
2158a1d19847SQu Wenruo 
2159a1d19847SQu Wenruo 	TP_printk_btrfs(
2160a1d19847SQu Wenruo 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s",
2161c92bb304SNikolay Borisov 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2162a1d19847SQu Wenruo 		__entry->rootid, __entry->start, __entry->len,
2163a1d19847SQu Wenruo 		__print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2164a1d19847SQu Wenruo );
2165a1d19847SQu Wenruo 
2166a1d19847SQu Wenruo TRACE_EVENT(btrfs_convert_extent_bit,
2167a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
2168a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned set_bits, unsigned clear_bits),
2169a1d19847SQu Wenruo 
2170a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, set_bits, clear_bits),
2171a1d19847SQu Wenruo 
2172a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
2173a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
2174a1d19847SQu Wenruo 		__field(	u64,		ino	)
2175a1d19847SQu Wenruo 		__field(	u64,		rootid	)
2176a1d19847SQu Wenruo 		__field(	u64,		start	)
2177a1d19847SQu Wenruo 		__field(	u64,		len	)
2178a1d19847SQu Wenruo 		__field(	unsigned,	set_bits)
2179a1d19847SQu Wenruo 		__field(	unsigned,	clear_bits)
2180a1d19847SQu Wenruo 	),
2181a1d19847SQu Wenruo 
2182a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
2183a1d19847SQu Wenruo 		__entry->owner = tree->owner;
21840988fc7bSDavid Sterba 		if (tree->inode) {
21850988fc7bSDavid Sterba 			const struct btrfs_inode *inode = tree->inode;
2186a1d19847SQu Wenruo 
21870988fc7bSDavid Sterba 			__entry->ino	= btrfs_ino(inode);
21880988fc7bSDavid Sterba 			__entry->rootid	= inode->root->root_key.objectid;
2189a1d19847SQu Wenruo 		} else {
2190a1d19847SQu Wenruo 			__entry->ino	= 0;
2191a1d19847SQu Wenruo 			__entry->rootid	= 0;
2192a1d19847SQu Wenruo 		}
2193a1d19847SQu Wenruo 		__entry->start		= start;
2194a1d19847SQu Wenruo 		__entry->len		= len;
2195a1d19847SQu Wenruo 		__entry->set_bits	= set_bits;
2196a1d19847SQu Wenruo 		__entry->clear_bits	= clear_bits;
2197a1d19847SQu Wenruo 	),
2198a1d19847SQu Wenruo 
2199a1d19847SQu Wenruo 	TP_printk_btrfs(
2200a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s",
2201c92bb304SNikolay Borisov 		  __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2202a1d19847SQu Wenruo 		  __entry->rootid, __entry->start, __entry->len,
2203a1d19847SQu Wenruo 		  __print_flags(__entry->set_bits , "|", EXTENT_FLAGS),
2204a1d19847SQu Wenruo 		  __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2205a1d19847SQu Wenruo );
2206a1d19847SQu Wenruo 
2207e5ad49e2SJosef Bacik DECLARE_EVENT_CLASS(btrfs_dump_space_info,
22088197766dSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2209e5ad49e2SJosef Bacik 		 const struct btrfs_space_info *sinfo),
2210e5ad49e2SJosef Bacik 
2211e5ad49e2SJosef Bacik 	TP_ARGS(fs_info, sinfo),
2212e5ad49e2SJosef Bacik 
2213e5ad49e2SJosef Bacik 	TP_STRUCT__entry_btrfs(
2214e5ad49e2SJosef Bacik 		__field(	u64,	flags			)
2215e5ad49e2SJosef Bacik 		__field(	u64,	total_bytes		)
2216e5ad49e2SJosef Bacik 		__field(	u64,	bytes_used		)
2217e5ad49e2SJosef Bacik 		__field(	u64,	bytes_pinned		)
2218e5ad49e2SJosef Bacik 		__field(	u64,	bytes_reserved		)
2219e5ad49e2SJosef Bacik 		__field(	u64,	bytes_may_use		)
2220e5ad49e2SJosef Bacik 		__field(	u64,	bytes_readonly		)
2221e5ad49e2SJosef Bacik 		__field(	u64,	reclaim_size		)
2222e5ad49e2SJosef Bacik 		__field(	int,	clamp			)
2223e5ad49e2SJosef Bacik 		__field(	u64,	global_reserved		)
2224e5ad49e2SJosef Bacik 		__field(	u64,	trans_reserved		)
2225e5ad49e2SJosef Bacik 		__field(	u64,	delayed_refs_reserved	)
2226e5ad49e2SJosef Bacik 		__field(	u64,	delayed_reserved	)
2227e5ad49e2SJosef Bacik 		__field(	u64,	free_chunk_space	)
22288197766dSJosef Bacik 		__field(	u64,	delalloc_bytes		)
22298197766dSJosef Bacik 		__field(	u64,	ordered_bytes		)
2230e5ad49e2SJosef Bacik 	),
2231e5ad49e2SJosef Bacik 
2232e5ad49e2SJosef Bacik 	TP_fast_assign_btrfs(fs_info,
2233e5ad49e2SJosef Bacik 		__entry->flags			=	sinfo->flags;
2234e5ad49e2SJosef Bacik 		__entry->total_bytes		=	sinfo->total_bytes;
2235e5ad49e2SJosef Bacik 		__entry->bytes_used		=	sinfo->bytes_used;
2236e5ad49e2SJosef Bacik 		__entry->bytes_pinned		=	sinfo->bytes_pinned;
2237e5ad49e2SJosef Bacik 		__entry->bytes_reserved		=	sinfo->bytes_reserved;
2238e5ad49e2SJosef Bacik 		__entry->bytes_may_use		=	sinfo->bytes_may_use;
2239e5ad49e2SJosef Bacik 		__entry->bytes_readonly		=	sinfo->bytes_readonly;
2240e5ad49e2SJosef Bacik 		__entry->reclaim_size		=	sinfo->reclaim_size;
2241e5ad49e2SJosef Bacik 		__entry->clamp			=	sinfo->clamp;
2242e5ad49e2SJosef Bacik 		__entry->global_reserved	=	fs_info->global_block_rsv.reserved;
2243e5ad49e2SJosef Bacik 		__entry->trans_reserved		=	fs_info->trans_block_rsv.reserved;
2244e5ad49e2SJosef Bacik 		__entry->delayed_refs_reserved	=	fs_info->delayed_refs_rsv.reserved;
2245e5ad49e2SJosef Bacik 		__entry->delayed_reserved	=	fs_info->delayed_block_rsv.reserved;
2246e5ad49e2SJosef Bacik 		__entry->free_chunk_space	=	atomic64_read(&fs_info->free_chunk_space);
22478197766dSJosef Bacik 		__entry->delalloc_bytes		=	percpu_counter_sum_positive(&fs_info->delalloc_bytes);
22488197766dSJosef Bacik 		__entry->ordered_bytes		=	percpu_counter_sum_positive(&fs_info->ordered_bytes);
2249e5ad49e2SJosef Bacik 	),
2250e5ad49e2SJosef Bacik 
2251e5ad49e2SJosef Bacik 	TP_printk_btrfs("flags=%s total_bytes=%llu bytes_used=%llu "
2252e5ad49e2SJosef Bacik 			"bytes_pinned=%llu bytes_reserved=%llu "
2253e5ad49e2SJosef Bacik 			"bytes_may_use=%llu bytes_readonly=%llu "
2254e5ad49e2SJosef Bacik 			"reclaim_size=%llu clamp=%d global_reserved=%llu "
2255e5ad49e2SJosef Bacik 			"trans_reserved=%llu delayed_refs_reserved=%llu "
22568197766dSJosef Bacik 			"delayed_reserved=%llu chunk_free_space=%llu "
22578197766dSJosef Bacik 			"delalloc_bytes=%llu ordered_bytes=%llu",
2258e5ad49e2SJosef Bacik 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2259e5ad49e2SJosef Bacik 			__entry->total_bytes, __entry->bytes_used,
2260e5ad49e2SJosef Bacik 			__entry->bytes_pinned, __entry->bytes_reserved,
2261e5ad49e2SJosef Bacik 			__entry->bytes_may_use, __entry->bytes_readonly,
2262e5ad49e2SJosef Bacik 			__entry->reclaim_size, __entry->clamp,
2263e5ad49e2SJosef Bacik 			__entry->global_reserved, __entry->trans_reserved,
2264e5ad49e2SJosef Bacik 			__entry->delayed_refs_reserved,
22658197766dSJosef Bacik 			__entry->delayed_reserved, __entry->free_chunk_space,
22668197766dSJosef Bacik 			__entry->delalloc_bytes, __entry->ordered_bytes)
2267e5ad49e2SJosef Bacik );
2268e5ad49e2SJosef Bacik 
2269e5ad49e2SJosef Bacik DEFINE_EVENT(btrfs_dump_space_info, btrfs_done_preemptive_reclaim,
22708197766dSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2271e5ad49e2SJosef Bacik 		 const struct btrfs_space_info *sinfo),
2272e5ad49e2SJosef Bacik 	TP_ARGS(fs_info, sinfo)
2273e5ad49e2SJosef Bacik );
2274e5ad49e2SJosef Bacik 
2275fcdef39cSJosef Bacik DEFINE_EVENT(btrfs_dump_space_info, btrfs_fail_all_tickets,
2276fcdef39cSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2277fcdef39cSJosef Bacik 		 const struct btrfs_space_info *sinfo),
2278fcdef39cSJosef Bacik 	TP_ARGS(fs_info, sinfo)
2279fcdef39cSJosef Bacik );
2280fcdef39cSJosef Bacik 
2281ac1ea10eSJosef Bacik TRACE_EVENT(btrfs_reserve_ticket,
2282ac1ea10eSJosef Bacik 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
2283ac1ea10eSJosef Bacik 		 u64 start_ns, int flush, int error),
2284ac1ea10eSJosef Bacik 
2285ac1ea10eSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, start_ns, flush, error),
2286ac1ea10eSJosef Bacik 
2287ac1ea10eSJosef Bacik 	TP_STRUCT__entry_btrfs(
2288ac1ea10eSJosef Bacik 		__field(	u64,	flags		)
2289ac1ea10eSJosef Bacik 		__field(	u64,	bytes		)
2290ac1ea10eSJosef Bacik 		__field(	u64,	start_ns	)
2291ac1ea10eSJosef Bacik 		__field(	int,	flush		)
2292ac1ea10eSJosef Bacik 		__field(	int,	error		)
2293ac1ea10eSJosef Bacik 	),
2294ac1ea10eSJosef Bacik 
2295ac1ea10eSJosef Bacik 	TP_fast_assign_btrfs(fs_info,
2296ac1ea10eSJosef Bacik 		__entry->flags		= flags;
2297ac1ea10eSJosef Bacik 		__entry->bytes		= bytes;
2298ac1ea10eSJosef Bacik 		__entry->start_ns	= start_ns;
2299ac1ea10eSJosef Bacik 		__entry->flush		= flush;
2300ac1ea10eSJosef Bacik 		__entry->error		= error;
2301ac1ea10eSJosef Bacik 	),
2302ac1ea10eSJosef Bacik 
2303ac1ea10eSJosef Bacik 	TP_printk_btrfs("flags=%s bytes=%llu start_ns=%llu flush=%s error=%d",
2304ac1ea10eSJosef Bacik 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2305ac1ea10eSJosef Bacik 			__entry->bytes, __entry->start_ns,
2306ac1ea10eSJosef Bacik 			__print_symbolic(__entry->flush, FLUSH_ACTIONS),
2307ac1ea10eSJosef Bacik 			__entry->error)
2308ac1ea10eSJosef Bacik );
2309ac1ea10eSJosef Bacik 
231034e73cc9SQu Wenruo DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock,
231134e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
231234e73cc9SQu Wenruo 
231334e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns),
231434e73cc9SQu Wenruo 
231534e73cc9SQu Wenruo 	TP_STRUCT__entry_btrfs(
231634e73cc9SQu Wenruo 		__field(	u64,	block		)
231734e73cc9SQu Wenruo 		__field(	u64,	generation	)
231834e73cc9SQu Wenruo 		__field(	u64,	start_ns	)
231934e73cc9SQu Wenruo 		__field(	u64,	end_ns		)
232034e73cc9SQu Wenruo 		__field(	u64,	diff_ns		)
232134e73cc9SQu Wenruo 		__field(	u64,	owner		)
232234e73cc9SQu Wenruo 		__field(	int,	is_log_tree	)
232334e73cc9SQu Wenruo 	),
232434e73cc9SQu Wenruo 
232534e73cc9SQu Wenruo 	TP_fast_assign_btrfs(eb->fs_info,
232634e73cc9SQu Wenruo 		__entry->block		= eb->start;
232734e73cc9SQu Wenruo 		__entry->generation	= btrfs_header_generation(eb);
232834e73cc9SQu Wenruo 		__entry->start_ns	= start_ns;
232934e73cc9SQu Wenruo 		__entry->end_ns		= ktime_get_ns();
233034e73cc9SQu Wenruo 		__entry->diff_ns	= __entry->end_ns - start_ns;
233134e73cc9SQu Wenruo 		__entry->owner		= btrfs_header_owner(eb);
233234e73cc9SQu Wenruo 		__entry->is_log_tree	= (eb->log_index >= 0);
233334e73cc9SQu Wenruo 	),
233434e73cc9SQu Wenruo 
233534e73cc9SQu Wenruo 	TP_printk_btrfs(
233634e73cc9SQu Wenruo "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d",
233734e73cc9SQu Wenruo 		__entry->block, __entry->generation,
233834e73cc9SQu Wenruo 		__entry->start_ns, __entry->end_ns, __entry->diff_ns,
233934e73cc9SQu Wenruo 		__entry->owner, __entry->is_log_tree)
234034e73cc9SQu Wenruo );
234134e73cc9SQu Wenruo 
234234e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock,
234334e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
234434e73cc9SQu Wenruo 
234534e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns)
234634e73cc9SQu Wenruo );
234734e73cc9SQu Wenruo 
234834e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock,
234934e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
235034e73cc9SQu Wenruo 
235134e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns)
235234e73cc9SQu Wenruo );
235334e73cc9SQu Wenruo 
235431aab402SQu Wenruo DECLARE_EVENT_CLASS(btrfs_locking_events,
235531aab402SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb),
235631aab402SQu Wenruo 
235731aab402SQu Wenruo 	TP_ARGS(eb),
235831aab402SQu Wenruo 
235931aab402SQu Wenruo 	TP_STRUCT__entry_btrfs(
236031aab402SQu Wenruo 		__field(	u64,	block		)
236131aab402SQu Wenruo 		__field(	u64,	generation	)
236231aab402SQu Wenruo 		__field(	u64,	owner		)
236331aab402SQu Wenruo 		__field(	int,	is_log_tree	)
236431aab402SQu Wenruo 	),
236531aab402SQu Wenruo 
236631aab402SQu Wenruo 	TP_fast_assign_btrfs(eb->fs_info,
236731aab402SQu Wenruo 		__entry->block		= eb->start;
236831aab402SQu Wenruo 		__entry->generation	= btrfs_header_generation(eb);
236931aab402SQu Wenruo 		__entry->owner		= btrfs_header_owner(eb);
237031aab402SQu Wenruo 		__entry->is_log_tree	= (eb->log_index >= 0);
237131aab402SQu Wenruo 	),
237231aab402SQu Wenruo 
237331aab402SQu Wenruo 	TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d",
237431aab402SQu Wenruo 		__entry->block, __entry->generation,
237531aab402SQu Wenruo 		__entry->owner, __entry->is_log_tree)
237631aab402SQu Wenruo );
237731aab402SQu Wenruo 
237831aab402SQu Wenruo #define DEFINE_BTRFS_LOCK_EVENT(name)				\
237931aab402SQu Wenruo DEFINE_EVENT(btrfs_locking_events, name,			\
238031aab402SQu Wenruo 		TP_PROTO(const struct extent_buffer *eb),	\
238131aab402SQu Wenruo 								\
238231aab402SQu Wenruo 		TP_ARGS(eb)					\
238331aab402SQu Wenruo )
238431aab402SQu Wenruo 
238531aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock);
238631aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock);
238731aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking);
238831aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read);
238931aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write);
239031aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock);
239131aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock);
239231aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic);
239331aab402SQu Wenruo 
2394480b9b4dSQu Wenruo DECLARE_EVENT_CLASS(btrfs__space_info_update,
2395480b9b4dSQu Wenruo 
23961d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
23971d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2398480b9b4dSQu Wenruo 
2399480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff),
2400480b9b4dSQu Wenruo 
2401480b9b4dSQu Wenruo 	TP_STRUCT__entry_btrfs(
2402480b9b4dSQu Wenruo 		__field(	u64,	type		)
2403480b9b4dSQu Wenruo 		__field(	u64,	old		)
2404480b9b4dSQu Wenruo 		__field(	s64,	diff		)
2405480b9b4dSQu Wenruo 	),
2406480b9b4dSQu Wenruo 
2407480b9b4dSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
2408480b9b4dSQu Wenruo 		__entry->type	= sinfo->flags;
2409480b9b4dSQu Wenruo 		__entry->old	= old;
2410480b9b4dSQu Wenruo 		__entry->diff	= diff;
2411480b9b4dSQu Wenruo 	),
2412480b9b4dSQu Wenruo 	TP_printk_btrfs("type=%s old=%llu diff=%lld",
2413480b9b4dSQu Wenruo 		__print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS),
2414480b9b4dSQu Wenruo 		__entry->old, __entry->diff)
2415480b9b4dSQu Wenruo );
2416480b9b4dSQu Wenruo 
2417480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use,
2418480b9b4dSQu Wenruo 
24191d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
24201d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2421480b9b4dSQu Wenruo 
2422480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff)
2423480b9b4dSQu Wenruo );
2424480b9b4dSQu Wenruo 
2425480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned,
2426480b9b4dSQu Wenruo 
24271d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
24281d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2429480b9b4dSQu Wenruo 
2430480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff)
2431480b9b4dSQu Wenruo );
2432480b9b4dSQu Wenruo 
2433b8bea09aSQu Wenruo DECLARE_EVENT_CLASS(btrfs_raid56_bio,
2434b8bea09aSQu Wenruo 
2435b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2436b8bea09aSQu Wenruo 		 const struct bio *bio,
2437b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2438b8bea09aSQu Wenruo 
2439b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info),
2440b8bea09aSQu Wenruo 
2441b8bea09aSQu Wenruo 	TP_STRUCT__entry_btrfs(
2442b8bea09aSQu Wenruo 		__field(	u64,	full_stripe	)
2443b8bea09aSQu Wenruo 		__field(	u64,	physical	)
2444b8bea09aSQu Wenruo 		__field(	u64,	devid		)
2445b8bea09aSQu Wenruo 		__field(	u32,	offset		)
2446b8bea09aSQu Wenruo 		__field(	u32,	len		)
2447b8bea09aSQu Wenruo 		__field(	u8,	opf		)
2448b8bea09aSQu Wenruo 		__field(	u8,	total_stripes	)
2449b8bea09aSQu Wenruo 		__field(	u8,	real_stripes	)
2450b8bea09aSQu Wenruo 		__field(	u8,	nr_data		)
2451b8bea09aSQu Wenruo 		__field(	u8,	stripe_nr	)
2452b8bea09aSQu Wenruo 	),
2453b8bea09aSQu Wenruo 
2454b8bea09aSQu Wenruo 	TP_fast_assign_btrfs(rbio->bioc->fs_info,
245518d758a2SQu Wenruo 		__entry->full_stripe	= rbio->bioc->full_stripe_logical;
2456b8bea09aSQu Wenruo 		__entry->physical	= bio->bi_iter.bi_sector << SECTOR_SHIFT;
2457b8bea09aSQu Wenruo 		__entry->len		= bio->bi_iter.bi_size;
2458b8bea09aSQu Wenruo 		__entry->opf		= bio_op(bio);
2459b8bea09aSQu Wenruo 		__entry->devid		= trace_info->devid;
2460b8bea09aSQu Wenruo 		__entry->offset		= trace_info->offset;
2461b8bea09aSQu Wenruo 		__entry->stripe_nr	= trace_info->stripe_nr;
2462b8bea09aSQu Wenruo 		__entry->total_stripes	= rbio->bioc->num_stripes;
2463b8bea09aSQu Wenruo 		__entry->real_stripes	= rbio->real_stripes;
2464b8bea09aSQu Wenruo 		__entry->nr_data	= rbio->nr_data;
2465b8bea09aSQu Wenruo 	),
2466b8bea09aSQu Wenruo 	/*
2467b8bea09aSQu Wenruo 	 * For type output, we need to output things like "DATA1"
2468b8bea09aSQu Wenruo 	 * (the first data stripe), "DATA2" (the second data stripe),
2469b8bea09aSQu Wenruo 	 * "PQ1" (P stripe),"PQ2" (Q stripe), "REPLACE0" (replace target device).
2470b8bea09aSQu Wenruo 	 */
2471b8bea09aSQu Wenruo 	TP_printk_btrfs(
2472b8bea09aSQu Wenruo "full_stripe=%llu devid=%lld type=%s%d offset=%d opf=0x%x physical=%llu len=%u",
2473b8bea09aSQu Wenruo 		__entry->full_stripe, __entry->devid,
2474b8bea09aSQu Wenruo 		(__entry->stripe_nr < __entry->nr_data) ? "DATA" :
2475b8bea09aSQu Wenruo 			((__entry->stripe_nr < __entry->real_stripes) ? "PQ" :
2476b8bea09aSQu Wenruo 			 "REPLACE"),
2477b8bea09aSQu Wenruo 		(__entry->stripe_nr < __entry->nr_data) ?
2478b8bea09aSQu Wenruo 			(__entry->stripe_nr + 1) :
2479b8bea09aSQu Wenruo 			((__entry->stripe_nr < __entry->real_stripes) ?
2480b8bea09aSQu Wenruo 			 (__entry->stripe_nr - __entry->nr_data + 1) : 0),
2481b8bea09aSQu Wenruo 		__entry->offset, __entry->opf, __entry->physical, __entry->len)
2482b8bea09aSQu Wenruo );
2483b8bea09aSQu Wenruo 
2484*dbb6ecb3SQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_read,
2485b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2486b8bea09aSQu Wenruo 		 const struct bio *bio,
2487b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2488b8bea09aSQu Wenruo 
2489b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2490b8bea09aSQu Wenruo );
2491b8bea09aSQu Wenruo 
2492*dbb6ecb3SQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_write,
2493b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2494b8bea09aSQu Wenruo 		 const struct bio *bio,
2495b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2496b8bea09aSQu Wenruo 
2497b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2498b8bea09aSQu Wenruo );
2499b8bea09aSQu Wenruo 
25001abe9b8aSliubo #endif /* _TRACE_BTRFS_H */
25011abe9b8aSliubo 
25021abe9b8aSliubo /* This part must be outside protection */
25031abe9b8aSliubo #include <trace/define_trace.h>
2504