xref: /openbmc/linux/include/trace/events/btrfs.h (revision e112e2b4)
11abe9b8aSliubo #undef TRACE_SYSTEM
21abe9b8aSliubo #define TRACE_SYSTEM btrfs
31abe9b8aSliubo 
41abe9b8aSliubo #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
51abe9b8aSliubo #define _TRACE_BTRFS_H
61abe9b8aSliubo 
71abe9b8aSliubo #include <linux/writeback.h>
81abe9b8aSliubo #include <linux/tracepoint.h>
9143bede5SJeff Mahoney #include <trace/events/gfpflags.h>
101abe9b8aSliubo 
111abe9b8aSliubo struct btrfs_root;
121abe9b8aSliubo struct btrfs_fs_info;
131abe9b8aSliubo struct btrfs_inode;
141abe9b8aSliubo struct extent_map;
151abe9b8aSliubo struct btrfs_ordered_extent;
161abe9b8aSliubo struct btrfs_delayed_ref_node;
171abe9b8aSliubo struct btrfs_delayed_tree_ref;
181abe9b8aSliubo struct btrfs_delayed_data_ref;
191abe9b8aSliubo struct btrfs_delayed_ref_head;
203f7de037SJosef Bacik struct btrfs_block_group_cache;
213f7de037SJosef Bacik struct btrfs_free_cluster;
221abe9b8aSliubo struct map_lookup;
231abe9b8aSliubo struct extent_buffer;
241abe9b8aSliubo 
251abe9b8aSliubo #define show_ref_type(type)						\
261abe9b8aSliubo 	__print_symbolic(type,						\
271abe9b8aSliubo 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
281abe9b8aSliubo 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
291abe9b8aSliubo 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
301abe9b8aSliubo 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
311abe9b8aSliubo 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
321abe9b8aSliubo 
331abe9b8aSliubo #define __show_root_type(obj)						\
347f34b746Sliubo 	__print_symbolic_u64(obj,					\
351abe9b8aSliubo 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
361abe9b8aSliubo 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
371abe9b8aSliubo 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
381abe9b8aSliubo 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
391abe9b8aSliubo 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
401abe9b8aSliubo 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
411abe9b8aSliubo 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
421abe9b8aSliubo 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
43*e112e2b4SLiu Bo 		{ BTRFS_QUOTA_TREE_OBJECTID,	"QUOTA_TREE"	},	\
441abe9b8aSliubo 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
451abe9b8aSliubo 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
461abe9b8aSliubo 
471abe9b8aSliubo #define show_root_type(obj)						\
481abe9b8aSliubo 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
49fb57dc81SLiu Bo 	      (obj >= BTRFS_ROOT_TREE_OBJECTID &&			\
50*e112e2b4SLiu Bo 	       obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
511abe9b8aSliubo 
523f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS	\
533f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"},	\
543f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"},	\
553f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"},	\
563f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, 	\
573f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, 	\
583f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, 	\
59*e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}, 	\
60*e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID5,	"RAID5"},	\
61*e112e2b4SLiu Bo 	{ BTRFS_BLOCK_GROUP_RAID6,	"RAID6"}
623f7de037SJosef Bacik 
638c2a3ca2SJosef Bacik #define BTRFS_UUID_SIZE 16
648c2a3ca2SJosef Bacik 
651abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit,
661abe9b8aSliubo 
671abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root),
681abe9b8aSliubo 
691abe9b8aSliubo 	TP_ARGS(root),
701abe9b8aSliubo 
711abe9b8aSliubo 	TP_STRUCT__entry(
721abe9b8aSliubo 		__field(	u64,  generation		)
731abe9b8aSliubo 		__field(	u64,  root_objectid		)
741abe9b8aSliubo 	),
751abe9b8aSliubo 
761abe9b8aSliubo 	TP_fast_assign(
771abe9b8aSliubo 		__entry->generation	= root->fs_info->generation;
781abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
791abe9b8aSliubo 	),
801abe9b8aSliubo 
811abe9b8aSliubo 	TP_printk("root = %llu(%s), gen = %llu",
821abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
831abe9b8aSliubo 		  (unsigned long long)__entry->generation)
841abe9b8aSliubo );
851abe9b8aSliubo 
861abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode,
871abe9b8aSliubo 
881abe9b8aSliubo 	TP_PROTO(struct inode *inode),
891abe9b8aSliubo 
901abe9b8aSliubo 	TP_ARGS(inode),
911abe9b8aSliubo 
921abe9b8aSliubo 	TP_STRUCT__entry(
931abe9b8aSliubo 		__field(	ino_t,  ino			)
941abe9b8aSliubo 		__field(	blkcnt_t,  blocks		)
951abe9b8aSliubo 		__field(	u64,  disk_i_size		)
961abe9b8aSliubo 		__field(	u64,  generation		)
971abe9b8aSliubo 		__field(	u64,  last_trans		)
981abe9b8aSliubo 		__field(	u64,  logged_trans		)
991abe9b8aSliubo 		__field(	u64,  root_objectid		)
1001abe9b8aSliubo 	),
1011abe9b8aSliubo 
1021abe9b8aSliubo 	TP_fast_assign(
1031abe9b8aSliubo 		__entry->ino	= inode->i_ino;
1041abe9b8aSliubo 		__entry->blocks	= inode->i_blocks;
1051abe9b8aSliubo 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
1061abe9b8aSliubo 		__entry->generation = BTRFS_I(inode)->generation;
1071abe9b8aSliubo 		__entry->last_trans = BTRFS_I(inode)->last_trans;
1081abe9b8aSliubo 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
1091abe9b8aSliubo 		__entry->root_objectid =
1101abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
1111abe9b8aSliubo 	),
1121abe9b8aSliubo 
1131abe9b8aSliubo 	TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
1141abe9b8aSliubo 		  "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
1151abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
1161abe9b8aSliubo 		  (unsigned long long)__entry->generation,
1171abe9b8aSliubo 		  (unsigned long)__entry->ino,
1181abe9b8aSliubo 		  (unsigned long long)__entry->blocks,
1191abe9b8aSliubo 		  (unsigned long long)__entry->disk_i_size,
1201abe9b8aSliubo 		  (unsigned long long)__entry->last_trans,
1211abe9b8aSliubo 		  (unsigned long long)__entry->logged_trans)
1221abe9b8aSliubo );
1231abe9b8aSliubo 
1241abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
1251abe9b8aSliubo 
1261abe9b8aSliubo 	TP_PROTO(struct inode *inode),
1271abe9b8aSliubo 
1281abe9b8aSliubo 	TP_ARGS(inode)
1291abe9b8aSliubo );
1301abe9b8aSliubo 
1311abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
1321abe9b8aSliubo 
1331abe9b8aSliubo 	TP_PROTO(struct inode *inode),
1341abe9b8aSliubo 
1351abe9b8aSliubo 	TP_ARGS(inode)
1361abe9b8aSliubo );
1371abe9b8aSliubo 
1381abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
1391abe9b8aSliubo 
1401abe9b8aSliubo 	TP_PROTO(struct inode *inode),
1411abe9b8aSliubo 
1421abe9b8aSliubo 	TP_ARGS(inode)
1431abe9b8aSliubo );
1441abe9b8aSliubo 
1451abe9b8aSliubo #define __show_map_type(type)						\
1467f34b746Sliubo 	__print_symbolic_u64(type,					\
1471abe9b8aSliubo 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
1481abe9b8aSliubo 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
1491abe9b8aSliubo 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
1501abe9b8aSliubo 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
1511abe9b8aSliubo 
1521abe9b8aSliubo #define show_map_type(type)			\
1531abe9b8aSliubo 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
1541abe9b8aSliubo 
1551abe9b8aSliubo #define show_map_flags(flag)						\
1561abe9b8aSliubo 	__print_flags(flag, "|",					\
1571abe9b8aSliubo 		{ EXTENT_FLAG_PINNED, 		"PINNED" 	},	\
1581abe9b8aSliubo 		{ EXTENT_FLAG_COMPRESSED, 	"COMPRESSED" 	},	\
1591abe9b8aSliubo 		{ EXTENT_FLAG_VACANCY, 		"VACANCY" 	},	\
160*e112e2b4SLiu Bo 		{ EXTENT_FLAG_PREALLOC, 	"PREALLOC" 	},	\
161*e112e2b4SLiu Bo 		{ EXTENT_FLAG_LOGGING,	 	"LOGGING" 	},	\
162*e112e2b4SLiu Bo 		{ EXTENT_FLAG_FILLING,	 	"FILLING" 	})
1631abe9b8aSliubo 
1641abe9b8aSliubo TRACE_EVENT(btrfs_get_extent,
1651abe9b8aSliubo 
1661abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct extent_map *map),
1671abe9b8aSliubo 
1681abe9b8aSliubo 	TP_ARGS(root, map),
1691abe9b8aSliubo 
1701abe9b8aSliubo 	TP_STRUCT__entry(
1711abe9b8aSliubo 		__field(	u64,  root_objectid	)
1721abe9b8aSliubo 		__field(	u64,  start		)
1731abe9b8aSliubo 		__field(	u64,  len		)
1741abe9b8aSliubo 		__field(	u64,  orig_start	)
1751abe9b8aSliubo 		__field(	u64,  block_start	)
1761abe9b8aSliubo 		__field(	u64,  block_len		)
1771abe9b8aSliubo 		__field(	unsigned long,  flags	)
1781abe9b8aSliubo 		__field(	int,  refs		)
1791abe9b8aSliubo 		__field(	unsigned int,  compress_type	)
1801abe9b8aSliubo 	),
1811abe9b8aSliubo 
1821abe9b8aSliubo 	TP_fast_assign(
1831abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
1841abe9b8aSliubo 		__entry->start 		= map->start;
1851abe9b8aSliubo 		__entry->len		= map->len;
1861abe9b8aSliubo 		__entry->orig_start	= map->orig_start;
1871abe9b8aSliubo 		__entry->block_start	= map->block_start;
1881abe9b8aSliubo 		__entry->block_len	= map->block_len;
1891abe9b8aSliubo 		__entry->flags		= map->flags;
1901abe9b8aSliubo 		__entry->refs		= atomic_read(&map->refs);
1911abe9b8aSliubo 		__entry->compress_type	= map->compress_type;
1921abe9b8aSliubo 	),
1931abe9b8aSliubo 
1941abe9b8aSliubo 	TP_printk("root = %llu(%s), start = %llu, len = %llu, "
1951abe9b8aSliubo 		  "orig_start = %llu, block_start = %llu(%s), "
1961abe9b8aSliubo 		  "block_len = %llu, flags = %s, refs = %u, "
1971abe9b8aSliubo 		  "compress_type = %u",
1981abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
1991abe9b8aSliubo 		  (unsigned long long)__entry->start,
2001abe9b8aSliubo 		  (unsigned long long)__entry->len,
2011abe9b8aSliubo 		  (unsigned long long)__entry->orig_start,
2021abe9b8aSliubo 		  show_map_type(__entry->block_start),
2031abe9b8aSliubo 		  (unsigned long long)__entry->block_len,
2041abe9b8aSliubo 		  show_map_flags(__entry->flags),
2051abe9b8aSliubo 		  __entry->refs, __entry->compress_type)
2061abe9b8aSliubo );
2071abe9b8aSliubo 
2081abe9b8aSliubo #define show_ordered_flags(flags)					\
2091abe9b8aSliubo 	__print_symbolic(flags,						\
2101abe9b8aSliubo 		{ BTRFS_ORDERED_IO_DONE, 	"IO_DONE" 	},	\
2111abe9b8aSliubo 		{ BTRFS_ORDERED_COMPLETE, 	"COMPLETE" 	},	\
2121abe9b8aSliubo 		{ BTRFS_ORDERED_NOCOW, 		"NOCOW" 	},	\
2131abe9b8aSliubo 		{ BTRFS_ORDERED_COMPRESSED, 	"COMPRESSED" 	},	\
2141abe9b8aSliubo 		{ BTRFS_ORDERED_PREALLOC, 	"PREALLOC" 	},	\
215*e112e2b4SLiu Bo 		{ BTRFS_ORDERED_DIRECT, 	"DIRECT" 	},	\
216*e112e2b4SLiu Bo 		{ BTRFS_ORDERED_IOERR, 		"IOERR" 	},	\
217*e112e2b4SLiu Bo 		{ BTRFS_ORDERED_UPDATED_ISIZE, 	"UPDATED_ISIZE"	},	\
218*e112e2b4SLiu Bo 		{ BTRFS_ORDERED_LOGGED_CSUM, 	"LOGGED_CSUM"	})
219*e112e2b4SLiu Bo 
2201abe9b8aSliubo 
2211abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent,
2221abe9b8aSliubo 
2231abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2241abe9b8aSliubo 
2251abe9b8aSliubo 	TP_ARGS(inode, ordered),
2261abe9b8aSliubo 
2271abe9b8aSliubo 	TP_STRUCT__entry(
2281abe9b8aSliubo 		__field(	ino_t,  ino		)
2291abe9b8aSliubo 		__field(	u64,  file_offset	)
2301abe9b8aSliubo 		__field(	u64,  start		)
2311abe9b8aSliubo 		__field(	u64,  len		)
2321abe9b8aSliubo 		__field(	u64,  disk_len		)
2331abe9b8aSliubo 		__field(	u64,  bytes_left	)
2341abe9b8aSliubo 		__field(	unsigned long,  flags	)
2351abe9b8aSliubo 		__field(	int,  compress_type	)
2361abe9b8aSliubo 		__field(	int,  refs		)
2371abe9b8aSliubo 		__field(	u64,  root_objectid	)
2381abe9b8aSliubo 	),
2391abe9b8aSliubo 
2401abe9b8aSliubo 	TP_fast_assign(
2411abe9b8aSliubo 		__entry->ino 		= inode->i_ino;
2421abe9b8aSliubo 		__entry->file_offset	= ordered->file_offset;
2431abe9b8aSliubo 		__entry->start		= ordered->start;
2441abe9b8aSliubo 		__entry->len		= ordered->len;
2451abe9b8aSliubo 		__entry->disk_len	= ordered->disk_len;
2461abe9b8aSliubo 		__entry->bytes_left	= ordered->bytes_left;
2471abe9b8aSliubo 		__entry->flags		= ordered->flags;
2481abe9b8aSliubo 		__entry->compress_type	= ordered->compress_type;
2491abe9b8aSliubo 		__entry->refs		= atomic_read(&ordered->refs);
2501abe9b8aSliubo 		__entry->root_objectid	=
2511abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
2521abe9b8aSliubo 	),
2531abe9b8aSliubo 
2541abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
2551abe9b8aSliubo 		  "start = %llu, len = %llu, disk_len = %llu, "
2561abe9b8aSliubo 		  "bytes_left = %llu, flags = %s, compress_type = %d, "
2571abe9b8aSliubo 		  "refs = %d",
2581abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2591abe9b8aSliubo 		  (unsigned long long)__entry->ino,
2601abe9b8aSliubo 		  (unsigned long long)__entry->file_offset,
2611abe9b8aSliubo 		  (unsigned long long)__entry->start,
2621abe9b8aSliubo 		  (unsigned long long)__entry->len,
2631abe9b8aSliubo 		  (unsigned long long)__entry->disk_len,
2641abe9b8aSliubo 		  (unsigned long long)__entry->bytes_left,
2651abe9b8aSliubo 		  show_ordered_flags(__entry->flags),
2661abe9b8aSliubo 		  __entry->compress_type, __entry->refs)
2671abe9b8aSliubo );
2681abe9b8aSliubo 
2691abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
2701abe9b8aSliubo 
2711abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2721abe9b8aSliubo 
2731abe9b8aSliubo 	TP_ARGS(inode, ordered)
2741abe9b8aSliubo );
2751abe9b8aSliubo 
2761abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
2771abe9b8aSliubo 
2781abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2791abe9b8aSliubo 
2801abe9b8aSliubo 	TP_ARGS(inode, ordered)
2811abe9b8aSliubo );
2821abe9b8aSliubo 
2831abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
2841abe9b8aSliubo 
2851abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2861abe9b8aSliubo 
2871abe9b8aSliubo 	TP_ARGS(inode, ordered)
2881abe9b8aSliubo );
2891abe9b8aSliubo 
2901abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
2911abe9b8aSliubo 
2921abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2931abe9b8aSliubo 
2941abe9b8aSliubo 	TP_ARGS(inode, ordered)
2951abe9b8aSliubo );
2961abe9b8aSliubo 
2971abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage,
2981abe9b8aSliubo 
2991abe9b8aSliubo 	TP_PROTO(struct page *page, struct inode *inode,
3001abe9b8aSliubo 		 struct writeback_control *wbc),
3011abe9b8aSliubo 
3021abe9b8aSliubo 	TP_ARGS(page, inode, wbc),
3031abe9b8aSliubo 
3041abe9b8aSliubo 	TP_STRUCT__entry(
3051abe9b8aSliubo 		__field(	ino_t,  ino			)
3061abe9b8aSliubo 		__field(	pgoff_t,  index			)
3071abe9b8aSliubo 		__field(	long,   nr_to_write		)
3081abe9b8aSliubo 		__field(	long,   pages_skipped		)
3091abe9b8aSliubo 		__field(	loff_t, range_start		)
3101abe9b8aSliubo 		__field(	loff_t, range_end		)
3111abe9b8aSliubo 		__field(	char,   for_kupdate		)
3121abe9b8aSliubo 		__field(	char,   for_reclaim		)
3131abe9b8aSliubo 		__field(	char,   range_cyclic		)
3141abe9b8aSliubo 		__field(	pgoff_t,  writeback_index	)
3151abe9b8aSliubo 		__field(	u64,    root_objectid		)
3161abe9b8aSliubo 	),
3171abe9b8aSliubo 
3181abe9b8aSliubo 	TP_fast_assign(
3191abe9b8aSliubo 		__entry->ino		= inode->i_ino;
3201abe9b8aSliubo 		__entry->index		= page->index;
3211abe9b8aSliubo 		__entry->nr_to_write	= wbc->nr_to_write;
3221abe9b8aSliubo 		__entry->pages_skipped	= wbc->pages_skipped;
3231abe9b8aSliubo 		__entry->range_start	= wbc->range_start;
3241abe9b8aSliubo 		__entry->range_end	= wbc->range_end;
3251abe9b8aSliubo 		__entry->for_kupdate	= wbc->for_kupdate;
3261abe9b8aSliubo 		__entry->for_reclaim	= wbc->for_reclaim;
3271abe9b8aSliubo 		__entry->range_cyclic	= wbc->range_cyclic;
3281abe9b8aSliubo 		__entry->writeback_index = inode->i_mapping->writeback_index;
3291abe9b8aSliubo 		__entry->root_objectid	=
3301abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
3311abe9b8aSliubo 	),
3321abe9b8aSliubo 
3331abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
3341abe9b8aSliubo 		  "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
335846d5a09SWu Fengguang 		  "range_end = %llu, for_kupdate = %d, "
3361abe9b8aSliubo 		  "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
3371abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3381abe9b8aSliubo 		  (unsigned long)__entry->ino, __entry->index,
3391abe9b8aSliubo 		  __entry->nr_to_write, __entry->pages_skipped,
3401abe9b8aSliubo 		  __entry->range_start, __entry->range_end,
341846d5a09SWu Fengguang 		  __entry->for_kupdate,
3421abe9b8aSliubo 		  __entry->for_reclaim, __entry->range_cyclic,
3431abe9b8aSliubo 		  (unsigned long)__entry->writeback_index)
3441abe9b8aSliubo );
3451abe9b8aSliubo 
3461abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage,
3471abe9b8aSliubo 
3481abe9b8aSliubo 	TP_PROTO(struct page *page, struct inode *inode,
3491abe9b8aSliubo 		 struct writeback_control *wbc),
3501abe9b8aSliubo 
3511abe9b8aSliubo 	TP_ARGS(page, inode, wbc)
3521abe9b8aSliubo );
3531abe9b8aSliubo 
3541abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook,
3551abe9b8aSliubo 
3561abe9b8aSliubo 	TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
3571abe9b8aSliubo 
3581abe9b8aSliubo 	TP_ARGS(page, start, end, uptodate),
3591abe9b8aSliubo 
3601abe9b8aSliubo 	TP_STRUCT__entry(
3611abe9b8aSliubo 		__field(	ino_t,	 ino		)
3621abe9b8aSliubo 		__field(	pgoff_t, index		)
3631abe9b8aSliubo 		__field(	u64,	 start		)
3641abe9b8aSliubo 		__field(	u64,	 end		)
3651abe9b8aSliubo 		__field(	int,	 uptodate	)
3661abe9b8aSliubo 		__field(	u64,    root_objectid	)
3671abe9b8aSliubo 	),
3681abe9b8aSliubo 
3691abe9b8aSliubo 	TP_fast_assign(
3701abe9b8aSliubo 		__entry->ino	= page->mapping->host->i_ino;
3711abe9b8aSliubo 		__entry->index	= page->index;
3721abe9b8aSliubo 		__entry->start	= start;
3731abe9b8aSliubo 		__entry->end	= end;
3741abe9b8aSliubo 		__entry->uptodate = uptodate;
3751abe9b8aSliubo 		__entry->root_objectid	=
3761abe9b8aSliubo 			 BTRFS_I(page->mapping->host)->root->root_key.objectid;
3771abe9b8aSliubo 	),
3781abe9b8aSliubo 
3791abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
3801abe9b8aSliubo 		  "end = %llu, uptodate = %d",
3811abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3821abe9b8aSliubo 		  (unsigned long)__entry->ino, (unsigned long)__entry->index,
3831abe9b8aSliubo 		  (unsigned long long)__entry->start,
3841abe9b8aSliubo 		  (unsigned long long)__entry->end, __entry->uptodate)
3851abe9b8aSliubo );
3861abe9b8aSliubo 
3871abe9b8aSliubo TRACE_EVENT(btrfs_sync_file,
3881abe9b8aSliubo 
3891abe9b8aSliubo 	TP_PROTO(struct file *file, int datasync),
3901abe9b8aSliubo 
3911abe9b8aSliubo 	TP_ARGS(file, datasync),
3921abe9b8aSliubo 
3931abe9b8aSliubo 	TP_STRUCT__entry(
3941abe9b8aSliubo 		__field(	ino_t,  ino		)
3951abe9b8aSliubo 		__field(	ino_t,  parent		)
3961abe9b8aSliubo 		__field(	int,    datasync	)
3971abe9b8aSliubo 		__field(	u64,    root_objectid	)
3981abe9b8aSliubo 	),
3991abe9b8aSliubo 
4001abe9b8aSliubo 	TP_fast_assign(
4011abe9b8aSliubo 		struct dentry *dentry = file->f_path.dentry;
4021abe9b8aSliubo 		struct inode *inode = dentry->d_inode;
4031abe9b8aSliubo 
4041abe9b8aSliubo 		__entry->ino		= inode->i_ino;
4051abe9b8aSliubo 		__entry->parent		= dentry->d_parent->d_inode->i_ino;
4061abe9b8aSliubo 		__entry->datasync	= datasync;
4071abe9b8aSliubo 		__entry->root_objectid	=
4081abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
4091abe9b8aSliubo 	),
4101abe9b8aSliubo 
4111abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
4121abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
4131abe9b8aSliubo 		  (unsigned long)__entry->ino, (unsigned long)__entry->parent,
4141abe9b8aSliubo 		  __entry->datasync)
4151abe9b8aSliubo );
4161abe9b8aSliubo 
4171abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs,
4181abe9b8aSliubo 
4191abe9b8aSliubo 	TP_PROTO(int wait),
4201abe9b8aSliubo 
4211abe9b8aSliubo 	TP_ARGS(wait),
4221abe9b8aSliubo 
4231abe9b8aSliubo 	TP_STRUCT__entry(
4241abe9b8aSliubo 		__field(	int,  wait		)
4251abe9b8aSliubo 	),
4261abe9b8aSliubo 
4271abe9b8aSliubo 	TP_fast_assign(
4281abe9b8aSliubo 		__entry->wait	= wait;
4291abe9b8aSliubo 	),
4301abe9b8aSliubo 
4311abe9b8aSliubo 	TP_printk("wait = %d", __entry->wait)
4321abe9b8aSliubo );
4331abe9b8aSliubo 
4341abe9b8aSliubo #define show_ref_action(action)						\
4351abe9b8aSliubo 	__print_symbolic(action,					\
4361abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
4371abe9b8aSliubo 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
4381abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
4391abe9b8aSliubo 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
4401abe9b8aSliubo 
4411abe9b8aSliubo 
4421abe9b8aSliubo TRACE_EVENT(btrfs_delayed_tree_ref,
4431abe9b8aSliubo 
4441abe9b8aSliubo 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
4451abe9b8aSliubo 		 struct btrfs_delayed_tree_ref *full_ref,
4461abe9b8aSliubo 		 int action),
4471abe9b8aSliubo 
4481abe9b8aSliubo 	TP_ARGS(ref, full_ref, action),
4491abe9b8aSliubo 
4501abe9b8aSliubo 	TP_STRUCT__entry(
4511abe9b8aSliubo 		__field(	u64,  bytenr		)
4521abe9b8aSliubo 		__field(	u64,  num_bytes		)
4531abe9b8aSliubo 		__field(	int,  action		)
4541abe9b8aSliubo 		__field(	u64,  parent		)
4551abe9b8aSliubo 		__field(	u64,  ref_root		)
4561abe9b8aSliubo 		__field(	int,  level		)
4571abe9b8aSliubo 		__field(	int,  type		)
458dea7d76eSLiu Bo 		__field(	u64,  seq		)
4591abe9b8aSliubo 	),
4601abe9b8aSliubo 
4611abe9b8aSliubo 	TP_fast_assign(
4621abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
4631abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
4641abe9b8aSliubo 		__entry->action		= action;
4651abe9b8aSliubo 		__entry->parent		= full_ref->parent;
4661abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
4671abe9b8aSliubo 		__entry->level		= full_ref->level;
4681abe9b8aSliubo 		__entry->type		= ref->type;
469dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
4701abe9b8aSliubo 	),
4711abe9b8aSliubo 
4721abe9b8aSliubo 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
4731abe9b8aSliubo 		  "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
474dea7d76eSLiu Bo 		  "type = %s, seq = %llu",
4751abe9b8aSliubo 		  (unsigned long long)__entry->bytenr,
4761abe9b8aSliubo 		  (unsigned long long)__entry->num_bytes,
4771abe9b8aSliubo 		  show_ref_action(__entry->action),
4781abe9b8aSliubo 		  show_root_type(__entry->parent),
4791abe9b8aSliubo 		  show_root_type(__entry->ref_root),
480dea7d76eSLiu Bo 		  __entry->level, show_ref_type(__entry->type),
481dea7d76eSLiu Bo 		  (unsigned long long)__entry->seq)
4821abe9b8aSliubo );
4831abe9b8aSliubo 
4841abe9b8aSliubo TRACE_EVENT(btrfs_delayed_data_ref,
4851abe9b8aSliubo 
4861abe9b8aSliubo 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
4871abe9b8aSliubo 		 struct btrfs_delayed_data_ref *full_ref,
4881abe9b8aSliubo 		 int action),
4891abe9b8aSliubo 
4901abe9b8aSliubo 	TP_ARGS(ref, full_ref, action),
4911abe9b8aSliubo 
4921abe9b8aSliubo 	TP_STRUCT__entry(
4931abe9b8aSliubo 		__field(	u64,  bytenr		)
4941abe9b8aSliubo 		__field(	u64,  num_bytes		)
4951abe9b8aSliubo 		__field(	int,  action		)
4961abe9b8aSliubo 		__field(	u64,  parent		)
4971abe9b8aSliubo 		__field(	u64,  ref_root		)
4981abe9b8aSliubo 		__field(	u64,  owner		)
4991abe9b8aSliubo 		__field(	u64,  offset		)
5001abe9b8aSliubo 		__field(	int,  type		)
501dea7d76eSLiu Bo 		__field(	u64,  seq		)
5021abe9b8aSliubo 	),
5031abe9b8aSliubo 
5041abe9b8aSliubo 	TP_fast_assign(
5051abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
5061abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
5071abe9b8aSliubo 		__entry->action		= action;
5081abe9b8aSliubo 		__entry->parent		= full_ref->parent;
5091abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
5101abe9b8aSliubo 		__entry->owner		= full_ref->objectid;
5111abe9b8aSliubo 		__entry->offset		= full_ref->offset;
5121abe9b8aSliubo 		__entry->type		= ref->type;
513dea7d76eSLiu Bo 		__entry->seq		= ref->seq;
5141abe9b8aSliubo 	),
5151abe9b8aSliubo 
5161abe9b8aSliubo 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
5171abe9b8aSliubo 		  "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
518dea7d76eSLiu Bo 		  "offset = %llu, type = %s, seq = %llu",
5191abe9b8aSliubo 		  (unsigned long long)__entry->bytenr,
5201abe9b8aSliubo 		  (unsigned long long)__entry->num_bytes,
5211abe9b8aSliubo 		  show_ref_action(__entry->action),
5221abe9b8aSliubo 		  show_root_type(__entry->parent),
5231abe9b8aSliubo 		  show_root_type(__entry->ref_root),
5241abe9b8aSliubo 		  (unsigned long long)__entry->owner,
5251abe9b8aSliubo 		  (unsigned long long)__entry->offset,
526dea7d76eSLiu Bo 		  show_ref_type(__entry->type),
527dea7d76eSLiu Bo 		  (unsigned long long)__entry->seq)
5281abe9b8aSliubo );
5291abe9b8aSliubo 
5301abe9b8aSliubo TRACE_EVENT(btrfs_delayed_ref_head,
5311abe9b8aSliubo 
5321abe9b8aSliubo 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
5331abe9b8aSliubo 		 struct btrfs_delayed_ref_head *head_ref,
5341abe9b8aSliubo 		 int action),
5351abe9b8aSliubo 
5361abe9b8aSliubo 	TP_ARGS(ref, head_ref, action),
5371abe9b8aSliubo 
5381abe9b8aSliubo 	TP_STRUCT__entry(
5391abe9b8aSliubo 		__field(	u64,  bytenr		)
5401abe9b8aSliubo 		__field(	u64,  num_bytes		)
5411abe9b8aSliubo 		__field(	int,  action		)
5421abe9b8aSliubo 		__field(	int,  is_data		)
5431abe9b8aSliubo 	),
5441abe9b8aSliubo 
5451abe9b8aSliubo 	TP_fast_assign(
5461abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
5471abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
5481abe9b8aSliubo 		__entry->action		= action;
5491abe9b8aSliubo 		__entry->is_data	= head_ref->is_data;
5501abe9b8aSliubo 	),
5511abe9b8aSliubo 
5521abe9b8aSliubo 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
5531abe9b8aSliubo 		  (unsigned long long)__entry->bytenr,
5541abe9b8aSliubo 		  (unsigned long long)__entry->num_bytes,
5551abe9b8aSliubo 		  show_ref_action(__entry->action),
5561abe9b8aSliubo 		  __entry->is_data)
5571abe9b8aSliubo );
5581abe9b8aSliubo 
5591abe9b8aSliubo #define show_chunk_type(type)					\
5601abe9b8aSliubo 	__print_flags(type, "|",				\
5611abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
5621abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
5631abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
5641abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
5651abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
5661abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
567*e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"},	\
568*e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID5, 	"RAID5"	},	\
569*e112e2b4SLiu Bo 		{ BTRFS_BLOCK_GROUP_RAID6, 	"RAID6"	})
5701abe9b8aSliubo 
5711abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk,
5721abe9b8aSliubo 
5731abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
5741abe9b8aSliubo 		 u64 offset, u64 size),
5751abe9b8aSliubo 
5761abe9b8aSliubo 	TP_ARGS(root, map, offset, size),
5771abe9b8aSliubo 
5781abe9b8aSliubo 	TP_STRUCT__entry(
5791abe9b8aSliubo 		__field(	int,  num_stripes		)
5801abe9b8aSliubo 		__field(	u64,  type			)
5811abe9b8aSliubo 		__field(	int,  sub_stripes		)
5821abe9b8aSliubo 		__field(	u64,  offset			)
5831abe9b8aSliubo 		__field(	u64,  size			)
5841abe9b8aSliubo 		__field(	u64,  root_objectid		)
5851abe9b8aSliubo 	),
5861abe9b8aSliubo 
5871abe9b8aSliubo 	TP_fast_assign(
5881abe9b8aSliubo 		__entry->num_stripes	= map->num_stripes;
5891abe9b8aSliubo 		__entry->type		= map->type;
5901abe9b8aSliubo 		__entry->sub_stripes	= map->sub_stripes;
5911abe9b8aSliubo 		__entry->offset		= offset;
5921abe9b8aSliubo 		__entry->size		= size;
5931abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
5941abe9b8aSliubo 	),
5951abe9b8aSliubo 
5961abe9b8aSliubo 	TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
5971abe9b8aSliubo 		  "num_stripes = %d, sub_stripes = %d, type = %s",
5981abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
5991abe9b8aSliubo 		  (unsigned long long)__entry->offset,
6001abe9b8aSliubo 		  (unsigned long long)__entry->size,
6011abe9b8aSliubo 		  __entry->num_stripes, __entry->sub_stripes,
6021abe9b8aSliubo 		  show_chunk_type(__entry->type))
6031abe9b8aSliubo );
6041abe9b8aSliubo 
6051abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
6061abe9b8aSliubo 
6071abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
6081abe9b8aSliubo 		 u64 offset, u64 size),
6091abe9b8aSliubo 
6101abe9b8aSliubo 	TP_ARGS(root, map, offset, size)
6111abe9b8aSliubo );
6121abe9b8aSliubo 
6131abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
6141abe9b8aSliubo 
6151abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
6161abe9b8aSliubo 		 u64 offset, u64 size),
6171abe9b8aSliubo 
6181abe9b8aSliubo 	TP_ARGS(root, map, offset, size)
6191abe9b8aSliubo );
6201abe9b8aSliubo 
6211abe9b8aSliubo TRACE_EVENT(btrfs_cow_block,
6221abe9b8aSliubo 
6231abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
6241abe9b8aSliubo 		 struct extent_buffer *cow),
6251abe9b8aSliubo 
6261abe9b8aSliubo 	TP_ARGS(root, buf, cow),
6271abe9b8aSliubo 
6281abe9b8aSliubo 	TP_STRUCT__entry(
6291abe9b8aSliubo 		__field(	u64,  root_objectid		)
6301abe9b8aSliubo 		__field(	u64,  buf_start			)
6311abe9b8aSliubo 		__field(	int,  refs			)
6321abe9b8aSliubo 		__field(	u64,  cow_start			)
6331abe9b8aSliubo 		__field(	int,  buf_level			)
6341abe9b8aSliubo 		__field(	int,  cow_level			)
6351abe9b8aSliubo 	),
6361abe9b8aSliubo 
6371abe9b8aSliubo 	TP_fast_assign(
6381abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
6391abe9b8aSliubo 		__entry->buf_start	= buf->start;
6401abe9b8aSliubo 		__entry->refs		= atomic_read(&buf->refs);
6411abe9b8aSliubo 		__entry->cow_start	= cow->start;
6421abe9b8aSliubo 		__entry->buf_level	= btrfs_header_level(buf);
6431abe9b8aSliubo 		__entry->cow_level	= btrfs_header_level(cow);
6441abe9b8aSliubo 	),
6451abe9b8aSliubo 
6461abe9b8aSliubo 	TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
6471abe9b8aSliubo 		  "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
6481abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
6491abe9b8aSliubo 		  __entry->refs,
6501abe9b8aSliubo 		  (unsigned long long)__entry->buf_start,
6511abe9b8aSliubo 		  __entry->buf_level,
6521abe9b8aSliubo 		  (unsigned long long)__entry->cow_start,
6531abe9b8aSliubo 		  __entry->cow_level)
6541abe9b8aSliubo );
6551abe9b8aSliubo 
6568c2a3ca2SJosef Bacik TRACE_EVENT(btrfs_space_reservation,
6578c2a3ca2SJosef Bacik 
6588c2a3ca2SJosef Bacik 	TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
6598c2a3ca2SJosef Bacik 		 u64 bytes, int reserve),
6608c2a3ca2SJosef Bacik 
6618c2a3ca2SJosef Bacik 	TP_ARGS(fs_info, type, val, bytes, reserve),
6628c2a3ca2SJosef Bacik 
6638c2a3ca2SJosef Bacik 	TP_STRUCT__entry(
6648c2a3ca2SJosef Bacik 		__array(	u8,	fsid,	BTRFS_UUID_SIZE	)
6658c2a3ca2SJosef Bacik 		__string(	type,	type			)
6668c2a3ca2SJosef Bacik 		__field(	u64,	val			)
6678c2a3ca2SJosef Bacik 		__field(	u64,	bytes			)
6688c2a3ca2SJosef Bacik 		__field(	int,	reserve			)
6698c2a3ca2SJosef Bacik 	),
6708c2a3ca2SJosef Bacik 
6718c2a3ca2SJosef Bacik 	TP_fast_assign(
6728c2a3ca2SJosef Bacik 		memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
6738c2a3ca2SJosef Bacik 		__assign_str(type, type);
6748c2a3ca2SJosef Bacik 		__entry->val		= val;
6758c2a3ca2SJosef Bacik 		__entry->bytes		= bytes;
6768c2a3ca2SJosef Bacik 		__entry->reserve	= reserve;
6778c2a3ca2SJosef Bacik 	),
6788c2a3ca2SJosef Bacik 
6798c2a3ca2SJosef Bacik 	TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
6808c2a3ca2SJosef Bacik 		  __entry->val, __entry->reserve ? "reserve" : "release",
6818c2a3ca2SJosef Bacik 		  __entry->bytes)
6828c2a3ca2SJosef Bacik );
6838c2a3ca2SJosef Bacik 
6841abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent,
6851abe9b8aSliubo 
6861abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
6871abe9b8aSliubo 
6881abe9b8aSliubo 	TP_ARGS(root, start, len),
6891abe9b8aSliubo 
6901abe9b8aSliubo 	TP_STRUCT__entry(
6911abe9b8aSliubo 		__field(	u64,  root_objectid		)
6921abe9b8aSliubo 		__field(	u64,  start			)
6931abe9b8aSliubo 		__field(	u64,  len			)
6941abe9b8aSliubo 	),
6951abe9b8aSliubo 
6961abe9b8aSliubo 	TP_fast_assign(
6971abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
6981abe9b8aSliubo 		__entry->start		= start;
6991abe9b8aSliubo 		__entry->len		= len;
7001abe9b8aSliubo 	),
7011abe9b8aSliubo 
7021abe9b8aSliubo 	TP_printk("root = %llu(%s), start = %llu, len = %llu",
7031abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
7041abe9b8aSliubo 		  (unsigned long long)__entry->start,
7051abe9b8aSliubo 		  (unsigned long long)__entry->len)
7061abe9b8aSliubo );
7071abe9b8aSliubo 
7081abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
7091abe9b8aSliubo 
7101abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
7111abe9b8aSliubo 
7121abe9b8aSliubo 	TP_ARGS(root, start, len)
7131abe9b8aSliubo );
7141abe9b8aSliubo 
7151abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
7161abe9b8aSliubo 
7171abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
7181abe9b8aSliubo 
7191abe9b8aSliubo 	TP_ARGS(root, start, len)
7201abe9b8aSliubo );
7211abe9b8aSliubo 
7223f7de037SJosef Bacik TRACE_EVENT(find_free_extent,
7233f7de037SJosef Bacik 
7243f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
7253f7de037SJosef Bacik 		 u64 data),
7263f7de037SJosef Bacik 
7273f7de037SJosef Bacik 	TP_ARGS(root, num_bytes, empty_size, data),
7283f7de037SJosef Bacik 
7293f7de037SJosef Bacik 	TP_STRUCT__entry(
7303f7de037SJosef Bacik 		__field(	u64,	root_objectid		)
7313f7de037SJosef Bacik 		__field(	u64,	num_bytes		)
7323f7de037SJosef Bacik 		__field(	u64,	empty_size		)
7333f7de037SJosef Bacik 		__field(	u64,	data			)
7343f7de037SJosef Bacik 	),
7353f7de037SJosef Bacik 
7363f7de037SJosef Bacik 	TP_fast_assign(
7373f7de037SJosef Bacik 		__entry->root_objectid	= root->root_key.objectid;
7383f7de037SJosef Bacik 		__entry->num_bytes	= num_bytes;
7393f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
7403f7de037SJosef Bacik 		__entry->data		= data;
7413f7de037SJosef Bacik 	),
7423f7de037SJosef Bacik 
7433f7de037SJosef Bacik 	TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
7443f7de037SJosef Bacik 		  "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
7453f7de037SJosef Bacik 		  __entry->num_bytes, __entry->empty_size, __entry->data,
7463f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->data, "|",
7473f7de037SJosef Bacik 				 BTRFS_GROUP_FLAGS))
7483f7de037SJosef Bacik );
7493f7de037SJosef Bacik 
7503f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent,
7513f7de037SJosef Bacik 
7523f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root,
7533f7de037SJosef Bacik 		 struct btrfs_block_group_cache *block_group, u64 start,
7543f7de037SJosef Bacik 		 u64 len),
7553f7de037SJosef Bacik 
7563f7de037SJosef Bacik 	TP_ARGS(root, block_group, start, len),
7573f7de037SJosef Bacik 
7583f7de037SJosef Bacik 	TP_STRUCT__entry(
7593f7de037SJosef Bacik 		__field(	u64,	root_objectid		)
7603f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
7613f7de037SJosef Bacik 		__field(	u64,	flags			)
7623f7de037SJosef Bacik 		__field(	u64,	start			)
7633f7de037SJosef Bacik 		__field(	u64,	len			)
7643f7de037SJosef Bacik 	),
7653f7de037SJosef Bacik 
7663f7de037SJosef Bacik 	TP_fast_assign(
7673f7de037SJosef Bacik 		__entry->root_objectid	= root->root_key.objectid;
7683f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
7693f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
7703f7de037SJosef Bacik 		__entry->start		= start;
7713f7de037SJosef Bacik 		__entry->len		= len;
7723f7de037SJosef Bacik 	),
7733f7de037SJosef Bacik 
7743f7de037SJosef Bacik 	TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
7753f7de037SJosef Bacik 		  "start = %Lu, len = %Lu",
7763f7de037SJosef Bacik 		  show_root_type(__entry->root_objectid), __entry->bg_objectid,
7773f7de037SJosef Bacik 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
7783f7de037SJosef Bacik 						"|", BTRFS_GROUP_FLAGS),
7793f7de037SJosef Bacik 		  __entry->start, __entry->len)
7803f7de037SJosef Bacik );
7813f7de037SJosef Bacik 
7823f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
7833f7de037SJosef Bacik 
7843f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root,
7853f7de037SJosef Bacik 		 struct btrfs_block_group_cache *block_group, u64 start,
7863f7de037SJosef Bacik 		 u64 len),
7873f7de037SJosef Bacik 
7883f7de037SJosef Bacik 	TP_ARGS(root, block_group, start, len)
7893f7de037SJosef Bacik );
7903f7de037SJosef Bacik 
7913f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
7923f7de037SJosef Bacik 
7933f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root,
7943f7de037SJosef Bacik 		 struct btrfs_block_group_cache *block_group, u64 start,
7953f7de037SJosef Bacik 		 u64 len),
7963f7de037SJosef Bacik 
7973f7de037SJosef Bacik 	TP_ARGS(root, block_group, start, len)
7983f7de037SJosef Bacik );
7993f7de037SJosef Bacik 
8003f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster,
8013f7de037SJosef Bacik 
8023f7de037SJosef Bacik 	TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
8033f7de037SJosef Bacik 		 u64 bytes, u64 empty_size, u64 min_bytes),
8043f7de037SJosef Bacik 
8053f7de037SJosef Bacik 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
8063f7de037SJosef Bacik 
8073f7de037SJosef Bacik 	TP_STRUCT__entry(
8083f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
8093f7de037SJosef Bacik 		__field(	u64,	flags			)
8103f7de037SJosef Bacik 		__field(	u64,	start			)
8113f7de037SJosef Bacik 		__field(	u64,	bytes			)
8123f7de037SJosef Bacik 		__field(	u64,	empty_size		)
8133f7de037SJosef Bacik 		__field(	u64,	min_bytes		)
8143f7de037SJosef Bacik 	),
8153f7de037SJosef Bacik 
8163f7de037SJosef Bacik 	TP_fast_assign(
8173f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
8183f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
8193f7de037SJosef Bacik 		__entry->start		= start;
8203f7de037SJosef Bacik 		__entry->bytes		= bytes;
8213f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
8223f7de037SJosef Bacik 		__entry->min_bytes	= min_bytes;
8233f7de037SJosef Bacik 	),
8243f7de037SJosef Bacik 
8253f7de037SJosef Bacik 	TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
8263f7de037SJosef Bacik 		  " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
8273f7de037SJosef Bacik 		  __entry->flags,
8283f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
8293f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
8303f7de037SJosef Bacik 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
8313f7de037SJosef Bacik );
8323f7de037SJosef Bacik 
8333f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup,
8343f7de037SJosef Bacik 
8353f7de037SJosef Bacik 	TP_PROTO(struct btrfs_block_group_cache *block_group),
8363f7de037SJosef Bacik 
8373f7de037SJosef Bacik 	TP_ARGS(block_group),
8383f7de037SJosef Bacik 
8393f7de037SJosef Bacik 	TP_STRUCT__entry(
8403f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
8413f7de037SJosef Bacik 	),
8423f7de037SJosef Bacik 
8433f7de037SJosef Bacik 	TP_fast_assign(
8443f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
8453f7de037SJosef Bacik 	),
8463f7de037SJosef Bacik 
8473f7de037SJosef Bacik 	TP_printk("block_group = %Lu", __entry->bg_objectid)
8483f7de037SJosef Bacik );
8493f7de037SJosef Bacik 
8503f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster,
8513f7de037SJosef Bacik 
8523f7de037SJosef Bacik 	TP_PROTO(struct btrfs_block_group_cache *block_group,
8533f7de037SJosef Bacik 		 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
8543f7de037SJosef Bacik 
8553f7de037SJosef Bacik 	TP_ARGS(block_group, cluster, size, bitmap),
8563f7de037SJosef Bacik 
8573f7de037SJosef Bacik 	TP_STRUCT__entry(
8583f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
8593f7de037SJosef Bacik 		__field(	u64,	flags			)
8603f7de037SJosef Bacik 		__field(	u64,	start			)
8613f7de037SJosef Bacik 		__field(	u64,	max_size		)
8623f7de037SJosef Bacik 		__field(	u64,	size			)
8633f7de037SJosef Bacik 		__field(	int,	bitmap			)
8643f7de037SJosef Bacik 	),
8653f7de037SJosef Bacik 
8663f7de037SJosef Bacik 	TP_fast_assign(
8673f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
8683f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
8693f7de037SJosef Bacik 		__entry->start		= cluster->window_start;
8703f7de037SJosef Bacik 		__entry->max_size	= cluster->max_size;
8713f7de037SJosef Bacik 		__entry->size		= size;
8723f7de037SJosef Bacik 		__entry->bitmap		= bitmap;
8733f7de037SJosef Bacik 	),
8743f7de037SJosef Bacik 
8753f7de037SJosef Bacik 	TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
8763f7de037SJosef Bacik 		  "size = %Lu, max_size = %Lu, bitmap = %d",
8773f7de037SJosef Bacik 		  __entry->bg_objectid,
8783f7de037SJosef Bacik 		  __entry->flags,
8793f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
8803f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
8813f7de037SJosef Bacik 		  __entry->size, __entry->max_size, __entry->bitmap)
8823f7de037SJosef Bacik );
8833f7de037SJosef Bacik 
884143bede5SJeff Mahoney struct extent_state;
885143bede5SJeff Mahoney TRACE_EVENT(alloc_extent_state,
886143bede5SJeff Mahoney 
887143bede5SJeff Mahoney 	TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
888143bede5SJeff Mahoney 
889143bede5SJeff Mahoney 	TP_ARGS(state, mask, IP),
890143bede5SJeff Mahoney 
891143bede5SJeff Mahoney 	TP_STRUCT__entry(
892143bede5SJeff Mahoney 		__field(struct extent_state *, state)
893143bede5SJeff Mahoney 		__field(gfp_t, mask)
894143bede5SJeff Mahoney 		__field(unsigned long, ip)
895143bede5SJeff Mahoney 	),
896143bede5SJeff Mahoney 
897143bede5SJeff Mahoney 	TP_fast_assign(
898143bede5SJeff Mahoney 		__entry->state	= state,
899143bede5SJeff Mahoney 		__entry->mask	= mask,
900143bede5SJeff Mahoney 		__entry->ip	= IP
901143bede5SJeff Mahoney 	),
902143bede5SJeff Mahoney 
903143bede5SJeff Mahoney 	TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
904143bede5SJeff Mahoney 		  show_gfp_flags(__entry->mask), (void *)__entry->ip)
905143bede5SJeff Mahoney );
906143bede5SJeff Mahoney 
907143bede5SJeff Mahoney TRACE_EVENT(free_extent_state,
908143bede5SJeff Mahoney 
909143bede5SJeff Mahoney 	TP_PROTO(struct extent_state *state, unsigned long IP),
910143bede5SJeff Mahoney 
911143bede5SJeff Mahoney 	TP_ARGS(state, IP),
912143bede5SJeff Mahoney 
913143bede5SJeff Mahoney 	TP_STRUCT__entry(
914143bede5SJeff Mahoney 		__field(struct extent_state *, state)
915143bede5SJeff Mahoney 		__field(unsigned long, ip)
916143bede5SJeff Mahoney 	),
917143bede5SJeff Mahoney 
918143bede5SJeff Mahoney 	TP_fast_assign(
919143bede5SJeff Mahoney 		__entry->state	= state,
920143bede5SJeff Mahoney 		__entry->ip = IP
921143bede5SJeff Mahoney 	),
922143bede5SJeff Mahoney 
923143bede5SJeff Mahoney 	TP_printk(" state=%p; caller = %pF", __entry->state,
924143bede5SJeff Mahoney 		  (void *)__entry->ip)
925143bede5SJeff Mahoney );
926143bede5SJeff Mahoney 
9271abe9b8aSliubo #endif /* _TRACE_BTRFS_H */
9281abe9b8aSliubo 
9291abe9b8aSliubo /* This part must be outside protection */
9301abe9b8aSliubo #include <trace/define_trace.h>
931