xref: /openbmc/linux/include/trace/events/btrfs.h (revision 3f7de037)
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>
91abe9b8aSliubo 
101abe9b8aSliubo struct btrfs_root;
111abe9b8aSliubo struct btrfs_fs_info;
121abe9b8aSliubo struct btrfs_inode;
131abe9b8aSliubo struct extent_map;
141abe9b8aSliubo struct btrfs_ordered_extent;
151abe9b8aSliubo struct btrfs_delayed_ref_node;
161abe9b8aSliubo struct btrfs_delayed_tree_ref;
171abe9b8aSliubo struct btrfs_delayed_data_ref;
181abe9b8aSliubo struct btrfs_delayed_ref_head;
19*3f7de037SJosef Bacik struct btrfs_block_group_cache;
20*3f7de037SJosef Bacik struct btrfs_free_cluster;
211abe9b8aSliubo struct map_lookup;
221abe9b8aSliubo struct extent_buffer;
231abe9b8aSliubo 
241abe9b8aSliubo #define show_ref_type(type)						\
251abe9b8aSliubo 	__print_symbolic(type,						\
261abe9b8aSliubo 		{ BTRFS_TREE_BLOCK_REF_KEY, 	"TREE_BLOCK_REF" },	\
271abe9b8aSliubo 		{ BTRFS_EXTENT_DATA_REF_KEY, 	"EXTENT_DATA_REF" },	\
281abe9b8aSliubo 		{ BTRFS_EXTENT_REF_V0_KEY, 	"EXTENT_REF_V0" },	\
291abe9b8aSliubo 		{ BTRFS_SHARED_BLOCK_REF_KEY, 	"SHARED_BLOCK_REF" },	\
301abe9b8aSliubo 		{ BTRFS_SHARED_DATA_REF_KEY, 	"SHARED_DATA_REF" })
311abe9b8aSliubo 
321abe9b8aSliubo #define __show_root_type(obj)						\
337f34b746Sliubo 	__print_symbolic_u64(obj,					\
341abe9b8aSliubo 		{ BTRFS_ROOT_TREE_OBJECTID, 	"ROOT_TREE"	},	\
351abe9b8aSliubo 		{ BTRFS_EXTENT_TREE_OBJECTID, 	"EXTENT_TREE"	},	\
361abe9b8aSliubo 		{ BTRFS_CHUNK_TREE_OBJECTID, 	"CHUNK_TREE"	},	\
371abe9b8aSliubo 		{ BTRFS_DEV_TREE_OBJECTID, 	"DEV_TREE"	},	\
381abe9b8aSliubo 		{ BTRFS_FS_TREE_OBJECTID, 	"FS_TREE"	},	\
391abe9b8aSliubo 		{ BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR"	},	\
401abe9b8aSliubo 		{ BTRFS_CSUM_TREE_OBJECTID, 	"CSUM_TREE"	},	\
411abe9b8aSliubo 		{ BTRFS_TREE_LOG_OBJECTID,	"TREE_LOG"	},	\
421abe9b8aSliubo 		{ BTRFS_TREE_RELOC_OBJECTID,	"TREE_RELOC"	},	\
431abe9b8aSliubo 		{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
441abe9b8aSliubo 
451abe9b8aSliubo #define show_root_type(obj)						\
461abe9b8aSliubo 	obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||		\
471abe9b8aSliubo 	      (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-"
481abe9b8aSliubo 
49*3f7de037SJosef Bacik #define BTRFS_GROUP_FLAGS	\
50*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DATA,	"DATA"}, \
51*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_SYSTEM,	"SYSTEM"}, \
52*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_METADATA,	"METADATA"}, \
53*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID0,	"RAID0"}, \
54*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID1,	"RAID1"}, \
55*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_DUP,	"DUP"}, \
56*3f7de037SJosef Bacik 	{ BTRFS_BLOCK_GROUP_RAID10,	"RAID10"}
57*3f7de037SJosef Bacik 
581abe9b8aSliubo TRACE_EVENT(btrfs_transaction_commit,
591abe9b8aSliubo 
601abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root),
611abe9b8aSliubo 
621abe9b8aSliubo 	TP_ARGS(root),
631abe9b8aSliubo 
641abe9b8aSliubo 	TP_STRUCT__entry(
651abe9b8aSliubo 		__field(	u64,  generation		)
661abe9b8aSliubo 		__field(	u64,  root_objectid		)
671abe9b8aSliubo 	),
681abe9b8aSliubo 
691abe9b8aSliubo 	TP_fast_assign(
701abe9b8aSliubo 		__entry->generation	= root->fs_info->generation;
711abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
721abe9b8aSliubo 	),
731abe9b8aSliubo 
741abe9b8aSliubo 	TP_printk("root = %llu(%s), gen = %llu",
751abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
761abe9b8aSliubo 		  (unsigned long long)__entry->generation)
771abe9b8aSliubo );
781abe9b8aSliubo 
791abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__inode,
801abe9b8aSliubo 
811abe9b8aSliubo 	TP_PROTO(struct inode *inode),
821abe9b8aSliubo 
831abe9b8aSliubo 	TP_ARGS(inode),
841abe9b8aSliubo 
851abe9b8aSliubo 	TP_STRUCT__entry(
861abe9b8aSliubo 		__field(	ino_t,  ino			)
871abe9b8aSliubo 		__field(	blkcnt_t,  blocks		)
881abe9b8aSliubo 		__field(	u64,  disk_i_size		)
891abe9b8aSliubo 		__field(	u64,  generation		)
901abe9b8aSliubo 		__field(	u64,  last_trans		)
911abe9b8aSliubo 		__field(	u64,  logged_trans		)
921abe9b8aSliubo 		__field(	u64,  root_objectid		)
931abe9b8aSliubo 	),
941abe9b8aSliubo 
951abe9b8aSliubo 	TP_fast_assign(
961abe9b8aSliubo 		__entry->ino	= inode->i_ino;
971abe9b8aSliubo 		__entry->blocks	= inode->i_blocks;
981abe9b8aSliubo 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
991abe9b8aSliubo 		__entry->generation = BTRFS_I(inode)->generation;
1001abe9b8aSliubo 		__entry->last_trans = BTRFS_I(inode)->last_trans;
1011abe9b8aSliubo 		__entry->logged_trans = BTRFS_I(inode)->logged_trans;
1021abe9b8aSliubo 		__entry->root_objectid =
1031abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
1041abe9b8aSliubo 	),
1051abe9b8aSliubo 
1061abe9b8aSliubo 	TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
1071abe9b8aSliubo 		  "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
1081abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
1091abe9b8aSliubo 		  (unsigned long long)__entry->generation,
1101abe9b8aSliubo 		  (unsigned long)__entry->ino,
1111abe9b8aSliubo 		  (unsigned long long)__entry->blocks,
1121abe9b8aSliubo 		  (unsigned long long)__entry->disk_i_size,
1131abe9b8aSliubo 		  (unsigned long long)__entry->last_trans,
1141abe9b8aSliubo 		  (unsigned long long)__entry->logged_trans)
1151abe9b8aSliubo );
1161abe9b8aSliubo 
1171abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
1181abe9b8aSliubo 
1191abe9b8aSliubo 	TP_PROTO(struct inode *inode),
1201abe9b8aSliubo 
1211abe9b8aSliubo 	TP_ARGS(inode)
1221abe9b8aSliubo );
1231abe9b8aSliubo 
1241abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
1251abe9b8aSliubo 
1261abe9b8aSliubo 	TP_PROTO(struct inode *inode),
1271abe9b8aSliubo 
1281abe9b8aSliubo 	TP_ARGS(inode)
1291abe9b8aSliubo );
1301abe9b8aSliubo 
1311abe9b8aSliubo DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
1321abe9b8aSliubo 
1331abe9b8aSliubo 	TP_PROTO(struct inode *inode),
1341abe9b8aSliubo 
1351abe9b8aSliubo 	TP_ARGS(inode)
1361abe9b8aSliubo );
1371abe9b8aSliubo 
1381abe9b8aSliubo #define __show_map_type(type)						\
1397f34b746Sliubo 	__print_symbolic_u64(type,					\
1401abe9b8aSliubo 		{ EXTENT_MAP_LAST_BYTE, "LAST_BYTE" 	},		\
1411abe9b8aSliubo 		{ EXTENT_MAP_HOLE, 	"HOLE" 		},		\
1421abe9b8aSliubo 		{ EXTENT_MAP_INLINE, 	"INLINE" 	},		\
1431abe9b8aSliubo 		{ EXTENT_MAP_DELALLOC,	"DELALLOC" 	})
1441abe9b8aSliubo 
1451abe9b8aSliubo #define show_map_type(type)			\
1461abe9b8aSliubo 	type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
1471abe9b8aSliubo 
1481abe9b8aSliubo #define show_map_flags(flag)						\
1491abe9b8aSliubo 	__print_flags(flag, "|",					\
1501abe9b8aSliubo 		{ EXTENT_FLAG_PINNED, 		"PINNED" 	},	\
1511abe9b8aSliubo 		{ EXTENT_FLAG_COMPRESSED, 	"COMPRESSED" 	},	\
1521abe9b8aSliubo 		{ EXTENT_FLAG_VACANCY, 		"VACANCY" 	},	\
1531abe9b8aSliubo 		{ EXTENT_FLAG_PREALLOC, 	"PREALLOC" 	})
1541abe9b8aSliubo 
1551abe9b8aSliubo TRACE_EVENT(btrfs_get_extent,
1561abe9b8aSliubo 
1571abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct extent_map *map),
1581abe9b8aSliubo 
1591abe9b8aSliubo 	TP_ARGS(root, map),
1601abe9b8aSliubo 
1611abe9b8aSliubo 	TP_STRUCT__entry(
1621abe9b8aSliubo 		__field(	u64,  root_objectid	)
1631abe9b8aSliubo 		__field(	u64,  start		)
1641abe9b8aSliubo 		__field(	u64,  len		)
1651abe9b8aSliubo 		__field(	u64,  orig_start	)
1661abe9b8aSliubo 		__field(	u64,  block_start	)
1671abe9b8aSliubo 		__field(	u64,  block_len		)
1681abe9b8aSliubo 		__field(	unsigned long,  flags	)
1691abe9b8aSliubo 		__field(	int,  refs		)
1701abe9b8aSliubo 		__field(	unsigned int,  compress_type	)
1711abe9b8aSliubo 	),
1721abe9b8aSliubo 
1731abe9b8aSliubo 	TP_fast_assign(
1741abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
1751abe9b8aSliubo 		__entry->start 		= map->start;
1761abe9b8aSliubo 		__entry->len		= map->len;
1771abe9b8aSliubo 		__entry->orig_start	= map->orig_start;
1781abe9b8aSliubo 		__entry->block_start	= map->block_start;
1791abe9b8aSliubo 		__entry->block_len	= map->block_len;
1801abe9b8aSliubo 		__entry->flags		= map->flags;
1811abe9b8aSliubo 		__entry->refs		= atomic_read(&map->refs);
1821abe9b8aSliubo 		__entry->compress_type	= map->compress_type;
1831abe9b8aSliubo 	),
1841abe9b8aSliubo 
1851abe9b8aSliubo 	TP_printk("root = %llu(%s), start = %llu, len = %llu, "
1861abe9b8aSliubo 		  "orig_start = %llu, block_start = %llu(%s), "
1871abe9b8aSliubo 		  "block_len = %llu, flags = %s, refs = %u, "
1881abe9b8aSliubo 		  "compress_type = %u",
1891abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
1901abe9b8aSliubo 		  (unsigned long long)__entry->start,
1911abe9b8aSliubo 		  (unsigned long long)__entry->len,
1921abe9b8aSliubo 		  (unsigned long long)__entry->orig_start,
1931abe9b8aSliubo 		  show_map_type(__entry->block_start),
1941abe9b8aSliubo 		  (unsigned long long)__entry->block_len,
1951abe9b8aSliubo 		  show_map_flags(__entry->flags),
1961abe9b8aSliubo 		  __entry->refs, __entry->compress_type)
1971abe9b8aSliubo );
1981abe9b8aSliubo 
1991abe9b8aSliubo #define show_ordered_flags(flags)					\
2001abe9b8aSliubo 	__print_symbolic(flags,					\
2011abe9b8aSliubo 		{ BTRFS_ORDERED_IO_DONE, 	"IO_DONE" 	},	\
2021abe9b8aSliubo 		{ BTRFS_ORDERED_COMPLETE, 	"COMPLETE" 	},	\
2031abe9b8aSliubo 		{ BTRFS_ORDERED_NOCOW, 		"NOCOW" 	},	\
2041abe9b8aSliubo 		{ BTRFS_ORDERED_COMPRESSED, 	"COMPRESSED" 	},	\
2051abe9b8aSliubo 		{ BTRFS_ORDERED_PREALLOC, 	"PREALLOC" 	},	\
2061abe9b8aSliubo 		{ BTRFS_ORDERED_DIRECT, 	"DIRECT" 	})
2071abe9b8aSliubo 
2081abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__ordered_extent,
2091abe9b8aSliubo 
2101abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2111abe9b8aSliubo 
2121abe9b8aSliubo 	TP_ARGS(inode, ordered),
2131abe9b8aSliubo 
2141abe9b8aSliubo 	TP_STRUCT__entry(
2151abe9b8aSliubo 		__field(	ino_t,  ino		)
2161abe9b8aSliubo 		__field(	u64,  file_offset	)
2171abe9b8aSliubo 		__field(	u64,  start		)
2181abe9b8aSliubo 		__field(	u64,  len		)
2191abe9b8aSliubo 		__field(	u64,  disk_len		)
2201abe9b8aSliubo 		__field(	u64,  bytes_left	)
2211abe9b8aSliubo 		__field(	unsigned long,  flags	)
2221abe9b8aSliubo 		__field(	int,  compress_type	)
2231abe9b8aSliubo 		__field(	int,  refs		)
2241abe9b8aSliubo 		__field(	u64,  root_objectid	)
2251abe9b8aSliubo 	),
2261abe9b8aSliubo 
2271abe9b8aSliubo 	TP_fast_assign(
2281abe9b8aSliubo 		__entry->ino 		= inode->i_ino;
2291abe9b8aSliubo 		__entry->file_offset	= ordered->file_offset;
2301abe9b8aSliubo 		__entry->start		= ordered->start;
2311abe9b8aSliubo 		__entry->len		= ordered->len;
2321abe9b8aSliubo 		__entry->disk_len	= ordered->disk_len;
2331abe9b8aSliubo 		__entry->bytes_left	= ordered->bytes_left;
2341abe9b8aSliubo 		__entry->flags		= ordered->flags;
2351abe9b8aSliubo 		__entry->compress_type	= ordered->compress_type;
2361abe9b8aSliubo 		__entry->refs		= atomic_read(&ordered->refs);
2371abe9b8aSliubo 		__entry->root_objectid	=
2381abe9b8aSliubo 				BTRFS_I(inode)->root->root_key.objectid;
2391abe9b8aSliubo 	),
2401abe9b8aSliubo 
2411abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
2421abe9b8aSliubo 		  "start = %llu, len = %llu, disk_len = %llu, "
2431abe9b8aSliubo 		  "bytes_left = %llu, flags = %s, compress_type = %d, "
2441abe9b8aSliubo 		  "refs = %d",
2451abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
2461abe9b8aSliubo 		  (unsigned long long)__entry->ino,
2471abe9b8aSliubo 		  (unsigned long long)__entry->file_offset,
2481abe9b8aSliubo 		  (unsigned long long)__entry->start,
2491abe9b8aSliubo 		  (unsigned long long)__entry->len,
2501abe9b8aSliubo 		  (unsigned long long)__entry->disk_len,
2511abe9b8aSliubo 		  (unsigned long long)__entry->bytes_left,
2521abe9b8aSliubo 		  show_ordered_flags(__entry->flags),
2531abe9b8aSliubo 		  __entry->compress_type, __entry->refs)
2541abe9b8aSliubo );
2551abe9b8aSliubo 
2561abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
2571abe9b8aSliubo 
2581abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2591abe9b8aSliubo 
2601abe9b8aSliubo 	TP_ARGS(inode, ordered)
2611abe9b8aSliubo );
2621abe9b8aSliubo 
2631abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
2641abe9b8aSliubo 
2651abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2661abe9b8aSliubo 
2671abe9b8aSliubo 	TP_ARGS(inode, ordered)
2681abe9b8aSliubo );
2691abe9b8aSliubo 
2701abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
2711abe9b8aSliubo 
2721abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2731abe9b8aSliubo 
2741abe9b8aSliubo 	TP_ARGS(inode, ordered)
2751abe9b8aSliubo );
2761abe9b8aSliubo 
2771abe9b8aSliubo DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
2781abe9b8aSliubo 
2791abe9b8aSliubo 	TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
2801abe9b8aSliubo 
2811abe9b8aSliubo 	TP_ARGS(inode, ordered)
2821abe9b8aSliubo );
2831abe9b8aSliubo 
2841abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__writepage,
2851abe9b8aSliubo 
2861abe9b8aSliubo 	TP_PROTO(struct page *page, struct inode *inode,
2871abe9b8aSliubo 		 struct writeback_control *wbc),
2881abe9b8aSliubo 
2891abe9b8aSliubo 	TP_ARGS(page, inode, wbc),
2901abe9b8aSliubo 
2911abe9b8aSliubo 	TP_STRUCT__entry(
2921abe9b8aSliubo 		__field(	ino_t,  ino			)
2931abe9b8aSliubo 		__field(	pgoff_t,  index			)
2941abe9b8aSliubo 		__field(	long,   nr_to_write		)
2951abe9b8aSliubo 		__field(	long,   pages_skipped		)
2961abe9b8aSliubo 		__field(	loff_t, range_start		)
2971abe9b8aSliubo 		__field(	loff_t, range_end		)
2981abe9b8aSliubo 		__field(	char,   for_kupdate		)
2991abe9b8aSliubo 		__field(	char,   for_reclaim		)
3001abe9b8aSliubo 		__field(	char,   range_cyclic		)
3011abe9b8aSliubo 		__field(	pgoff_t,  writeback_index	)
3021abe9b8aSliubo 		__field(	u64,    root_objectid		)
3031abe9b8aSliubo 	),
3041abe9b8aSliubo 
3051abe9b8aSliubo 	TP_fast_assign(
3061abe9b8aSliubo 		__entry->ino		= inode->i_ino;
3071abe9b8aSliubo 		__entry->index		= page->index;
3081abe9b8aSliubo 		__entry->nr_to_write	= wbc->nr_to_write;
3091abe9b8aSliubo 		__entry->pages_skipped	= wbc->pages_skipped;
3101abe9b8aSliubo 		__entry->range_start	= wbc->range_start;
3111abe9b8aSliubo 		__entry->range_end	= wbc->range_end;
3121abe9b8aSliubo 		__entry->for_kupdate	= wbc->for_kupdate;
3131abe9b8aSliubo 		__entry->for_reclaim	= wbc->for_reclaim;
3141abe9b8aSliubo 		__entry->range_cyclic	= wbc->range_cyclic;
3151abe9b8aSliubo 		__entry->writeback_index = inode->i_mapping->writeback_index;
3161abe9b8aSliubo 		__entry->root_objectid	=
3171abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
3181abe9b8aSliubo 	),
3191abe9b8aSliubo 
3201abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
3211abe9b8aSliubo 		  "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
322846d5a09SWu Fengguang 		  "range_end = %llu, for_kupdate = %d, "
3231abe9b8aSliubo 		  "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
3241abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3251abe9b8aSliubo 		  (unsigned long)__entry->ino, __entry->index,
3261abe9b8aSliubo 		  __entry->nr_to_write, __entry->pages_skipped,
3271abe9b8aSliubo 		  __entry->range_start, __entry->range_end,
328846d5a09SWu Fengguang 		  __entry->for_kupdate,
3291abe9b8aSliubo 		  __entry->for_reclaim, __entry->range_cyclic,
3301abe9b8aSliubo 		  (unsigned long)__entry->writeback_index)
3311abe9b8aSliubo );
3321abe9b8aSliubo 
3331abe9b8aSliubo DEFINE_EVENT(btrfs__writepage, __extent_writepage,
3341abe9b8aSliubo 
3351abe9b8aSliubo 	TP_PROTO(struct page *page, struct inode *inode,
3361abe9b8aSliubo 		 struct writeback_control *wbc),
3371abe9b8aSliubo 
3381abe9b8aSliubo 	TP_ARGS(page, inode, wbc)
3391abe9b8aSliubo );
3401abe9b8aSliubo 
3411abe9b8aSliubo TRACE_EVENT(btrfs_writepage_end_io_hook,
3421abe9b8aSliubo 
3431abe9b8aSliubo 	TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
3441abe9b8aSliubo 
3451abe9b8aSliubo 	TP_ARGS(page, start, end, uptodate),
3461abe9b8aSliubo 
3471abe9b8aSliubo 	TP_STRUCT__entry(
3481abe9b8aSliubo 		__field(	ino_t,	 ino		)
3491abe9b8aSliubo 		__field(	pgoff_t, index		)
3501abe9b8aSliubo 		__field(	u64,	 start		)
3511abe9b8aSliubo 		__field(	u64,	 end		)
3521abe9b8aSliubo 		__field(	int,	 uptodate	)
3531abe9b8aSliubo 		__field(	u64,    root_objectid	)
3541abe9b8aSliubo 	),
3551abe9b8aSliubo 
3561abe9b8aSliubo 	TP_fast_assign(
3571abe9b8aSliubo 		__entry->ino	= page->mapping->host->i_ino;
3581abe9b8aSliubo 		__entry->index	= page->index;
3591abe9b8aSliubo 		__entry->start	= start;
3601abe9b8aSliubo 		__entry->end	= end;
3611abe9b8aSliubo 		__entry->uptodate = uptodate;
3621abe9b8aSliubo 		__entry->root_objectid	=
3631abe9b8aSliubo 			 BTRFS_I(page->mapping->host)->root->root_key.objectid;
3641abe9b8aSliubo 	),
3651abe9b8aSliubo 
3661abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
3671abe9b8aSliubo 		  "end = %llu, uptodate = %d",
3681abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
3691abe9b8aSliubo 		  (unsigned long)__entry->ino, (unsigned long)__entry->index,
3701abe9b8aSliubo 		  (unsigned long long)__entry->start,
3711abe9b8aSliubo 		  (unsigned long long)__entry->end, __entry->uptodate)
3721abe9b8aSliubo );
3731abe9b8aSliubo 
3741abe9b8aSliubo TRACE_EVENT(btrfs_sync_file,
3751abe9b8aSliubo 
3761abe9b8aSliubo 	TP_PROTO(struct file *file, int datasync),
3771abe9b8aSliubo 
3781abe9b8aSliubo 	TP_ARGS(file, datasync),
3791abe9b8aSliubo 
3801abe9b8aSliubo 	TP_STRUCT__entry(
3811abe9b8aSliubo 		__field(	ino_t,  ino		)
3821abe9b8aSliubo 		__field(	ino_t,  parent		)
3831abe9b8aSliubo 		__field(	int,    datasync	)
3841abe9b8aSliubo 		__field(	u64,    root_objectid	)
3851abe9b8aSliubo 	),
3861abe9b8aSliubo 
3871abe9b8aSliubo 	TP_fast_assign(
3881abe9b8aSliubo 		struct dentry *dentry = file->f_path.dentry;
3891abe9b8aSliubo 		struct inode *inode = dentry->d_inode;
3901abe9b8aSliubo 
3911abe9b8aSliubo 		__entry->ino		= inode->i_ino;
3921abe9b8aSliubo 		__entry->parent		= dentry->d_parent->d_inode->i_ino;
3931abe9b8aSliubo 		__entry->datasync	= datasync;
3941abe9b8aSliubo 		__entry->root_objectid	=
3951abe9b8aSliubo 				 BTRFS_I(inode)->root->root_key.objectid;
3961abe9b8aSliubo 	),
3971abe9b8aSliubo 
3981abe9b8aSliubo 	TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
3991abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
4001abe9b8aSliubo 		  (unsigned long)__entry->ino, (unsigned long)__entry->parent,
4011abe9b8aSliubo 		  __entry->datasync)
4021abe9b8aSliubo );
4031abe9b8aSliubo 
4041abe9b8aSliubo TRACE_EVENT(btrfs_sync_fs,
4051abe9b8aSliubo 
4061abe9b8aSliubo 	TP_PROTO(int wait),
4071abe9b8aSliubo 
4081abe9b8aSliubo 	TP_ARGS(wait),
4091abe9b8aSliubo 
4101abe9b8aSliubo 	TP_STRUCT__entry(
4111abe9b8aSliubo 		__field(	int,  wait		)
4121abe9b8aSliubo 	),
4131abe9b8aSliubo 
4141abe9b8aSliubo 	TP_fast_assign(
4151abe9b8aSliubo 		__entry->wait	= wait;
4161abe9b8aSliubo 	),
4171abe9b8aSliubo 
4181abe9b8aSliubo 	TP_printk("wait = %d", __entry->wait)
4191abe9b8aSliubo );
4201abe9b8aSliubo 
4211abe9b8aSliubo #define show_ref_action(action)						\
4221abe9b8aSliubo 	__print_symbolic(action,					\
4231abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },	\
4241abe9b8aSliubo 		{ BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },	\
4251abe9b8aSliubo 		{ BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, 	\
4261abe9b8aSliubo 		{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
4271abe9b8aSliubo 
4281abe9b8aSliubo 
4291abe9b8aSliubo TRACE_EVENT(btrfs_delayed_tree_ref,
4301abe9b8aSliubo 
4311abe9b8aSliubo 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
4321abe9b8aSliubo 		 struct btrfs_delayed_tree_ref *full_ref,
4331abe9b8aSliubo 		 int action),
4341abe9b8aSliubo 
4351abe9b8aSliubo 	TP_ARGS(ref, full_ref, action),
4361abe9b8aSliubo 
4371abe9b8aSliubo 	TP_STRUCT__entry(
4381abe9b8aSliubo 		__field(	u64,  bytenr		)
4391abe9b8aSliubo 		__field(	u64,  num_bytes		)
4401abe9b8aSliubo 		__field(	int,  action		)
4411abe9b8aSliubo 		__field(	u64,  parent		)
4421abe9b8aSliubo 		__field(	u64,  ref_root		)
4431abe9b8aSliubo 		__field(	int,  level		)
4441abe9b8aSliubo 		__field(	int,  type		)
4451abe9b8aSliubo 	),
4461abe9b8aSliubo 
4471abe9b8aSliubo 	TP_fast_assign(
4481abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
4491abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
4501abe9b8aSliubo 		__entry->action		= action;
4511abe9b8aSliubo 		__entry->parent		= full_ref->parent;
4521abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
4531abe9b8aSliubo 		__entry->level		= full_ref->level;
4541abe9b8aSliubo 		__entry->type		= ref->type;
4551abe9b8aSliubo 	),
4561abe9b8aSliubo 
4571abe9b8aSliubo 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
4581abe9b8aSliubo 		  "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
4591abe9b8aSliubo 		  "type = %s",
4601abe9b8aSliubo 		  (unsigned long long)__entry->bytenr,
4611abe9b8aSliubo 		  (unsigned long long)__entry->num_bytes,
4621abe9b8aSliubo 		  show_ref_action(__entry->action),
4631abe9b8aSliubo 		  show_root_type(__entry->parent),
4641abe9b8aSliubo 		  show_root_type(__entry->ref_root),
4651abe9b8aSliubo 		  __entry->level, show_ref_type(__entry->type))
4661abe9b8aSliubo );
4671abe9b8aSliubo 
4681abe9b8aSliubo TRACE_EVENT(btrfs_delayed_data_ref,
4691abe9b8aSliubo 
4701abe9b8aSliubo 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
4711abe9b8aSliubo 		 struct btrfs_delayed_data_ref *full_ref,
4721abe9b8aSliubo 		 int action),
4731abe9b8aSliubo 
4741abe9b8aSliubo 	TP_ARGS(ref, full_ref, action),
4751abe9b8aSliubo 
4761abe9b8aSliubo 	TP_STRUCT__entry(
4771abe9b8aSliubo 		__field(	u64,  bytenr		)
4781abe9b8aSliubo 		__field(	u64,  num_bytes		)
4791abe9b8aSliubo 		__field(	int,  action		)
4801abe9b8aSliubo 		__field(	u64,  parent		)
4811abe9b8aSliubo 		__field(	u64,  ref_root		)
4821abe9b8aSliubo 		__field(	u64,  owner		)
4831abe9b8aSliubo 		__field(	u64,  offset		)
4841abe9b8aSliubo 		__field(	int,  type		)
4851abe9b8aSliubo 	),
4861abe9b8aSliubo 
4871abe9b8aSliubo 	TP_fast_assign(
4881abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
4891abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
4901abe9b8aSliubo 		__entry->action		= action;
4911abe9b8aSliubo 		__entry->parent		= full_ref->parent;
4921abe9b8aSliubo 		__entry->ref_root	= full_ref->root;
4931abe9b8aSliubo 		__entry->owner		= full_ref->objectid;
4941abe9b8aSliubo 		__entry->offset		= full_ref->offset;
4951abe9b8aSliubo 		__entry->type		= ref->type;
4961abe9b8aSliubo 	),
4971abe9b8aSliubo 
4981abe9b8aSliubo 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
4991abe9b8aSliubo 		  "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
5001abe9b8aSliubo 		  "offset = %llu, type = %s",
5011abe9b8aSliubo 		  (unsigned long long)__entry->bytenr,
5021abe9b8aSliubo 		  (unsigned long long)__entry->num_bytes,
5031abe9b8aSliubo 		  show_ref_action(__entry->action),
5041abe9b8aSliubo 		  show_root_type(__entry->parent),
5051abe9b8aSliubo 		  show_root_type(__entry->ref_root),
5061abe9b8aSliubo 		  (unsigned long long)__entry->owner,
5071abe9b8aSliubo 		  (unsigned long long)__entry->offset,
5081abe9b8aSliubo 		  show_ref_type(__entry->type))
5091abe9b8aSliubo );
5101abe9b8aSliubo 
5111abe9b8aSliubo TRACE_EVENT(btrfs_delayed_ref_head,
5121abe9b8aSliubo 
5131abe9b8aSliubo 	TP_PROTO(struct btrfs_delayed_ref_node *ref,
5141abe9b8aSliubo 		 struct btrfs_delayed_ref_head *head_ref,
5151abe9b8aSliubo 		 int action),
5161abe9b8aSliubo 
5171abe9b8aSliubo 	TP_ARGS(ref, head_ref, action),
5181abe9b8aSliubo 
5191abe9b8aSliubo 	TP_STRUCT__entry(
5201abe9b8aSliubo 		__field(	u64,  bytenr		)
5211abe9b8aSliubo 		__field(	u64,  num_bytes		)
5221abe9b8aSliubo 		__field(	int,  action		)
5231abe9b8aSliubo 		__field(	int,  is_data		)
5241abe9b8aSliubo 	),
5251abe9b8aSliubo 
5261abe9b8aSliubo 	TP_fast_assign(
5271abe9b8aSliubo 		__entry->bytenr		= ref->bytenr;
5281abe9b8aSliubo 		__entry->num_bytes	= ref->num_bytes;
5291abe9b8aSliubo 		__entry->action		= action;
5301abe9b8aSliubo 		__entry->is_data	= head_ref->is_data;
5311abe9b8aSliubo 	),
5321abe9b8aSliubo 
5331abe9b8aSliubo 	TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
5341abe9b8aSliubo 		  (unsigned long long)__entry->bytenr,
5351abe9b8aSliubo 		  (unsigned long long)__entry->num_bytes,
5361abe9b8aSliubo 		  show_ref_action(__entry->action),
5371abe9b8aSliubo 		  __entry->is_data)
5381abe9b8aSliubo );
5391abe9b8aSliubo 
5401abe9b8aSliubo #define show_chunk_type(type)					\
5411abe9b8aSliubo 	__print_flags(type, "|",				\
5421abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DATA, 	"DATA"	},	\
5431abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_SYSTEM, 	"SYSTEM"},	\
5441abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_METADATA, 	"METADATA"},	\
5451abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID0, 	"RAID0" },	\
5461abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID1, 	"RAID1" },	\
5471abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_DUP, 	"DUP"	},	\
5481abe9b8aSliubo 		{ BTRFS_BLOCK_GROUP_RAID10, 	"RAID10"})
5491abe9b8aSliubo 
5501abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__chunk,
5511abe9b8aSliubo 
5521abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
5531abe9b8aSliubo 		 u64 offset, u64 size),
5541abe9b8aSliubo 
5551abe9b8aSliubo 	TP_ARGS(root, map, offset, size),
5561abe9b8aSliubo 
5571abe9b8aSliubo 	TP_STRUCT__entry(
5581abe9b8aSliubo 		__field(	int,  num_stripes		)
5591abe9b8aSliubo 		__field(	u64,  type			)
5601abe9b8aSliubo 		__field(	int,  sub_stripes		)
5611abe9b8aSliubo 		__field(	u64,  offset			)
5621abe9b8aSliubo 		__field(	u64,  size			)
5631abe9b8aSliubo 		__field(	u64,  root_objectid		)
5641abe9b8aSliubo 	),
5651abe9b8aSliubo 
5661abe9b8aSliubo 	TP_fast_assign(
5671abe9b8aSliubo 		__entry->num_stripes	= map->num_stripes;
5681abe9b8aSliubo 		__entry->type		= map->type;
5691abe9b8aSliubo 		__entry->sub_stripes	= map->sub_stripes;
5701abe9b8aSliubo 		__entry->offset		= offset;
5711abe9b8aSliubo 		__entry->size		= size;
5721abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
5731abe9b8aSliubo 	),
5741abe9b8aSliubo 
5751abe9b8aSliubo 	TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
5761abe9b8aSliubo 		  "num_stripes = %d, sub_stripes = %d, type = %s",
5771abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
5781abe9b8aSliubo 		  (unsigned long long)__entry->offset,
5791abe9b8aSliubo 		  (unsigned long long)__entry->size,
5801abe9b8aSliubo 		  __entry->num_stripes, __entry->sub_stripes,
5811abe9b8aSliubo 		  show_chunk_type(__entry->type))
5821abe9b8aSliubo );
5831abe9b8aSliubo 
5841abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
5851abe9b8aSliubo 
5861abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
5871abe9b8aSliubo 		 u64 offset, u64 size),
5881abe9b8aSliubo 
5891abe9b8aSliubo 	TP_ARGS(root, map, offset, size)
5901abe9b8aSliubo );
5911abe9b8aSliubo 
5921abe9b8aSliubo DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
5931abe9b8aSliubo 
5941abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
5951abe9b8aSliubo 		 u64 offset, u64 size),
5961abe9b8aSliubo 
5971abe9b8aSliubo 	TP_ARGS(root, map, offset, size)
5981abe9b8aSliubo );
5991abe9b8aSliubo 
6001abe9b8aSliubo TRACE_EVENT(btrfs_cow_block,
6011abe9b8aSliubo 
6021abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
6031abe9b8aSliubo 		 struct extent_buffer *cow),
6041abe9b8aSliubo 
6051abe9b8aSliubo 	TP_ARGS(root, buf, cow),
6061abe9b8aSliubo 
6071abe9b8aSliubo 	TP_STRUCT__entry(
6081abe9b8aSliubo 		__field(	u64,  root_objectid		)
6091abe9b8aSliubo 		__field(	u64,  buf_start			)
6101abe9b8aSliubo 		__field(	int,  refs			)
6111abe9b8aSliubo 		__field(	u64,  cow_start			)
6121abe9b8aSliubo 		__field(	int,  buf_level			)
6131abe9b8aSliubo 		__field(	int,  cow_level			)
6141abe9b8aSliubo 	),
6151abe9b8aSliubo 
6161abe9b8aSliubo 	TP_fast_assign(
6171abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
6181abe9b8aSliubo 		__entry->buf_start	= buf->start;
6191abe9b8aSliubo 		__entry->refs		= atomic_read(&buf->refs);
6201abe9b8aSliubo 		__entry->cow_start	= cow->start;
6211abe9b8aSliubo 		__entry->buf_level	= btrfs_header_level(buf);
6221abe9b8aSliubo 		__entry->cow_level	= btrfs_header_level(cow);
6231abe9b8aSliubo 	),
6241abe9b8aSliubo 
6251abe9b8aSliubo 	TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
6261abe9b8aSliubo 		  "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
6271abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
6281abe9b8aSliubo 		  __entry->refs,
6291abe9b8aSliubo 		  (unsigned long long)__entry->buf_start,
6301abe9b8aSliubo 		  __entry->buf_level,
6311abe9b8aSliubo 		  (unsigned long long)__entry->cow_start,
6321abe9b8aSliubo 		  __entry->cow_level)
6331abe9b8aSliubo );
6341abe9b8aSliubo 
6351abe9b8aSliubo DECLARE_EVENT_CLASS(btrfs__reserved_extent,
6361abe9b8aSliubo 
6371abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
6381abe9b8aSliubo 
6391abe9b8aSliubo 	TP_ARGS(root, start, len),
6401abe9b8aSliubo 
6411abe9b8aSliubo 	TP_STRUCT__entry(
6421abe9b8aSliubo 		__field(	u64,  root_objectid		)
6431abe9b8aSliubo 		__field(	u64,  start			)
6441abe9b8aSliubo 		__field(	u64,  len			)
6451abe9b8aSliubo 	),
6461abe9b8aSliubo 
6471abe9b8aSliubo 	TP_fast_assign(
6481abe9b8aSliubo 		__entry->root_objectid	= root->root_key.objectid;
6491abe9b8aSliubo 		__entry->start		= start;
6501abe9b8aSliubo 		__entry->len		= len;
6511abe9b8aSliubo 	),
6521abe9b8aSliubo 
6531abe9b8aSliubo 	TP_printk("root = %llu(%s), start = %llu, len = %llu",
6541abe9b8aSliubo 		  show_root_type(__entry->root_objectid),
6551abe9b8aSliubo 		  (unsigned long long)__entry->start,
6561abe9b8aSliubo 		  (unsigned long long)__entry->len)
6571abe9b8aSliubo );
6581abe9b8aSliubo 
6591abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
6601abe9b8aSliubo 
6611abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
6621abe9b8aSliubo 
6631abe9b8aSliubo 	TP_ARGS(root, start, len)
6641abe9b8aSliubo );
6651abe9b8aSliubo 
6661abe9b8aSliubo DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
6671abe9b8aSliubo 
6681abe9b8aSliubo 	TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
6691abe9b8aSliubo 
6701abe9b8aSliubo 	TP_ARGS(root, start, len)
6711abe9b8aSliubo );
6721abe9b8aSliubo 
673*3f7de037SJosef Bacik TRACE_EVENT(find_free_extent,
674*3f7de037SJosef Bacik 
675*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
676*3f7de037SJosef Bacik 		 u64 data),
677*3f7de037SJosef Bacik 
678*3f7de037SJosef Bacik 	TP_ARGS(root, num_bytes, empty_size, data),
679*3f7de037SJosef Bacik 
680*3f7de037SJosef Bacik 	TP_STRUCT__entry(
681*3f7de037SJosef Bacik 		__field(	u64,	root_objectid		)
682*3f7de037SJosef Bacik 		__field(	u64,	num_bytes		)
683*3f7de037SJosef Bacik 		__field(	u64,	empty_size		)
684*3f7de037SJosef Bacik 		__field(	u64,	data			)
685*3f7de037SJosef Bacik 	),
686*3f7de037SJosef Bacik 
687*3f7de037SJosef Bacik 	TP_fast_assign(
688*3f7de037SJosef Bacik 		__entry->root_objectid	= root->root_key.objectid;
689*3f7de037SJosef Bacik 		__entry->num_bytes	= num_bytes;
690*3f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
691*3f7de037SJosef Bacik 		__entry->data		= data;
692*3f7de037SJosef Bacik 	),
693*3f7de037SJosef Bacik 
694*3f7de037SJosef Bacik 	TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
695*3f7de037SJosef Bacik 		  "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
696*3f7de037SJosef Bacik 		  __entry->num_bytes, __entry->empty_size, __entry->data,
697*3f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->data, "|",
698*3f7de037SJosef Bacik 				 BTRFS_GROUP_FLAGS))
699*3f7de037SJosef Bacik );
700*3f7de037SJosef Bacik 
701*3f7de037SJosef Bacik DECLARE_EVENT_CLASS(btrfs__reserve_extent,
702*3f7de037SJosef Bacik 
703*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root,
704*3f7de037SJosef Bacik 		 struct btrfs_block_group_cache *block_group, u64 start,
705*3f7de037SJosef Bacik 		 u64 len),
706*3f7de037SJosef Bacik 
707*3f7de037SJosef Bacik 	TP_ARGS(root, block_group, start, len),
708*3f7de037SJosef Bacik 
709*3f7de037SJosef Bacik 	TP_STRUCT__entry(
710*3f7de037SJosef Bacik 		__field(	u64,	root_objectid		)
711*3f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
712*3f7de037SJosef Bacik 		__field(	u64,	flags			)
713*3f7de037SJosef Bacik 		__field(	u64,	start			)
714*3f7de037SJosef Bacik 		__field(	u64,	len			)
715*3f7de037SJosef Bacik 	),
716*3f7de037SJosef Bacik 
717*3f7de037SJosef Bacik 	TP_fast_assign(
718*3f7de037SJosef Bacik 		__entry->root_objectid	= root->root_key.objectid;
719*3f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
720*3f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
721*3f7de037SJosef Bacik 		__entry->start		= start;
722*3f7de037SJosef Bacik 		__entry->len		= len;
723*3f7de037SJosef Bacik 	),
724*3f7de037SJosef Bacik 
725*3f7de037SJosef Bacik 	TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
726*3f7de037SJosef Bacik 		  "start = %Lu, len = %Lu",
727*3f7de037SJosef Bacik 		  show_root_type(__entry->root_objectid), __entry->bg_objectid,
728*3f7de037SJosef Bacik 		  __entry->flags, __print_flags((unsigned long)__entry->flags,
729*3f7de037SJosef Bacik 						"|", BTRFS_GROUP_FLAGS),
730*3f7de037SJosef Bacik 		  __entry->start, __entry->len)
731*3f7de037SJosef Bacik );
732*3f7de037SJosef Bacik 
733*3f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
734*3f7de037SJosef Bacik 
735*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root,
736*3f7de037SJosef Bacik 		 struct btrfs_block_group_cache *block_group, u64 start,
737*3f7de037SJosef Bacik 		 u64 len),
738*3f7de037SJosef Bacik 
739*3f7de037SJosef Bacik 	TP_ARGS(root, block_group, start, len)
740*3f7de037SJosef Bacik );
741*3f7de037SJosef Bacik 
742*3f7de037SJosef Bacik DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
743*3f7de037SJosef Bacik 
744*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_root *root,
745*3f7de037SJosef Bacik 		 struct btrfs_block_group_cache *block_group, u64 start,
746*3f7de037SJosef Bacik 		 u64 len),
747*3f7de037SJosef Bacik 
748*3f7de037SJosef Bacik 	TP_ARGS(root, block_group, start, len)
749*3f7de037SJosef Bacik );
750*3f7de037SJosef Bacik 
751*3f7de037SJosef Bacik TRACE_EVENT(btrfs_find_cluster,
752*3f7de037SJosef Bacik 
753*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
754*3f7de037SJosef Bacik 		 u64 bytes, u64 empty_size, u64 min_bytes),
755*3f7de037SJosef Bacik 
756*3f7de037SJosef Bacik 	TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
757*3f7de037SJosef Bacik 
758*3f7de037SJosef Bacik 	TP_STRUCT__entry(
759*3f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
760*3f7de037SJosef Bacik 		__field(	u64,	flags			)
761*3f7de037SJosef Bacik 		__field(	u64,	start			)
762*3f7de037SJosef Bacik 		__field(	u64,	bytes			)
763*3f7de037SJosef Bacik 		__field(	u64,	empty_size		)
764*3f7de037SJosef Bacik 		__field(	u64,	min_bytes		)
765*3f7de037SJosef Bacik 	),
766*3f7de037SJosef Bacik 
767*3f7de037SJosef Bacik 	TP_fast_assign(
768*3f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
769*3f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
770*3f7de037SJosef Bacik 		__entry->start		= start;
771*3f7de037SJosef Bacik 		__entry->bytes		= bytes;
772*3f7de037SJosef Bacik 		__entry->empty_size	= empty_size;
773*3f7de037SJosef Bacik 		__entry->min_bytes	= min_bytes;
774*3f7de037SJosef Bacik 	),
775*3f7de037SJosef Bacik 
776*3f7de037SJosef Bacik 	TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
777*3f7de037SJosef Bacik 		  " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
778*3f7de037SJosef Bacik 		  __entry->flags,
779*3f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
780*3f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
781*3f7de037SJosef Bacik 		  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
782*3f7de037SJosef Bacik );
783*3f7de037SJosef Bacik 
784*3f7de037SJosef Bacik TRACE_EVENT(btrfs_failed_cluster_setup,
785*3f7de037SJosef Bacik 
786*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_block_group_cache *block_group),
787*3f7de037SJosef Bacik 
788*3f7de037SJosef Bacik 	TP_ARGS(block_group),
789*3f7de037SJosef Bacik 
790*3f7de037SJosef Bacik 	TP_STRUCT__entry(
791*3f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
792*3f7de037SJosef Bacik 	),
793*3f7de037SJosef Bacik 
794*3f7de037SJosef Bacik 	TP_fast_assign(
795*3f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
796*3f7de037SJosef Bacik 	),
797*3f7de037SJosef Bacik 
798*3f7de037SJosef Bacik 	TP_printk("block_group = %Lu", __entry->bg_objectid)
799*3f7de037SJosef Bacik );
800*3f7de037SJosef Bacik 
801*3f7de037SJosef Bacik TRACE_EVENT(btrfs_setup_cluster,
802*3f7de037SJosef Bacik 
803*3f7de037SJosef Bacik 	TP_PROTO(struct btrfs_block_group_cache *block_group,
804*3f7de037SJosef Bacik 		 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
805*3f7de037SJosef Bacik 
806*3f7de037SJosef Bacik 	TP_ARGS(block_group, cluster, size, bitmap),
807*3f7de037SJosef Bacik 
808*3f7de037SJosef Bacik 	TP_STRUCT__entry(
809*3f7de037SJosef Bacik 		__field(	u64,	bg_objectid		)
810*3f7de037SJosef Bacik 		__field(	u64,	flags			)
811*3f7de037SJosef Bacik 		__field(	u64,	start			)
812*3f7de037SJosef Bacik 		__field(	u64,	max_size		)
813*3f7de037SJosef Bacik 		__field(	u64,	size			)
814*3f7de037SJosef Bacik 		__field(	int,	bitmap			)
815*3f7de037SJosef Bacik 	),
816*3f7de037SJosef Bacik 
817*3f7de037SJosef Bacik 	TP_fast_assign(
818*3f7de037SJosef Bacik 		__entry->bg_objectid	= block_group->key.objectid;
819*3f7de037SJosef Bacik 		__entry->flags		= block_group->flags;
820*3f7de037SJosef Bacik 		__entry->start		= cluster->window_start;
821*3f7de037SJosef Bacik 		__entry->max_size	= cluster->max_size;
822*3f7de037SJosef Bacik 		__entry->size		= size;
823*3f7de037SJosef Bacik 		__entry->bitmap		= bitmap;
824*3f7de037SJosef Bacik 	),
825*3f7de037SJosef Bacik 
826*3f7de037SJosef Bacik 	TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
827*3f7de037SJosef Bacik 		  "size = %Lu, max_size = %Lu, bitmap = %d",
828*3f7de037SJosef Bacik 		  __entry->bg_objectid,
829*3f7de037SJosef Bacik 		  __entry->flags,
830*3f7de037SJosef Bacik 		  __print_flags((unsigned long)__entry->flags, "|",
831*3f7de037SJosef Bacik 				BTRFS_GROUP_FLAGS), __entry->start,
832*3f7de037SJosef Bacik 		  __entry->size, __entry->max_size, __entry->bitmap)
833*3f7de037SJosef Bacik );
834*3f7de037SJosef Bacik 
8351abe9b8aSliubo #endif /* _TRACE_BTRFS_H */
8361abe9b8aSliubo 
8371abe9b8aSliubo /* This part must be outside protection */
8381abe9b8aSliubo #include <trace/define_trace.h>
839