xref: /linux/fs/bcachefs/trace.h (revision ae10fe017bf54653a61a93e49fac1c3e2b474e20)
11c6fdbd8SKent Overstreet /* SPDX-License-Identifier: GPL-2.0 */
21c6fdbd8SKent Overstreet #undef TRACE_SYSTEM
31c6fdbd8SKent Overstreet #define TRACE_SYSTEM bcachefs
41c6fdbd8SKent Overstreet 
51c6fdbd8SKent Overstreet #if !defined(_TRACE_BCACHEFS_H) || defined(TRACE_HEADER_MULTI_READ)
61c6fdbd8SKent Overstreet #define _TRACE_BCACHEFS_H
71c6fdbd8SKent Overstreet 
81c6fdbd8SKent Overstreet #include <linux/tracepoint.h>
91c6fdbd8SKent Overstreet 
109f96568cSKent Overstreet #define TRACE_BPOS_entries(name)				\
119f96568cSKent Overstreet 	__field(u64,			name##_inode	)	\
129f96568cSKent Overstreet 	__field(u64,			name##_offset	)	\
139f96568cSKent Overstreet 	__field(u32,			name##_snapshot	)
149f96568cSKent Overstreet 
159f96568cSKent Overstreet #define TRACE_BPOS_assign(dst, src)				\
169f96568cSKent Overstreet 	__entry->dst##_inode		= (src).inode;		\
179f96568cSKent Overstreet 	__entry->dst##_offset		= (src).offset;		\
189f96568cSKent Overstreet 	__entry->dst##_snapshot		= (src).snapshot
199f96568cSKent Overstreet 
201c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bpos,
2112043cf1SKent Overstreet 	TP_PROTO(const struct bpos *p),
221c6fdbd8SKent Overstreet 	TP_ARGS(p),
231c6fdbd8SKent Overstreet 
241c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
259f96568cSKent Overstreet 		TRACE_BPOS_entries(p)
261c6fdbd8SKent Overstreet 	),
271c6fdbd8SKent Overstreet 
281c6fdbd8SKent Overstreet 	TP_fast_assign(
299f96568cSKent Overstreet 		TRACE_BPOS_assign(p, *p);
301c6fdbd8SKent Overstreet 	),
311c6fdbd8SKent Overstreet 
329f96568cSKent Overstreet 	TP_printk("%llu:%llu:%u", __entry->p_inode, __entry->p_offset, __entry->p_snapshot)
331c6fdbd8SKent Overstreet );
341c6fdbd8SKent Overstreet 
351c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bkey,
361c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
371c6fdbd8SKent Overstreet 	TP_ARGS(k),
381c6fdbd8SKent Overstreet 
391c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
401c6fdbd8SKent Overstreet 		__field(u64,	inode				)
411c6fdbd8SKent Overstreet 		__field(u64,	offset				)
421c6fdbd8SKent Overstreet 		__field(u32,	size				)
431c6fdbd8SKent Overstreet 	),
441c6fdbd8SKent Overstreet 
451c6fdbd8SKent Overstreet 	TP_fast_assign(
461c6fdbd8SKent Overstreet 		__entry->inode	= k->p.inode;
471c6fdbd8SKent Overstreet 		__entry->offset	= k->p.offset;
481c6fdbd8SKent Overstreet 		__entry->size	= k->size;
491c6fdbd8SKent Overstreet 	),
501c6fdbd8SKent Overstreet 
511c6fdbd8SKent Overstreet 	TP_printk("%llu:%llu len %u", __entry->inode,
521c6fdbd8SKent Overstreet 		  __entry->offset, __entry->size)
531c6fdbd8SKent Overstreet );
541c6fdbd8SKent Overstreet 
55674cfc26SKent Overstreet DECLARE_EVENT_CLASS(btree_node,
56674cfc26SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
57674cfc26SKent Overstreet 	TP_ARGS(c, b),
58674cfc26SKent Overstreet 
59674cfc26SKent Overstreet 	TP_STRUCT__entry(
60674cfc26SKent Overstreet 		__field(dev_t,		dev			)
61674cfc26SKent Overstreet 		__field(u8,		level			)
62674cfc26SKent Overstreet 		__field(u8,		btree_id		)
63674cfc26SKent Overstreet 		TRACE_BPOS_entries(pos)
64674cfc26SKent Overstreet 	),
65674cfc26SKent Overstreet 
66674cfc26SKent Overstreet 	TP_fast_assign(
67674cfc26SKent Overstreet 		__entry->dev		= c->dev;
68674cfc26SKent Overstreet 		__entry->level		= b->c.level;
69674cfc26SKent Overstreet 		__entry->btree_id	= b->c.btree_id;
70674cfc26SKent Overstreet 		TRACE_BPOS_assign(pos, b->key.k.p);
71674cfc26SKent Overstreet 	),
72674cfc26SKent Overstreet 
73674cfc26SKent Overstreet 	TP_printk("%d,%d %u %s %llu:%llu:%u",
74674cfc26SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
75674cfc26SKent Overstreet 		  __entry->level,
76674cfc26SKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
77674cfc26SKent Overstreet 		  __entry->pos_inode, __entry->pos_offset, __entry->pos_snapshot)
78674cfc26SKent Overstreet );
79674cfc26SKent Overstreet 
801c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bch_fs,
811c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
821c6fdbd8SKent Overstreet 	TP_ARGS(c),
831c6fdbd8SKent Overstreet 
841c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
85ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
861c6fdbd8SKent Overstreet 	),
871c6fdbd8SKent Overstreet 
881c6fdbd8SKent Overstreet 	TP_fast_assign(
89ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
901c6fdbd8SKent Overstreet 	),
911c6fdbd8SKent Overstreet 
92ddc7dd62SKent Overstreet 	TP_printk("%d,%d", MAJOR(__entry->dev), MINOR(__entry->dev))
931c6fdbd8SKent Overstreet );
941c6fdbd8SKent Overstreet 
951c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bio,
961c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
971c6fdbd8SKent Overstreet 	TP_ARGS(bio),
981c6fdbd8SKent Overstreet 
991c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
1001c6fdbd8SKent Overstreet 		__field(dev_t,		dev			)
1011c6fdbd8SKent Overstreet 		__field(sector_t,	sector			)
1021c6fdbd8SKent Overstreet 		__field(unsigned int,	nr_sector		)
1031c6fdbd8SKent Overstreet 		__array(char,		rwbs,	6		)
1041c6fdbd8SKent Overstreet 	),
1051c6fdbd8SKent Overstreet 
1061c6fdbd8SKent Overstreet 	TP_fast_assign(
1071c6fdbd8SKent Overstreet 		__entry->dev		= bio->bi_bdev ? bio_dev(bio) : 0;
1081c6fdbd8SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
1091c6fdbd8SKent Overstreet 		__entry->nr_sector	= bio->bi_iter.bi_size >> 9;
1101c6fdbd8SKent Overstreet 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
1111c6fdbd8SKent Overstreet 	),
1121c6fdbd8SKent Overstreet 
1131c6fdbd8SKent Overstreet 	TP_printk("%d,%d  %s %llu + %u",
1141c6fdbd8SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
1151c6fdbd8SKent Overstreet 		  (unsigned long long)__entry->sector, __entry->nr_sector)
1161c6fdbd8SKent Overstreet );
1171c6fdbd8SKent Overstreet 
1184254f5bfSKent Overstreet /* super-io.c: */
1194254f5bfSKent Overstreet TRACE_EVENT(write_super,
1204254f5bfSKent Overstreet 	TP_PROTO(struct bch_fs *c, unsigned long ip),
1214254f5bfSKent Overstreet 	TP_ARGS(c, ip),
1224254f5bfSKent Overstreet 
1234254f5bfSKent Overstreet 	TP_STRUCT__entry(
1244254f5bfSKent Overstreet 		__field(dev_t,		dev	)
1254254f5bfSKent Overstreet 		__field(unsigned long,	ip	)
1264254f5bfSKent Overstreet 	),
1274254f5bfSKent Overstreet 
1284254f5bfSKent Overstreet 	TP_fast_assign(
1294254f5bfSKent Overstreet 		__entry->dev		= c->dev;
1304254f5bfSKent Overstreet 		__entry->ip		= ip;
1314254f5bfSKent Overstreet 	),
1324254f5bfSKent Overstreet 
1334254f5bfSKent Overstreet 	TP_printk("%d,%d for %pS",
1344254f5bfSKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1354254f5bfSKent Overstreet 		  (void *) __entry->ip)
1364254f5bfSKent Overstreet );
1374254f5bfSKent Overstreet 
1381c6fdbd8SKent Overstreet /* io.c: */
1391c6fdbd8SKent Overstreet 
140674cfc26SKent Overstreet DEFINE_EVENT(bio, read_promote,
1411c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1421c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1431c6fdbd8SKent Overstreet );
1441c6fdbd8SKent Overstreet 
1451c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_bounce,
1461c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1471c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1481c6fdbd8SKent Overstreet );
1491c6fdbd8SKent Overstreet 
150674cfc26SKent Overstreet DEFINE_EVENT(bio, read_split,
151674cfc26SKent Overstreet 	TP_PROTO(struct bio *bio),
152674cfc26SKent Overstreet 	TP_ARGS(bio)
153674cfc26SKent Overstreet );
154674cfc26SKent Overstreet 
1551c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_retry,
1561c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1571c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1581c6fdbd8SKent Overstreet );
1591c6fdbd8SKent Overstreet 
160674cfc26SKent Overstreet DEFINE_EVENT(bio, read_reuse_race,
1611c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1621c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1631c6fdbd8SKent Overstreet );
1641c6fdbd8SKent Overstreet 
1651c6fdbd8SKent Overstreet /* Journal */
1661c6fdbd8SKent Overstreet 
1671c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_full,
1681c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
1691c6fdbd8SKent Overstreet 	TP_ARGS(c)
1701c6fdbd8SKent Overstreet );
1711c6fdbd8SKent Overstreet 
1721c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_entry_full,
1731c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
1741c6fdbd8SKent Overstreet 	TP_ARGS(c)
1751c6fdbd8SKent Overstreet );
1761c6fdbd8SKent Overstreet 
1771c6fdbd8SKent Overstreet DEFINE_EVENT(bio, journal_write,
1781c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1791c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1801c6fdbd8SKent Overstreet );
1811c6fdbd8SKent Overstreet 
1828a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_start,
1831f93726eSKent Overstreet 	TP_PROTO(struct bch_fs *c, bool direct, bool kicked,
1841f93726eSKent Overstreet 		 u64 min_nr, u64 min_key_cache,
1858a92e545SKent Overstreet 		 u64 prereserved, u64 prereserved_total,
1868a92e545SKent Overstreet 		 u64 btree_cache_dirty, u64 btree_cache_total,
1878a92e545SKent Overstreet 		 u64 btree_key_cache_dirty, u64 btree_key_cache_total),
1881f93726eSKent Overstreet 	TP_ARGS(c, direct, kicked, min_nr, min_key_cache, prereserved, prereserved_total,
1898a92e545SKent Overstreet 		btree_cache_dirty, btree_cache_total,
1908a92e545SKent Overstreet 		btree_key_cache_dirty, btree_key_cache_total),
1918a92e545SKent Overstreet 
1928a92e545SKent Overstreet 	TP_STRUCT__entry(
193ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
1941f93726eSKent Overstreet 		__field(bool,		direct			)
1951f93726eSKent Overstreet 		__field(bool,		kicked			)
1968a92e545SKent Overstreet 		__field(u64,		min_nr			)
1971f93726eSKent Overstreet 		__field(u64,		min_key_cache		)
1988a92e545SKent Overstreet 		__field(u64,		prereserved		)
1998a92e545SKent Overstreet 		__field(u64,		prereserved_total	)
2008a92e545SKent Overstreet 		__field(u64,		btree_cache_dirty	)
2018a92e545SKent Overstreet 		__field(u64,		btree_cache_total	)
2028a92e545SKent Overstreet 		__field(u64,		btree_key_cache_dirty	)
2038a92e545SKent Overstreet 		__field(u64,		btree_key_cache_total	)
2048a92e545SKent Overstreet 	),
2058a92e545SKent Overstreet 
2068a92e545SKent Overstreet 	TP_fast_assign(
207ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
2081f93726eSKent Overstreet 		__entry->direct			= direct;
2091f93726eSKent Overstreet 		__entry->kicked			= kicked;
2108a92e545SKent Overstreet 		__entry->min_nr			= min_nr;
2111f93726eSKent Overstreet 		__entry->min_key_cache		= min_key_cache;
2128a92e545SKent Overstreet 		__entry->prereserved		= prereserved;
2138a92e545SKent Overstreet 		__entry->prereserved_total	= prereserved_total;
2148a92e545SKent Overstreet 		__entry->btree_cache_dirty	= btree_cache_dirty;
2158a92e545SKent Overstreet 		__entry->btree_cache_total	= btree_cache_total;
2168a92e545SKent Overstreet 		__entry->btree_key_cache_dirty	= btree_key_cache_dirty;
2178a92e545SKent Overstreet 		__entry->btree_key_cache_total	= btree_key_cache_total;
2188a92e545SKent Overstreet 	),
2198a92e545SKent Overstreet 
2201f93726eSKent Overstreet 	TP_printk("%d,%d direct %u kicked %u min %llu key cache %llu prereserved %llu/%llu btree cache %llu/%llu key cache %llu/%llu",
221ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2221f93726eSKent Overstreet 		  __entry->direct,
2231f93726eSKent Overstreet 		  __entry->kicked,
2248a92e545SKent Overstreet 		  __entry->min_nr,
2251f93726eSKent Overstreet 		  __entry->min_key_cache,
2268a92e545SKent Overstreet 		  __entry->prereserved,
2278a92e545SKent Overstreet 		  __entry->prereserved_total,
2288a92e545SKent Overstreet 		  __entry->btree_cache_dirty,
2298a92e545SKent Overstreet 		  __entry->btree_cache_total,
2308a92e545SKent Overstreet 		  __entry->btree_key_cache_dirty,
2318a92e545SKent Overstreet 		  __entry->btree_key_cache_total)
2328a92e545SKent Overstreet );
2338a92e545SKent Overstreet 
2348a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_finish,
2358a92e545SKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 nr_flushed),
2368a92e545SKent Overstreet 	TP_ARGS(c, nr_flushed),
2378a92e545SKent Overstreet 
2388a92e545SKent Overstreet 	TP_STRUCT__entry(
239ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
2408a92e545SKent Overstreet 		__field(u64,		nr_flushed		)
2418a92e545SKent Overstreet 	),
2428a92e545SKent Overstreet 
2438a92e545SKent Overstreet 	TP_fast_assign(
244ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
2458a92e545SKent Overstreet 		__entry->nr_flushed	= nr_flushed;
2468a92e545SKent Overstreet 	),
2478a92e545SKent Overstreet 
2481f93726eSKent Overstreet 	TP_printk("%d,%d flushed %llu",
249ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
250ddc7dd62SKent Overstreet 		  __entry->nr_flushed)
2518a92e545SKent Overstreet );
2528a92e545SKent Overstreet 
2531c6fdbd8SKent Overstreet /* bset.c: */
2541c6fdbd8SKent Overstreet 
2551c6fdbd8SKent Overstreet DEFINE_EVENT(bpos, bkey_pack_pos_fail,
25612043cf1SKent Overstreet 	TP_PROTO(const struct bpos *p),
2571c6fdbd8SKent Overstreet 	TP_ARGS(p)
2581c6fdbd8SKent Overstreet );
2591c6fdbd8SKent Overstreet 
260674cfc26SKent Overstreet /* Btree cache: */
2611c6fdbd8SKent Overstreet 
262674cfc26SKent Overstreet TRACE_EVENT(btree_cache_scan,
263674cfc26SKent Overstreet 	TP_PROTO(long nr_to_scan, long can_free, long ret),
264674cfc26SKent Overstreet 	TP_ARGS(nr_to_scan, can_free, ret),
2651c6fdbd8SKent Overstreet 
2661c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
267674cfc26SKent Overstreet 		__field(long,	nr_to_scan		)
268674cfc26SKent Overstreet 		__field(long,	can_free		)
269674cfc26SKent Overstreet 		__field(long,	ret			)
2701c6fdbd8SKent Overstreet 	),
2711c6fdbd8SKent Overstreet 
2721c6fdbd8SKent Overstreet 	TP_fast_assign(
273674cfc26SKent Overstreet 		__entry->nr_to_scan	= nr_to_scan;
274674cfc26SKent Overstreet 		__entry->can_free	= can_free;
275674cfc26SKent Overstreet 		__entry->ret		= ret;
2761c6fdbd8SKent Overstreet 	),
2771c6fdbd8SKent Overstreet 
278674cfc26SKent Overstreet 	TP_printk("scanned for %li nodes, can free %li, ret %li",
279674cfc26SKent Overstreet 		  __entry->nr_to_scan, __entry->can_free, __entry->ret)
2801c6fdbd8SKent Overstreet );
2811c6fdbd8SKent Overstreet 
282674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_cache_reap,
2831c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
2841c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
2851c6fdbd8SKent Overstreet );
2861c6fdbd8SKent Overstreet 
287674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_lock_fail,
288674cfc26SKent Overstreet 	TP_PROTO(struct bch_fs *c),
289674cfc26SKent Overstreet 	TP_ARGS(c)
290674cfc26SKent Overstreet );
291674cfc26SKent Overstreet 
292674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_lock,
293674cfc26SKent Overstreet 	TP_PROTO(struct bch_fs *c),
294674cfc26SKent Overstreet 	TP_ARGS(c)
295674cfc26SKent Overstreet );
296674cfc26SKent Overstreet 
297674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize,
298674cfc26SKent Overstreet 	TP_PROTO(struct bch_fs *c),
299674cfc26SKent Overstreet 	TP_ARGS(c)
300674cfc26SKent Overstreet );
301674cfc26SKent Overstreet 
302674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_unlock,
303674cfc26SKent Overstreet 	TP_PROTO(struct bch_fs *c),
304674cfc26SKent Overstreet 	TP_ARGS(c)
305674cfc26SKent Overstreet );
306674cfc26SKent Overstreet 
307674cfc26SKent Overstreet /* Btree */
308674cfc26SKent Overstreet 
309674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_read,
310674cfc26SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
311674cfc26SKent Overstreet 	TP_ARGS(c, b)
312674cfc26SKent Overstreet );
313674cfc26SKent Overstreet 
314674cfc26SKent Overstreet TRACE_EVENT(btree_node_write,
3151c6fdbd8SKent Overstreet 	TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
3161c6fdbd8SKent Overstreet 	TP_ARGS(b, bytes, sectors),
3171c6fdbd8SKent Overstreet 
3181c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
31926609b61SKent Overstreet 		__field(enum btree_node_type,	type)
3201c6fdbd8SKent Overstreet 		__field(unsigned,	bytes			)
3211c6fdbd8SKent Overstreet 		__field(unsigned,	sectors			)
3221c6fdbd8SKent Overstreet 	),
3231c6fdbd8SKent Overstreet 
3241c6fdbd8SKent Overstreet 	TP_fast_assign(
3251c6fdbd8SKent Overstreet 		__entry->type	= btree_node_type(b);
3261c6fdbd8SKent Overstreet 		__entry->bytes	= bytes;
3271c6fdbd8SKent Overstreet 		__entry->sectors = sectors;
3281c6fdbd8SKent Overstreet 	),
3291c6fdbd8SKent Overstreet 
3301c6fdbd8SKent Overstreet 	TP_printk("bkey type %u bytes %u sectors %u",
3311c6fdbd8SKent Overstreet 		  __entry->type , __entry->bytes, __entry->sectors)
3321c6fdbd8SKent Overstreet );
3331c6fdbd8SKent Overstreet 
3341c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_alloc,
3351c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3361c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3371c6fdbd8SKent Overstreet );
3381c6fdbd8SKent Overstreet 
3391c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_free,
3401c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3411c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3421c6fdbd8SKent Overstreet );
3431c6fdbd8SKent Overstreet 
3441c6fdbd8SKent Overstreet TRACE_EVENT(btree_reserve_get_fail,
3455f417394SKent Overstreet 	TP_PROTO(const char *trans_fn,
3465f417394SKent Overstreet 		 unsigned long caller_ip,
3475f417394SKent Overstreet 		 size_t required),
3485f417394SKent Overstreet 	TP_ARGS(trans_fn, caller_ip, required),
3491c6fdbd8SKent Overstreet 
3501c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
3515f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
3525f417394SKent Overstreet 		__field(unsigned long,		caller_ip	)
3531c6fdbd8SKent Overstreet 		__field(size_t,			required	)
3541c6fdbd8SKent Overstreet 	),
3551c6fdbd8SKent Overstreet 
3561c6fdbd8SKent Overstreet 	TP_fast_assign(
3575f417394SKent Overstreet 		strlcpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
3585f417394SKent Overstreet 		__entry->caller_ip	= caller_ip;
3591c6fdbd8SKent Overstreet 		__entry->required	= required;
3601c6fdbd8SKent Overstreet 	),
3611c6fdbd8SKent Overstreet 
3625f417394SKent Overstreet 	TP_printk("%s %pS required %zu",
3635f417394SKent Overstreet 		  __entry->trans_fn,
3645f417394SKent Overstreet 		  (void *) __entry->caller_ip,
3655f417394SKent Overstreet 		  __entry->required)
3661c6fdbd8SKent Overstreet );
3671c6fdbd8SKent Overstreet 
368674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_compact,
3691c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3701c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3711c6fdbd8SKent Overstreet );
3721c6fdbd8SKent Overstreet 
373674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_merge,
3741c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3751c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3761c6fdbd8SKent Overstreet );
3771c6fdbd8SKent Overstreet 
378674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_split,
3791c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3801c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3811c6fdbd8SKent Overstreet );
3821c6fdbd8SKent Overstreet 
383674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_rewrite,
3841f93726eSKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3851f93726eSKent Overstreet 	TP_ARGS(c, b)
3861f93726eSKent Overstreet );
3871f93726eSKent Overstreet 
388674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_set_root,
3891c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3901c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3911c6fdbd8SKent Overstreet );
3921c6fdbd8SKent Overstreet 
393674cfc26SKent Overstreet TRACE_EVENT(btree_path_relock_fail,
3949f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
395bc82d08bSKent Overstreet 		 unsigned long caller_ip,
3969f96568cSKent Overstreet 		 struct btree_path *path,
3979f96568cSKent Overstreet 		 unsigned level),
3989f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path, level),
399bc82d08bSKent Overstreet 
400bc82d08bSKent Overstreet 	TP_STRUCT__entry(
4015f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
4024b59a319SKent Overstreet 		__field(unsigned long,		caller_ip	)
403bc82d08bSKent Overstreet 		__field(u8,			btree_id	)
404367d72ddSKent Overstreet 		__field(u8,			level		)
4059f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
4065f1dd9a6SKent Overstreet 		__array(char,			node, 24	)
407bc82d08bSKent Overstreet 		__field(u32,			iter_lock_seq	)
408bc82d08bSKent Overstreet 		__field(u32,			node_lock_seq	)
409bc82d08bSKent Overstreet 	),
410bc82d08bSKent Overstreet 
411bc82d08bSKent Overstreet 	TP_fast_assign(
4125f1dd9a6SKent Overstreet 		struct btree *b = btree_path_node(path, level);
4135f1dd9a6SKent Overstreet 
4149f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
4154b59a319SKent Overstreet 		__entry->caller_ip		= caller_ip;
4169f96568cSKent Overstreet 		__entry->btree_id		= path->btree_id;
417367d72ddSKent Overstreet 		__entry->level			= path->level;
4189f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos);
4195f1dd9a6SKent Overstreet 		if (IS_ERR(b))
4205f1dd9a6SKent Overstreet 			strscpy(__entry->node, bch2_err_str(PTR_ERR(b)), sizeof(__entry->node));
4215f1dd9a6SKent Overstreet 		else
4225f1dd9a6SKent Overstreet 			scnprintf(__entry->node, sizeof(__entry->node), "%px", b);
4239f96568cSKent Overstreet 		__entry->iter_lock_seq		= path->l[level].lock_seq;
4249f96568cSKent Overstreet 		__entry->node_lock_seq		= is_btree_node(path, level) ? path->l[level].b->c.lock.state.seq : 0;
425bc82d08bSKent Overstreet 	),
426bc82d08bSKent Overstreet 
427367d72ddSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u level %u node %s iter seq %u lock seq %u",
428bc82d08bSKent Overstreet 		  __entry->trans_fn,
4294b59a319SKent Overstreet 		  (void *) __entry->caller_ip,
4309f96568cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
431bc82d08bSKent Overstreet 		  __entry->pos_inode,
432bc82d08bSKent Overstreet 		  __entry->pos_offset,
433bc82d08bSKent Overstreet 		  __entry->pos_snapshot,
434367d72ddSKent Overstreet 		  __entry->level,
435bc82d08bSKent Overstreet 		  __entry->node,
436bc82d08bSKent Overstreet 		  __entry->iter_lock_seq,
437bc82d08bSKent Overstreet 		  __entry->node_lock_seq)
438bc82d08bSKent Overstreet );
439bc82d08bSKent Overstreet 
440674cfc26SKent Overstreet TRACE_EVENT(btree_path_upgrade_fail,
4419f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
44249e401faSKent Overstreet 		 unsigned long caller_ip,
4439f96568cSKent Overstreet 		 struct btree_path *path,
4449f96568cSKent Overstreet 		 unsigned level),
4459f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path, level),
44649e401faSKent Overstreet 
44749e401faSKent Overstreet 	TP_STRUCT__entry(
4485f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
44949e401faSKent Overstreet 		__field(unsigned long,		caller_ip	)
45049e401faSKent Overstreet 		__field(u8,			btree_id	)
451367d72ddSKent Overstreet 		__field(u8,			level		)
4529f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
45349e401faSKent Overstreet 		__field(u8,			locked		)
45449e401faSKent Overstreet 		__field(u8,			self_read_count	)
45549e401faSKent Overstreet 		__field(u8,			self_intent_count)
4569f96568cSKent Overstreet 		__field(u8,			read_count	)
45749e401faSKent Overstreet 		__field(u8,			intent_count	)
458367d72ddSKent Overstreet 		__field(u32,			iter_lock_seq	)
459367d72ddSKent Overstreet 		__field(u32,			node_lock_seq	)
46049e401faSKent Overstreet 	),
46149e401faSKent Overstreet 
46249e401faSKent Overstreet 	TP_fast_assign(
4639f96568cSKent Overstreet 		struct six_lock_count c;
4649f96568cSKent Overstreet 
4659f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
46649e401faSKent Overstreet 		__entry->caller_ip		= caller_ip;
4679f96568cSKent Overstreet 		__entry->btree_id		= path->btree_id;
468367d72ddSKent Overstreet 		__entry->level			= level;
4699f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos);
4709f96568cSKent Overstreet 		__entry->locked			= btree_node_locked(path, level);
4719f96568cSKent Overstreet 
47214599cceSKent Overstreet 		c = bch2_btree_node_lock_counts(trans, NULL, &path->l[level].b->c, level),
473e3738c69SKent Overstreet 		__entry->self_read_count	= c.n[SIX_LOCK_read];
474e3738c69SKent Overstreet 		__entry->self_intent_count	= c.n[SIX_LOCK_intent];
4759f96568cSKent Overstreet 		c = six_lock_counts(&path->l[level].b->c.lock);
476e3738c69SKent Overstreet 		__entry->read_count		= c.n[SIX_LOCK_read];
477e3738c69SKent Overstreet 		__entry->intent_count		= c.n[SIX_LOCK_read];
478367d72ddSKent Overstreet 		__entry->iter_lock_seq		= path->l[level].lock_seq;
479367d72ddSKent Overstreet 		__entry->node_lock_seq		= is_btree_node(path, level) ? path->l[level].b->c.lock.state.seq : 0;
48049e401faSKent Overstreet 	),
48149e401faSKent Overstreet 
482367d72ddSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u level %u locked %u held %u:%u lock count %u:%u iter seq %u lock seq %u",
48349e401faSKent Overstreet 		  __entry->trans_fn,
48449e401faSKent Overstreet 		  (void *) __entry->caller_ip,
4859f96568cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
48649e401faSKent Overstreet 		  __entry->pos_inode,
48749e401faSKent Overstreet 		  __entry->pos_offset,
48849e401faSKent Overstreet 		  __entry->pos_snapshot,
489367d72ddSKent Overstreet 		  __entry->level,
49049e401faSKent Overstreet 		  __entry->locked,
49149e401faSKent Overstreet 		  __entry->self_read_count,
49249e401faSKent Overstreet 		  __entry->self_intent_count,
49349e401faSKent Overstreet 		  __entry->read_count,
494367d72ddSKent Overstreet 		  __entry->intent_count,
495367d72ddSKent Overstreet 		  __entry->iter_lock_seq,
496367d72ddSKent Overstreet 		  __entry->node_lock_seq)
49749e401faSKent Overstreet );
49849e401faSKent Overstreet 
4991c6fdbd8SKent Overstreet /* Garbage collection */
5001c6fdbd8SKent Overstreet 
5011f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_start,
5021c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
5031c6fdbd8SKent Overstreet 	TP_ARGS(c)
5041c6fdbd8SKent Overstreet );
5051c6fdbd8SKent Overstreet 
5061f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_end,
5071c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
5081c6fdbd8SKent Overstreet 	TP_ARGS(c)
5091c6fdbd8SKent Overstreet );
5101c6fdbd8SKent Overstreet 
5111c6fdbd8SKent Overstreet /* Allocator */
5121c6fdbd8SKent Overstreet 
5131c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bucket_alloc,
514f25d8215SKent Overstreet 	TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
51568b6cd19SKent Overstreet 		 bool user,
51668b6cd19SKent Overstreet 		 u64 bucket,
5178ef98313SKent Overstreet 		 u64 free,
518f25d8215SKent Overstreet 		 u64 avail,
5198ef98313SKent Overstreet 		 u64 copygc_wait_amount,
5208ef98313SKent Overstreet 		 s64 copygc_waiting_for,
521*ae10fe01SKent Overstreet 		 struct bucket_alloc_state *s,
522f25d8215SKent Overstreet 		 bool nonblocking,
523615f867cSKent Overstreet 		 const char *err),
52468b6cd19SKent Overstreet 	TP_ARGS(ca, alloc_reserve, user, bucket, free, avail,
52568b6cd19SKent Overstreet 		copygc_wait_amount, copygc_waiting_for,
526*ae10fe01SKent Overstreet 		s, nonblocking, err),
5271c6fdbd8SKent Overstreet 
5281c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
52989baec78SKent Overstreet 		__field(dev_t,			dev			)
5303e154711SKent Overstreet 		__array(char,	reserve,	16			)
53168b6cd19SKent Overstreet 		__field(bool,			user	)
53268b6cd19SKent Overstreet 		__field(u64,			bucket	)
5338ef98313SKent Overstreet 		__field(u64,			free			)
534f25d8215SKent Overstreet 		__field(u64,			avail			)
5358ef98313SKent Overstreet 		__field(u64,			copygc_wait_amount	)
5368ef98313SKent Overstreet 		__field(s64,			copygc_waiting_for	)
537f25d8215SKent Overstreet 		__field(u64,			seen			)
538f25d8215SKent Overstreet 		__field(u64,			open			)
539f25d8215SKent Overstreet 		__field(u64,			need_journal_commit	)
540f25d8215SKent Overstreet 		__field(u64,			nouse			)
541f25d8215SKent Overstreet 		__field(bool,			nonblocking		)
54268b6cd19SKent Overstreet 		__array(char,			err,	32		)
5431c6fdbd8SKent Overstreet 	),
5441c6fdbd8SKent Overstreet 
5451c6fdbd8SKent Overstreet 	TP_fast_assign(
546eacb2574SKent Overstreet 		__entry->dev		= ca->dev;
5473e154711SKent Overstreet 		strlcpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve));
54868b6cd19SKent Overstreet 		__entry->user		= user;
54968b6cd19SKent Overstreet 		__entry->bucket		= bucket;
5508ef98313SKent Overstreet 		__entry->free		= free;
551f25d8215SKent Overstreet 		__entry->avail		= avail;
5528ef98313SKent Overstreet 		__entry->copygc_wait_amount	= copygc_wait_amount;
5538ef98313SKent Overstreet 		__entry->copygc_waiting_for	= copygc_waiting_for;
554*ae10fe01SKent Overstreet 		__entry->seen		= s->buckets_seen;
555*ae10fe01SKent Overstreet 		__entry->open		= s->skipped_open;
556*ae10fe01SKent Overstreet 		__entry->need_journal_commit = s->skipped_need_journal_commit;
557*ae10fe01SKent Overstreet 		__entry->nouse		= s->skipped_nouse;
558f25d8215SKent Overstreet 		__entry->nonblocking	= nonblocking;
559615f867cSKent Overstreet 		strlcpy(__entry->err, err, sizeof(__entry->err));
5601c6fdbd8SKent Overstreet 	),
5611c6fdbd8SKent Overstreet 
56268b6cd19SKent Overstreet 	TP_printk("%d,%d reserve %s user %u bucket %llu free %llu avail %llu copygc_wait %llu/%lli seen %llu open %llu need_journal_commit %llu nouse %llu nonblocking %u err %s",
56389baec78SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
564f25d8215SKent Overstreet 		  __entry->reserve,
56568b6cd19SKent Overstreet 		  __entry->user,
56668b6cd19SKent Overstreet 		  __entry->bucket,
5678ef98313SKent Overstreet 		  __entry->free,
568f25d8215SKent Overstreet 		  __entry->avail,
5698ef98313SKent Overstreet 		  __entry->copygc_wait_amount,
5708ef98313SKent Overstreet 		  __entry->copygc_waiting_for,
571f25d8215SKent Overstreet 		  __entry->seen,
572f25d8215SKent Overstreet 		  __entry->open,
573f25d8215SKent Overstreet 		  __entry->need_journal_commit,
574f25d8215SKent Overstreet 		  __entry->nouse,
575f25d8215SKent Overstreet 		  __entry->nonblocking,
576615f867cSKent Overstreet 		  __entry->err)
5771c6fdbd8SKent Overstreet );
5781c6fdbd8SKent Overstreet 
5791c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc,
580f25d8215SKent Overstreet 	TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
58168b6cd19SKent Overstreet 		 bool user,
58268b6cd19SKent Overstreet 		 u64 bucket,
5838ef98313SKent Overstreet 		 u64 free,
584f25d8215SKent Overstreet 		 u64 avail,
5858ef98313SKent Overstreet 		 u64 copygc_wait_amount,
5868ef98313SKent Overstreet 		 s64 copygc_waiting_for,
587*ae10fe01SKent Overstreet 		 struct bucket_alloc_state *s,
588f25d8215SKent Overstreet 		 bool nonblocking,
589615f867cSKent Overstreet 		 const char *err),
59068b6cd19SKent Overstreet 	TP_ARGS(ca, alloc_reserve, user, bucket, free, avail,
59168b6cd19SKent Overstreet 		copygc_wait_amount, copygc_waiting_for,
592*ae10fe01SKent Overstreet 		s, nonblocking, err)
5931c6fdbd8SKent Overstreet );
5941c6fdbd8SKent Overstreet 
5951c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
596f25d8215SKent Overstreet 	TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
59768b6cd19SKent Overstreet 		 bool user,
59868b6cd19SKent Overstreet 		 u64 bucket,
5998ef98313SKent Overstreet 		 u64 free,
600f25d8215SKent Overstreet 		 u64 avail,
6018ef98313SKent Overstreet 		 u64 copygc_wait_amount,
6028ef98313SKent Overstreet 		 s64 copygc_waiting_for,
603*ae10fe01SKent Overstreet 		 struct bucket_alloc_state *s,
604f25d8215SKent Overstreet 		 bool nonblocking,
605615f867cSKent Overstreet 		 const char *err),
60668b6cd19SKent Overstreet 	TP_ARGS(ca, alloc_reserve, user, bucket, free, avail,
60768b6cd19SKent Overstreet 		copygc_wait_amount, copygc_waiting_for,
608*ae10fe01SKent Overstreet 		s, nonblocking, err)
6091c6fdbd8SKent Overstreet );
6101c6fdbd8SKent Overstreet 
6111f93726eSKent Overstreet TRACE_EVENT(discard_buckets,
6121f93726eSKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 seen, u64 open,
613615f867cSKent Overstreet 		 u64 need_journal_commit, u64 discarded, const char *err),
614615f867cSKent Overstreet 	TP_ARGS(c, seen, open, need_journal_commit, discarded, err),
6151f93726eSKent Overstreet 
6161f93726eSKent Overstreet 	TP_STRUCT__entry(
6171f93726eSKent Overstreet 		__field(dev_t,		dev			)
6181f93726eSKent Overstreet 		__field(u64,		seen			)
6191f93726eSKent Overstreet 		__field(u64,		open			)
6201f93726eSKent Overstreet 		__field(u64,		need_journal_commit	)
6211f93726eSKent Overstreet 		__field(u64,		discarded		)
622615f867cSKent Overstreet 		__array(char,		err,	16		)
6231f93726eSKent Overstreet 	),
6241f93726eSKent Overstreet 
6251f93726eSKent Overstreet 	TP_fast_assign(
6261f93726eSKent Overstreet 		__entry->dev			= c->dev;
6271f93726eSKent Overstreet 		__entry->seen			= seen;
6281f93726eSKent Overstreet 		__entry->open			= open;
6291f93726eSKent Overstreet 		__entry->need_journal_commit	= need_journal_commit;
6301f93726eSKent Overstreet 		__entry->discarded		= discarded;
631615f867cSKent Overstreet 		strlcpy(__entry->err, err, sizeof(__entry->err));
6321f93726eSKent Overstreet 	),
6331f93726eSKent Overstreet 
634615f867cSKent Overstreet 	TP_printk("%d%d seen %llu open %llu need_journal_commit %llu discarded %llu err %s",
6351f93726eSKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
6361f93726eSKent Overstreet 		  __entry->seen,
6371f93726eSKent Overstreet 		  __entry->open,
6381f93726eSKent Overstreet 		  __entry->need_journal_commit,
6391f93726eSKent Overstreet 		  __entry->discarded,
640615f867cSKent Overstreet 		  __entry->err)
6411f93726eSKent Overstreet );
6421f93726eSKent Overstreet 
643674cfc26SKent Overstreet TRACE_EVENT(bucket_invalidate,
64438585367SKent Overstreet 	TP_PROTO(struct bch_fs *c, unsigned dev, u64 bucket, u32 sectors),
64538585367SKent Overstreet 	TP_ARGS(c, dev, bucket, sectors),
6461f93726eSKent Overstreet 
6471f93726eSKent Overstreet 	TP_STRUCT__entry(
6481f93726eSKent Overstreet 		__field(dev_t,		dev			)
6491f93726eSKent Overstreet 		__field(u32,		dev_idx			)
65038585367SKent Overstreet 		__field(u32,		sectors			)
6511f93726eSKent Overstreet 		__field(u64,		bucket			)
6521f93726eSKent Overstreet 	),
6531f93726eSKent Overstreet 
6541f93726eSKent Overstreet 	TP_fast_assign(
6551f93726eSKent Overstreet 		__entry->dev		= c->dev;
6561f93726eSKent Overstreet 		__entry->dev_idx	= dev;
65738585367SKent Overstreet 		__entry->sectors	= sectors;
6581f93726eSKent Overstreet 		__entry->bucket		= bucket;
6591f93726eSKent Overstreet 	),
6601f93726eSKent Overstreet 
66138585367SKent Overstreet 	TP_printk("%d:%d invalidated %u:%llu cached sectors %u",
6621f93726eSKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
66338585367SKent Overstreet 		  __entry->dev_idx, __entry->bucket,
66438585367SKent Overstreet 		  __entry->sectors)
6651f93726eSKent Overstreet );
6661f93726eSKent Overstreet 
6671c6fdbd8SKent Overstreet /* Moving IO */
6681c6fdbd8SKent Overstreet 
669674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_read,
6701c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
6711c6fdbd8SKent Overstreet 	TP_ARGS(k)
6721c6fdbd8SKent Overstreet );
6731c6fdbd8SKent Overstreet 
674674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_write,
6751c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
6761c6fdbd8SKent Overstreet 	TP_ARGS(k)
6771c6fdbd8SKent Overstreet );
6781c6fdbd8SKent Overstreet 
679674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_finish,
680674cfc26SKent Overstreet 	TP_PROTO(const struct bkey *k),
681674cfc26SKent Overstreet 	TP_ARGS(k)
682674cfc26SKent Overstreet );
683674cfc26SKent Overstreet 
684674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_fail,
685674cfc26SKent Overstreet 	TP_PROTO(const struct bkey *k),
686674cfc26SKent Overstreet 	TP_ARGS(k)
687674cfc26SKent Overstreet );
688674cfc26SKent Overstreet 
689674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_alloc_mem_fail,
6901c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
6911c6fdbd8SKent Overstreet 	TP_ARGS(k)
6921c6fdbd8SKent Overstreet );
6931c6fdbd8SKent Overstreet 
6941c6fdbd8SKent Overstreet TRACE_EVENT(move_data,
6951c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 sectors_moved,
6961c6fdbd8SKent Overstreet 		 u64 keys_moved),
6971c6fdbd8SKent Overstreet 	TP_ARGS(c, sectors_moved, keys_moved),
6981c6fdbd8SKent Overstreet 
6991c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
700ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
7011c6fdbd8SKent Overstreet 		__field(u64,		sectors_moved	)
7021c6fdbd8SKent Overstreet 		__field(u64,		keys_moved	)
7031c6fdbd8SKent Overstreet 	),
7041c6fdbd8SKent Overstreet 
7051c6fdbd8SKent Overstreet 	TP_fast_assign(
706ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
7071c6fdbd8SKent Overstreet 		__entry->sectors_moved = sectors_moved;
7081c6fdbd8SKent Overstreet 		__entry->keys_moved = keys_moved;
7091c6fdbd8SKent Overstreet 	),
7101c6fdbd8SKent Overstreet 
711ddc7dd62SKent Overstreet 	TP_printk("%d,%d sectors_moved %llu keys_moved %llu",
712ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
713ddc7dd62SKent Overstreet 		  __entry->sectors_moved, __entry->keys_moved)
7141c6fdbd8SKent Overstreet );
7151c6fdbd8SKent Overstreet 
7161c6fdbd8SKent Overstreet TRACE_EVENT(copygc,
717e6d11615SKent Overstreet 	TP_PROTO(struct bch_fs *c,
7181c6fdbd8SKent Overstreet 		 u64 sectors_moved, u64 sectors_not_moved,
7191c6fdbd8SKent Overstreet 		 u64 buckets_moved, u64 buckets_not_moved),
720e6d11615SKent Overstreet 	TP_ARGS(c,
7211c6fdbd8SKent Overstreet 		sectors_moved, sectors_not_moved,
7221c6fdbd8SKent Overstreet 		buckets_moved, buckets_not_moved),
7231c6fdbd8SKent Overstreet 
7241c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
725ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
7261c6fdbd8SKent Overstreet 		__field(u64,		sectors_moved		)
7271c6fdbd8SKent Overstreet 		__field(u64,		sectors_not_moved	)
7281c6fdbd8SKent Overstreet 		__field(u64,		buckets_moved		)
7291c6fdbd8SKent Overstreet 		__field(u64,		buckets_not_moved	)
7301c6fdbd8SKent Overstreet 	),
7311c6fdbd8SKent Overstreet 
7321c6fdbd8SKent Overstreet 	TP_fast_assign(
733ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
7341c6fdbd8SKent Overstreet 		__entry->sectors_moved		= sectors_moved;
7351c6fdbd8SKent Overstreet 		__entry->sectors_not_moved	= sectors_not_moved;
7361c6fdbd8SKent Overstreet 		__entry->buckets_moved		= buckets_moved;
7371c6fdbd8SKent Overstreet 		__entry->buckets_not_moved = buckets_moved;
7381c6fdbd8SKent Overstreet 	),
7391c6fdbd8SKent Overstreet 
740ddc7dd62SKent Overstreet 	TP_printk("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu",
741ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
7421c6fdbd8SKent Overstreet 		  __entry->sectors_moved, __entry->sectors_not_moved,
7431c6fdbd8SKent Overstreet 		  __entry->buckets_moved, __entry->buckets_not_moved)
7441c6fdbd8SKent Overstreet );
7451c6fdbd8SKent Overstreet 
74619d2819dSKent Overstreet TRACE_EVENT(copygc_wait,
74719d2819dSKent Overstreet 	TP_PROTO(struct bch_fs *c,
74819d2819dSKent Overstreet 		 u64 wait_amount, u64 until),
74919d2819dSKent Overstreet 	TP_ARGS(c, wait_amount, until),
75019d2819dSKent Overstreet 
75119d2819dSKent Overstreet 	TP_STRUCT__entry(
752ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
75319d2819dSKent Overstreet 		__field(u64,		wait_amount		)
75419d2819dSKent Overstreet 		__field(u64,		until			)
75519d2819dSKent Overstreet 	),
75619d2819dSKent Overstreet 
75719d2819dSKent Overstreet 	TP_fast_assign(
758ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
75919d2819dSKent Overstreet 		__entry->wait_amount	= wait_amount;
76019d2819dSKent Overstreet 		__entry->until		= until;
76119d2819dSKent Overstreet 	),
76219d2819dSKent Overstreet 
763ddc7dd62SKent Overstreet 	TP_printk("%d,%u waiting for %llu sectors until %llu",
764ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
765ddc7dd62SKent Overstreet 		  __entry->wait_amount, __entry->until)
76619d2819dSKent Overstreet );
76719d2819dSKent Overstreet 
76812043cf1SKent Overstreet /* btree transactions: */
76912043cf1SKent Overstreet 
7701f93726eSKent Overstreet DECLARE_EVENT_CLASS(transaction_event,
7719f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
772531a0095SKent Overstreet 		 unsigned long caller_ip),
7739f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip),
774ba5c6557SKent Overstreet 
775ba5c6557SKent Overstreet 	TP_STRUCT__entry(
7765f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
777531a0095SKent Overstreet 		__field(unsigned long,		caller_ip	)
778ba5c6557SKent Overstreet 	),
779ba5c6557SKent Overstreet 
780ba5c6557SKent Overstreet 	TP_fast_assign(
7819f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
782531a0095SKent Overstreet 		__entry->caller_ip		= caller_ip;
783ba5c6557SKent Overstreet 	),
784ba5c6557SKent Overstreet 
785669f87a5SKent Overstreet 	TP_printk("%s %pS", __entry->trans_fn, (void *) __entry->caller_ip)
786669f87a5SKent Overstreet );
787669f87a5SKent Overstreet 
7881f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	transaction_commit,
7899f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
790669f87a5SKent Overstreet 		 unsigned long caller_ip),
7919f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
792ba5c6557SKent Overstreet );
793ba5c6557SKent Overstreet 
794674cfc26SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_injected,
7959f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
796a0cb8d78SKent Overstreet 		 unsigned long caller_ip),
7979f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
798a0cb8d78SKent Overstreet );
799a0cb8d78SKent Overstreet 
8001f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_blocked_journal_reclaim,
8019f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
802531a0095SKent Overstreet 		 unsigned long caller_ip),
8039f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
804531a0095SKent Overstreet );
805531a0095SKent Overstreet 
8061f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_journal_res_get,
8079f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
808531a0095SKent Overstreet 		 unsigned long caller_ip),
8099f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
810531a0095SKent Overstreet );
811531a0095SKent Overstreet 
812ce56bf7fSKent Overstreet 
813ce56bf7fSKent Overstreet TRACE_EVENT(trans_restart_journal_preres_get,
8149f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
815ce56bf7fSKent Overstreet 		 unsigned long caller_ip,
816ce56bf7fSKent Overstreet 		 unsigned flags),
817ce56bf7fSKent Overstreet 	TP_ARGS(trans, caller_ip, flags),
818ce56bf7fSKent Overstreet 
819ce56bf7fSKent Overstreet 	TP_STRUCT__entry(
820ce56bf7fSKent Overstreet 		__array(char,			trans_fn, 32	)
821ce56bf7fSKent Overstreet 		__field(unsigned long,		caller_ip	)
822ce56bf7fSKent Overstreet 		__field(unsigned,		flags		)
823ce56bf7fSKent Overstreet 	),
824ce56bf7fSKent Overstreet 
825ce56bf7fSKent Overstreet 	TP_fast_assign(
826ce56bf7fSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
827ce56bf7fSKent Overstreet 		__entry->caller_ip		= caller_ip;
828ce56bf7fSKent Overstreet 		__entry->flags			= flags;
829ce56bf7fSKent Overstreet 	),
830ce56bf7fSKent Overstreet 
831ce56bf7fSKent Overstreet 	TP_printk("%s %pS %x", __entry->trans_fn,
832ce56bf7fSKent Overstreet 		  (void *) __entry->caller_ip,
833ce56bf7fSKent Overstreet 		  __entry->flags)
834531a0095SKent Overstreet );
835531a0095SKent Overstreet 
8361f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_journal_reclaim,
8379f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
838531a0095SKent Overstreet 		 unsigned long caller_ip),
8399f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
840531a0095SKent Overstreet );
841531a0095SKent Overstreet 
8421f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_fault_inject,
8439f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
844531a0095SKent Overstreet 		 unsigned long caller_ip),
8459f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
846531a0095SKent Overstreet );
847531a0095SKent Overstreet 
8481f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_traverse_all,
8499f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
850531a0095SKent Overstreet 		 unsigned long caller_ip),
8519f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
852531a0095SKent Overstreet );
853531a0095SKent Overstreet 
8541f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_mark_replicas,
8559f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
8561f93726eSKent Overstreet 		 unsigned long caller_ip),
8579f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
8581f93726eSKent Overstreet );
8591f93726eSKent Overstreet 
8601f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_key_cache_raced,
8619f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
86212ce5b7dSKent Overstreet 		 unsigned long caller_ip),
8639f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
86412ce5b7dSKent Overstreet );
86512ce5b7dSKent Overstreet 
8660990efaeSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_too_many_iters,
8679f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
8680990efaeSKent Overstreet 		 unsigned long caller_ip),
8699f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
8700990efaeSKent Overstreet );
8710990efaeSKent Overstreet 
872531a0095SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart_iter,
8739f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
874531a0095SKent Overstreet 		 unsigned long caller_ip,
8759f96568cSKent Overstreet 		 struct btree_path *path),
8769f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path),
877531a0095SKent Overstreet 
878531a0095SKent Overstreet 	TP_STRUCT__entry(
8795f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
8804b59a319SKent Overstreet 		__field(unsigned long,		caller_ip	)
881531a0095SKent Overstreet 		__field(u8,			btree_id	)
8829f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
883531a0095SKent Overstreet 	),
884531a0095SKent Overstreet 
885531a0095SKent Overstreet 	TP_fast_assign(
8869f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
8874b59a319SKent Overstreet 		__entry->caller_ip		= caller_ip;
8889f96568cSKent Overstreet 		__entry->btree_id		= path->btree_id;
8899f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos)
890531a0095SKent Overstreet 	),
891531a0095SKent Overstreet 
8929f96568cSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u",
893669f87a5SKent Overstreet 		  __entry->trans_fn,
8944b59a319SKent Overstreet 		  (void *) __entry->caller_ip,
8959f96568cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
896531a0095SKent Overstreet 		  __entry->pos_inode,
897531a0095SKent Overstreet 		  __entry->pos_offset,
898531a0095SKent Overstreet 		  __entry->pos_snapshot)
899531a0095SKent Overstreet );
900531a0095SKent Overstreet 
901531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_btree_node_reused,
9029f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
903531a0095SKent Overstreet 		 unsigned long caller_ip,
9049f96568cSKent Overstreet 		 struct btree_path *path),
9059f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
906531a0095SKent Overstreet );
907531a0095SKent Overstreet 
908531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_btree_node_split,
9099f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
910531a0095SKent Overstreet 		 unsigned long caller_ip,
9119f96568cSKent Overstreet 		 struct btree_path *path),
9129f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
913531a0095SKent Overstreet );
914531a0095SKent Overstreet 
915367d72ddSKent Overstreet TRACE_EVENT(trans_restart_upgrade,
9169f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
917531a0095SKent Overstreet 		 unsigned long caller_ip,
918367d72ddSKent Overstreet 		 struct btree_path *path,
919367d72ddSKent Overstreet 		 unsigned old_locks_want,
920367d72ddSKent Overstreet 		 unsigned new_locks_want),
921367d72ddSKent Overstreet 	TP_ARGS(trans, caller_ip, path, old_locks_want, new_locks_want),
922531a0095SKent Overstreet 
923367d72ddSKent Overstreet 	TP_STRUCT__entry(
924367d72ddSKent Overstreet 		__array(char,			trans_fn, 32	)
925367d72ddSKent Overstreet 		__field(unsigned long,		caller_ip	)
926367d72ddSKent Overstreet 		__field(u8,			btree_id	)
927367d72ddSKent Overstreet 		__field(u8,			old_locks_want	)
928367d72ddSKent Overstreet 		__field(u8,			new_locks_want	)
929367d72ddSKent Overstreet 		TRACE_BPOS_entries(pos)
930367d72ddSKent Overstreet 	),
931367d72ddSKent Overstreet 
932367d72ddSKent Overstreet 	TP_fast_assign(
933367d72ddSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
934367d72ddSKent Overstreet 		__entry->caller_ip		= caller_ip;
935367d72ddSKent Overstreet 		__entry->btree_id		= path->btree_id;
936367d72ddSKent Overstreet 		__entry->old_locks_want		= old_locks_want;
937367d72ddSKent Overstreet 		__entry->new_locks_want		= new_locks_want;
938367d72ddSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos)
939367d72ddSKent Overstreet 	),
940367d72ddSKent Overstreet 
941367d72ddSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u locks_want %u -> %u",
942367d72ddSKent Overstreet 		  __entry->trans_fn,
943367d72ddSKent Overstreet 		  (void *) __entry->caller_ip,
944367d72ddSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
945367d72ddSKent Overstreet 		  __entry->pos_inode,
946367d72ddSKent Overstreet 		  __entry->pos_offset,
947367d72ddSKent Overstreet 		  __entry->pos_snapshot,
948367d72ddSKent Overstreet 		  __entry->old_locks_want,
949367d72ddSKent Overstreet 		  __entry->new_locks_want)
950531a0095SKent Overstreet );
951531a0095SKent Overstreet 
952531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock,
9539f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
954531a0095SKent Overstreet 		 unsigned long caller_ip,
9559f96568cSKent Overstreet 		 struct btree_path *path),
9569f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
957531a0095SKent Overstreet );
958531a0095SKent Overstreet 
959bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_next_node,
9609f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
961bc82d08bSKent Overstreet 		 unsigned long caller_ip,
9629f96568cSKent Overstreet 		 struct btree_path *path),
9639f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
964bc82d08bSKent Overstreet );
965bc82d08bSKent Overstreet 
966bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_parent_for_fill,
9679f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
968bc82d08bSKent Overstreet 		 unsigned long caller_ip,
9699f96568cSKent Overstreet 		 struct btree_path *path),
9709f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
971bc82d08bSKent Overstreet );
972bc82d08bSKent Overstreet 
973bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_after_fill,
9749f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
975bc82d08bSKent Overstreet 		 unsigned long caller_ip,
9769f96568cSKent Overstreet 		 struct btree_path *path),
9779f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
978bc82d08bSKent Overstreet );
979bc82d08bSKent Overstreet 
980674cfc26SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_key_cache_upgrade,
9819f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
98249e401faSKent Overstreet 		 unsigned long caller_ip),
9839f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
98449e401faSKent Overstreet );
98549e401faSKent Overstreet 
986bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_key_cache_fill,
9879f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
988bc82d08bSKent Overstreet 		 unsigned long caller_ip,
9899f96568cSKent Overstreet 		 struct btree_path *path),
9909f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
991bc82d08bSKent Overstreet );
992bc82d08bSKent Overstreet 
993bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_path,
9949f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
995bc82d08bSKent Overstreet 		 unsigned long caller_ip,
9969f96568cSKent Overstreet 		 struct btree_path *path),
9979f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
998bc82d08bSKent Overstreet );
999bc82d08bSKent Overstreet 
1000bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_path_intent,
10019f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1002bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10039f96568cSKent Overstreet 		 struct btree_path *path),
10049f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1005bc82d08bSKent Overstreet );
1006bc82d08bSKent Overstreet 
1007531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_traverse,
10089f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1009531a0095SKent Overstreet 		 unsigned long caller_ip,
10109f96568cSKent Overstreet 		 struct btree_path *path),
10119f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1012531a0095SKent Overstreet );
1013531a0095SKent Overstreet 
10148f9ad91aSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_memory_allocation_failure,
10159f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
10168f9ad91aSKent Overstreet 		 unsigned long caller_ip,
10179f96568cSKent Overstreet 		 struct btree_path *path),
10189f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
10198f9ad91aSKent Overstreet );
10208f9ad91aSKent Overstreet 
10210d7009d7SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_would_deadlock,
10229f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
10230d7009d7SKent Overstreet 		 unsigned long caller_ip),
10240d7009d7SKent Overstreet 	TP_ARGS(trans, caller_ip)
1025ba5c6557SKent Overstreet );
1026ba5c6557SKent Overstreet 
102733bd5d06SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_would_deadlock_recursion_limit,
102833bd5d06SKent Overstreet 	TP_PROTO(struct btree_trans *trans,
102933bd5d06SKent Overstreet 		 unsigned long caller_ip),
103033bd5d06SKent Overstreet 	TP_ARGS(trans, caller_ip)
103133bd5d06SKent Overstreet );
103233bd5d06SKent Overstreet 
1033caaa66aaSKent Overstreet TRACE_EVENT(trans_restart_would_deadlock_write,
10349f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans),
10359f96568cSKent Overstreet 	TP_ARGS(trans),
1036caaa66aaSKent Overstreet 
1037caaa66aaSKent Overstreet 	TP_STRUCT__entry(
10385f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
1039caaa66aaSKent Overstreet 	),
1040caaa66aaSKent Overstreet 
1041caaa66aaSKent Overstreet 	TP_fast_assign(
10429f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
1043caaa66aaSKent Overstreet 	),
1044caaa66aaSKent Overstreet 
1045669f87a5SKent Overstreet 	TP_printk("%s", __entry->trans_fn)
1046caaa66aaSKent Overstreet );
1047caaa66aaSKent Overstreet 
104820bceecbSKent Overstreet TRACE_EVENT(trans_restart_mem_realloced,
10499f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1050669f87a5SKent Overstreet 		 unsigned long caller_ip,
105173a117d2SKent Overstreet 		 unsigned long bytes),
10529f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, bytes),
105320bceecbSKent Overstreet 
105420bceecbSKent Overstreet 	TP_STRUCT__entry(
10555f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
105673a117d2SKent Overstreet 		__field(unsigned long,		caller_ip	)
105720bceecbSKent Overstreet 		__field(unsigned long,		bytes		)
105820bceecbSKent Overstreet 	),
105920bceecbSKent Overstreet 
106020bceecbSKent Overstreet 	TP_fast_assign(
10619f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
106273a117d2SKent Overstreet 		__entry->caller_ip	= caller_ip;
106320bceecbSKent Overstreet 		__entry->bytes		= bytes;
106420bceecbSKent Overstreet 	),
106520bceecbSKent Overstreet 
1066669f87a5SKent Overstreet 	TP_printk("%s %pS bytes %lu",
1067669f87a5SKent Overstreet 		  __entry->trans_fn,
106873a117d2SKent Overstreet 		  (void *) __entry->caller_ip,
106973a117d2SKent Overstreet 		  __entry->bytes)
1070ba5c6557SKent Overstreet );
1071ba5c6557SKent Overstreet 
10723a306f3cSKent Overstreet TRACE_EVENT(trans_restart_key_cache_key_realloced,
10739f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1074ddf11d8cSKent Overstreet 		 unsigned long caller_ip,
10759f96568cSKent Overstreet 		 struct btree_path *path,
10763a306f3cSKent Overstreet 		 unsigned old_u64s,
10773a306f3cSKent Overstreet 		 unsigned new_u64s),
10789f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path, old_u64s, new_u64s),
10793a306f3cSKent Overstreet 
10803a306f3cSKent Overstreet 	TP_STRUCT__entry(
10815f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
10823a306f3cSKent Overstreet 		__field(unsigned long,		caller_ip	)
10833a306f3cSKent Overstreet 		__field(enum btree_id,		btree_id	)
10849f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
10853a306f3cSKent Overstreet 		__field(u32,			old_u64s	)
10863a306f3cSKent Overstreet 		__field(u32,			new_u64s	)
10873a306f3cSKent Overstreet 	),
10883a306f3cSKent Overstreet 
10893a306f3cSKent Overstreet 	TP_fast_assign(
10909f96568cSKent Overstreet 		strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
10913a306f3cSKent Overstreet 		__entry->caller_ip		= caller_ip;
10929f96568cSKent Overstreet 
10939f96568cSKent Overstreet 		__entry->btree_id	= path->btree_id;
10949f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos);
10953a306f3cSKent Overstreet 		__entry->old_u64s	= old_u64s;
10963a306f3cSKent Overstreet 		__entry->new_u64s	= new_u64s;
10973a306f3cSKent Overstreet 	),
10983a306f3cSKent Overstreet 
10993a306f3cSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u old_u64s %u new_u64s %u",
11003a306f3cSKent Overstreet 		  __entry->trans_fn,
11013a306f3cSKent Overstreet 		  (void *) __entry->caller_ip,
11023a306f3cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
110349e401faSKent Overstreet 		  __entry->pos_inode,
110449e401faSKent Overstreet 		  __entry->pos_offset,
11059f96568cSKent Overstreet 		  __entry->pos_snapshot,
11069f96568cSKent Overstreet 		  __entry->old_u64s,
11079f96568cSKent Overstreet 		  __entry->new_u64s)
110849e401faSKent Overstreet );
110949e401faSKent Overstreet 
11101c6fdbd8SKent Overstreet #endif /* _TRACE_BCACHEFS_H */
11111c6fdbd8SKent Overstreet 
11121c6fdbd8SKent Overstreet /* This part must be outside protection */
11131c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_PATH
11141c6fdbd8SKent Overstreet #define TRACE_INCLUDE_PATH ../../fs/bcachefs
11151c6fdbd8SKent Overstreet 
11161c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_FILE
11171c6fdbd8SKent Overstreet #define TRACE_INCLUDE_FILE trace
11181c6fdbd8SKent Overstreet 
11191c6fdbd8SKent Overstreet #include <trace/define_trace.h>
1120