xref: /openbmc/linux/include/trace/events/btrfs.h (revision 5bea2508)
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;
351abe9b8aSliubo 
361abe9b8aSliubo #define show_ref_type(type)						\
371abe9b8aSliubo 	__print_symbolic(type,						\
381abe9b8aSliubo 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
391abe9b8aSliubo 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
401abe9b8aSliubo 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
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_INODE_IO_FAILURE,	  "INODE_IO_FAILURE")	    \
88c92bb304SNikolay Borisov 	EM( IO_TREE_RELOC_BLOCKS,	  "RELOC_BLOCKS")	    \
89c92bb304SNikolay Borisov 	EM( IO_TREE_TRANS_DIRTY_PAGES,	  "TRANS_DIRTY_PAGES")      \
90c92bb304SNikolay Borisov 	EM( IO_TREE_ROOT_DIRTY_LOG_PAGES, "ROOT_DIRTY_LOG_PAGES")   \
91c92bb304SNikolay Borisov 	EM( IO_TREE_INODE_FILE_EXTENT,	  "INODE_FILE_EXTENT")      \
92c92bb304SNikolay Borisov 	EM( IO_TREE_LOG_CSUM_RANGE,	  "LOG_CSUM_RANGE")         \
93c92bb304SNikolay Borisov 	EMe(IO_TREE_SELFTEST,		  "SELFTEST")
94c92bb304SNikolay Borisov 
95f0cdd15cSNikolay Borisov #define FLUSH_STATES							\
96f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_ITEMS_NR,	"FLUSH_DELAYED_ITEMS_NR")	\
97f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_ITEMS,	"FLUSH_DELAYED_ITEMS")		\
98f0cdd15cSNikolay Borisov 	EM( FLUSH_DELALLOC,		"FLUSH_DELALLOC")		\
99f0cdd15cSNikolay Borisov 	EM( FLUSH_DELALLOC_WAIT,	"FLUSH_DELALLOC_WAIT")		\
10003fe78ccSJosef Bacik 	EM( FLUSH_DELALLOC_FULL,	"FLUSH_DELALLOC_FULL")		\
101f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_REFS_NR,	"FLUSH_DELAYED_REFS_NR")	\
102f0cdd15cSNikolay Borisov 	EM( FLUSH_DELAYED_REFS,		"FLUSH_ELAYED_REFS")		\
103f0cdd15cSNikolay Borisov 	EM( ALLOC_CHUNK,		"ALLOC_CHUNK")			\
104f0cdd15cSNikolay Borisov 	EM( ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE")		\
105f0cdd15cSNikolay Borisov 	EM( RUN_DELAYED_IPUTS,		"RUN_DELAYED_IPUTS")		\
106c416a30cSJosef Bacik 	EMe(COMMIT_TRANS,		"COMMIT_TRANS")
107f0cdd15cSNikolay Borisov 
1085bca2c95SNikolay Borisov /*
1095bca2c95SNikolay Borisov  * First define the enums in the above macros to be exported to userspace via
1105bca2c95SNikolay Borisov  * TRACE_DEFINE_ENUM().
1115bca2c95SNikolay Borisov  */
1125bca2c95SNikolay Borisov 
1130840dd28SNikolay Borisov #undef EM
1140840dd28SNikolay Borisov #undef EMe
1150840dd28SNikolay Borisov #define EM(a, b)	TRACE_DEFINE_ENUM(a);
1160840dd28SNikolay Borisov #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
1170840dd28SNikolay Borisov 
1185bca2c95SNikolay Borisov FLUSH_ACTIONS
1190840dd28SNikolay Borisov FI_TYPES
1201cb1f0b2SNikolay Borisov QGROUP_RSV_TYPES
121c92bb304SNikolay Borisov IO_TREE_OWNER
122f0cdd15cSNikolay Borisov FLUSH_STATES
1230840dd28SNikolay Borisov 
1245bca2c95SNikolay Borisov /*
1255bca2c95SNikolay Borisov  * Now redefine the EM and EMe macros to map the enums to the strings that will
1265bca2c95SNikolay Borisov  * be printed in the output
1275bca2c95SNikolay Borisov  */
1285bca2c95SNikolay Borisov 
1290840dd28SNikolay Borisov #undef EM
1300840dd28SNikolay Borisov #undef EMe
1310840dd28SNikolay Borisov #define EM(a, b)        {a, b},
1320840dd28SNikolay Borisov #define EMe(a, b)       {a, b}
13309ed2f16SLiu Bo 
134a1d19847SQu Wenruo 
1353f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS	\
1363f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
1373f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
1383f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
1393f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
1403f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
1413f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
142e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
143e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
144e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
1453f7de037SJosef Bacik 
146a1d19847SQu Wenruo #define EXTENT_FLAGS						\
147a1d19847SQu Wenruo 	{ EXTENT_DIRTY,			"DIRTY"},		\
148a1d19847SQu Wenruo 	{ EXTENT_UPTODATE,		"UPTODATE"},		\
149a1d19847SQu Wenruo 	{ EXTENT_LOCKED,		"LOCKED"},		\
150a1d19847SQu Wenruo 	{ EXTENT_NEW,			"NEW"},			\
151a1d19847SQu Wenruo 	{ EXTENT_DELALLOC,		"DELALLOC"},		\
152a1d19847SQu Wenruo 	{ EXTENT_DEFRAG,		"DEFRAG"},		\
153a1d19847SQu Wenruo 	{ EXTENT_BOUNDARY,		"BOUNDARY"},		\
154a1d19847SQu Wenruo 	{ EXTENT_NODATASUM,		"NODATASUM"},		\
155a1d19847SQu Wenruo 	{ EXTENT_CLEAR_META_RESV,	"CLEAR_META_RESV"},	\
156a1d19847SQu Wenruo 	{ EXTENT_NEED_WAIT,		"NEED_WAIT"},		\
157a1d19847SQu Wenruo 	{ EXTENT_DAMAGED,		"DAMAGED"},		\
158a1d19847SQu Wenruo 	{ EXTENT_NORESERVE,		"NORESERVE"},		\
159a1d19847SQu Wenruo 	{ EXTENT_QGROUP_RESERVED,	"QGROUP_RESERVED"},	\
160a1d19847SQu Wenruo 	{ EXTENT_CLEAR_DATA_RESV,	"CLEAR_DATA_RESV"},	\
161a1d19847SQu Wenruo 	{ EXTENT_DELALLOC_NEW,		"DELALLOC_NEW"}
162a1d19847SQu Wenruo 
163b94417eaSAnand Jain #define BTRFS_FSID_SIZE 16
164b94417eaSAnand Jain #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
165bc074524SJeff Mahoney 
166bc074524SJeff Mahoney #define TP_fast_assign_fsid(fs_info)					\
167a1d19847SQu Wenruo ({									\
168a1d19847SQu Wenruo 	if (fs_info)							\
169a1d19847SQu Wenruo 		memcpy(__entry->fsid, fs_info->fs_devices->fsid,	\
170a1d19847SQu Wenruo 		       BTRFS_FSID_SIZE);				\
171a1d19847SQu Wenruo 	else								\
172a1d19847SQu Wenruo 		memset(__entry->fsid, 0, BTRFS_FSID_SIZE);		\
173a1d19847SQu Wenruo })
174bc074524SJeff Mahoney 
175bc074524SJeff Mahoney #define TP_STRUCT__entry_btrfs(args...)					\
176bc074524SJeff Mahoney 	TP_STRUCT__entry(						\
177bc074524SJeff Mahoney 		TP_STRUCT__entry_fsid					\
178bc074524SJeff Mahoney 		args)
179bc074524SJeff Mahoney #define TP_fast_assign_btrfs(fs_info, args...)				\
180bc074524SJeff Mahoney 	TP_fast_assign(							\
181bc074524SJeff Mahoney 		TP_fast_assign_fsid(fs_info);				\
182bc074524SJeff Mahoney 		args)
183bc074524SJeff Mahoney #define TP_printk_btrfs(fmt, args...) \
184bc074524SJeff Mahoney 	TP_printk("%pU: " fmt, __entry->fsid, args)
1858c2a3ca2SJosef Bacik 
1861abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit,
1871abe9b8aSliubo 
1882e4e97abSJosef Bacik 	TP_PROTO(const struct btrfs_fs_info *fs_info),
1891abe9b8aSliubo 
1902e4e97abSJosef Bacik 	TP_ARGS(fs_info),
1911abe9b8aSliubo 
192bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1931abe9b8aSliubo 		__field(	u64,  generation		)
1941abe9b8aSliubo 		__field(	u64,  root_objectid		)
1951abe9b8aSliubo 	),
1961abe9b8aSliubo 
1972e4e97abSJosef Bacik 	TP_fast_assign_btrfs(fs_info,
1982e4e97abSJosef Bacik 		__entry->generation	= fs_info->generation;
1992e4e97abSJosef Bacik 		__entry->root_objectid	= BTRFS_ROOT_TREE_OBJECTID;
2001abe9b8aSliubo 	),
2011abe9b8aSliubo 
20279bcb71aSDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu",
2031abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2048eec8463SDavid Sterba 		  __entry->generation)
2051abe9b8aSliubo );
2061abe9b8aSliubo 
2071abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode,
2081abe9b8aSliubo 
2099a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2101abe9b8aSliubo 
2111abe9b8aSliubo 	TP_ARGS(inode),
2121abe9b8aSliubo 
213bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
214f8f8e189SDavid Sterba 		__field(	u64,  ino			)
21594c3f6c6SDavid Sterba 		__field(	u64,  blocks			)
2161abe9b8aSliubo 		__field(	u64,  disk_i_size		)
2171abe9b8aSliubo 		__field(	u64,  generation		)
2181abe9b8aSliubo 		__field(	u64,  last_trans		)
2191abe9b8aSliubo 		__field(	u64,  logged_trans		)
2201abe9b8aSliubo 		__field(	u64,  root_objectid		)
2211abe9b8aSliubo 	),
2221abe9b8aSliubo 
223bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
224f8f8e189SDavid Sterba 		__entry->ino	= btrfs_ino(BTRFS_I(inode));
2251abe9b8aSliubo 		__entry->blocks	= inode->i_blocks;
2261abe9b8aSliubo 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
2271abe9b8aSliubo 		__entry->generation = BTRFS_I(inode)->generation;
2281abe9b8aSliubo 		__entry->last_trans = BTRFS_I(inode)->last_trans;
2291abe9b8aSliubo 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
2301abe9b8aSliubo 		__entry->root_objectid =
2311abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
2321abe9b8aSliubo 	),
2331abe9b8aSliubo 
234f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
235562a7a07SDavid Sterba 		  "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
2361abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2378eec8463SDavid Sterba 		  __entry->generation,
2388eec8463SDavid Sterba 		  __entry->ino,
23994c3f6c6SDavid Sterba 		  __entry->blocks,
2408eec8463SDavid Sterba 		  __entry->disk_i_size,
2418eec8463SDavid Sterba 		  __entry->last_trans,
2428eec8463SDavid Sterba 		  __entry->logged_trans)
2431abe9b8aSliubo );
2441abe9b8aSliubo 
2451abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
2461abe9b8aSliubo 
2479a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2481abe9b8aSliubo 
2491abe9b8aSliubo 	TP_ARGS(inode)
2501abe9b8aSliubo );
2511abe9b8aSliubo 
2521abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
2531abe9b8aSliubo 
2549a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2551abe9b8aSliubo 
2561abe9b8aSliubo 	TP_ARGS(inode)
2571abe9b8aSliubo );
2581abe9b8aSliubo 
2591abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
2601abe9b8aSliubo 
2619a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode),
2621abe9b8aSliubo 
2631abe9b8aSliubo 	TP_ARGS(inode)
2641abe9b8aSliubo );
2651abe9b8aSliubo 
2661abe9b8aSliubo #define __show_map_type(type)						\
2677f34b746Sliubo 	__print_symbolic_u64(type,					\
2681abe9b8aSliubo 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
2691abe9b8aSliubo 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
2701abe9b8aSliubo 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
2711abe9b8aSliubo 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
2721abe9b8aSliubo 
2731abe9b8aSliubo #define show_map_type(type)			\
2741abe9b8aSliubo 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
2751abe9b8aSliubo 
2761abe9b8aSliubo #define show_map_flags(flag)						\
2771abe9b8aSliubo 	__print_flags(flag, "|",					\
278254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PINNED), 		"PINNED" 	},\
279254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_COMPRESSED), 	"COMPRESSED" 	},\
280254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_PREALLOC), 		"PREALLOC" 	},\
281254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_LOGGING),	 	"LOGGING" 	},\
282254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FILLING),	 	"FILLING" 	},\
283254a2d14SLiu Bo 		{ (1 << EXTENT_FLAG_FS_MAPPING),	"FS_MAPPING"	})
2841abe9b8aSliubo 
2854cd8587cSSteven Rostedt TRACE_EVENT_CONDITION(btrfs_get_extent,
2861abe9b8aSliubo 
2879a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
2889a35b637SJeff Mahoney 		 const struct extent_map *map),
2891abe9b8aSliubo 
29092a1bf76SLiu Bo 	TP_ARGS(root, inode, map),
2911abe9b8aSliubo 
2924cd8587cSSteven Rostedt 	TP_CONDITION(map),
2934cd8587cSSteven Rostedt 
294bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
2951abe9b8aSliubo 		__field(	u64,  root_objectid	)
29692a1bf76SLiu Bo 		__field(	u64,  ino		)
2971abe9b8aSliubo 		__field(	u64,  start		)
2981abe9b8aSliubo 		__field(	u64,  len		)
2991abe9b8aSliubo 		__field(	u64,  orig_start	)
3001abe9b8aSliubo 		__field(	u64,  block_start	)
3011abe9b8aSliubo 		__field(	u64,  block_len		)
3021abe9b8aSliubo 		__field(	unsigned long,  flags	)
3031abe9b8aSliubo 		__field(	int,  refs		)
3041abe9b8aSliubo 		__field(	unsigned int,  compress_type	)
3051abe9b8aSliubo 	),
3061abe9b8aSliubo 
307bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
3081abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
30992a1bf76SLiu Bo 		__entry->ino		= btrfs_ino(inode);
3101abe9b8aSliubo 		__entry->start		= map->start;
3111abe9b8aSliubo 		__entry->len		= map->len;
3121abe9b8aSliubo 		__entry->orig_start	= map->orig_start;
3131abe9b8aSliubo 		__entry->block_start	= map->block_start;
3141abe9b8aSliubo 		__entry->block_len	= map->block_len;
3151abe9b8aSliubo 		__entry->flags		= map->flags;
316490b54d6SElena Reshetova 		__entry->refs		= refcount_read(&map->refs);
3171abe9b8aSliubo 		__entry->compress_type	= map->compress_type;
3181abe9b8aSliubo 	),
3191abe9b8aSliubo 
320562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
321562a7a07SDavid Sterba 		  "orig_start=%llu block_start=%llu(%s) "
322562a7a07SDavid Sterba 		  "block_len=%llu flags=%s refs=%u "
3231abe9b8aSliubo 		  "compress_type=%u",
3241abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3258eec8463SDavid Sterba 		  __entry->ino,
3268eec8463SDavid Sterba 		  __entry->start,
3278eec8463SDavid Sterba 		  __entry->len,
3288eec8463SDavid Sterba 		  __entry->orig_start,
3291abe9b8aSliubo 		  show_map_type(__entry->block_start),
3308eec8463SDavid Sterba 		  __entry->block_len,
3311abe9b8aSliubo 		  show_map_flags(__entry->flags),
3321abe9b8aSliubo 		  __entry->refs, __entry->compress_type)
3331abe9b8aSliubo );
3341abe9b8aSliubo 
335393da918SLiu Bo TRACE_EVENT(btrfs_handle_em_exist,
336393da918SLiu Bo 
3371d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
338f46b24c9SDavid Sterba 		const struct extent_map *existing, const struct extent_map *map,
339f46b24c9SDavid Sterba 		u64 start, u64 len),
340393da918SLiu Bo 
341f46b24c9SDavid Sterba 	TP_ARGS(fs_info, existing, map, start, len),
342393da918SLiu Bo 
343f46b24c9SDavid Sterba 	TP_STRUCT__entry_btrfs(
344393da918SLiu Bo 		__field(	u64,  e_start		)
345393da918SLiu Bo 		__field(	u64,  e_len		)
346393da918SLiu Bo 		__field(	u64,  map_start		)
347393da918SLiu Bo 		__field(	u64,  map_len		)
348393da918SLiu Bo 		__field(	u64,  start		)
349393da918SLiu Bo 		__field(	u64,  len		)
350393da918SLiu Bo 	),
351393da918SLiu Bo 
352f46b24c9SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
353393da918SLiu Bo 		__entry->e_start	= existing->start;
354393da918SLiu Bo 		__entry->e_len		= existing->len;
355393da918SLiu Bo 		__entry->map_start	= map->start;
356393da918SLiu Bo 		__entry->map_len	= map->len;
357393da918SLiu Bo 		__entry->start		= start;
358393da918SLiu Bo 		__entry->len		= len;
359393da918SLiu Bo 	),
360393da918SLiu Bo 
361f46b24c9SDavid Sterba 	TP_printk_btrfs("start=%llu len=%llu "
362393da918SLiu Bo 		  "existing(start=%llu len=%llu) "
363393da918SLiu Bo 		  "em(start=%llu len=%llu)",
3648eec8463SDavid Sterba 		  __entry->start,
3658eec8463SDavid Sterba 		  __entry->len,
3668eec8463SDavid Sterba 		  __entry->e_start,
3678eec8463SDavid Sterba 		  __entry->e_len,
3688eec8463SDavid Sterba 		  __entry->map_start,
3698eec8463SDavid Sterba 		  __entry->map_len)
370393da918SLiu Bo );
371393da918SLiu Bo 
37209ed2f16SLiu Bo /* file extent item */
37309ed2f16SLiu Bo DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
37409ed2f16SLiu Bo 
3751d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
3761d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
37709ed2f16SLiu Bo 
37809ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start),
37909ed2f16SLiu Bo 
38009ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
38109ed2f16SLiu Bo 		__field(	u64,	root_obj	)
38209ed2f16SLiu Bo 		__field(	u64,	ino		)
38309ed2f16SLiu Bo 		__field(	loff_t,	isize		)
38409ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
38509ed2f16SLiu Bo 		__field(	u64,	num_bytes	)
38609ed2f16SLiu Bo 		__field(	u64,	ram_bytes	)
38709ed2f16SLiu Bo 		__field(	u64,	disk_bytenr	)
38809ed2f16SLiu Bo 		__field(	u64,	disk_num_bytes	)
38909ed2f16SLiu Bo 		__field(	u64,	extent_offset	)
39009ed2f16SLiu Bo 		__field(	u8,	extent_type	)
39109ed2f16SLiu Bo 		__field(	u8,	compression	)
39209ed2f16SLiu Bo 		__field(	u64,	extent_start	)
39309ed2f16SLiu Bo 		__field(	u64,	extent_end	)
39409ed2f16SLiu Bo 	),
39509ed2f16SLiu Bo 
39609ed2f16SLiu Bo 	TP_fast_assign_btrfs(bi->root->fs_info,
3974fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
39809ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
39909ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
40009ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
40109ed2f16SLiu Bo 		__entry->num_bytes	= btrfs_file_extent_num_bytes(l, fi);
40209ed2f16SLiu Bo 		__entry->ram_bytes	= btrfs_file_extent_ram_bytes(l, fi);
40309ed2f16SLiu Bo 		__entry->disk_bytenr	= btrfs_file_extent_disk_bytenr(l, fi);
40409ed2f16SLiu Bo 		__entry->disk_num_bytes	= btrfs_file_extent_disk_num_bytes(l, fi);
40509ed2f16SLiu Bo 		__entry->extent_offset	= btrfs_file_extent_offset(l, fi);
40609ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
40709ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
40809ed2f16SLiu Bo 		__entry->extent_start	= start;
40909ed2f16SLiu Bo 		__entry->extent_end	= (start + __entry->num_bytes);
41009ed2f16SLiu Bo 	),
41109ed2f16SLiu Bo 
41209ed2f16SLiu Bo 	TP_printk_btrfs(
41309ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
41409ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
41509ed2f16SLiu Bo 		"(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
41609ed2f16SLiu Bo 		"disk_num_bytes=%llu extent_offset=%llu type=%s "
41709ed2f16SLiu Bo 		"compression=%u",
41809ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino,
41909ed2f16SLiu Bo 		__entry->isize,
42009ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
42109ed2f16SLiu Bo 		__entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
42209ed2f16SLiu Bo 		__entry->disk_bytenr, __entry->disk_num_bytes,
4230840dd28SNikolay Borisov 		__entry->extent_offset, __print_symbolic(__entry->extent_type, FI_TYPES),
42409ed2f16SLiu Bo 		__entry->compression)
42509ed2f16SLiu Bo );
42609ed2f16SLiu Bo 
42709ed2f16SLiu Bo DECLARE_EVENT_CLASS(
42809ed2f16SLiu Bo 	btrfs__file_extent_item_inline,
42909ed2f16SLiu Bo 
4301d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4311d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
43209ed2f16SLiu Bo 
43309ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot,  start),
43409ed2f16SLiu Bo 
43509ed2f16SLiu Bo 	TP_STRUCT__entry_btrfs(
43609ed2f16SLiu Bo 		__field(	u64,	root_obj	)
43709ed2f16SLiu Bo 		__field(	u64,	ino		)
43809ed2f16SLiu Bo 		__field(	loff_t,	isize		)
43909ed2f16SLiu Bo 		__field(	u64,	disk_isize	)
44009ed2f16SLiu Bo 		__field(	u8,	extent_type	)
44109ed2f16SLiu Bo 		__field(	u8,	compression	)
44209ed2f16SLiu Bo 		__field(	u64,	extent_start	)
44309ed2f16SLiu Bo 		__field(	u64,	extent_end	)
44409ed2f16SLiu Bo 	),
44509ed2f16SLiu Bo 
44609ed2f16SLiu Bo 	TP_fast_assign_btrfs(
44709ed2f16SLiu Bo 		bi->root->fs_info,
4484fd786e6SMisono Tomohiro 		__entry->root_obj	= bi->root->root_key.objectid;
44909ed2f16SLiu Bo 		__entry->ino		= btrfs_ino(bi);
45009ed2f16SLiu Bo 		__entry->isize		= bi->vfs_inode.i_size;
45109ed2f16SLiu Bo 		__entry->disk_isize	= bi->disk_i_size;
45209ed2f16SLiu Bo 		__entry->extent_type	= btrfs_file_extent_type(l, fi);
45309ed2f16SLiu Bo 		__entry->compression	= btrfs_file_extent_compression(l, fi);
45409ed2f16SLiu Bo 		__entry->extent_start	= start;
455e41ca589SQu Wenruo 		__entry->extent_end	= (start + btrfs_file_extent_ram_bytes(l, fi));
45609ed2f16SLiu Bo 	),
45709ed2f16SLiu Bo 
45809ed2f16SLiu Bo 	TP_printk_btrfs(
45909ed2f16SLiu Bo 		"root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
46009ed2f16SLiu Bo 		"file extent range=[%llu %llu] "
46109ed2f16SLiu Bo 		"extent_type=%s compression=%u",
46209ed2f16SLiu Bo 		show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
46309ed2f16SLiu Bo 		__entry->disk_isize, __entry->extent_start,
4640840dd28SNikolay Borisov 		__entry->extent_end, __print_symbolic(__entry->extent_type, FI_TYPES),
46509ed2f16SLiu Bo 		__entry->compression)
46609ed2f16SLiu Bo );
46709ed2f16SLiu Bo 
46809ed2f16SLiu Bo DEFINE_EVENT(
46909ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
47009ed2f16SLiu Bo 
4711d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4721d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
47309ed2f16SLiu Bo 
47409ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
47509ed2f16SLiu Bo );
47609ed2f16SLiu Bo 
47709ed2f16SLiu Bo DEFINE_EVENT(
47809ed2f16SLiu Bo 	btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
47909ed2f16SLiu Bo 
4801d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4811d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, u64 start),
48209ed2f16SLiu Bo 
48309ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, start)
48409ed2f16SLiu Bo );
48509ed2f16SLiu Bo 
48609ed2f16SLiu Bo DEFINE_EVENT(
48709ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
48809ed2f16SLiu Bo 
4891d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4901d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
49109ed2f16SLiu Bo 
49209ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
49309ed2f16SLiu Bo );
49409ed2f16SLiu Bo 
49509ed2f16SLiu Bo DEFINE_EVENT(
49609ed2f16SLiu Bo 	btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
49709ed2f16SLiu Bo 
4981d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_inode *bi, const struct extent_buffer *l,
4991d2e7c7cSDavid Sterba 		 const struct btrfs_file_extent_item *fi, int slot, u64 start),
50009ed2f16SLiu Bo 
50109ed2f16SLiu Bo 	TP_ARGS(bi, l, fi, slot, start)
50209ed2f16SLiu Bo );
50309ed2f16SLiu Bo 
5041abe9b8aSliubo #define show_ordered_flags(flags)					   \
5059d04a8ceSLiu Bo 	__print_flags(flags, "|",					   \
5063c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_REGULAR), 	"REGULAR" 	}, \
5073c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_NOCOW), 		"NOCOW" 	}, \
5083c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_PREALLOC), 	"PREALLOC" 	}, \
5093c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_COMPRESSED), 	"COMPRESSED" 	}, \
5103c198fe0SQu Wenruo 		{ (1 << BTRFS_ORDERED_DIRECT),	 	"DIRECT" 	}, \
5119d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IO_DONE), 	"IO_DONE" 	}, \
5129d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_COMPLETE), 	"COMPLETE" 	}, \
5139d04a8ceSLiu Bo 		{ (1 << BTRFS_ORDERED_IOERR), 		"IOERR" 	}, \
514792ddef0SLiu Bo 		{ (1 << BTRFS_ORDERED_TRUNCATED), 	"TRUNCATED"	})
515e112e2b4SLiu Bo 
5161abe9b8aSliubo 
5171abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent,
5181abe9b8aSliubo 
519acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5209a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5211abe9b8aSliubo 
5221abe9b8aSliubo 	TP_ARGS(inode, ordered),
5231abe9b8aSliubo 
524bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
525f8f8e189SDavid Sterba 		__field(	u64,  ino		)
5261abe9b8aSliubo 		__field(	u64,  file_offset	)
5271abe9b8aSliubo 		__field(	u64,  start		)
5281abe9b8aSliubo 		__field(	u64,  len		)
5291abe9b8aSliubo 		__field(	u64,  disk_len		)
5301abe9b8aSliubo 		__field(	u64,  bytes_left	)
5311abe9b8aSliubo 		__field(	unsigned long,  flags	)
5321abe9b8aSliubo 		__field(	int,  compress_type	)
5331abe9b8aSliubo 		__field(	int,  refs		)
5341abe9b8aSliubo 		__field(	u64,  root_objectid	)
53578566548SLiu Bo 		__field(	u64,  truncated_len	)
5361abe9b8aSliubo 	),
5371abe9b8aSliubo 
538acbf1dd0SNikolay Borisov 	TP_fast_assign_btrfs(inode->root->fs_info,
539acbf1dd0SNikolay Borisov 		__entry->ino 		= btrfs_ino(inode);
5401abe9b8aSliubo 		__entry->file_offset	= ordered->file_offset;
541bffe633eSOmar Sandoval 		__entry->start		= ordered->disk_bytenr;
542bffe633eSOmar Sandoval 		__entry->len		= ordered->num_bytes;
543bffe633eSOmar Sandoval 		__entry->disk_len	= ordered->disk_num_bytes;
5441abe9b8aSliubo 		__entry->bytes_left	= ordered->bytes_left;
5451abe9b8aSliubo 		__entry->flags		= ordered->flags;
5461abe9b8aSliubo 		__entry->compress_type	= ordered->compress_type;
547e76edab7SElena Reshetova 		__entry->refs		= refcount_read(&ordered->refs);
548acbf1dd0SNikolay Borisov 		__entry->root_objectid	= inode->root->root_key.objectid;
54978566548SLiu Bo 		__entry->truncated_len	= ordered->truncated_len;
5501abe9b8aSliubo 	),
5511abe9b8aSliubo 
552562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
553562a7a07SDavid Sterba 		  "start=%llu len=%llu disk_len=%llu "
554562a7a07SDavid Sterba 		  "truncated_len=%llu "
555562a7a07SDavid Sterba 		  "bytes_left=%llu flags=%s compress_type=%d "
5561abe9b8aSliubo 		  "refs=%d",
5571abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
5588eec8463SDavid Sterba 		  __entry->ino,
5598eec8463SDavid Sterba 		  __entry->file_offset,
5608eec8463SDavid Sterba 		  __entry->start,
5618eec8463SDavid Sterba 		  __entry->len,
5628eec8463SDavid Sterba 		  __entry->disk_len,
5638eec8463SDavid Sterba 		  __entry->truncated_len,
5648eec8463SDavid Sterba 		  __entry->bytes_left,
5651abe9b8aSliubo 		  show_ordered_flags(__entry->flags),
5661abe9b8aSliubo 		  __entry->compress_type, __entry->refs)
5671abe9b8aSliubo );
5681abe9b8aSliubo 
5691abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
5701abe9b8aSliubo 
571acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5729a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5731abe9b8aSliubo 
5741abe9b8aSliubo 	TP_ARGS(inode, ordered)
5751abe9b8aSliubo );
5761abe9b8aSliubo 
5771abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
5781abe9b8aSliubo 
579acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5809a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5811abe9b8aSliubo 
5821abe9b8aSliubo 	TP_ARGS(inode, ordered)
5831abe9b8aSliubo );
5841abe9b8aSliubo 
5851abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
5861abe9b8aSliubo 
587acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5889a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5891abe9b8aSliubo 
5901abe9b8aSliubo 	TP_ARGS(inode, ordered)
5911abe9b8aSliubo );
5921abe9b8aSliubo 
5931abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
5941abe9b8aSliubo 
595acbf1dd0SNikolay Borisov 	TP_PROTO(const struct btrfs_inode *inode,
5969a35b637SJeff Mahoney 		 const struct btrfs_ordered_extent *ordered),
5971abe9b8aSliubo 
5981abe9b8aSliubo 	TP_ARGS(inode, ordered)
5991abe9b8aSliubo );
6001abe9b8aSliubo 
601*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup,
602*5bea2508SJohannes Thumshirn 
603*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
604*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
605*5bea2508SJohannes Thumshirn 
606*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
607*5bea2508SJohannes Thumshirn );
608*5bea2508SJohannes Thumshirn 
609*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_range,
610*5bea2508SJohannes Thumshirn 
611*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
612*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
613*5bea2508SJohannes Thumshirn 
614*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
615*5bea2508SJohannes Thumshirn );
616*5bea2508SJohannes Thumshirn 
617*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_first_range,
618*5bea2508SJohannes Thumshirn 
619*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
620*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
621*5bea2508SJohannes Thumshirn 
622*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
623*5bea2508SJohannes Thumshirn );
624*5bea2508SJohannes Thumshirn 
625*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_for_logging,
626*5bea2508SJohannes Thumshirn 
627*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
628*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
629*5bea2508SJohannes Thumshirn 
630*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
631*5bea2508SJohannes Thumshirn );
632*5bea2508SJohannes Thumshirn 
633*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_lookup_first,
634*5bea2508SJohannes Thumshirn 
635*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
636*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
637*5bea2508SJohannes Thumshirn 
638*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
639*5bea2508SJohannes Thumshirn );
640*5bea2508SJohannes Thumshirn 
641*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_split,
642*5bea2508SJohannes Thumshirn 
643*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
644*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
645*5bea2508SJohannes Thumshirn 
646*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
647*5bea2508SJohannes Thumshirn );
648*5bea2508SJohannes Thumshirn 
649*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_dec_test_pending,
650*5bea2508SJohannes Thumshirn 
651*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
652*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
653*5bea2508SJohannes Thumshirn 
654*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
655*5bea2508SJohannes Thumshirn );
656*5bea2508SJohannes Thumshirn 
657*5bea2508SJohannes Thumshirn DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_mark_finished,
658*5bea2508SJohannes Thumshirn 
659*5bea2508SJohannes Thumshirn 	     TP_PROTO(const struct btrfs_inode *inode,
660*5bea2508SJohannes Thumshirn 		      const struct btrfs_ordered_extent *ordered),
661*5bea2508SJohannes Thumshirn 
662*5bea2508SJohannes Thumshirn 	     TP_ARGS(inode, ordered)
663*5bea2508SJohannes Thumshirn );
664*5bea2508SJohannes Thumshirn 
6651abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage,
6661abe9b8aSliubo 
6679a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
6689a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
6691abe9b8aSliubo 
6701abe9b8aSliubo 	TP_ARGS(page, inode, wbc),
6711abe9b8aSliubo 
672bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
673f8f8e189SDavid Sterba 		__field(	u64,	ino			)
6741abe9b8aSliubo 		__field(	pgoff_t,  index			)
6751abe9b8aSliubo 		__field(	long,   nr_to_write		)
6761abe9b8aSliubo 		__field(	long,   pages_skipped		)
6771abe9b8aSliubo 		__field(	loff_t, range_start		)
6781abe9b8aSliubo 		__field(	loff_t, range_end		)
6791abe9b8aSliubo 		__field(	char,   for_kupdate		)
6801abe9b8aSliubo 		__field(	char,   for_reclaim		)
6811abe9b8aSliubo 		__field(	char,   range_cyclic		)
68294c3f6c6SDavid Sterba 		__field(	unsigned long,  writeback_index	)
6831abe9b8aSliubo 		__field(	u64,    root_objectid		)
6841abe9b8aSliubo 	),
6851abe9b8aSliubo 
686bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
687f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
6881abe9b8aSliubo 		__entry->index		= page->index;
6891abe9b8aSliubo 		__entry->nr_to_write	= wbc->nr_to_write;
6901abe9b8aSliubo 		__entry->pages_skipped	= wbc->pages_skipped;
6911abe9b8aSliubo 		__entry->range_start	= wbc->range_start;
6921abe9b8aSliubo 		__entry->range_end	= wbc->range_end;
6931abe9b8aSliubo 		__entry->for_kupdate	= wbc->for_kupdate;
6941abe9b8aSliubo 		__entry->for_reclaim	= wbc->for_reclaim;
6951abe9b8aSliubo 		__entry->range_cyclic	= wbc->range_cyclic;
6961abe9b8aSliubo 		__entry->writeback_index = inode->i_mapping->writeback_index;
6971abe9b8aSliubo 		__entry->root_objectid	=
6981abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
6991abe9b8aSliubo 	),
7001abe9b8aSliubo 
701f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
702562a7a07SDavid Sterba 		  "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
703562a7a07SDavid Sterba 		  "range_end=%llu for_kupdate=%d "
704562a7a07SDavid Sterba 		  "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
7051abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
7068eec8463SDavid Sterba 		  __entry->ino, __entry->index,
7071abe9b8aSliubo 		  __entry->nr_to_write, __entry->pages_skipped,
7081abe9b8aSliubo 		  __entry->range_start, __entry->range_end,
709846d5a09SWu Fengguang 		  __entry->for_kupdate,
7101abe9b8aSliubo 		  __entry->for_reclaim, __entry->range_cyclic,
71194c3f6c6SDavid Sterba 		  __entry->writeback_index)
7121abe9b8aSliubo );
7131abe9b8aSliubo 
7141abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage,
7151abe9b8aSliubo 
7169a35b637SJeff Mahoney 	TP_PROTO(const struct page *page, const struct inode *inode,
7179a35b637SJeff Mahoney 		 const struct writeback_control *wbc),
7181abe9b8aSliubo 
7191abe9b8aSliubo 	TP_ARGS(page, inode, wbc)
7201abe9b8aSliubo );
7211abe9b8aSliubo 
7221abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook,
7231abe9b8aSliubo 
72438a39ac7SQu Wenruo 	TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 end,
72538a39ac7SQu Wenruo 		 int uptodate),
7261abe9b8aSliubo 
72738a39ac7SQu Wenruo 	TP_ARGS(inode, start, end, uptodate),
7281abe9b8aSliubo 
729bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
730f8f8e189SDavid Sterba 		__field(	u64,	 ino		)
7311abe9b8aSliubo 		__field(	u64,	 start		)
7321abe9b8aSliubo 		__field(	u64,	 end		)
7331abe9b8aSliubo 		__field(	int,	 uptodate	)
7341abe9b8aSliubo 		__field(	u64,    root_objectid	)
7351abe9b8aSliubo 	),
7361abe9b8aSliubo 
73738a39ac7SQu Wenruo 	TP_fast_assign_btrfs(inode->root->fs_info,
73838a39ac7SQu Wenruo 		__entry->ino	= btrfs_ino(inode);
7391abe9b8aSliubo 		__entry->start	= start;
7401abe9b8aSliubo 		__entry->end	= end;
7411abe9b8aSliubo 		__entry->uptodate = uptodate;
74238a39ac7SQu Wenruo 		__entry->root_objectid = inode->root->root_key.objectid;
7431abe9b8aSliubo 	),
7441abe9b8aSliubo 
74538a39ac7SQu Wenruo 	TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu end=%llu uptodate=%d",
7461abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
74738a39ac7SQu Wenruo 		  __entry->ino, __entry->start,
7488eec8463SDavid Sterba 		  __entry->end, __entry->uptodate)
7491abe9b8aSliubo );
7501abe9b8aSliubo 
7511abe9b8aSliubo TRACE_EVENT(btrfs_sync_file,
7521abe9b8aSliubo 
7539a35b637SJeff Mahoney 	TP_PROTO(const struct file *file, int datasync),
7541abe9b8aSliubo 
7551abe9b8aSliubo 	TP_ARGS(file, datasync),
7561abe9b8aSliubo 
757bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
758f8f8e189SDavid Sterba 		__field(	u64,	ino		)
759f8f8e189SDavid Sterba 		__field(	u64,	parent		)
7601abe9b8aSliubo 		__field(	int,    datasync	)
7611abe9b8aSliubo 		__field(	u64,    root_objectid	)
7621abe9b8aSliubo 	),
7631abe9b8aSliubo 
7641abe9b8aSliubo 	TP_fast_assign(
7659a35b637SJeff Mahoney 		const struct dentry *dentry = file->f_path.dentry;
7669a35b637SJeff Mahoney 		const struct inode *inode = d_inode(dentry);
7671abe9b8aSliubo 
768bc074524SJeff Mahoney 		TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
769f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
770f8f8e189SDavid Sterba 		__entry->parent		= btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
7711abe9b8aSliubo 		__entry->datasync	= datasync;
7721abe9b8aSliubo 		__entry->root_objectid	=
7731abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
7741abe9b8aSliubo 	),
7751abe9b8aSliubo 
776f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
7771abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
7788eec8463SDavid Sterba 		  __entry->ino,
7798eec8463SDavid Sterba 		  __entry->parent,
7801abe9b8aSliubo 		  __entry->datasync)
7811abe9b8aSliubo );
7821abe9b8aSliubo 
7831abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs,
7841abe9b8aSliubo 
7859a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
7861abe9b8aSliubo 
787bc074524SJeff Mahoney 	TP_ARGS(fs_info, wait),
7881abe9b8aSliubo 
789bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
7901abe9b8aSliubo 		__field(	int,  wait		)
7911abe9b8aSliubo 	),
7921abe9b8aSliubo 
793bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
7941abe9b8aSliubo 		__entry->wait	= wait;
7951abe9b8aSliubo 	),
7961abe9b8aSliubo 
797bc074524SJeff Mahoney 	TP_printk_btrfs("wait=%d", __entry->wait)
7981abe9b8aSliubo );
7991abe9b8aSliubo 
800c83f8effSJosef Bacik TRACE_EVENT(btrfs_add_block_group,
801c83f8effSJosef Bacik 
8029a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
80332da5386SDavid Sterba 		 const struct btrfs_block_group *block_group, int create),
804c83f8effSJosef Bacik 
805c83f8effSJosef Bacik 	TP_ARGS(fs_info, block_group, create),
806c83f8effSJosef Bacik 
8072e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
808c83f8effSJosef Bacik 		__field(	u64,	offset			)
809c83f8effSJosef Bacik 		__field(	u64,	size			)
810c83f8effSJosef Bacik 		__field(	u64,	flags			)
811c83f8effSJosef Bacik 		__field(	u64,	bytes_used		)
812c83f8effSJosef Bacik 		__field(	u64,	bytes_super		)
813c83f8effSJosef Bacik 		__field(	int,	create			)
814c83f8effSJosef Bacik 	),
815c83f8effSJosef Bacik 
8162e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
817b3470b5dSDavid Sterba 		__entry->offset		= block_group->start;
818b3470b5dSDavid Sterba 		__entry->size		= block_group->length;
819c83f8effSJosef Bacik 		__entry->flags		= block_group->flags;
820bf38be65SDavid Sterba 		__entry->bytes_used	= block_group->used;
821c83f8effSJosef Bacik 		__entry->bytes_super	= block_group->bytes_super;
822c83f8effSJosef Bacik 		__entry->create		= create;
823c83f8effSJosef Bacik 	),
824c83f8effSJosef Bacik 
8252e63e62dSDavid Sterba 	TP_printk_btrfs("block_group offset=%llu size=%llu "
826562a7a07SDavid Sterba 		  "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
8272e63e62dSDavid Sterba 		  "create=%d",
8288eec8463SDavid Sterba 		  __entry->offset,
8298eec8463SDavid Sterba 		  __entry->size,
8308eec8463SDavid Sterba 		  __entry->flags,
831c83f8effSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
832c83f8effSJosef Bacik 				BTRFS_GROUP_FLAGS),
8338eec8463SDavid Sterba 		  __entry->bytes_used,
8348eec8463SDavid Sterba 		  __entry->bytes_super, __entry->create)
835c83f8effSJosef Bacik );
836c83f8effSJosef Bacik 
8371abe9b8aSliubo #define show_ref_action(action)						\
8381abe9b8aSliubo 	__print_symbolic(action,					\
8391abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
8401abe9b8aSliubo 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
8411abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
8421abe9b8aSliubo 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
8431abe9b8aSliubo 
8441abe9b8aSliubo 
845599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
8461abe9b8aSliubo 
8479a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8489a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8499a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
8501abe9b8aSliubo 		 int action),
8511abe9b8aSliubo 
852bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
8531abe9b8aSliubo 
854bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
8551abe9b8aSliubo 		__field(	u64,  bytenr		)
8561abe9b8aSliubo 		__field(	u64,  num_bytes		)
8571abe9b8aSliubo 		__field(	int,  action		)
8581abe9b8aSliubo 		__field(	u64,  parent		)
8591abe9b8aSliubo 		__field(	u64,  ref_root		)
8601abe9b8aSliubo 		__field(	int,  level		)
8611abe9b8aSliubo 		__field(	int,  type		)
862dea7d76eSLiu Bo 		__field(	u64,  seq		)
8631abe9b8aSliubo 	),
8641abe9b8aSliubo 
865bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
8661abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
8671abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
8681abe9b8aSliubo 		__entry->action		= action;
8691abe9b8aSliubo 		__entry->parent		= full_ref->parent;
8701abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
8711abe9b8aSliubo 		__entry->level		= full_ref->level;
8721abe9b8aSliubo 		__entry->type		= ref->type;
873dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
8741abe9b8aSliubo 	),
8751abe9b8aSliubo 
876562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
877562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) level=%d "
878562a7a07SDavid Sterba 		  "type=%s seq=%llu",
8798eec8463SDavid Sterba 		  __entry->bytenr,
8808eec8463SDavid Sterba 		  __entry->num_bytes,
8811abe9b8aSliubo 		  show_ref_action(__entry->action),
8821abe9b8aSliubo 		  show_root_type(__entry->parent),
8831abe9b8aSliubo 		  show_root_type(__entry->ref_root),
884dea7d76eSLiu Bo 		  __entry->level, show_ref_type(__entry->type),
8858eec8463SDavid Sterba 		  __entry->seq)
8861abe9b8aSliubo );
8871abe9b8aSliubo 
888599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
889599c75ecSLiu Bo 
8909a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
8919a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
8929a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
893599c75ecSLiu Bo 		 int action),
894599c75ecSLiu Bo 
895bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
896599c75ecSLiu Bo );
897599c75ecSLiu Bo 
898599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
899599c75ecSLiu Bo 
9009a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9019a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9029a35b637SJeff Mahoney 		 const struct btrfs_delayed_tree_ref *full_ref,
903599c75ecSLiu Bo 		 int action),
904599c75ecSLiu Bo 
905bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
906599c75ecSLiu Bo );
907599c75ecSLiu Bo 
908599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
9091abe9b8aSliubo 
9109a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9119a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9129a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
9131abe9b8aSliubo 		 int action),
9141abe9b8aSliubo 
915bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action),
9161abe9b8aSliubo 
917bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9181abe9b8aSliubo 		__field(	u64,  bytenr		)
9191abe9b8aSliubo 		__field(	u64,  num_bytes		)
9201abe9b8aSliubo 		__field(	int,  action		)
9211abe9b8aSliubo 		__field(	u64,  parent		)
9221abe9b8aSliubo 		__field(	u64,  ref_root		)
9231abe9b8aSliubo 		__field(	u64,  owner		)
9241abe9b8aSliubo 		__field(	u64,  offset		)
9251abe9b8aSliubo 		__field(	int,  type		)
926dea7d76eSLiu Bo 		__field(	u64,  seq		)
9271abe9b8aSliubo 	),
9281abe9b8aSliubo 
929bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
9301abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
9311abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
9321abe9b8aSliubo 		__entry->action		= action;
9331abe9b8aSliubo 		__entry->parent		= full_ref->parent;
9341abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
9351abe9b8aSliubo 		__entry->owner		= full_ref->objectid;
9361abe9b8aSliubo 		__entry->offset		= full_ref->offset;
9371abe9b8aSliubo 		__entry->type		= ref->type;
938dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
9391abe9b8aSliubo 	),
9401abe9b8aSliubo 
941562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
942562a7a07SDavid Sterba 		  "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
943562a7a07SDavid Sterba 		  "offset=%llu type=%s seq=%llu",
9448eec8463SDavid Sterba 		  __entry->bytenr,
9458eec8463SDavid Sterba 		  __entry->num_bytes,
9461abe9b8aSliubo 		  show_ref_action(__entry->action),
9471abe9b8aSliubo 		  show_root_type(__entry->parent),
9481abe9b8aSliubo 		  show_root_type(__entry->ref_root),
9498eec8463SDavid Sterba 		  __entry->owner,
9508eec8463SDavid Sterba 		  __entry->offset,
951dea7d76eSLiu Bo 		  show_ref_type(__entry->type),
9528eec8463SDavid Sterba 		  __entry->seq)
9531abe9b8aSliubo );
9541abe9b8aSliubo 
955599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
956599c75ecSLiu Bo 
9579a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9589a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9599a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
960599c75ecSLiu Bo 		 int action),
961599c75ecSLiu Bo 
962bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
963599c75ecSLiu Bo );
964599c75ecSLiu Bo 
965599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
966599c75ecSLiu Bo 
9679a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9689a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_node *ref,
9699a35b637SJeff Mahoney 		 const struct btrfs_delayed_data_ref *full_ref,
970599c75ecSLiu Bo 		 int action),
971599c75ecSLiu Bo 
972bc074524SJeff Mahoney 	TP_ARGS(fs_info, ref, full_ref, action)
973599c75ecSLiu Bo );
974599c75ecSLiu Bo 
975599c75ecSLiu Bo DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
9761abe9b8aSliubo 
9779a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
9789a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
9791abe9b8aSliubo 		 int action),
9801abe9b8aSliubo 
981d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action),
9821abe9b8aSliubo 
983bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
9841abe9b8aSliubo 		__field(	u64,  bytenr		)
9851abe9b8aSliubo 		__field(	u64,  num_bytes		)
9861abe9b8aSliubo 		__field(	int,  action		)
9871abe9b8aSliubo 		__field(	int,  is_data		)
9881abe9b8aSliubo 	),
9891abe9b8aSliubo 
990bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
991d278850eSJosef Bacik 		__entry->bytenr		= head_ref->bytenr;
992d278850eSJosef Bacik 		__entry->num_bytes	= head_ref->num_bytes;
9931abe9b8aSliubo 		__entry->action		= action;
9941abe9b8aSliubo 		__entry->is_data	= head_ref->is_data;
9951abe9b8aSliubo 	),
9961abe9b8aSliubo 
997562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
9988eec8463SDavid Sterba 		  __entry->bytenr,
9998eec8463SDavid Sterba 		  __entry->num_bytes,
10001abe9b8aSliubo 		  show_ref_action(__entry->action),
10011abe9b8aSliubo 		  __entry->is_data)
10021abe9b8aSliubo );
10031abe9b8aSliubo 
1004599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
1005599c75ecSLiu Bo 
10069a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10079a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
1008599c75ecSLiu Bo 		 int action),
1009599c75ecSLiu Bo 
1010d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
1011599c75ecSLiu Bo );
1012599c75ecSLiu Bo 
1013599c75ecSLiu Bo DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
1014599c75ecSLiu Bo 
10159a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10169a35b637SJeff Mahoney 		 const struct btrfs_delayed_ref_head *head_ref,
1017599c75ecSLiu Bo 		 int action),
1018599c75ecSLiu Bo 
1019d278850eSJosef Bacik 	TP_ARGS(fs_info, head_ref, action)
1020599c75ecSLiu Bo );
1021599c75ecSLiu Bo 
10221abe9b8aSliubo #define show_chunk_type(type)					\
10231abe9b8aSliubo 	__print_flags(type, "|",				\
10241abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
10251abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
10261abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
10271abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
10281abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
10291abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
1030e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
1031e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
1032e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
10331abe9b8aSliubo 
10341abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk,
10351abe9b8aSliubo 
10369a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10379a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10381abe9b8aSliubo 
10396bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size),
10401abe9b8aSliubo 
1041bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10421abe9b8aSliubo 		__field(	int,  num_stripes		)
10431abe9b8aSliubo 		__field(	u64,  type			)
10441abe9b8aSliubo 		__field(	int,  sub_stripes		)
10451abe9b8aSliubo 		__field(	u64,  offset			)
10461abe9b8aSliubo 		__field(	u64,  size			)
10471abe9b8aSliubo 		__field(	u64,  root_objectid		)
10481abe9b8aSliubo 	),
10491abe9b8aSliubo 
10506bccf3abSJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
10511abe9b8aSliubo 		__entry->num_stripes	= map->num_stripes;
10521abe9b8aSliubo 		__entry->type		= map->type;
10531abe9b8aSliubo 		__entry->sub_stripes	= map->sub_stripes;
10541abe9b8aSliubo 		__entry->offset		= offset;
10551abe9b8aSliubo 		__entry->size		= size;
10566bccf3abSJeff Mahoney 		__entry->root_objectid	= fs_info->chunk_root->root_key.objectid;
10571abe9b8aSliubo 	),
10581abe9b8aSliubo 
1059562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
1060562a7a07SDavid Sterba 		  "num_stripes=%d sub_stripes=%d type=%s",
10611abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
10628eec8463SDavid Sterba 		  __entry->offset,
10638eec8463SDavid Sterba 		  __entry->size,
10641abe9b8aSliubo 		  __entry->num_stripes, __entry->sub_stripes,
10651abe9b8aSliubo 		  show_chunk_type(__entry->type))
10661abe9b8aSliubo );
10671abe9b8aSliubo 
10681abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
10691abe9b8aSliubo 
10709a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10719a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10721abe9b8aSliubo 
10736bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
10741abe9b8aSliubo );
10751abe9b8aSliubo 
10761abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
10771abe9b8aSliubo 
10789a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
10799a35b637SJeff Mahoney 		 const struct map_lookup *map, u64 offset, u64 size),
10801abe9b8aSliubo 
10816bccf3abSJeff Mahoney 	TP_ARGS(fs_info, map, offset, size)
10821abe9b8aSliubo );
10831abe9b8aSliubo 
10841abe9b8aSliubo TRACE_EVENT(btrfs_cow_block,
10851abe9b8aSliubo 
10869a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
10879a35b637SJeff Mahoney 		 const struct extent_buffer *cow),
10881abe9b8aSliubo 
10891abe9b8aSliubo 	TP_ARGS(root, buf, cow),
10901abe9b8aSliubo 
1091bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
10921abe9b8aSliubo 		__field(	u64,  root_objectid		)
10931abe9b8aSliubo 		__field(	u64,  buf_start			)
10941abe9b8aSliubo 		__field(	int,  refs			)
10951abe9b8aSliubo 		__field(	u64,  cow_start			)
10961abe9b8aSliubo 		__field(	int,  buf_level			)
10971abe9b8aSliubo 		__field(	int,  cow_level			)
10981abe9b8aSliubo 	),
10991abe9b8aSliubo 
1100bc074524SJeff Mahoney 	TP_fast_assign_btrfs(root->fs_info,
11011abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
11021abe9b8aSliubo 		__entry->buf_start	= buf->start;
11031abe9b8aSliubo 		__entry->refs		= atomic_read(&buf->refs);
11041abe9b8aSliubo 		__entry->cow_start	= cow->start;
11051abe9b8aSliubo 		__entry->buf_level	= btrfs_header_level(buf);
11061abe9b8aSliubo 		__entry->cow_level	= btrfs_header_level(cow);
11071abe9b8aSliubo 	),
11081abe9b8aSliubo 
1109562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
1110562a7a07SDavid Sterba 		  "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
11111abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
11121abe9b8aSliubo 		  __entry->refs,
11138eec8463SDavid Sterba 		  __entry->buf_start,
11141abe9b8aSliubo 		  __entry->buf_level,
11158eec8463SDavid Sterba 		  __entry->cow_start,
11161abe9b8aSliubo 		  __entry->cow_level)
11171abe9b8aSliubo );
11181abe9b8aSliubo 
11198c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation,
11208c2a3ca2SJosef Bacik 
11211d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info, const char *type, u64 val,
11228c2a3ca2SJosef Bacik 		 u64 bytes, int reserve),
11238c2a3ca2SJosef Bacik 
11248c2a3ca2SJosef Bacik 	TP_ARGS(fs_info, type, val, bytes, reserve),
11258c2a3ca2SJosef Bacik 
1126bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
11278c2a3ca2SJosef Bacik 		__string(	type,	type			)
11288c2a3ca2SJosef Bacik 		__field(	u64,	val			)
11298c2a3ca2SJosef Bacik 		__field(	u64,	bytes			)
11308c2a3ca2SJosef Bacik 		__field(	int,	reserve			)
11318c2a3ca2SJosef Bacik 	),
11328c2a3ca2SJosef Bacik 
1133bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
11348c2a3ca2SJosef Bacik 		__assign_str(type, type);
11358c2a3ca2SJosef Bacik 		__entry->val		= val;
11368c2a3ca2SJosef Bacik 		__entry->bytes		= bytes;
11378c2a3ca2SJosef Bacik 		__entry->reserve	= reserve;
11388c2a3ca2SJosef Bacik 	),
11398c2a3ca2SJosef Bacik 
11405439c7f5SDavid Sterba 	TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
1141bc074524SJeff Mahoney 			__entry->reserve ? "reserve" : "release",
11428c2a3ca2SJosef Bacik 			__entry->bytes)
11438c2a3ca2SJosef Bacik );
11448c2a3ca2SJosef Bacik 
1145f376df2bSJosef Bacik TRACE_EVENT(btrfs_trigger_flush,
1146f376df2bSJosef Bacik 
11479a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
11481d2e7c7cSDavid Sterba 		 int flush, const char *reason),
1149f376df2bSJosef Bacik 
1150f376df2bSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, flush, reason),
1151f376df2bSJosef Bacik 
11522e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1153f376df2bSJosef Bacik 		__field(	u64,	flags			)
1154f376df2bSJosef Bacik 		__field(	u64,	bytes			)
1155f376df2bSJosef Bacik 		__field(	int,	flush			)
1156f376df2bSJosef Bacik 		__string(	reason,	reason			)
1157f376df2bSJosef Bacik 	),
1158f376df2bSJosef Bacik 
11592e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1160f376df2bSJosef Bacik 		__entry->flags	= flags;
1161f376df2bSJosef Bacik 		__entry->bytes	= bytes;
1162f376df2bSJosef Bacik 		__entry->flush	= flush;
116378c14b38SJoe Perches 		__assign_str(reason, reason);
1164f376df2bSJosef Bacik 	),
1165f376df2bSJosef Bacik 
11662e63e62dSDavid Sterba 	TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
11672e63e62dSDavid Sterba 		  __get_str(reason), __entry->flush,
116845e31869SNikolay Borisov 		  __print_symbolic(__entry->flush, FLUSH_ACTIONS),
11698eec8463SDavid Sterba 		  __entry->flags,
1170f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1171f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
11728eec8463SDavid Sterba 		  __entry->bytes)
1173f376df2bSJosef Bacik );
1174f376df2bSJosef Bacik 
1175f376df2bSJosef Bacik 
1176f376df2bSJosef Bacik TRACE_EVENT(btrfs_flush_space,
1177f376df2bSJosef Bacik 
11789a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
11794b02b00fSJosef Bacik 		 int state, int ret, bool for_preempt),
1180f376df2bSJosef Bacik 
11814b02b00fSJosef Bacik 	TP_ARGS(fs_info, flags, num_bytes, state, ret, for_preempt),
1182f376df2bSJosef Bacik 
11832e63e62dSDavid Sterba 	TP_STRUCT__entry_btrfs(
1184f376df2bSJosef Bacik 		__field(	u64,	flags			)
1185f376df2bSJosef Bacik 		__field(	u64,	num_bytes		)
1186f376df2bSJosef Bacik 		__field(	int,	state			)
1187f376df2bSJosef Bacik 		__field(	int,	ret			)
11884b02b00fSJosef Bacik 		__field(       bool,	for_preempt		)
1189f376df2bSJosef Bacik 	),
1190f376df2bSJosef Bacik 
11912e63e62dSDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1192f376df2bSJosef Bacik 		__entry->flags		=	flags;
1193f376df2bSJosef Bacik 		__entry->num_bytes	=	num_bytes;
1194f376df2bSJosef Bacik 		__entry->state		=	state;
1195f376df2bSJosef Bacik 		__entry->ret		=	ret;
11964b02b00fSJosef Bacik 		__entry->for_preempt	=	for_preempt;
1197f376df2bSJosef Bacik 	),
1198f376df2bSJosef Bacik 
11994b02b00fSJosef Bacik 	TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d for_preempt=%d",
12002e63e62dSDavid Sterba 		  __entry->state,
1201f0cdd15cSNikolay Borisov 		  __print_symbolic(__entry->state, FLUSH_STATES),
12028eec8463SDavid Sterba 		  __entry->flags,
1203f376df2bSJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
1204f376df2bSJosef Bacik 				BTRFS_GROUP_FLAGS),
12054b02b00fSJosef Bacik 		  __entry->num_bytes, __entry->ret, __entry->for_preempt)
1206f376df2bSJosef Bacik );
1207f376df2bSJosef Bacik 
12081abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent,
12091abe9b8aSliubo 
12109a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
12111abe9b8aSliubo 
121271ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len),
12131abe9b8aSliubo 
1214bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12151abe9b8aSliubo 		__field(	u64,  start			)
12161abe9b8aSliubo 		__field(	u64,  len			)
12171abe9b8aSliubo 	),
12181abe9b8aSliubo 
121971ff6437SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
12201abe9b8aSliubo 		__entry->start		= start;
12211abe9b8aSliubo 		__entry->len		= len;
12221abe9b8aSliubo 	),
12231abe9b8aSliubo 
1224562a7a07SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
122571ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
12268eec8463SDavid Sterba 		  __entry->start,
12278eec8463SDavid Sterba 		  __entry->len)
12281abe9b8aSliubo );
12291abe9b8aSliubo 
12301abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
12311abe9b8aSliubo 
12329a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
12331abe9b8aSliubo 
123471ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
12351abe9b8aSliubo );
12361abe9b8aSliubo 
12371abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
12381abe9b8aSliubo 
12399a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
12401abe9b8aSliubo 
124171ff6437SJeff Mahoney 	TP_ARGS(fs_info, start, len)
12421abe9b8aSliubo );
12431abe9b8aSliubo 
12443f7de037SJosef Bacik TRACE_EVENT(find_free_extent,
12453f7de037SJosef Bacik 
1246437490feSQu Wenruo 	TP_PROTO(const struct btrfs_root *root, u64 num_bytes,
12479a35b637SJeff Mahoney 		 u64 empty_size, u64 data),
12483f7de037SJosef Bacik 
1249437490feSQu Wenruo 	TP_ARGS(root, num_bytes, empty_size, data),
12503f7de037SJosef Bacik 
1251bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1252437490feSQu Wenruo 		__field(	u64,	root_objectid		)
12533f7de037SJosef Bacik 		__field(	u64,	num_bytes		)
12543f7de037SJosef Bacik 		__field(	u64,	empty_size		)
12553f7de037SJosef Bacik 		__field(	u64,	data			)
12563f7de037SJosef Bacik 	),
12573f7de037SJosef Bacik 
1258437490feSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
1259437490feSQu Wenruo 		__entry->root_objectid	= root->root_key.objectid;
12603f7de037SJosef Bacik 		__entry->num_bytes	= num_bytes;
12613f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
12623f7de037SJosef Bacik 		__entry->data		= data;
12633f7de037SJosef Bacik 	),
12643f7de037SJosef Bacik 
12655439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
1266437490feSQu Wenruo 		  show_root_type(__entry->root_objectid),
12673f7de037SJosef Bacik 		  __entry->num_bytes, __entry->empty_size, __entry->data,
12683f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->data, "|",
12693f7de037SJosef Bacik 				 BTRFS_GROUP_FLAGS))
12703f7de037SJosef Bacik );
12713f7de037SJosef Bacik 
12723f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent,
12733f7de037SJosef Bacik 
127432da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
12753f7de037SJosef Bacik 		 u64 len),
12763f7de037SJosef Bacik 
12773dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len),
12783f7de037SJosef Bacik 
1279bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
12803f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
12813f7de037SJosef Bacik 		__field(	u64,	flags			)
12823f7de037SJosef Bacik 		__field(	u64,	start			)
12833f7de037SJosef Bacik 		__field(	u64,	len			)
12843f7de037SJosef Bacik 	),
12853f7de037SJosef Bacik 
12863dca5c94SQu Wenruo 	TP_fast_assign_btrfs(block_group->fs_info,
1287b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
12883f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
12893f7de037SJosef Bacik 		__entry->start		= start;
12903f7de037SJosef Bacik 		__entry->len		= len;
12913f7de037SJosef Bacik 	),
12923f7de037SJosef Bacik 
12935439c7f5SDavid Sterba 	TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
12945439c7f5SDavid Sterba 		  "start=%llu len=%llu",
129571ff6437SJeff Mahoney 		  show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
129671ff6437SJeff Mahoney 		  __entry->bg_objectid,
12973f7de037SJosef Bacik 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
12983f7de037SJosef Bacik 						"|", BTRFS_GROUP_FLAGS),
12993f7de037SJosef Bacik 		  __entry->start, __entry->len)
13003f7de037SJosef Bacik );
13013f7de037SJosef Bacik 
13023f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
13033f7de037SJosef Bacik 
130432da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
13053f7de037SJosef Bacik 		 u64 len),
13063f7de037SJosef Bacik 
13073dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len)
13083f7de037SJosef Bacik );
13093f7de037SJosef Bacik 
13103f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
13113f7de037SJosef Bacik 
131232da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
13133f7de037SJosef Bacik 		 u64 len),
13143f7de037SJosef Bacik 
13153dca5c94SQu Wenruo 	TP_ARGS(block_group, start, len)
13163f7de037SJosef Bacik );
13173f7de037SJosef Bacik 
13183f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster,
13193f7de037SJosef Bacik 
132032da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group, u64 start,
13213f7de037SJosef Bacik 		 u64 bytes, u64 empty_size, u64 min_bytes),
13223f7de037SJosef Bacik 
13233f7de037SJosef Bacik 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
13243f7de037SJosef Bacik 
1325bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13263f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
13273f7de037SJosef Bacik 		__field(	u64,	flags			)
13283f7de037SJosef Bacik 		__field(	u64,	start			)
13293f7de037SJosef Bacik 		__field(	u64,	bytes			)
13303f7de037SJosef Bacik 		__field(	u64,	empty_size		)
13313f7de037SJosef Bacik 		__field(	u64,	min_bytes		)
13323f7de037SJosef Bacik 	),
13333f7de037SJosef Bacik 
1334bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1335b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
13363f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
13373f7de037SJosef Bacik 		__entry->start		= start;
13383f7de037SJosef Bacik 		__entry->bytes		= bytes;
13393f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
13403f7de037SJosef Bacik 		__entry->min_bytes	= min_bytes;
13413f7de037SJosef Bacik 	),
13423f7de037SJosef Bacik 
13435439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
13445439c7f5SDavid Sterba 		  "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
13453f7de037SJosef Bacik 		  __entry->flags,
13463f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
13473f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
13483f7de037SJosef Bacik 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
13493f7de037SJosef Bacik );
13503f7de037SJosef Bacik 
13513f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup,
13523f7de037SJosef Bacik 
135332da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group),
13543f7de037SJosef Bacik 
13553f7de037SJosef Bacik 	TP_ARGS(block_group),
13563f7de037SJosef Bacik 
1357bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13583f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
13593f7de037SJosef Bacik 	),
13603f7de037SJosef Bacik 
1361bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1362b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
13633f7de037SJosef Bacik 	),
13643f7de037SJosef Bacik 
13655439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
13663f7de037SJosef Bacik );
13673f7de037SJosef Bacik 
13683f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster,
13693f7de037SJosef Bacik 
137032da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *block_group,
13719a35b637SJeff Mahoney 		 const struct btrfs_free_cluster *cluster,
13729a35b637SJeff Mahoney 		 u64 size, int bitmap),
13733f7de037SJosef Bacik 
13743f7de037SJosef Bacik 	TP_ARGS(block_group, cluster, size, bitmap),
13753f7de037SJosef Bacik 
1376bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
13773f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
13783f7de037SJosef Bacik 		__field(	u64,	flags			)
13793f7de037SJosef Bacik 		__field(	u64,	start			)
13803f7de037SJosef Bacik 		__field(	u64,	max_size		)
13813f7de037SJosef Bacik 		__field(	u64,	size			)
13823f7de037SJosef Bacik 		__field(	int,	bitmap			)
13833f7de037SJosef Bacik 	),
13843f7de037SJosef Bacik 
1385bc074524SJeff Mahoney 	TP_fast_assign_btrfs(block_group->fs_info,
1386b3470b5dSDavid Sterba 		__entry->bg_objectid	= block_group->start;
13873f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
13883f7de037SJosef Bacik 		__entry->start		= cluster->window_start;
13893f7de037SJosef Bacik 		__entry->max_size	= cluster->max_size;
13903f7de037SJosef Bacik 		__entry->size		= size;
13913f7de037SJosef Bacik 		__entry->bitmap		= bitmap;
13923f7de037SJosef Bacik 	),
13933f7de037SJosef Bacik 
13945439c7f5SDavid Sterba 	TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
13955439c7f5SDavid Sterba 		  "size=%llu max_size=%llu bitmap=%d",
13963f7de037SJosef Bacik 		  __entry->bg_objectid,
13973f7de037SJosef Bacik 		  __entry->flags,
13983f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
13993f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
14003f7de037SJosef Bacik 		  __entry->size, __entry->max_size, __entry->bitmap)
14013f7de037SJosef Bacik );
14023f7de037SJosef Bacik 
1403143bede5SJeff Mahoney struct extent_state;
1404143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state,
1405143bede5SJeff Mahoney 
14069a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state,
14079a35b637SJeff Mahoney 		 gfp_t mask, unsigned long IP),
1408143bede5SJeff Mahoney 
1409143bede5SJeff Mahoney 	TP_ARGS(state, mask, IP),
1410143bede5SJeff Mahoney 
1411143bede5SJeff Mahoney 	TP_STRUCT__entry(
14129a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
1413fe573327SVasily Averin 		__field(unsigned long, mask)
141494c3f6c6SDavid Sterba 		__field(const void*, ip)
1415143bede5SJeff Mahoney 	),
1416143bede5SJeff Mahoney 
1417143bede5SJeff Mahoney 	TP_fast_assign(
1418143bede5SJeff Mahoney 		__entry->state	= state,
1419fe573327SVasily Averin 		__entry->mask	= (__force unsigned long)mask,
142094c3f6c6SDavid Sterba 		__entry->ip	= (const void *)IP
1421143bede5SJeff Mahoney 	),
1422143bede5SJeff Mahoney 
1423562a7a07SDavid Sterba 	TP_printk("state=%p mask=%s caller=%pS", __entry->state,
142494c3f6c6SDavid Sterba 		  show_gfp_flags(__entry->mask), __entry->ip)
1425143bede5SJeff Mahoney );
1426143bede5SJeff Mahoney 
1427143bede5SJeff Mahoney TRACE_EVENT(free_extent_state,
1428143bede5SJeff Mahoney 
14299a35b637SJeff Mahoney 	TP_PROTO(const struct extent_state *state, unsigned long IP),
1430143bede5SJeff Mahoney 
1431143bede5SJeff Mahoney 	TP_ARGS(state, IP),
1432143bede5SJeff Mahoney 
1433143bede5SJeff Mahoney 	TP_STRUCT__entry(
14349a35b637SJeff Mahoney 		__field(const struct extent_state *, state)
143594c3f6c6SDavid Sterba 		__field(const void*, ip)
1436143bede5SJeff Mahoney 	),
1437143bede5SJeff Mahoney 
1438143bede5SJeff Mahoney 	TP_fast_assign(
1439143bede5SJeff Mahoney 		__entry->state	= state,
144094c3f6c6SDavid Sterba 		__entry->ip = (const void *)IP
1441143bede5SJeff Mahoney 	),
1442143bede5SJeff Mahoney 
144394c3f6c6SDavid Sterba 	TP_printk("state=%p caller=%pS", __entry->state, __entry->ip)
1444143bede5SJeff Mahoney );
1445143bede5SJeff Mahoney 
144652483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work,
144752483bc2SQu Wenruo 
14489a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
144952483bc2SQu Wenruo 
145052483bc2SQu Wenruo 	TP_ARGS(work),
145152483bc2SQu Wenruo 
1452bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14539a35b637SJeff Mahoney 		__field(	const void *,	work			)
14549a35b637SJeff Mahoney 		__field(	const void *,	wq			)
14559a35b637SJeff Mahoney 		__field(	const void *,	func			)
14569a35b637SJeff Mahoney 		__field(	const void *,	ordered_func		)
14579a35b637SJeff Mahoney 		__field(	const void *,	ordered_free		)
14589a35b637SJeff Mahoney 		__field(	const void *,	normal_work		)
145952483bc2SQu Wenruo 	),
146052483bc2SQu Wenruo 
1461bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_work_owner(work),
146252483bc2SQu Wenruo 		__entry->work		= work;
146352483bc2SQu Wenruo 		__entry->wq		= work->wq;
146452483bc2SQu Wenruo 		__entry->func		= work->func;
146552483bc2SQu Wenruo 		__entry->ordered_func	= work->ordered_func;
146652483bc2SQu Wenruo 		__entry->ordered_free	= work->ordered_free;
1467b38a6258SLiu Bo 		__entry->normal_work	= &work->normal_work;
146852483bc2SQu Wenruo 	),
146952483bc2SQu Wenruo 
1470d75f773cSSakari Ailus 	TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
1471b38a6258SLiu Bo 		  "ordered_free=%p",
1472b38a6258SLiu Bo 		  __entry->work, __entry->normal_work, __entry->wq,
1473b38a6258SLiu Bo 		   __entry->func, __entry->ordered_func, __entry->ordered_free)
147452483bc2SQu Wenruo );
147552483bc2SQu Wenruo 
1476ac0c7cf8SDavid Sterba /*
1477c9eb55dbSOmar Sandoval  * For situations when the work is freed, we pass fs_info and a tag that matches
1478c9eb55dbSOmar Sandoval  * the address of the work structure so it can be paired with the scheduling
1479c9eb55dbSOmar Sandoval  * event. DO NOT add anything here that dereferences wtag.
1480ac0c7cf8SDavid Sterba  */
148152483bc2SQu Wenruo DECLARE_EVENT_CLASS(btrfs__work__done,
148252483bc2SQu Wenruo 
14839a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
148452483bc2SQu Wenruo 
1485ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag),
148652483bc2SQu Wenruo 
1487bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
14889a35b637SJeff Mahoney 		__field(	const void *,	wtag			)
148952483bc2SQu Wenruo 	),
149052483bc2SQu Wenruo 
1491ac0c7cf8SDavid Sterba 	TP_fast_assign_btrfs(fs_info,
1492ac0c7cf8SDavid Sterba 		__entry->wtag		= wtag;
149352483bc2SQu Wenruo 	),
149452483bc2SQu Wenruo 
1495ac0c7cf8SDavid Sterba 	TP_printk_btrfs("work->%p", __entry->wtag)
149652483bc2SQu Wenruo );
149752483bc2SQu Wenruo 
149852483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_queued,
149952483bc2SQu Wenruo 
15009a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
150152483bc2SQu Wenruo 
150252483bc2SQu Wenruo 	TP_ARGS(work)
150352483bc2SQu Wenruo );
150452483bc2SQu Wenruo 
150552483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_work_sched,
150652483bc2SQu Wenruo 
15079a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
150852483bc2SQu Wenruo 
150952483bc2SQu Wenruo 	TP_ARGS(work)
151052483bc2SQu Wenruo );
151152483bc2SQu Wenruo 
151252483bc2SQu Wenruo DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
151352483bc2SQu Wenruo 
15149a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
151552483bc2SQu Wenruo 
1516ac0c7cf8SDavid Sterba 	TP_ARGS(fs_info, wtag)
151752483bc2SQu Wenruo );
151852483bc2SQu Wenruo 
151952483bc2SQu Wenruo DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
152052483bc2SQu Wenruo 
15219a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_work *work),
152252483bc2SQu Wenruo 
152352483bc2SQu Wenruo 	TP_ARGS(work)
152452483bc2SQu Wenruo );
152552483bc2SQu Wenruo 
1526a31b4a43SChristoph Hellwig DECLARE_EVENT_CLASS(btrfs_workqueue,
1527c3a46891SQu Wenruo 
1528a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq, const char *name),
1529c3a46891SQu Wenruo 
1530a31b4a43SChristoph Hellwig 	TP_ARGS(wq, name),
1531c3a46891SQu Wenruo 
1532bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
15339a35b637SJeff Mahoney 		__field(	const void *,	wq			)
1534c3a46891SQu Wenruo 		__string(	name,	name			)
1535c3a46891SQu Wenruo 	),
1536c3a46891SQu Wenruo 
1537bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1538c3a46891SQu Wenruo 		__entry->wq		= wq;
1539c3a46891SQu Wenruo 		__assign_str(name, name);
1540c3a46891SQu Wenruo 	),
1541c3a46891SQu Wenruo 
1542a31b4a43SChristoph Hellwig 	TP_printk_btrfs("name=%s wq=%p", __get_str(name),
1543c3a46891SQu Wenruo 		  __entry->wq)
1544c3a46891SQu Wenruo );
1545c3a46891SQu Wenruo 
1546a31b4a43SChristoph Hellwig DEFINE_EVENT(btrfs_workqueue, btrfs_workqueue_alloc,
1547c3a46891SQu Wenruo 
1548a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq, const char *name),
1549c3a46891SQu Wenruo 
1550a31b4a43SChristoph Hellwig 	TP_ARGS(wq, name)
1551c3a46891SQu Wenruo );
1552c3a46891SQu Wenruo 
1553a31b4a43SChristoph Hellwig DECLARE_EVENT_CLASS(btrfs_workqueue_done,
1554c3a46891SQu Wenruo 
1555a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq),
1556c3a46891SQu Wenruo 
1557c3a46891SQu Wenruo 	TP_ARGS(wq),
1558c3a46891SQu Wenruo 
1559bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
15609a35b637SJeff Mahoney 		__field(	const void *,	wq		)
1561c3a46891SQu Wenruo 	),
1562c3a46891SQu Wenruo 
1563bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1564c3a46891SQu Wenruo 		__entry->wq		= wq;
1565c3a46891SQu Wenruo 	),
1566c3a46891SQu Wenruo 
1567bc074524SJeff Mahoney 	TP_printk_btrfs("wq=%p", __entry->wq)
1568c3a46891SQu Wenruo );
1569c3a46891SQu Wenruo 
1570a31b4a43SChristoph Hellwig DEFINE_EVENT(btrfs_workqueue_done, btrfs_workqueue_destroy,
1571c3a46891SQu Wenruo 
1572a31b4a43SChristoph Hellwig 	TP_PROTO(const struct btrfs_workqueue *wq),
1573c3a46891SQu Wenruo 
1574c3a46891SQu Wenruo 	TP_ARGS(wq)
1575c3a46891SQu Wenruo );
157652483bc2SQu Wenruo 
157781fb6f77SQu Wenruo #define BTRFS_QGROUP_OPERATIONS				\
157881fb6f77SQu Wenruo 	{ QGROUP_RESERVE,	"reserve"	},	\
157981fb6f77SQu Wenruo 	{ QGROUP_RELEASE,	"release"	},	\
158081fb6f77SQu Wenruo 	{ QGROUP_FREE,		"free"		}
158181fb6f77SQu Wenruo 
158281fb6f77SQu Wenruo DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
158381fb6f77SQu Wenruo 
15849a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
15859a35b637SJeff Mahoney 		 u64 reserved, int op),
158681fb6f77SQu Wenruo 
158781fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op),
158881fb6f77SQu Wenruo 
1589bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
159081fb6f77SQu Wenruo 		__field(	u64,		rootid		)
1591f8f8e189SDavid Sterba 		__field(	u64,		ino		)
159281fb6f77SQu Wenruo 		__field(	u64,		start		)
159381fb6f77SQu Wenruo 		__field(	u64,		len		)
159481fb6f77SQu Wenruo 		__field(	u64,		reserved	)
159581fb6f77SQu Wenruo 		__field(	int,		op		)
159681fb6f77SQu Wenruo 	),
159781fb6f77SQu Wenruo 
1598bc074524SJeff Mahoney 	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
15994fd786e6SMisono Tomohiro 		__entry->rootid		=
16004fd786e6SMisono Tomohiro 			BTRFS_I(inode)->root->root_key.objectid;
1601f8f8e189SDavid Sterba 		__entry->ino		= btrfs_ino(BTRFS_I(inode));
160281fb6f77SQu Wenruo 		__entry->start		= start;
160381fb6f77SQu Wenruo 		__entry->len		= len;
160481fb6f77SQu Wenruo 		__entry->reserved	= reserved;
160581fb6f77SQu Wenruo 		__entry->op		= op;
160681fb6f77SQu Wenruo 	),
160781fb6f77SQu Wenruo 
1608f8f8e189SDavid Sterba 	TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
160981fb6f77SQu Wenruo 		  __entry->rootid, __entry->ino, __entry->start, __entry->len,
161081fb6f77SQu Wenruo 		  __entry->reserved,
161181fb6f77SQu Wenruo 		  __print_flags((unsigned long)__entry->op, "",
161281fb6f77SQu Wenruo 				BTRFS_QGROUP_OPERATIONS)
161381fb6f77SQu Wenruo 	)
161481fb6f77SQu Wenruo );
161581fb6f77SQu Wenruo 
161681fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
161781fb6f77SQu Wenruo 
16189a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
16199a35b637SJeff Mahoney 		 u64 reserved, int op),
162081fb6f77SQu Wenruo 
162181fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
162281fb6f77SQu Wenruo );
162381fb6f77SQu Wenruo 
162481fb6f77SQu Wenruo DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
162581fb6f77SQu Wenruo 
16269a35b637SJeff Mahoney 	TP_PROTO(const struct inode *inode, u64 start, u64 len,
16279a35b637SJeff Mahoney 		 u64 reserved, int op),
162881fb6f77SQu Wenruo 
162981fb6f77SQu Wenruo 	TP_ARGS(inode, start, len, reserved, op)
163081fb6f77SQu Wenruo );
163181fb6f77SQu Wenruo 
16320f5dcf8dSMark Fasheh DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
16339a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
16349a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
16350f5dcf8dSMark Fasheh 
1636bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec),
16370f5dcf8dSMark Fasheh 
1638bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
16390f5dcf8dSMark Fasheh 		__field(	u64,  bytenr		)
16400f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes		)
16410f5dcf8dSMark Fasheh 	),
16420f5dcf8dSMark Fasheh 
1643bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
16440f5dcf8dSMark Fasheh 		__entry->bytenr		= rec->bytenr,
16450f5dcf8dSMark Fasheh 		__entry->num_bytes	= rec->num_bytes;
16460f5dcf8dSMark Fasheh 	),
16470f5dcf8dSMark Fasheh 
1648562a7a07SDavid Sterba 	TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
164994c3f6c6SDavid Sterba 		  __entry->bytenr, __entry->num_bytes)
16500f5dcf8dSMark Fasheh );
16510f5dcf8dSMark Fasheh 
16520f5dcf8dSMark Fasheh DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
16530f5dcf8dSMark Fasheh 
16549a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
16559a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
16560f5dcf8dSMark Fasheh 
1657bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
16580f5dcf8dSMark Fasheh );
16590f5dcf8dSMark Fasheh 
166050b3e040SQu Wenruo DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
16610f5dcf8dSMark Fasheh 
16629a35b637SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
16639a35b637SJeff Mahoney 		 const struct btrfs_qgroup_extent_record *rec),
16640f5dcf8dSMark Fasheh 
1665bc074524SJeff Mahoney 	TP_ARGS(fs_info, rec)
16660f5dcf8dSMark Fasheh );
16670f5dcf8dSMark Fasheh 
1668c337e7b0SQu Wenruo TRACE_EVENT(qgroup_num_dirty_extents,
1669c337e7b0SQu Wenruo 
1670c337e7b0SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1671c337e7b0SQu Wenruo 		 u64 num_dirty_extents),
1672c337e7b0SQu Wenruo 
1673c337e7b0SQu Wenruo 	TP_ARGS(fs_info, transid, num_dirty_extents),
1674c337e7b0SQu Wenruo 
1675c337e7b0SQu Wenruo 	TP_STRUCT__entry_btrfs(
1676c337e7b0SQu Wenruo 		__field(	u64, transid			)
1677c337e7b0SQu Wenruo 		__field(	u64, num_dirty_extents		)
1678c337e7b0SQu Wenruo 	),
1679c337e7b0SQu Wenruo 
1680c337e7b0SQu Wenruo 	TP_fast_assign_btrfs(fs_info,
1681c337e7b0SQu Wenruo 		__entry->transid	   = transid;
1682c337e7b0SQu Wenruo 		__entry->num_dirty_extents = num_dirty_extents;
1683c337e7b0SQu Wenruo 	),
1684c337e7b0SQu Wenruo 
1685c337e7b0SQu Wenruo 	TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1686c337e7b0SQu Wenruo 		__entry->transid, __entry->num_dirty_extents)
1687c337e7b0SQu Wenruo );
1688c337e7b0SQu Wenruo 
16890f5dcf8dSMark Fasheh TRACE_EVENT(btrfs_qgroup_account_extent,
16900f5dcf8dSMark Fasheh 
1691c9f6f3cdSQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
1692bc074524SJeff Mahoney 		 u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
16930f5dcf8dSMark Fasheh 
1694c9f6f3cdSQu Wenruo 	TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1695c9f6f3cdSQu Wenruo 		nr_new_roots),
16960f5dcf8dSMark Fasheh 
1697bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
1698c9f6f3cdSQu Wenruo 		__field(	u64,  transid			)
16990f5dcf8dSMark Fasheh 		__field(	u64,  bytenr			)
17000f5dcf8dSMark Fasheh 		__field(	u64,  num_bytes			)
17010f5dcf8dSMark Fasheh 		__field(	u64,  nr_old_roots		)
17020f5dcf8dSMark Fasheh 		__field(	u64,  nr_new_roots		)
17030f5dcf8dSMark Fasheh 	),
17040f5dcf8dSMark Fasheh 
1705bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
1706c9f6f3cdSQu Wenruo 		__entry->transid	= transid;
17070f5dcf8dSMark Fasheh 		__entry->bytenr		= bytenr;
17080f5dcf8dSMark Fasheh 		__entry->num_bytes	= num_bytes;
17090f5dcf8dSMark Fasheh 		__entry->nr_old_roots	= nr_old_roots;
17100f5dcf8dSMark Fasheh 		__entry->nr_new_roots	= nr_new_roots;
17110f5dcf8dSMark Fasheh 	),
17120f5dcf8dSMark Fasheh 
1713c9f6f3cdSQu Wenruo 	TP_printk_btrfs(
1714c9f6f3cdSQu Wenruo "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1715c9f6f3cdSQu Wenruo 		__entry->transid,
17160f5dcf8dSMark Fasheh 		__entry->bytenr,
17170f5dcf8dSMark Fasheh 		__entry->num_bytes,
17180f5dcf8dSMark Fasheh 		__entry->nr_old_roots,
17190f5dcf8dSMark Fasheh 		__entry->nr_new_roots)
17200f5dcf8dSMark Fasheh );
17210f5dcf8dSMark Fasheh 
17220f5dcf8dSMark Fasheh TRACE_EVENT(qgroup_update_counters,
17230f5dcf8dSMark Fasheh 
17248b317901SQu Wenruo 	TP_PROTO(const struct btrfs_fs_info *fs_info,
17251d2e7c7cSDavid Sterba 		 const struct btrfs_qgroup *qgroup,
1726bc074524SJeff Mahoney 		 u64 cur_old_count, u64 cur_new_count),
17270f5dcf8dSMark Fasheh 
17288b317901SQu Wenruo 	TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
17290f5dcf8dSMark Fasheh 
1730bc074524SJeff Mahoney 	TP_STRUCT__entry_btrfs(
17310f5dcf8dSMark Fasheh 		__field(	u64,  qgid			)
17328b317901SQu Wenruo 		__field(	u64,  old_rfer			)
17338b317901SQu Wenruo 		__field(	u64,  old_excl			)
17340f5dcf8dSMark Fasheh 		__field(	u64,  cur_old_count		)
17350f5dcf8dSMark Fasheh 		__field(	u64,  cur_new_count		)
17360f5dcf8dSMark Fasheh 	),
17370f5dcf8dSMark Fasheh 
1738bc074524SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
17398b317901SQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
17408b317901SQu Wenruo 		__entry->old_rfer	= qgroup->rfer;
17418b317901SQu Wenruo 		__entry->old_excl	= qgroup->excl;
17420f5dcf8dSMark Fasheh 		__entry->cur_old_count	= cur_old_count;
17430f5dcf8dSMark Fasheh 		__entry->cur_new_count	= cur_new_count;
17440f5dcf8dSMark Fasheh 	),
17450f5dcf8dSMark Fasheh 
17468b317901SQu Wenruo 	TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
17478b317901SQu Wenruo 		  __entry->qgid, __entry->old_rfer, __entry->old_excl,
17488b317901SQu Wenruo 		  __entry->cur_old_count, __entry->cur_new_count)
17490f5dcf8dSMark Fasheh );
17500f5dcf8dSMark Fasheh 
17513159fe7bSQu Wenruo TRACE_EVENT(qgroup_update_reserve,
17523159fe7bSQu Wenruo 
17533159fe7bSQu Wenruo 	TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
175464ee4e75SQu Wenruo 		 s64 diff, int type),
17553159fe7bSQu Wenruo 
175664ee4e75SQu Wenruo 	TP_ARGS(fs_info, qgroup, diff, type),
17573159fe7bSQu Wenruo 
17583159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
17593159fe7bSQu Wenruo 		__field(	u64,	qgid			)
17603159fe7bSQu Wenruo 		__field(	u64,	cur_reserved		)
17613159fe7bSQu Wenruo 		__field(	s64,	diff			)
176264ee4e75SQu Wenruo 		__field(	int,	type			)
17633159fe7bSQu Wenruo 	),
17643159fe7bSQu Wenruo 
17653159fe7bSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
17663159fe7bSQu Wenruo 		__entry->qgid		= qgroup->qgroupid;
176764ee4e75SQu Wenruo 		__entry->cur_reserved	= qgroup->rsv.values[type];
17683159fe7bSQu Wenruo 		__entry->diff		= diff;
17691b2442b4SQu Wenruo 		__entry->type		= type;
17703159fe7bSQu Wenruo 	),
17713159fe7bSQu Wenruo 
177264ee4e75SQu Wenruo 	TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
17731cb1f0b2SNikolay Borisov 		__entry->qgid, __print_symbolic(__entry->type, QGROUP_RSV_TYPES),
177464ee4e75SQu Wenruo 		__entry->cur_reserved, __entry->diff)
17753159fe7bSQu Wenruo );
17763159fe7bSQu Wenruo 
17773159fe7bSQu Wenruo TRACE_EVENT(qgroup_meta_reserve,
17783159fe7bSQu Wenruo 
17794ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff, int type),
17803159fe7bSQu Wenruo 
17814ee0d883SQu Wenruo 	TP_ARGS(root, diff, type),
17823159fe7bSQu Wenruo 
17833159fe7bSQu Wenruo 	TP_STRUCT__entry_btrfs(
17843159fe7bSQu Wenruo 		__field(	u64,	refroot			)
17853159fe7bSQu Wenruo 		__field(	s64,	diff			)
17864ee0d883SQu Wenruo 		__field(	int,	type			)
17873159fe7bSQu Wenruo 	),
17883159fe7bSQu Wenruo 
17893159fe7bSQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
17904fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
17913159fe7bSQu Wenruo 		__entry->diff		= diff;
17921b2442b4SQu Wenruo 		__entry->type		= type;
17933159fe7bSQu Wenruo 	),
17943159fe7bSQu Wenruo 
17954ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
17964ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
17971cb1f0b2SNikolay Borisov 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
17984ee0d883SQu Wenruo );
17994ee0d883SQu Wenruo 
18004ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_convert,
18014ee0d883SQu Wenruo 
18024ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root, s64 diff),
18034ee0d883SQu Wenruo 
18044ee0d883SQu Wenruo 	TP_ARGS(root, diff),
18054ee0d883SQu Wenruo 
18064ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
18074ee0d883SQu Wenruo 		__field(	u64,	refroot			)
18084ee0d883SQu Wenruo 		__field(	s64,	diff			)
18094ee0d883SQu Wenruo 	),
18104ee0d883SQu Wenruo 
18114ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
18124fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
18134ee0d883SQu Wenruo 		__entry->diff		= diff;
18144ee0d883SQu Wenruo 	),
18154ee0d883SQu Wenruo 
18164ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
18174ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
18181cb1f0b2SNikolay Borisov 		__print_symbolic(BTRFS_QGROUP_RSV_META_PREALLOC, QGROUP_RSV_TYPES),
18191cb1f0b2SNikolay Borisov 		__print_symbolic(BTRFS_QGROUP_RSV_META_PERTRANS, QGROUP_RSV_TYPES),
18204ee0d883SQu Wenruo 		__entry->diff)
18214ee0d883SQu Wenruo );
18224ee0d883SQu Wenruo 
18234ee0d883SQu Wenruo TRACE_EVENT(qgroup_meta_free_all_pertrans,
18244ee0d883SQu Wenruo 
18254ee0d883SQu Wenruo 	TP_PROTO(struct btrfs_root *root),
18264ee0d883SQu Wenruo 
18274ee0d883SQu Wenruo 	TP_ARGS(root),
18284ee0d883SQu Wenruo 
18294ee0d883SQu Wenruo 	TP_STRUCT__entry_btrfs(
18304ee0d883SQu Wenruo 		__field(	u64,	refroot			)
18314ee0d883SQu Wenruo 		__field(	s64,	diff			)
18324ee0d883SQu Wenruo 		__field(	int,	type			)
18334ee0d883SQu Wenruo 	),
18344ee0d883SQu Wenruo 
18354ee0d883SQu Wenruo 	TP_fast_assign_btrfs(root->fs_info,
18364fd786e6SMisono Tomohiro 		__entry->refroot	= root->root_key.objectid;
18374ee0d883SQu Wenruo 		spin_lock(&root->qgroup_meta_rsv_lock);
18384ee0d883SQu Wenruo 		__entry->diff		= -(s64)root->qgroup_meta_rsv_pertrans;
18394ee0d883SQu Wenruo 		spin_unlock(&root->qgroup_meta_rsv_lock);
18404ee0d883SQu Wenruo 		__entry->type		= BTRFS_QGROUP_RSV_META_PERTRANS;
18414ee0d883SQu Wenruo 	),
18424ee0d883SQu Wenruo 
18434ee0d883SQu Wenruo 	TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
18444ee0d883SQu Wenruo 		show_root_type(__entry->refroot),
18451cb1f0b2SNikolay Borisov 		__print_symbolic(__entry->type, QGROUP_RSV_TYPES), __entry->diff)
18463159fe7bSQu Wenruo );
18473159fe7bSQu Wenruo 
184800142756SJeff Mahoney DECLARE_EVENT_CLASS(btrfs__prelim_ref,
184900142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
185000142756SJeff Mahoney 		 const struct prelim_ref *oldref,
185100142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
185200142756SJeff Mahoney 	TP_ARGS(fs_info, newref, oldref, tree_size),
185300142756SJeff Mahoney 
185400142756SJeff Mahoney 	TP_STRUCT__entry_btrfs(
185500142756SJeff Mahoney 		__field(	u64,  root_id		)
185600142756SJeff Mahoney 		__field(	u64,  objectid		)
185700142756SJeff Mahoney 		__field(	 u8,  type		)
185800142756SJeff Mahoney 		__field(	u64,  offset		)
185900142756SJeff Mahoney 		__field(	int,  level		)
186000142756SJeff Mahoney 		__field(	int,  old_count		)
186100142756SJeff Mahoney 		__field(	u64,  parent		)
186200142756SJeff Mahoney 		__field(	u64,  bytenr		)
186300142756SJeff Mahoney 		__field(	int,  mod_count		)
186400142756SJeff Mahoney 		__field(	u64,  tree_size		)
186500142756SJeff Mahoney 	),
186600142756SJeff Mahoney 
186700142756SJeff Mahoney 	TP_fast_assign_btrfs(fs_info,
186800142756SJeff Mahoney 		__entry->root_id	= oldref->root_id;
186900142756SJeff Mahoney 		__entry->objectid	= oldref->key_for_search.objectid;
187000142756SJeff Mahoney 		__entry->type		= oldref->key_for_search.type;
187100142756SJeff Mahoney 		__entry->offset		= oldref->key_for_search.offset;
187200142756SJeff Mahoney 		__entry->level		= oldref->level;
187300142756SJeff Mahoney 		__entry->old_count	= oldref->count;
187400142756SJeff Mahoney 		__entry->parent		= oldref->parent;
187500142756SJeff Mahoney 		__entry->bytenr		= oldref->wanted_disk_byte;
187600142756SJeff Mahoney 		__entry->mod_count	= newref ? newref->count : 0;
187700142756SJeff Mahoney 		__entry->tree_size	= tree_size;
187800142756SJeff Mahoney 	),
187900142756SJeff Mahoney 
188000142756SJeff 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",
18818eec8463SDavid Sterba 			__entry->root_id,
18828eec8463SDavid Sterba 			__entry->objectid, __entry->type,
18838eec8463SDavid Sterba 			__entry->offset, __entry->level,
188400142756SJeff Mahoney 			__entry->old_count, __entry->mod_count,
188500142756SJeff Mahoney 			__entry->old_count + __entry->mod_count,
18868eec8463SDavid Sterba 			__entry->parent,
18878eec8463SDavid Sterba 			__entry->bytenr,
18888eec8463SDavid Sterba 			__entry->tree_size)
188900142756SJeff Mahoney );
189000142756SJeff Mahoney 
189100142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
189200142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
189300142756SJeff Mahoney 		 const struct prelim_ref *oldref,
189400142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
189500142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
189600142756SJeff Mahoney );
189700142756SJeff Mahoney 
189800142756SJeff Mahoney DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
189900142756SJeff Mahoney 	TP_PROTO(const struct btrfs_fs_info *fs_info,
190000142756SJeff Mahoney 		 const struct prelim_ref *oldref,
190100142756SJeff Mahoney 		 const struct prelim_ref *newref, u64 tree_size),
190200142756SJeff Mahoney 	TP_ARGS(fs_info, oldref, newref, tree_size)
190300142756SJeff Mahoney );
190400142756SJeff Mahoney 
1905dd48d407SJosef Bacik TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
19061d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_root *root, u64 ino, int mod),
1907dd48d407SJosef Bacik 
1908dd48d407SJosef Bacik 	TP_ARGS(root, ino, mod),
1909dd48d407SJosef Bacik 
1910dd48d407SJosef Bacik 	TP_STRUCT__entry_btrfs(
1911dd48d407SJosef Bacik 		__field(	u64, root_objectid	)
1912dd48d407SJosef Bacik 		__field(	u64, ino		)
1913dd48d407SJosef Bacik 		__field(	int, mod		)
1914dd48d407SJosef Bacik 	),
1915dd48d407SJosef Bacik 
1916dd48d407SJosef Bacik 	TP_fast_assign_btrfs(root->fs_info,
19174fd786e6SMisono Tomohiro 		__entry->root_objectid	= root->root_key.objectid;
1918dd48d407SJosef Bacik 		__entry->ino		= ino;
1919dd48d407SJosef Bacik 		__entry->mod		= mod;
1920dd48d407SJosef Bacik 	),
1921dd48d407SJosef Bacik 
1922dd48d407SJosef Bacik 	TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1923dd48d407SJosef Bacik 			show_root_type(__entry->root_objectid),
19248eec8463SDavid Sterba 			__entry->ino, __entry->mod)
1925dd48d407SJosef Bacik );
19263dca5c94SQu Wenruo 
19274ed0a7a3SQu Wenruo DECLARE_EVENT_CLASS(btrfs__block_group,
192832da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
19294ed0a7a3SQu Wenruo 
19304ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache),
19314ed0a7a3SQu Wenruo 
19324ed0a7a3SQu Wenruo 	TP_STRUCT__entry_btrfs(
19334ed0a7a3SQu Wenruo 		__field(	u64,	bytenr		)
19344ed0a7a3SQu Wenruo 		__field(	u64,	len		)
19354ed0a7a3SQu Wenruo 		__field(	u64,	used		)
19364ed0a7a3SQu Wenruo 		__field(	u64,	flags		)
19374ed0a7a3SQu Wenruo 	),
19384ed0a7a3SQu Wenruo 
19394ed0a7a3SQu Wenruo 	TP_fast_assign_btrfs(bg_cache->fs_info,
1940b3470b5dSDavid Sterba 		__entry->bytenr = bg_cache->start,
1941b3470b5dSDavid Sterba 		__entry->len	= bg_cache->length,
1942bf38be65SDavid Sterba 		__entry->used	= bg_cache->used;
19434ed0a7a3SQu Wenruo 		__entry->flags	= bg_cache->flags;
19444ed0a7a3SQu Wenruo 	),
19454ed0a7a3SQu Wenruo 
19464ed0a7a3SQu Wenruo 	TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
19474ed0a7a3SQu Wenruo 		__entry->bytenr, __entry->len, __entry->used, __entry->flags,
19484ed0a7a3SQu Wenruo 		__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
19494ed0a7a3SQu Wenruo );
19504ed0a7a3SQu Wenruo 
19514ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
195232da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
19534ed0a7a3SQu Wenruo 
19544ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
19554ed0a7a3SQu Wenruo );
19564ed0a7a3SQu Wenruo 
19574ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
195832da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
19594ed0a7a3SQu Wenruo 
19604ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
19614ed0a7a3SQu Wenruo );
19624ed0a7a3SQu Wenruo 
196318bb8bbfSJohannes Thumshirn DEFINE_EVENT(btrfs__block_group, btrfs_add_reclaim_block_group,
196418bb8bbfSJohannes Thumshirn 	TP_PROTO(const struct btrfs_block_group *bg_cache),
196518bb8bbfSJohannes Thumshirn 
196618bb8bbfSJohannes Thumshirn 	TP_ARGS(bg_cache)
196718bb8bbfSJohannes Thumshirn );
196818bb8bbfSJohannes Thumshirn 
196918bb8bbfSJohannes Thumshirn DEFINE_EVENT(btrfs__block_group, btrfs_reclaim_block_group,
197018bb8bbfSJohannes Thumshirn 	TP_PROTO(const struct btrfs_block_group *bg_cache),
197118bb8bbfSJohannes Thumshirn 
197218bb8bbfSJohannes Thumshirn 	TP_ARGS(bg_cache)
197318bb8bbfSJohannes Thumshirn );
197418bb8bbfSJohannes Thumshirn 
19754ed0a7a3SQu Wenruo DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
197632da5386SDavid Sterba 	TP_PROTO(const struct btrfs_block_group *bg_cache),
19774ed0a7a3SQu Wenruo 
19784ed0a7a3SQu Wenruo 	TP_ARGS(bg_cache)
19794ed0a7a3SQu Wenruo );
19804ed0a7a3SQu Wenruo 
1981a1d19847SQu Wenruo TRACE_EVENT(btrfs_set_extent_bit,
1982a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
1983a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned set_bits),
1984a1d19847SQu Wenruo 
1985a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, set_bits),
1986a1d19847SQu Wenruo 
1987a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
1988a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
1989a1d19847SQu Wenruo 		__field(	u64,		ino	)
1990a1d19847SQu Wenruo 		__field(	u64,		rootid	)
1991a1d19847SQu Wenruo 		__field(	u64,		start	)
1992a1d19847SQu Wenruo 		__field(	u64,		len	)
1993a1d19847SQu Wenruo 		__field(	unsigned,	set_bits)
1994a1d19847SQu Wenruo 	),
1995a1d19847SQu Wenruo 
1996a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
1997a1d19847SQu Wenruo 		__entry->owner = tree->owner;
1998a1d19847SQu Wenruo 		if (tree->private_data) {
19991d2e7c7cSDavid Sterba 			const struct inode *inode = tree->private_data;
2000a1d19847SQu Wenruo 
2001a1d19847SQu Wenruo 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
2002a1d19847SQu Wenruo 			__entry->rootid	=
2003a1d19847SQu Wenruo 				BTRFS_I(inode)->root->root_key.objectid;
2004a1d19847SQu Wenruo 		} else {
2005a1d19847SQu Wenruo 			__entry->ino	= 0;
2006a1d19847SQu Wenruo 			__entry->rootid	= 0;
2007a1d19847SQu Wenruo 		}
2008a1d19847SQu Wenruo 		__entry->start		= start;
2009a1d19847SQu Wenruo 		__entry->len		= len;
2010a1d19847SQu Wenruo 		__entry->set_bits	= set_bits;
2011a1d19847SQu Wenruo 	),
2012a1d19847SQu Wenruo 
2013a1d19847SQu Wenruo 	TP_printk_btrfs(
2014a1d19847SQu Wenruo 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s",
2015c92bb304SNikolay Borisov 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2016a1d19847SQu Wenruo 		__entry->rootid, __entry->start, __entry->len,
2017a1d19847SQu Wenruo 		__print_flags(__entry->set_bits, "|", EXTENT_FLAGS))
2018a1d19847SQu Wenruo );
2019a1d19847SQu Wenruo 
2020a1d19847SQu Wenruo TRACE_EVENT(btrfs_clear_extent_bit,
2021a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
2022a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned clear_bits),
2023a1d19847SQu Wenruo 
2024a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, clear_bits),
2025a1d19847SQu Wenruo 
2026a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
2027a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
2028a1d19847SQu Wenruo 		__field(	u64,		ino	)
2029a1d19847SQu Wenruo 		__field(	u64,		rootid	)
2030a1d19847SQu Wenruo 		__field(	u64,		start	)
2031a1d19847SQu Wenruo 		__field(	u64,		len	)
2032a1d19847SQu Wenruo 		__field(	unsigned,	clear_bits)
2033a1d19847SQu Wenruo 	),
2034a1d19847SQu Wenruo 
2035a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
2036a1d19847SQu Wenruo 		__entry->owner = tree->owner;
2037a1d19847SQu Wenruo 		if (tree->private_data) {
20381d2e7c7cSDavid Sterba 			const struct inode *inode = tree->private_data;
2039a1d19847SQu Wenruo 
2040a1d19847SQu Wenruo 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
2041a1d19847SQu Wenruo 			__entry->rootid	=
2042a1d19847SQu Wenruo 				BTRFS_I(inode)->root->root_key.objectid;
2043a1d19847SQu Wenruo 		} else {
2044a1d19847SQu Wenruo 			__entry->ino	= 0;
2045a1d19847SQu Wenruo 			__entry->rootid	= 0;
2046a1d19847SQu Wenruo 		}
2047a1d19847SQu Wenruo 		__entry->start		= start;
2048a1d19847SQu Wenruo 		__entry->len		= len;
2049a1d19847SQu Wenruo 		__entry->clear_bits	= clear_bits;
2050a1d19847SQu Wenruo 	),
2051a1d19847SQu Wenruo 
2052a1d19847SQu Wenruo 	TP_printk_btrfs(
2053a1d19847SQu Wenruo 		"io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s",
2054c92bb304SNikolay Borisov 		__print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2055a1d19847SQu Wenruo 		__entry->rootid, __entry->start, __entry->len,
2056a1d19847SQu Wenruo 		__print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2057a1d19847SQu Wenruo );
2058a1d19847SQu Wenruo 
2059a1d19847SQu Wenruo TRACE_EVENT(btrfs_convert_extent_bit,
2060a1d19847SQu Wenruo 	TP_PROTO(const struct extent_io_tree *tree,
2061a1d19847SQu Wenruo 		 u64 start, u64 len, unsigned set_bits, unsigned clear_bits),
2062a1d19847SQu Wenruo 
2063a1d19847SQu Wenruo 	TP_ARGS(tree, start, len, set_bits, clear_bits),
2064a1d19847SQu Wenruo 
2065a1d19847SQu Wenruo 	TP_STRUCT__entry_btrfs(
2066a1d19847SQu Wenruo 		__field(	unsigned,	owner	)
2067a1d19847SQu Wenruo 		__field(	u64,		ino	)
2068a1d19847SQu Wenruo 		__field(	u64,		rootid	)
2069a1d19847SQu Wenruo 		__field(	u64,		start	)
2070a1d19847SQu Wenruo 		__field(	u64,		len	)
2071a1d19847SQu Wenruo 		__field(	unsigned,	set_bits)
2072a1d19847SQu Wenruo 		__field(	unsigned,	clear_bits)
2073a1d19847SQu Wenruo 	),
2074a1d19847SQu Wenruo 
2075a1d19847SQu Wenruo 	TP_fast_assign_btrfs(tree->fs_info,
2076a1d19847SQu Wenruo 		__entry->owner = tree->owner;
2077a1d19847SQu Wenruo 		if (tree->private_data) {
20781d2e7c7cSDavid Sterba 			const struct inode *inode = tree->private_data;
2079a1d19847SQu Wenruo 
2080a1d19847SQu Wenruo 			__entry->ino	= btrfs_ino(BTRFS_I(inode));
2081a1d19847SQu Wenruo 			__entry->rootid	=
2082a1d19847SQu Wenruo 				BTRFS_I(inode)->root->root_key.objectid;
2083a1d19847SQu Wenruo 		} else {
2084a1d19847SQu Wenruo 			__entry->ino	= 0;
2085a1d19847SQu Wenruo 			__entry->rootid	= 0;
2086a1d19847SQu Wenruo 		}
2087a1d19847SQu Wenruo 		__entry->start		= start;
2088a1d19847SQu Wenruo 		__entry->len		= len;
2089a1d19847SQu Wenruo 		__entry->set_bits	= set_bits;
2090a1d19847SQu Wenruo 		__entry->clear_bits	= clear_bits;
2091a1d19847SQu Wenruo 	),
2092a1d19847SQu Wenruo 
2093a1d19847SQu Wenruo 	TP_printk_btrfs(
2094a1d19847SQu Wenruo "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s",
2095c92bb304SNikolay Borisov 		  __print_symbolic(__entry->owner, IO_TREE_OWNER), __entry->ino,
2096a1d19847SQu Wenruo 		  __entry->rootid, __entry->start, __entry->len,
2097a1d19847SQu Wenruo 		  __print_flags(__entry->set_bits , "|", EXTENT_FLAGS),
2098a1d19847SQu Wenruo 		  __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2099a1d19847SQu Wenruo );
2100a1d19847SQu Wenruo 
2101e5ad49e2SJosef Bacik DECLARE_EVENT_CLASS(btrfs_dump_space_info,
21028197766dSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2103e5ad49e2SJosef Bacik 		 const struct btrfs_space_info *sinfo),
2104e5ad49e2SJosef Bacik 
2105e5ad49e2SJosef Bacik 	TP_ARGS(fs_info, sinfo),
2106e5ad49e2SJosef Bacik 
2107e5ad49e2SJosef Bacik 	TP_STRUCT__entry_btrfs(
2108e5ad49e2SJosef Bacik 		__field(	u64,	flags			)
2109e5ad49e2SJosef Bacik 		__field(	u64,	total_bytes		)
2110e5ad49e2SJosef Bacik 		__field(	u64,	bytes_used		)
2111e5ad49e2SJosef Bacik 		__field(	u64,	bytes_pinned		)
2112e5ad49e2SJosef Bacik 		__field(	u64,	bytes_reserved		)
2113e5ad49e2SJosef Bacik 		__field(	u64,	bytes_may_use		)
2114e5ad49e2SJosef Bacik 		__field(	u64,	bytes_readonly		)
2115e5ad49e2SJosef Bacik 		__field(	u64,	reclaim_size		)
2116e5ad49e2SJosef Bacik 		__field(	int,	clamp			)
2117e5ad49e2SJosef Bacik 		__field(	u64,	global_reserved		)
2118e5ad49e2SJosef Bacik 		__field(	u64,	trans_reserved		)
2119e5ad49e2SJosef Bacik 		__field(	u64,	delayed_refs_reserved	)
2120e5ad49e2SJosef Bacik 		__field(	u64,	delayed_reserved	)
2121e5ad49e2SJosef Bacik 		__field(	u64,	free_chunk_space	)
21228197766dSJosef Bacik 		__field(	u64,	delalloc_bytes		)
21238197766dSJosef Bacik 		__field(	u64,	ordered_bytes		)
2124e5ad49e2SJosef Bacik 	),
2125e5ad49e2SJosef Bacik 
2126e5ad49e2SJosef Bacik 	TP_fast_assign_btrfs(fs_info,
2127e5ad49e2SJosef Bacik 		__entry->flags			=	sinfo->flags;
2128e5ad49e2SJosef Bacik 		__entry->total_bytes		=	sinfo->total_bytes;
2129e5ad49e2SJosef Bacik 		__entry->bytes_used		=	sinfo->bytes_used;
2130e5ad49e2SJosef Bacik 		__entry->bytes_pinned		=	sinfo->bytes_pinned;
2131e5ad49e2SJosef Bacik 		__entry->bytes_reserved		=	sinfo->bytes_reserved;
2132e5ad49e2SJosef Bacik 		__entry->bytes_may_use		=	sinfo->bytes_may_use;
2133e5ad49e2SJosef Bacik 		__entry->bytes_readonly		=	sinfo->bytes_readonly;
2134e5ad49e2SJosef Bacik 		__entry->reclaim_size		=	sinfo->reclaim_size;
2135e5ad49e2SJosef Bacik 		__entry->clamp			=	sinfo->clamp;
2136e5ad49e2SJosef Bacik 		__entry->global_reserved	=	fs_info->global_block_rsv.reserved;
2137e5ad49e2SJosef Bacik 		__entry->trans_reserved		=	fs_info->trans_block_rsv.reserved;
2138e5ad49e2SJosef Bacik 		__entry->delayed_refs_reserved	=	fs_info->delayed_refs_rsv.reserved;
2139e5ad49e2SJosef Bacik 		__entry->delayed_reserved	=	fs_info->delayed_block_rsv.reserved;
2140e5ad49e2SJosef Bacik 		__entry->free_chunk_space	=	atomic64_read(&fs_info->free_chunk_space);
21418197766dSJosef Bacik 		__entry->delalloc_bytes		=	percpu_counter_sum_positive(&fs_info->delalloc_bytes);
21428197766dSJosef Bacik 		__entry->ordered_bytes		=	percpu_counter_sum_positive(&fs_info->ordered_bytes);
2143e5ad49e2SJosef Bacik 	),
2144e5ad49e2SJosef Bacik 
2145e5ad49e2SJosef Bacik 	TP_printk_btrfs("flags=%s total_bytes=%llu bytes_used=%llu "
2146e5ad49e2SJosef Bacik 			"bytes_pinned=%llu bytes_reserved=%llu "
2147e5ad49e2SJosef Bacik 			"bytes_may_use=%llu bytes_readonly=%llu "
2148e5ad49e2SJosef Bacik 			"reclaim_size=%llu clamp=%d global_reserved=%llu "
2149e5ad49e2SJosef Bacik 			"trans_reserved=%llu delayed_refs_reserved=%llu "
21508197766dSJosef Bacik 			"delayed_reserved=%llu chunk_free_space=%llu "
21518197766dSJosef Bacik 			"delalloc_bytes=%llu ordered_bytes=%llu",
2152e5ad49e2SJosef Bacik 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2153e5ad49e2SJosef Bacik 			__entry->total_bytes, __entry->bytes_used,
2154e5ad49e2SJosef Bacik 			__entry->bytes_pinned, __entry->bytes_reserved,
2155e5ad49e2SJosef Bacik 			__entry->bytes_may_use, __entry->bytes_readonly,
2156e5ad49e2SJosef Bacik 			__entry->reclaim_size, __entry->clamp,
2157e5ad49e2SJosef Bacik 			__entry->global_reserved, __entry->trans_reserved,
2158e5ad49e2SJosef Bacik 			__entry->delayed_refs_reserved,
21598197766dSJosef Bacik 			__entry->delayed_reserved, __entry->free_chunk_space,
21608197766dSJosef Bacik 			__entry->delalloc_bytes, __entry->ordered_bytes)
2161e5ad49e2SJosef Bacik );
2162e5ad49e2SJosef Bacik 
2163e5ad49e2SJosef Bacik DEFINE_EVENT(btrfs_dump_space_info, btrfs_done_preemptive_reclaim,
21648197766dSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2165e5ad49e2SJosef Bacik 		 const struct btrfs_space_info *sinfo),
2166e5ad49e2SJosef Bacik 	TP_ARGS(fs_info, sinfo)
2167e5ad49e2SJosef Bacik );
2168e5ad49e2SJosef Bacik 
2169fcdef39cSJosef Bacik DEFINE_EVENT(btrfs_dump_space_info, btrfs_fail_all_tickets,
2170fcdef39cSJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info,
2171fcdef39cSJosef Bacik 		 const struct btrfs_space_info *sinfo),
2172fcdef39cSJosef Bacik 	TP_ARGS(fs_info, sinfo)
2173fcdef39cSJosef Bacik );
2174fcdef39cSJosef Bacik 
2175ac1ea10eSJosef Bacik TRACE_EVENT(btrfs_reserve_ticket,
2176ac1ea10eSJosef Bacik 	TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
2177ac1ea10eSJosef Bacik 		 u64 start_ns, int flush, int error),
2178ac1ea10eSJosef Bacik 
2179ac1ea10eSJosef Bacik 	TP_ARGS(fs_info, flags, bytes, start_ns, flush, error),
2180ac1ea10eSJosef Bacik 
2181ac1ea10eSJosef Bacik 	TP_STRUCT__entry_btrfs(
2182ac1ea10eSJosef Bacik 		__field(	u64,	flags		)
2183ac1ea10eSJosef Bacik 		__field(	u64,	bytes		)
2184ac1ea10eSJosef Bacik 		__field(	u64,	start_ns	)
2185ac1ea10eSJosef Bacik 		__field(	int,	flush		)
2186ac1ea10eSJosef Bacik 		__field(	int,	error		)
2187ac1ea10eSJosef Bacik 	),
2188ac1ea10eSJosef Bacik 
2189ac1ea10eSJosef Bacik 	TP_fast_assign_btrfs(fs_info,
2190ac1ea10eSJosef Bacik 		__entry->flags		= flags;
2191ac1ea10eSJosef Bacik 		__entry->bytes		= bytes;
2192ac1ea10eSJosef Bacik 		__entry->start_ns	= start_ns;
2193ac1ea10eSJosef Bacik 		__entry->flush		= flush;
2194ac1ea10eSJosef Bacik 		__entry->error		= error;
2195ac1ea10eSJosef Bacik 	),
2196ac1ea10eSJosef Bacik 
2197ac1ea10eSJosef Bacik 	TP_printk_btrfs("flags=%s bytes=%llu start_ns=%llu flush=%s error=%d",
2198ac1ea10eSJosef Bacik 			__print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS),
2199ac1ea10eSJosef Bacik 			__entry->bytes, __entry->start_ns,
2200ac1ea10eSJosef Bacik 			__print_symbolic(__entry->flush, FLUSH_ACTIONS),
2201ac1ea10eSJosef Bacik 			__entry->error)
2202ac1ea10eSJosef Bacik );
2203ac1ea10eSJosef Bacik 
220434e73cc9SQu Wenruo DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock,
220534e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
220634e73cc9SQu Wenruo 
220734e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns),
220834e73cc9SQu Wenruo 
220934e73cc9SQu Wenruo 	TP_STRUCT__entry_btrfs(
221034e73cc9SQu Wenruo 		__field(	u64,	block		)
221134e73cc9SQu Wenruo 		__field(	u64,	generation	)
221234e73cc9SQu Wenruo 		__field(	u64,	start_ns	)
221334e73cc9SQu Wenruo 		__field(	u64,	end_ns		)
221434e73cc9SQu Wenruo 		__field(	u64,	diff_ns		)
221534e73cc9SQu Wenruo 		__field(	u64,	owner		)
221634e73cc9SQu Wenruo 		__field(	int,	is_log_tree	)
221734e73cc9SQu Wenruo 	),
221834e73cc9SQu Wenruo 
221934e73cc9SQu Wenruo 	TP_fast_assign_btrfs(eb->fs_info,
222034e73cc9SQu Wenruo 		__entry->block		= eb->start;
222134e73cc9SQu Wenruo 		__entry->generation	= btrfs_header_generation(eb);
222234e73cc9SQu Wenruo 		__entry->start_ns	= start_ns;
222334e73cc9SQu Wenruo 		__entry->end_ns		= ktime_get_ns();
222434e73cc9SQu Wenruo 		__entry->diff_ns	= __entry->end_ns - start_ns;
222534e73cc9SQu Wenruo 		__entry->owner		= btrfs_header_owner(eb);
222634e73cc9SQu Wenruo 		__entry->is_log_tree	= (eb->log_index >= 0);
222734e73cc9SQu Wenruo 	),
222834e73cc9SQu Wenruo 
222934e73cc9SQu Wenruo 	TP_printk_btrfs(
223034e73cc9SQu Wenruo "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d",
223134e73cc9SQu Wenruo 		__entry->block, __entry->generation,
223234e73cc9SQu Wenruo 		__entry->start_ns, __entry->end_ns, __entry->diff_ns,
223334e73cc9SQu Wenruo 		__entry->owner, __entry->is_log_tree)
223434e73cc9SQu Wenruo );
223534e73cc9SQu Wenruo 
223634e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock,
223734e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
223834e73cc9SQu Wenruo 
223934e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns)
224034e73cc9SQu Wenruo );
224134e73cc9SQu Wenruo 
224234e73cc9SQu Wenruo DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock,
224334e73cc9SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
224434e73cc9SQu Wenruo 
224534e73cc9SQu Wenruo 	TP_ARGS(eb, start_ns)
224634e73cc9SQu Wenruo );
224734e73cc9SQu Wenruo 
224831aab402SQu Wenruo DECLARE_EVENT_CLASS(btrfs_locking_events,
224931aab402SQu Wenruo 	TP_PROTO(const struct extent_buffer *eb),
225031aab402SQu Wenruo 
225131aab402SQu Wenruo 	TP_ARGS(eb),
225231aab402SQu Wenruo 
225331aab402SQu Wenruo 	TP_STRUCT__entry_btrfs(
225431aab402SQu Wenruo 		__field(	u64,	block		)
225531aab402SQu Wenruo 		__field(	u64,	generation	)
225631aab402SQu Wenruo 		__field(	u64,	owner		)
225731aab402SQu Wenruo 		__field(	int,	is_log_tree	)
225831aab402SQu Wenruo 	),
225931aab402SQu Wenruo 
226031aab402SQu Wenruo 	TP_fast_assign_btrfs(eb->fs_info,
226131aab402SQu Wenruo 		__entry->block		= eb->start;
226231aab402SQu Wenruo 		__entry->generation	= btrfs_header_generation(eb);
226331aab402SQu Wenruo 		__entry->owner		= btrfs_header_owner(eb);
226431aab402SQu Wenruo 		__entry->is_log_tree	= (eb->log_index >= 0);
226531aab402SQu Wenruo 	),
226631aab402SQu Wenruo 
226731aab402SQu Wenruo 	TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d",
226831aab402SQu Wenruo 		__entry->block, __entry->generation,
226931aab402SQu Wenruo 		__entry->owner, __entry->is_log_tree)
227031aab402SQu Wenruo );
227131aab402SQu Wenruo 
227231aab402SQu Wenruo #define DEFINE_BTRFS_LOCK_EVENT(name)				\
227331aab402SQu Wenruo DEFINE_EVENT(btrfs_locking_events, name,			\
227431aab402SQu Wenruo 		TP_PROTO(const struct extent_buffer *eb),	\
227531aab402SQu Wenruo 								\
227631aab402SQu Wenruo 		TP_ARGS(eb)					\
227731aab402SQu Wenruo )
227831aab402SQu Wenruo 
227931aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock);
228031aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock);
228131aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking);
228231aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read);
228331aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write);
228431aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock);
228531aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock);
228631aab402SQu Wenruo DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic);
228731aab402SQu Wenruo 
2288480b9b4dSQu Wenruo DECLARE_EVENT_CLASS(btrfs__space_info_update,
2289480b9b4dSQu Wenruo 
22901d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
22911d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2292480b9b4dSQu Wenruo 
2293480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff),
2294480b9b4dSQu Wenruo 
2295480b9b4dSQu Wenruo 	TP_STRUCT__entry_btrfs(
2296480b9b4dSQu Wenruo 		__field(	u64,	type		)
2297480b9b4dSQu Wenruo 		__field(	u64,	old		)
2298480b9b4dSQu Wenruo 		__field(	s64,	diff		)
2299480b9b4dSQu Wenruo 	),
2300480b9b4dSQu Wenruo 
2301480b9b4dSQu Wenruo 	TP_fast_assign_btrfs(fs_info,
2302480b9b4dSQu Wenruo 		__entry->type	= sinfo->flags;
2303480b9b4dSQu Wenruo 		__entry->old	= old;
2304480b9b4dSQu Wenruo 		__entry->diff	= diff;
2305480b9b4dSQu Wenruo 	),
2306480b9b4dSQu Wenruo 	TP_printk_btrfs("type=%s old=%llu diff=%lld",
2307480b9b4dSQu Wenruo 		__print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS),
2308480b9b4dSQu Wenruo 		__entry->old, __entry->diff)
2309480b9b4dSQu Wenruo );
2310480b9b4dSQu Wenruo 
2311480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use,
2312480b9b4dSQu Wenruo 
23131d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
23141d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2315480b9b4dSQu Wenruo 
2316480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff)
2317480b9b4dSQu Wenruo );
2318480b9b4dSQu Wenruo 
2319480b9b4dSQu Wenruo DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned,
2320480b9b4dSQu Wenruo 
23211d2e7c7cSDavid Sterba 	TP_PROTO(const struct btrfs_fs_info *fs_info,
23221d2e7c7cSDavid Sterba 		 const struct btrfs_space_info *sinfo, u64 old, s64 diff),
2323480b9b4dSQu Wenruo 
2324480b9b4dSQu Wenruo 	TP_ARGS(fs_info, sinfo, old, diff)
2325480b9b4dSQu Wenruo );
2326480b9b4dSQu Wenruo 
2327b8bea09aSQu Wenruo DECLARE_EVENT_CLASS(btrfs_raid56_bio,
2328b8bea09aSQu Wenruo 
2329b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2330b8bea09aSQu Wenruo 		 const struct bio *bio,
2331b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2332b8bea09aSQu Wenruo 
2333b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info),
2334b8bea09aSQu Wenruo 
2335b8bea09aSQu Wenruo 	TP_STRUCT__entry_btrfs(
2336b8bea09aSQu Wenruo 		__field(	u64,	full_stripe	)
2337b8bea09aSQu Wenruo 		__field(	u64,	physical	)
2338b8bea09aSQu Wenruo 		__field(	u64,	devid		)
2339b8bea09aSQu Wenruo 		__field(	u32,	offset		)
2340b8bea09aSQu Wenruo 		__field(	u32,	len		)
2341b8bea09aSQu Wenruo 		__field(	u8,	opf		)
2342b8bea09aSQu Wenruo 		__field(	u8,	total_stripes	)
2343b8bea09aSQu Wenruo 		__field(	u8,	real_stripes	)
2344b8bea09aSQu Wenruo 		__field(	u8,	nr_data		)
2345b8bea09aSQu Wenruo 		__field(	u8,	stripe_nr	)
2346b8bea09aSQu Wenruo 	),
2347b8bea09aSQu Wenruo 
2348b8bea09aSQu Wenruo 	TP_fast_assign_btrfs(rbio->bioc->fs_info,
2349b8bea09aSQu Wenruo 		__entry->full_stripe	= rbio->bioc->raid_map[0];
2350b8bea09aSQu Wenruo 		__entry->physical	= bio->bi_iter.bi_sector << SECTOR_SHIFT;
2351b8bea09aSQu Wenruo 		__entry->len		= bio->bi_iter.bi_size;
2352b8bea09aSQu Wenruo 		__entry->opf		= bio_op(bio);
2353b8bea09aSQu Wenruo 		__entry->devid		= trace_info->devid;
2354b8bea09aSQu Wenruo 		__entry->offset		= trace_info->offset;
2355b8bea09aSQu Wenruo 		__entry->stripe_nr	= trace_info->stripe_nr;
2356b8bea09aSQu Wenruo 		__entry->total_stripes	= rbio->bioc->num_stripes;
2357b8bea09aSQu Wenruo 		__entry->real_stripes	= rbio->real_stripes;
2358b8bea09aSQu Wenruo 		__entry->nr_data	= rbio->nr_data;
2359b8bea09aSQu Wenruo 	),
2360b8bea09aSQu Wenruo 	/*
2361b8bea09aSQu Wenruo 	 * For type output, we need to output things like "DATA1"
2362b8bea09aSQu Wenruo 	 * (the first data stripe), "DATA2" (the second data stripe),
2363b8bea09aSQu Wenruo 	 * "PQ1" (P stripe),"PQ2" (Q stripe), "REPLACE0" (replace target device).
2364b8bea09aSQu Wenruo 	 */
2365b8bea09aSQu Wenruo 	TP_printk_btrfs(
2366b8bea09aSQu Wenruo "full_stripe=%llu devid=%lld type=%s%d offset=%d opf=0x%x physical=%llu len=%u",
2367b8bea09aSQu Wenruo 		__entry->full_stripe, __entry->devid,
2368b8bea09aSQu Wenruo 		(__entry->stripe_nr < __entry->nr_data) ? "DATA" :
2369b8bea09aSQu Wenruo 			((__entry->stripe_nr < __entry->real_stripes) ? "PQ" :
2370b8bea09aSQu Wenruo 			 "REPLACE"),
2371b8bea09aSQu Wenruo 		(__entry->stripe_nr < __entry->nr_data) ?
2372b8bea09aSQu Wenruo 			(__entry->stripe_nr + 1) :
2373b8bea09aSQu Wenruo 			((__entry->stripe_nr < __entry->real_stripes) ?
2374b8bea09aSQu Wenruo 			 (__entry->stripe_nr - __entry->nr_data + 1) : 0),
2375b8bea09aSQu Wenruo 		__entry->offset, __entry->opf, __entry->physical, __entry->len)
2376b8bea09aSQu Wenruo );
2377b8bea09aSQu Wenruo 
2378b8bea09aSQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_read_partial,
2379b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2380b8bea09aSQu Wenruo 		 const struct bio *bio,
2381b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2382b8bea09aSQu Wenruo 
2383b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2384b8bea09aSQu Wenruo );
2385b8bea09aSQu Wenruo 
2386b8bea09aSQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_write_stripe,
2387b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2388b8bea09aSQu Wenruo 		 const struct bio *bio,
2389b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2390b8bea09aSQu Wenruo 
2391b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2392b8bea09aSQu Wenruo );
2393b8bea09aSQu Wenruo 
2394b8bea09aSQu Wenruo 
2395b8bea09aSQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_scrub_write_stripe,
2396b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2397b8bea09aSQu Wenruo 		 const struct bio *bio,
2398b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2399b8bea09aSQu Wenruo 
2400b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2401b8bea09aSQu Wenruo );
2402b8bea09aSQu Wenruo 
2403b8bea09aSQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_scrub_read,
2404b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2405b8bea09aSQu Wenruo 		 const struct bio *bio,
2406b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2407b8bea09aSQu Wenruo 
2408b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2409b8bea09aSQu Wenruo );
2410b8bea09aSQu Wenruo 
2411b8bea09aSQu Wenruo DEFINE_EVENT(btrfs_raid56_bio, raid56_scrub_read_recover,
2412b8bea09aSQu Wenruo 	TP_PROTO(const struct btrfs_raid_bio *rbio,
2413b8bea09aSQu Wenruo 		 const struct bio *bio,
2414b8bea09aSQu Wenruo 		 const struct raid56_bio_trace_info *trace_info),
2415b8bea09aSQu Wenruo 
2416b8bea09aSQu Wenruo 	TP_ARGS(rbio, bio, trace_info)
2417b8bea09aSQu Wenruo );
2418b8bea09aSQu Wenruo 
24191abe9b8aSliubo #endif /* _TRACE_BTRFS_H */
24201abe9b8aSliubo 
24211abe9b8aSliubo /* This part must be outside protection */
24221abe9b8aSliubo #include <trace/define_trace.h>
2423