xref: /linux/fs/bcachefs/trace.h (revision 7635e1a6d6740ce76e1c2204f9237f01c98153b3)
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,
347adf6360bSKent Overstreet 		 size_t required,
348adf6360bSKent Overstreet 		 int ret),
349adf6360bSKent Overstreet 	TP_ARGS(trans_fn, caller_ip, required, ret),
3501c6fdbd8SKent Overstreet 
3511c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
3525f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
3535f417394SKent Overstreet 		__field(unsigned long,		caller_ip	)
3541c6fdbd8SKent Overstreet 		__field(size_t,			required	)
355adf6360bSKent Overstreet 		__array(char,			ret, 32		)
3561c6fdbd8SKent Overstreet 	),
3571c6fdbd8SKent Overstreet 
3581c6fdbd8SKent Overstreet 	TP_fast_assign(
359a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
3605f417394SKent Overstreet 		__entry->caller_ip	= caller_ip;
3611c6fdbd8SKent Overstreet 		__entry->required	= required;
362adf6360bSKent Overstreet 		strscpy(__entry->ret, bch2_err_str(ret), sizeof(__entry->ret));
3631c6fdbd8SKent Overstreet 	),
3641c6fdbd8SKent Overstreet 
365adf6360bSKent Overstreet 	TP_printk("%s %pS required %zu ret %s",
3665f417394SKent Overstreet 		  __entry->trans_fn,
3675f417394SKent Overstreet 		  (void *) __entry->caller_ip,
368adf6360bSKent Overstreet 		  __entry->required,
369adf6360bSKent Overstreet 		  __entry->ret)
3701c6fdbd8SKent Overstreet );
3711c6fdbd8SKent Overstreet 
372674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_compact,
3731c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3741c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3751c6fdbd8SKent Overstreet );
3761c6fdbd8SKent Overstreet 
377674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_merge,
3781c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3791c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3801c6fdbd8SKent Overstreet );
3811c6fdbd8SKent Overstreet 
382674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_split,
3831c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3841c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3851c6fdbd8SKent Overstreet );
3861c6fdbd8SKent Overstreet 
387674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_rewrite,
3881f93726eSKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3891f93726eSKent Overstreet 	TP_ARGS(c, b)
3901f93726eSKent Overstreet );
3911f93726eSKent Overstreet 
392674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_set_root,
3931c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3941c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3951c6fdbd8SKent Overstreet );
3961c6fdbd8SKent Overstreet 
397674cfc26SKent Overstreet TRACE_EVENT(btree_path_relock_fail,
3989f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
399bc82d08bSKent Overstreet 		 unsigned long caller_ip,
4009f96568cSKent Overstreet 		 struct btree_path *path,
4019f96568cSKent Overstreet 		 unsigned level),
4029f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path, level),
403bc82d08bSKent Overstreet 
404bc82d08bSKent Overstreet 	TP_STRUCT__entry(
4055f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
4064b59a319SKent Overstreet 		__field(unsigned long,		caller_ip	)
407bc82d08bSKent Overstreet 		__field(u8,			btree_id	)
408367d72ddSKent Overstreet 		__field(u8,			level		)
4099f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
4105f1dd9a6SKent Overstreet 		__array(char,			node, 24	)
411bc82d08bSKent Overstreet 		__field(u32,			iter_lock_seq	)
412bc82d08bSKent Overstreet 		__field(u32,			node_lock_seq	)
413bc82d08bSKent Overstreet 	),
414bc82d08bSKent Overstreet 
415bc82d08bSKent Overstreet 	TP_fast_assign(
4165f1dd9a6SKent Overstreet 		struct btree *b = btree_path_node(path, level);
4175f1dd9a6SKent Overstreet 
418a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
4194b59a319SKent Overstreet 		__entry->caller_ip		= caller_ip;
4209f96568cSKent Overstreet 		__entry->btree_id		= path->btree_id;
421367d72ddSKent Overstreet 		__entry->level			= path->level;
4229f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos);
4235f1dd9a6SKent Overstreet 		if (IS_ERR(b))
4245f1dd9a6SKent Overstreet 			strscpy(__entry->node, bch2_err_str(PTR_ERR(b)), sizeof(__entry->node));
4255f1dd9a6SKent Overstreet 		else
4265f1dd9a6SKent Overstreet 			scnprintf(__entry->node, sizeof(__entry->node), "%px", b);
4279f96568cSKent Overstreet 		__entry->iter_lock_seq		= path->l[level].lock_seq;
4289f96568cSKent Overstreet 		__entry->node_lock_seq		= is_btree_node(path, level) ? path->l[level].b->c.lock.state.seq : 0;
429bc82d08bSKent Overstreet 	),
430bc82d08bSKent Overstreet 
431367d72ddSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u level %u node %s iter seq %u lock seq %u",
432bc82d08bSKent Overstreet 		  __entry->trans_fn,
4334b59a319SKent Overstreet 		  (void *) __entry->caller_ip,
4349f96568cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
435bc82d08bSKent Overstreet 		  __entry->pos_inode,
436bc82d08bSKent Overstreet 		  __entry->pos_offset,
437bc82d08bSKent Overstreet 		  __entry->pos_snapshot,
438367d72ddSKent Overstreet 		  __entry->level,
439bc82d08bSKent Overstreet 		  __entry->node,
440bc82d08bSKent Overstreet 		  __entry->iter_lock_seq,
441bc82d08bSKent Overstreet 		  __entry->node_lock_seq)
442bc82d08bSKent Overstreet );
443bc82d08bSKent Overstreet 
444674cfc26SKent Overstreet TRACE_EVENT(btree_path_upgrade_fail,
4459f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
44649e401faSKent Overstreet 		 unsigned long caller_ip,
4479f96568cSKent Overstreet 		 struct btree_path *path,
4489f96568cSKent Overstreet 		 unsigned level),
4499f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path, level),
45049e401faSKent Overstreet 
45149e401faSKent Overstreet 	TP_STRUCT__entry(
4525f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
45349e401faSKent Overstreet 		__field(unsigned long,		caller_ip	)
45449e401faSKent Overstreet 		__field(u8,			btree_id	)
455367d72ddSKent Overstreet 		__field(u8,			level		)
4569f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
45749e401faSKent Overstreet 		__field(u8,			locked		)
45849e401faSKent Overstreet 		__field(u8,			self_read_count	)
45949e401faSKent Overstreet 		__field(u8,			self_intent_count)
4609f96568cSKent Overstreet 		__field(u8,			read_count	)
46149e401faSKent Overstreet 		__field(u8,			intent_count	)
462367d72ddSKent Overstreet 		__field(u32,			iter_lock_seq	)
463367d72ddSKent Overstreet 		__field(u32,			node_lock_seq	)
46449e401faSKent Overstreet 	),
46549e401faSKent Overstreet 
46649e401faSKent Overstreet 	TP_fast_assign(
4679f96568cSKent Overstreet 		struct six_lock_count c;
4689f96568cSKent Overstreet 
469a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
47049e401faSKent Overstreet 		__entry->caller_ip		= caller_ip;
4719f96568cSKent Overstreet 		__entry->btree_id		= path->btree_id;
472367d72ddSKent Overstreet 		__entry->level			= level;
4739f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos);
4749f96568cSKent Overstreet 		__entry->locked			= btree_node_locked(path, level);
4759f96568cSKent Overstreet 
47614599cceSKent Overstreet 		c = bch2_btree_node_lock_counts(trans, NULL, &path->l[level].b->c, level),
477e3738c69SKent Overstreet 		__entry->self_read_count	= c.n[SIX_LOCK_read];
478e3738c69SKent Overstreet 		__entry->self_intent_count	= c.n[SIX_LOCK_intent];
4799f96568cSKent Overstreet 		c = six_lock_counts(&path->l[level].b->c.lock);
480e3738c69SKent Overstreet 		__entry->read_count		= c.n[SIX_LOCK_read];
481e3738c69SKent Overstreet 		__entry->intent_count		= c.n[SIX_LOCK_read];
482367d72ddSKent Overstreet 		__entry->iter_lock_seq		= path->l[level].lock_seq;
483367d72ddSKent Overstreet 		__entry->node_lock_seq		= is_btree_node(path, level) ? path->l[level].b->c.lock.state.seq : 0;
48449e401faSKent Overstreet 	),
48549e401faSKent Overstreet 
486367d72ddSKent 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",
48749e401faSKent Overstreet 		  __entry->trans_fn,
48849e401faSKent Overstreet 		  (void *) __entry->caller_ip,
4899f96568cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
49049e401faSKent Overstreet 		  __entry->pos_inode,
49149e401faSKent Overstreet 		  __entry->pos_offset,
49249e401faSKent Overstreet 		  __entry->pos_snapshot,
493367d72ddSKent Overstreet 		  __entry->level,
49449e401faSKent Overstreet 		  __entry->locked,
49549e401faSKent Overstreet 		  __entry->self_read_count,
49649e401faSKent Overstreet 		  __entry->self_intent_count,
49749e401faSKent Overstreet 		  __entry->read_count,
498367d72ddSKent Overstreet 		  __entry->intent_count,
499367d72ddSKent Overstreet 		  __entry->iter_lock_seq,
500367d72ddSKent Overstreet 		  __entry->node_lock_seq)
50149e401faSKent Overstreet );
50249e401faSKent Overstreet 
5031c6fdbd8SKent Overstreet /* Garbage collection */
5041c6fdbd8SKent Overstreet 
5051f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_start,
5061c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
5071c6fdbd8SKent Overstreet 	TP_ARGS(c)
5081c6fdbd8SKent Overstreet );
5091c6fdbd8SKent Overstreet 
5101f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_end,
5111c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
5121c6fdbd8SKent Overstreet 	TP_ARGS(c)
5131c6fdbd8SKent Overstreet );
5141c6fdbd8SKent Overstreet 
5151c6fdbd8SKent Overstreet /* Allocator */
5161c6fdbd8SKent Overstreet 
5171c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bucket_alloc,
518f25d8215SKent Overstreet 	TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
51968b6cd19SKent Overstreet 		 u64 bucket,
5208ef98313SKent Overstreet 		 u64 free,
521f25d8215SKent Overstreet 		 u64 avail,
5228ef98313SKent Overstreet 		 u64 copygc_wait_amount,
5238ef98313SKent Overstreet 		 s64 copygc_waiting_for,
524ae10fe01SKent Overstreet 		 struct bucket_alloc_state *s,
525f25d8215SKent Overstreet 		 bool nonblocking,
526615f867cSKent Overstreet 		 const char *err),
527*7635e1a6SKent Overstreet 	TP_ARGS(ca, alloc_reserve, bucket, free, avail,
52868b6cd19SKent Overstreet 		copygc_wait_amount, copygc_waiting_for,
529ae10fe01SKent Overstreet 		s, nonblocking, err),
5301c6fdbd8SKent Overstreet 
5311c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
5321a14e255SKent Overstreet 		__field(u8,			dev			)
5333e154711SKent Overstreet 		__array(char,	reserve,	16			)
53468b6cd19SKent Overstreet 		__field(u64,			bucket	)
5358ef98313SKent Overstreet 		__field(u64,			free			)
536f25d8215SKent Overstreet 		__field(u64,			avail			)
5378ef98313SKent Overstreet 		__field(u64,			copygc_wait_amount	)
5388ef98313SKent Overstreet 		__field(s64,			copygc_waiting_for	)
539f25d8215SKent Overstreet 		__field(u64,			seen			)
540f25d8215SKent Overstreet 		__field(u64,			open			)
541f25d8215SKent Overstreet 		__field(u64,			need_journal_commit	)
542f25d8215SKent Overstreet 		__field(u64,			nouse			)
543f25d8215SKent Overstreet 		__field(bool,			nonblocking		)
544a8b3a677SKent Overstreet 		__field(u64,			nocow			)
54568b6cd19SKent Overstreet 		__array(char,			err,	32		)
5461c6fdbd8SKent Overstreet 	),
5471c6fdbd8SKent Overstreet 
5481c6fdbd8SKent Overstreet 	TP_fast_assign(
5491a14e255SKent Overstreet 		__entry->dev		= ca->dev_idx;
550a1019576SKent Overstreet 		strscpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve));
55168b6cd19SKent Overstreet 		__entry->bucket		= bucket;
5528ef98313SKent Overstreet 		__entry->free		= free;
553f25d8215SKent Overstreet 		__entry->avail		= avail;
5548ef98313SKent Overstreet 		__entry->copygc_wait_amount	= copygc_wait_amount;
5558ef98313SKent Overstreet 		__entry->copygc_waiting_for	= copygc_waiting_for;
556ae10fe01SKent Overstreet 		__entry->seen		= s->buckets_seen;
557ae10fe01SKent Overstreet 		__entry->open		= s->skipped_open;
558ae10fe01SKent Overstreet 		__entry->need_journal_commit = s->skipped_need_journal_commit;
559ae10fe01SKent Overstreet 		__entry->nouse		= s->skipped_nouse;
560f25d8215SKent Overstreet 		__entry->nonblocking	= nonblocking;
561a8b3a677SKent Overstreet 		__entry->nocow		= s->skipped_nocow;
562a1019576SKent Overstreet 		strscpy(__entry->err, err, sizeof(__entry->err));
5631c6fdbd8SKent Overstreet 	),
5641c6fdbd8SKent Overstreet 
565*7635e1a6SKent Overstreet 	TP_printk("reserve %s bucket %u:%llu free %llu avail %llu copygc_wait %llu/%lli seen %llu open %llu need_journal_commit %llu nouse %llu nocow %llu nonblocking %u err %s",
566f25d8215SKent Overstreet 		  __entry->reserve,
5671a14e255SKent Overstreet 		  __entry->dev,
56868b6cd19SKent Overstreet 		  __entry->bucket,
5698ef98313SKent Overstreet 		  __entry->free,
570f25d8215SKent Overstreet 		  __entry->avail,
5718ef98313SKent Overstreet 		  __entry->copygc_wait_amount,
5728ef98313SKent Overstreet 		  __entry->copygc_waiting_for,
573f25d8215SKent Overstreet 		  __entry->seen,
574f25d8215SKent Overstreet 		  __entry->open,
575f25d8215SKent Overstreet 		  __entry->need_journal_commit,
576f25d8215SKent Overstreet 		  __entry->nouse,
577a8b3a677SKent Overstreet 		  __entry->nocow,
578f25d8215SKent Overstreet 		  __entry->nonblocking,
579615f867cSKent Overstreet 		  __entry->err)
5801c6fdbd8SKent Overstreet );
5811c6fdbd8SKent Overstreet 
5821c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc,
583f25d8215SKent Overstreet 	TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
58468b6cd19SKent Overstreet 		 u64 bucket,
5858ef98313SKent Overstreet 		 u64 free,
586f25d8215SKent Overstreet 		 u64 avail,
5878ef98313SKent Overstreet 		 u64 copygc_wait_amount,
5888ef98313SKent Overstreet 		 s64 copygc_waiting_for,
589ae10fe01SKent Overstreet 		 struct bucket_alloc_state *s,
590f25d8215SKent Overstreet 		 bool nonblocking,
591615f867cSKent Overstreet 		 const char *err),
592*7635e1a6SKent Overstreet 	TP_ARGS(ca, alloc_reserve, bucket, free, avail,
59368b6cd19SKent Overstreet 		copygc_wait_amount, copygc_waiting_for,
594ae10fe01SKent Overstreet 		s, nonblocking, err)
5951c6fdbd8SKent Overstreet );
5961c6fdbd8SKent Overstreet 
5971c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
598f25d8215SKent Overstreet 	TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
59968b6cd19SKent Overstreet 		 u64 bucket,
6008ef98313SKent Overstreet 		 u64 free,
601f25d8215SKent Overstreet 		 u64 avail,
6028ef98313SKent Overstreet 		 u64 copygc_wait_amount,
6038ef98313SKent Overstreet 		 s64 copygc_waiting_for,
604ae10fe01SKent Overstreet 		 struct bucket_alloc_state *s,
605f25d8215SKent Overstreet 		 bool nonblocking,
606615f867cSKent Overstreet 		 const char *err),
607*7635e1a6SKent Overstreet 	TP_ARGS(ca, alloc_reserve, bucket, free, avail,
60868b6cd19SKent Overstreet 		copygc_wait_amount, copygc_waiting_for,
609ae10fe01SKent Overstreet 		s, nonblocking, err)
6101c6fdbd8SKent Overstreet );
6111c6fdbd8SKent Overstreet 
6121f93726eSKent Overstreet TRACE_EVENT(discard_buckets,
6131f93726eSKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 seen, u64 open,
614615f867cSKent Overstreet 		 u64 need_journal_commit, u64 discarded, const char *err),
615615f867cSKent Overstreet 	TP_ARGS(c, seen, open, need_journal_commit, discarded, err),
6161f93726eSKent Overstreet 
6171f93726eSKent Overstreet 	TP_STRUCT__entry(
6181f93726eSKent Overstreet 		__field(dev_t,		dev			)
6191f93726eSKent Overstreet 		__field(u64,		seen			)
6201f93726eSKent Overstreet 		__field(u64,		open			)
6211f93726eSKent Overstreet 		__field(u64,		need_journal_commit	)
6221f93726eSKent Overstreet 		__field(u64,		discarded		)
623615f867cSKent Overstreet 		__array(char,		err,	16		)
6241f93726eSKent Overstreet 	),
6251f93726eSKent Overstreet 
6261f93726eSKent Overstreet 	TP_fast_assign(
6271f93726eSKent Overstreet 		__entry->dev			= c->dev;
6281f93726eSKent Overstreet 		__entry->seen			= seen;
6291f93726eSKent Overstreet 		__entry->open			= open;
6301f93726eSKent Overstreet 		__entry->need_journal_commit	= need_journal_commit;
6311f93726eSKent Overstreet 		__entry->discarded		= discarded;
632a1019576SKent Overstreet 		strscpy(__entry->err, err, sizeof(__entry->err));
6331f93726eSKent Overstreet 	),
6341f93726eSKent Overstreet 
635615f867cSKent Overstreet 	TP_printk("%d%d seen %llu open %llu need_journal_commit %llu discarded %llu err %s",
6361f93726eSKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
6371f93726eSKent Overstreet 		  __entry->seen,
6381f93726eSKent Overstreet 		  __entry->open,
6391f93726eSKent Overstreet 		  __entry->need_journal_commit,
6401f93726eSKent Overstreet 		  __entry->discarded,
641615f867cSKent Overstreet 		  __entry->err)
6421f93726eSKent Overstreet );
6431f93726eSKent Overstreet 
644674cfc26SKent Overstreet TRACE_EVENT(bucket_invalidate,
64538585367SKent Overstreet 	TP_PROTO(struct bch_fs *c, unsigned dev, u64 bucket, u32 sectors),
64638585367SKent Overstreet 	TP_ARGS(c, dev, bucket, sectors),
6471f93726eSKent Overstreet 
6481f93726eSKent Overstreet 	TP_STRUCT__entry(
6491f93726eSKent Overstreet 		__field(dev_t,		dev			)
6501f93726eSKent Overstreet 		__field(u32,		dev_idx			)
65138585367SKent Overstreet 		__field(u32,		sectors			)
6521f93726eSKent Overstreet 		__field(u64,		bucket			)
6531f93726eSKent Overstreet 	),
6541f93726eSKent Overstreet 
6551f93726eSKent Overstreet 	TP_fast_assign(
6561f93726eSKent Overstreet 		__entry->dev		= c->dev;
6571f93726eSKent Overstreet 		__entry->dev_idx	= dev;
65838585367SKent Overstreet 		__entry->sectors	= sectors;
6591f93726eSKent Overstreet 		__entry->bucket		= bucket;
6601f93726eSKent Overstreet 	),
6611f93726eSKent Overstreet 
66238585367SKent Overstreet 	TP_printk("%d:%d invalidated %u:%llu cached sectors %u",
6631f93726eSKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
66438585367SKent Overstreet 		  __entry->dev_idx, __entry->bucket,
66538585367SKent Overstreet 		  __entry->sectors)
6661f93726eSKent Overstreet );
6671f93726eSKent Overstreet 
6681c6fdbd8SKent Overstreet /* Moving IO */
6691c6fdbd8SKent Overstreet 
670674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_read,
6711c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
6721c6fdbd8SKent Overstreet 	TP_ARGS(k)
6731c6fdbd8SKent Overstreet );
6741c6fdbd8SKent Overstreet 
675674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_write,
6761c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
6771c6fdbd8SKent Overstreet 	TP_ARGS(k)
6781c6fdbd8SKent Overstreet );
6791c6fdbd8SKent Overstreet 
680674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_finish,
681674cfc26SKent Overstreet 	TP_PROTO(const struct bkey *k),
682674cfc26SKent Overstreet 	TP_ARGS(k)
683674cfc26SKent Overstreet );
684674cfc26SKent Overstreet 
685674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_fail,
686674cfc26SKent Overstreet 	TP_PROTO(const struct bkey *k),
687674cfc26SKent Overstreet 	TP_ARGS(k)
688674cfc26SKent Overstreet );
689674cfc26SKent Overstreet 
690674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_alloc_mem_fail,
6911c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
6921c6fdbd8SKent Overstreet 	TP_ARGS(k)
6931c6fdbd8SKent Overstreet );
6941c6fdbd8SKent Overstreet 
6951c6fdbd8SKent Overstreet TRACE_EVENT(move_data,
6961c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 sectors_moved,
6971c6fdbd8SKent Overstreet 		 u64 keys_moved),
6981c6fdbd8SKent Overstreet 	TP_ARGS(c, sectors_moved, keys_moved),
6991c6fdbd8SKent Overstreet 
7001c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
701ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
7021c6fdbd8SKent Overstreet 		__field(u64,		sectors_moved	)
7031c6fdbd8SKent Overstreet 		__field(u64,		keys_moved	)
7041c6fdbd8SKent Overstreet 	),
7051c6fdbd8SKent Overstreet 
7061c6fdbd8SKent Overstreet 	TP_fast_assign(
707ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
7081c6fdbd8SKent Overstreet 		__entry->sectors_moved = sectors_moved;
7091c6fdbd8SKent Overstreet 		__entry->keys_moved = keys_moved;
7101c6fdbd8SKent Overstreet 	),
7111c6fdbd8SKent Overstreet 
712ddc7dd62SKent Overstreet 	TP_printk("%d,%d sectors_moved %llu keys_moved %llu",
713ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
714ddc7dd62SKent Overstreet 		  __entry->sectors_moved, __entry->keys_moved)
7151c6fdbd8SKent Overstreet );
7161c6fdbd8SKent Overstreet 
7178e3f913eSKent Overstreet TRACE_EVENT(evacuate_bucket,
7188e3f913eSKent Overstreet 	TP_PROTO(struct bch_fs *c, struct bpos *bucket,
7198e3f913eSKent Overstreet 		 unsigned sectors, unsigned bucket_size,
72080c33085SKent Overstreet 		 u64 fragmentation, int ret),
72180c33085SKent Overstreet 	TP_ARGS(c, bucket, sectors, bucket_size, fragmentation, ret),
7228e3f913eSKent Overstreet 
7238e3f913eSKent Overstreet 	TP_STRUCT__entry(
7248e3f913eSKent Overstreet 		__field(dev_t,		dev		)
7258e3f913eSKent Overstreet 		__field(u64,		member		)
7268e3f913eSKent Overstreet 		__field(u64,		bucket		)
7278e3f913eSKent Overstreet 		__field(u32,		sectors		)
7288e3f913eSKent Overstreet 		__field(u32,		bucket_size	)
72980c33085SKent Overstreet 		__field(u64,		fragmentation	)
7308e3f913eSKent Overstreet 		__field(int,		ret		)
7318e3f913eSKent Overstreet 	),
7328e3f913eSKent Overstreet 
7338e3f913eSKent Overstreet 	TP_fast_assign(
7348e3f913eSKent Overstreet 		__entry->dev			= c->dev;
7358e3f913eSKent Overstreet 		__entry->member			= bucket->inode;
7368e3f913eSKent Overstreet 		__entry->bucket			= bucket->offset;
7378e3f913eSKent Overstreet 		__entry->sectors		= sectors;
7388e3f913eSKent Overstreet 		__entry->bucket_size		= bucket_size;
73980c33085SKent Overstreet 		__entry->fragmentation		= fragmentation;
7408e3f913eSKent Overstreet 		__entry->ret			= ret;
7418e3f913eSKent Overstreet 	),
7428e3f913eSKent Overstreet 
74380c33085SKent Overstreet 	TP_printk("%d,%d %llu:%llu sectors %u/%u fragmentation %llu ret %i",
7448e3f913eSKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
7458e3f913eSKent Overstreet 		  __entry->member, __entry->bucket,
7468e3f913eSKent Overstreet 		  __entry->sectors, __entry->bucket_size,
74780c33085SKent Overstreet 		  __entry->fragmentation, __entry->ret)
7488e3f913eSKent Overstreet );
7498e3f913eSKent Overstreet 
7501c6fdbd8SKent Overstreet TRACE_EVENT(copygc,
751e6d11615SKent Overstreet 	TP_PROTO(struct bch_fs *c,
7521c6fdbd8SKent Overstreet 		 u64 sectors_moved, u64 sectors_not_moved,
7531c6fdbd8SKent Overstreet 		 u64 buckets_moved, u64 buckets_not_moved),
754e6d11615SKent Overstreet 	TP_ARGS(c,
7551c6fdbd8SKent Overstreet 		sectors_moved, sectors_not_moved,
7561c6fdbd8SKent Overstreet 		buckets_moved, buckets_not_moved),
7571c6fdbd8SKent Overstreet 
7581c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
759ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
7601c6fdbd8SKent Overstreet 		__field(u64,		sectors_moved		)
7611c6fdbd8SKent Overstreet 		__field(u64,		sectors_not_moved	)
7621c6fdbd8SKent Overstreet 		__field(u64,		buckets_moved		)
7631c6fdbd8SKent Overstreet 		__field(u64,		buckets_not_moved	)
7641c6fdbd8SKent Overstreet 	),
7651c6fdbd8SKent Overstreet 
7661c6fdbd8SKent Overstreet 	TP_fast_assign(
767ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
7681c6fdbd8SKent Overstreet 		__entry->sectors_moved		= sectors_moved;
7691c6fdbd8SKent Overstreet 		__entry->sectors_not_moved	= sectors_not_moved;
7701c6fdbd8SKent Overstreet 		__entry->buckets_moved		= buckets_moved;
7711c6fdbd8SKent Overstreet 		__entry->buckets_not_moved = buckets_moved;
7721c6fdbd8SKent Overstreet 	),
7731c6fdbd8SKent Overstreet 
774ddc7dd62SKent Overstreet 	TP_printk("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu",
775ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
7761c6fdbd8SKent Overstreet 		  __entry->sectors_moved, __entry->sectors_not_moved,
7771c6fdbd8SKent Overstreet 		  __entry->buckets_moved, __entry->buckets_not_moved)
7781c6fdbd8SKent Overstreet );
7791c6fdbd8SKent Overstreet 
78019d2819dSKent Overstreet TRACE_EVENT(copygc_wait,
78119d2819dSKent Overstreet 	TP_PROTO(struct bch_fs *c,
78219d2819dSKent Overstreet 		 u64 wait_amount, u64 until),
78319d2819dSKent Overstreet 	TP_ARGS(c, wait_amount, until),
78419d2819dSKent Overstreet 
78519d2819dSKent Overstreet 	TP_STRUCT__entry(
786ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
78719d2819dSKent Overstreet 		__field(u64,		wait_amount		)
78819d2819dSKent Overstreet 		__field(u64,		until			)
78919d2819dSKent Overstreet 	),
79019d2819dSKent Overstreet 
79119d2819dSKent Overstreet 	TP_fast_assign(
792ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
79319d2819dSKent Overstreet 		__entry->wait_amount	= wait_amount;
79419d2819dSKent Overstreet 		__entry->until		= until;
79519d2819dSKent Overstreet 	),
79619d2819dSKent Overstreet 
797ddc7dd62SKent Overstreet 	TP_printk("%d,%u waiting for %llu sectors until %llu",
798ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
799ddc7dd62SKent Overstreet 		  __entry->wait_amount, __entry->until)
80019d2819dSKent Overstreet );
80119d2819dSKent Overstreet 
80212043cf1SKent Overstreet /* btree transactions: */
80312043cf1SKent Overstreet 
8041f93726eSKent Overstreet DECLARE_EVENT_CLASS(transaction_event,
8059f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
806531a0095SKent Overstreet 		 unsigned long caller_ip),
8079f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip),
808ba5c6557SKent Overstreet 
809ba5c6557SKent Overstreet 	TP_STRUCT__entry(
8105f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
811531a0095SKent Overstreet 		__field(unsigned long,		caller_ip	)
812ba5c6557SKent Overstreet 	),
813ba5c6557SKent Overstreet 
814ba5c6557SKent Overstreet 	TP_fast_assign(
815a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
816531a0095SKent Overstreet 		__entry->caller_ip		= caller_ip;
817ba5c6557SKent Overstreet 	),
818ba5c6557SKent Overstreet 
819669f87a5SKent Overstreet 	TP_printk("%s %pS", __entry->trans_fn, (void *) __entry->caller_ip)
820669f87a5SKent Overstreet );
821669f87a5SKent Overstreet 
8221f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	transaction_commit,
8239f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
824669f87a5SKent Overstreet 		 unsigned long caller_ip),
8259f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
826ba5c6557SKent Overstreet );
827ba5c6557SKent Overstreet 
828674cfc26SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_injected,
8299f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
830a0cb8d78SKent Overstreet 		 unsigned long caller_ip),
8319f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
832a0cb8d78SKent Overstreet );
833a0cb8d78SKent Overstreet 
834e151580dSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_split_race,
835e151580dSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
836e151580dSKent Overstreet 		 unsigned long caller_ip),
837e151580dSKent Overstreet 	TP_ARGS(trans, caller_ip)
838e151580dSKent Overstreet );
839e151580dSKent Overstreet 
8401f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_blocked_journal_reclaim,
8419f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
842531a0095SKent Overstreet 		 unsigned long caller_ip),
8439f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
844531a0095SKent Overstreet );
845531a0095SKent Overstreet 
8461f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_journal_res_get,
8479f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
848531a0095SKent Overstreet 		 unsigned long caller_ip),
8499f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
850531a0095SKent Overstreet );
851531a0095SKent Overstreet 
852ce56bf7fSKent Overstreet 
853ce56bf7fSKent Overstreet TRACE_EVENT(trans_restart_journal_preres_get,
8549f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
855ce56bf7fSKent Overstreet 		 unsigned long caller_ip,
856ce56bf7fSKent Overstreet 		 unsigned flags),
857ce56bf7fSKent Overstreet 	TP_ARGS(trans, caller_ip, flags),
858ce56bf7fSKent Overstreet 
859ce56bf7fSKent Overstreet 	TP_STRUCT__entry(
860ce56bf7fSKent Overstreet 		__array(char,			trans_fn, 32	)
861ce56bf7fSKent Overstreet 		__field(unsigned long,		caller_ip	)
862ce56bf7fSKent Overstreet 		__field(unsigned,		flags		)
863ce56bf7fSKent Overstreet 	),
864ce56bf7fSKent Overstreet 
865ce56bf7fSKent Overstreet 	TP_fast_assign(
866a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
867ce56bf7fSKent Overstreet 		__entry->caller_ip		= caller_ip;
868ce56bf7fSKent Overstreet 		__entry->flags			= flags;
869ce56bf7fSKent Overstreet 	),
870ce56bf7fSKent Overstreet 
871ce56bf7fSKent Overstreet 	TP_printk("%s %pS %x", __entry->trans_fn,
872ce56bf7fSKent Overstreet 		  (void *) __entry->caller_ip,
873ce56bf7fSKent Overstreet 		  __entry->flags)
874531a0095SKent Overstreet );
875531a0095SKent Overstreet 
8761f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_journal_reclaim,
8779f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
878531a0095SKent Overstreet 		 unsigned long caller_ip),
8799f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
880531a0095SKent Overstreet );
881531a0095SKent Overstreet 
8821f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_fault_inject,
8839f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
884531a0095SKent Overstreet 		 unsigned long caller_ip),
8859f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
886531a0095SKent Overstreet );
887531a0095SKent Overstreet 
8881f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_traverse_all,
8899f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
890531a0095SKent Overstreet 		 unsigned long caller_ip),
8919f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
892531a0095SKent Overstreet );
893531a0095SKent Overstreet 
8941f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_mark_replicas,
8959f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
8961f93726eSKent Overstreet 		 unsigned long caller_ip),
8979f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
8981f93726eSKent Overstreet );
8991f93726eSKent Overstreet 
9001f93726eSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_key_cache_raced,
9019f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
90212ce5b7dSKent Overstreet 		 unsigned long caller_ip),
9039f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
90412ce5b7dSKent Overstreet );
90512ce5b7dSKent Overstreet 
9060990efaeSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_too_many_iters,
9079f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
9080990efaeSKent Overstreet 		 unsigned long caller_ip),
9099f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
9100990efaeSKent Overstreet );
9110990efaeSKent Overstreet 
912531a0095SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart_iter,
9139f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
914531a0095SKent Overstreet 		 unsigned long caller_ip,
9159f96568cSKent Overstreet 		 struct btree_path *path),
9169f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path),
917531a0095SKent Overstreet 
918531a0095SKent Overstreet 	TP_STRUCT__entry(
9195f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
9204b59a319SKent Overstreet 		__field(unsigned long,		caller_ip	)
921531a0095SKent Overstreet 		__field(u8,			btree_id	)
9229f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
923531a0095SKent Overstreet 	),
924531a0095SKent Overstreet 
925531a0095SKent Overstreet 	TP_fast_assign(
926a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
9274b59a319SKent Overstreet 		__entry->caller_ip		= caller_ip;
9289f96568cSKent Overstreet 		__entry->btree_id		= path->btree_id;
9299f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos)
930531a0095SKent Overstreet 	),
931531a0095SKent Overstreet 
9329f96568cSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u",
933669f87a5SKent Overstreet 		  __entry->trans_fn,
9344b59a319SKent Overstreet 		  (void *) __entry->caller_ip,
9359f96568cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
936531a0095SKent Overstreet 		  __entry->pos_inode,
937531a0095SKent Overstreet 		  __entry->pos_offset,
938531a0095SKent Overstreet 		  __entry->pos_snapshot)
939531a0095SKent Overstreet );
940531a0095SKent Overstreet 
941531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_btree_node_reused,
9429f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
943531a0095SKent Overstreet 		 unsigned long caller_ip,
9449f96568cSKent Overstreet 		 struct btree_path *path),
9459f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
946531a0095SKent Overstreet );
947531a0095SKent Overstreet 
948531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_btree_node_split,
9499f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
950531a0095SKent Overstreet 		 unsigned long caller_ip,
9519f96568cSKent Overstreet 		 struct btree_path *path),
9529f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
953531a0095SKent Overstreet );
954531a0095SKent Overstreet 
955367d72ddSKent Overstreet TRACE_EVENT(trans_restart_upgrade,
9569f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
957531a0095SKent Overstreet 		 unsigned long caller_ip,
958367d72ddSKent Overstreet 		 struct btree_path *path,
959367d72ddSKent Overstreet 		 unsigned old_locks_want,
960367d72ddSKent Overstreet 		 unsigned new_locks_want),
961367d72ddSKent Overstreet 	TP_ARGS(trans, caller_ip, path, old_locks_want, new_locks_want),
962531a0095SKent Overstreet 
963367d72ddSKent Overstreet 	TP_STRUCT__entry(
964367d72ddSKent Overstreet 		__array(char,			trans_fn, 32	)
965367d72ddSKent Overstreet 		__field(unsigned long,		caller_ip	)
966367d72ddSKent Overstreet 		__field(u8,			btree_id	)
967367d72ddSKent Overstreet 		__field(u8,			old_locks_want	)
968367d72ddSKent Overstreet 		__field(u8,			new_locks_want	)
969367d72ddSKent Overstreet 		TRACE_BPOS_entries(pos)
970367d72ddSKent Overstreet 	),
971367d72ddSKent Overstreet 
972367d72ddSKent Overstreet 	TP_fast_assign(
973a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
974367d72ddSKent Overstreet 		__entry->caller_ip		= caller_ip;
975367d72ddSKent Overstreet 		__entry->btree_id		= path->btree_id;
976367d72ddSKent Overstreet 		__entry->old_locks_want		= old_locks_want;
977367d72ddSKent Overstreet 		__entry->new_locks_want		= new_locks_want;
978367d72ddSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos)
979367d72ddSKent Overstreet 	),
980367d72ddSKent Overstreet 
981367d72ddSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u locks_want %u -> %u",
982367d72ddSKent Overstreet 		  __entry->trans_fn,
983367d72ddSKent Overstreet 		  (void *) __entry->caller_ip,
984367d72ddSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
985367d72ddSKent Overstreet 		  __entry->pos_inode,
986367d72ddSKent Overstreet 		  __entry->pos_offset,
987367d72ddSKent Overstreet 		  __entry->pos_snapshot,
988367d72ddSKent Overstreet 		  __entry->old_locks_want,
989367d72ddSKent Overstreet 		  __entry->new_locks_want)
990531a0095SKent Overstreet );
991531a0095SKent Overstreet 
992531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock,
9939f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
994531a0095SKent Overstreet 		 unsigned long caller_ip,
9959f96568cSKent Overstreet 		 struct btree_path *path),
9969f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
997531a0095SKent Overstreet );
998531a0095SKent Overstreet 
999bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_next_node,
10009f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1001bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10029f96568cSKent Overstreet 		 struct btree_path *path),
10039f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1004bc82d08bSKent Overstreet );
1005bc82d08bSKent Overstreet 
1006bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_parent_for_fill,
10079f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1008bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10099f96568cSKent Overstreet 		 struct btree_path *path),
10109f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1011bc82d08bSKent Overstreet );
1012bc82d08bSKent Overstreet 
1013bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_after_fill,
10149f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1015bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10169f96568cSKent Overstreet 		 struct btree_path *path),
10179f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1018bc82d08bSKent Overstreet );
1019bc82d08bSKent Overstreet 
1020674cfc26SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_key_cache_upgrade,
10219f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
102249e401faSKent Overstreet 		 unsigned long caller_ip),
10239f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip)
102449e401faSKent Overstreet );
102549e401faSKent Overstreet 
1026bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_key_cache_fill,
10279f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1028bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10299f96568cSKent Overstreet 		 struct btree_path *path),
10309f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1031bc82d08bSKent Overstreet );
1032bc82d08bSKent Overstreet 
1033bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_path,
10349f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1035bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10369f96568cSKent Overstreet 		 struct btree_path *path),
10379f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1038bc82d08bSKent Overstreet );
1039bc82d08bSKent Overstreet 
1040bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock_path_intent,
10419f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1042bc82d08bSKent Overstreet 		 unsigned long caller_ip,
10439f96568cSKent Overstreet 		 struct btree_path *path),
10449f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1045bc82d08bSKent Overstreet );
1046bc82d08bSKent Overstreet 
1047531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_traverse,
10489f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1049531a0095SKent Overstreet 		 unsigned long caller_ip,
10509f96568cSKent Overstreet 		 struct btree_path *path),
10519f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
1052531a0095SKent Overstreet );
1053531a0095SKent Overstreet 
10548f9ad91aSKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_memory_allocation_failure,
10559f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
10568f9ad91aSKent Overstreet 		 unsigned long caller_ip,
10579f96568cSKent Overstreet 		 struct btree_path *path),
10589f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path)
10598f9ad91aSKent Overstreet );
10608f9ad91aSKent Overstreet 
10610d7009d7SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_would_deadlock,
10629f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
10630d7009d7SKent Overstreet 		 unsigned long caller_ip),
10640d7009d7SKent Overstreet 	TP_ARGS(trans, caller_ip)
1065ba5c6557SKent Overstreet );
1066ba5c6557SKent Overstreet 
106733bd5d06SKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_would_deadlock_recursion_limit,
106833bd5d06SKent Overstreet 	TP_PROTO(struct btree_trans *trans,
106933bd5d06SKent Overstreet 		 unsigned long caller_ip),
107033bd5d06SKent Overstreet 	TP_ARGS(trans, caller_ip)
107133bd5d06SKent Overstreet );
107233bd5d06SKent Overstreet 
1073caaa66aaSKent Overstreet TRACE_EVENT(trans_restart_would_deadlock_write,
10749f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans),
10759f96568cSKent Overstreet 	TP_ARGS(trans),
1076caaa66aaSKent Overstreet 
1077caaa66aaSKent Overstreet 	TP_STRUCT__entry(
10785f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
1079caaa66aaSKent Overstreet 	),
1080caaa66aaSKent Overstreet 
1081caaa66aaSKent Overstreet 	TP_fast_assign(
1082a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
1083caaa66aaSKent Overstreet 	),
1084caaa66aaSKent Overstreet 
1085669f87a5SKent Overstreet 	TP_printk("%s", __entry->trans_fn)
1086caaa66aaSKent Overstreet );
1087caaa66aaSKent Overstreet 
108820bceecbSKent Overstreet TRACE_EVENT(trans_restart_mem_realloced,
10899f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1090669f87a5SKent Overstreet 		 unsigned long caller_ip,
109173a117d2SKent Overstreet 		 unsigned long bytes),
10929f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, bytes),
109320bceecbSKent Overstreet 
109420bceecbSKent Overstreet 	TP_STRUCT__entry(
10955f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
109673a117d2SKent Overstreet 		__field(unsigned long,		caller_ip	)
109720bceecbSKent Overstreet 		__field(unsigned long,		bytes		)
109820bceecbSKent Overstreet 	),
109920bceecbSKent Overstreet 
110020bceecbSKent Overstreet 	TP_fast_assign(
1101a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
110273a117d2SKent Overstreet 		__entry->caller_ip	= caller_ip;
110320bceecbSKent Overstreet 		__entry->bytes		= bytes;
110420bceecbSKent Overstreet 	),
110520bceecbSKent Overstreet 
1106669f87a5SKent Overstreet 	TP_printk("%s %pS bytes %lu",
1107669f87a5SKent Overstreet 		  __entry->trans_fn,
110873a117d2SKent Overstreet 		  (void *) __entry->caller_ip,
110973a117d2SKent Overstreet 		  __entry->bytes)
1110ba5c6557SKent Overstreet );
1111ba5c6557SKent Overstreet 
11123a306f3cSKent Overstreet TRACE_EVENT(trans_restart_key_cache_key_realloced,
11139f96568cSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1114ddf11d8cSKent Overstreet 		 unsigned long caller_ip,
11159f96568cSKent Overstreet 		 struct btree_path *path,
11163a306f3cSKent Overstreet 		 unsigned old_u64s,
11173a306f3cSKent Overstreet 		 unsigned new_u64s),
11189f96568cSKent Overstreet 	TP_ARGS(trans, caller_ip, path, old_u64s, new_u64s),
11193a306f3cSKent Overstreet 
11203a306f3cSKent Overstreet 	TP_STRUCT__entry(
11215f1dd9a6SKent Overstreet 		__array(char,			trans_fn, 32	)
11223a306f3cSKent Overstreet 		__field(unsigned long,		caller_ip	)
11233a306f3cSKent Overstreet 		__field(enum btree_id,		btree_id	)
11249f96568cSKent Overstreet 		TRACE_BPOS_entries(pos)
11253a306f3cSKent Overstreet 		__field(u32,			old_u64s	)
11263a306f3cSKent Overstreet 		__field(u32,			new_u64s	)
11273a306f3cSKent Overstreet 	),
11283a306f3cSKent Overstreet 
11293a306f3cSKent Overstreet 	TP_fast_assign(
1130a1019576SKent Overstreet 		strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
11313a306f3cSKent Overstreet 		__entry->caller_ip		= caller_ip;
11329f96568cSKent Overstreet 
11339f96568cSKent Overstreet 		__entry->btree_id	= path->btree_id;
11349f96568cSKent Overstreet 		TRACE_BPOS_assign(pos, path->pos);
11353a306f3cSKent Overstreet 		__entry->old_u64s	= old_u64s;
11363a306f3cSKent Overstreet 		__entry->new_u64s	= new_u64s;
11373a306f3cSKent Overstreet 	),
11383a306f3cSKent Overstreet 
11393a306f3cSKent Overstreet 	TP_printk("%s %pS btree %s pos %llu:%llu:%u old_u64s %u new_u64s %u",
11403a306f3cSKent Overstreet 		  __entry->trans_fn,
11413a306f3cSKent Overstreet 		  (void *) __entry->caller_ip,
11423a306f3cSKent Overstreet 		  bch2_btree_ids[__entry->btree_id],
114349e401faSKent Overstreet 		  __entry->pos_inode,
114449e401faSKent Overstreet 		  __entry->pos_offset,
11459f96568cSKent Overstreet 		  __entry->pos_snapshot,
11469f96568cSKent Overstreet 		  __entry->old_u64s,
11479f96568cSKent Overstreet 		  __entry->new_u64s)
114849e401faSKent Overstreet );
114949e401faSKent Overstreet 
1150920e69bcSKent Overstreet DEFINE_EVENT(transaction_event,	trans_restart_write_buffer_flush,
1151920e69bcSKent Overstreet 	TP_PROTO(struct btree_trans *trans,
1152920e69bcSKent Overstreet 		 unsigned long caller_ip),
1153920e69bcSKent Overstreet 	TP_ARGS(trans, caller_ip)
1154920e69bcSKent Overstreet );
1155920e69bcSKent Overstreet 
1156920e69bcSKent Overstreet TRACE_EVENT(write_buffer_flush,
1157920e69bcSKent Overstreet 	TP_PROTO(struct btree_trans *trans, size_t nr, size_t skipped, size_t fast, size_t size),
1158920e69bcSKent Overstreet 	TP_ARGS(trans, nr, skipped, fast, size),
1159920e69bcSKent Overstreet 
1160920e69bcSKent Overstreet 	TP_STRUCT__entry(
1161920e69bcSKent Overstreet 		__field(size_t,		nr		)
1162920e69bcSKent Overstreet 		__field(size_t,		skipped		)
1163920e69bcSKent Overstreet 		__field(size_t,		fast		)
1164920e69bcSKent Overstreet 		__field(size_t,		size		)
1165920e69bcSKent Overstreet 	),
1166920e69bcSKent Overstreet 
1167920e69bcSKent Overstreet 	TP_fast_assign(
1168920e69bcSKent Overstreet 		__entry->nr	= nr;
1169920e69bcSKent Overstreet 		__entry->skipped = skipped;
1170920e69bcSKent Overstreet 		__entry->fast	= fast;
1171920e69bcSKent Overstreet 		__entry->size	= size;
1172920e69bcSKent Overstreet 	),
1173920e69bcSKent Overstreet 
1174920e69bcSKent Overstreet 	TP_printk("%zu/%zu skipped %zu fast %zu",
1175920e69bcSKent Overstreet 		  __entry->nr, __entry->size, __entry->skipped, __entry->fast)
1176920e69bcSKent Overstreet );
1177920e69bcSKent Overstreet 
1178920e69bcSKent Overstreet TRACE_EVENT(write_buffer_flush_slowpath,
1179920e69bcSKent Overstreet 	TP_PROTO(struct btree_trans *trans, size_t nr, size_t size),
1180920e69bcSKent Overstreet 	TP_ARGS(trans, nr, size),
1181920e69bcSKent Overstreet 
1182920e69bcSKent Overstreet 	TP_STRUCT__entry(
1183920e69bcSKent Overstreet 		__field(size_t,		nr		)
1184920e69bcSKent Overstreet 		__field(size_t,		size		)
1185920e69bcSKent Overstreet 	),
1186920e69bcSKent Overstreet 
1187920e69bcSKent Overstreet 	TP_fast_assign(
1188920e69bcSKent Overstreet 		__entry->nr	= nr;
1189920e69bcSKent Overstreet 		__entry->size	= size;
1190920e69bcSKent Overstreet 	),
1191920e69bcSKent Overstreet 
1192920e69bcSKent Overstreet 	TP_printk("%zu/%zu", __entry->nr, __entry->size)
1193920e69bcSKent Overstreet );
1194920e69bcSKent Overstreet 
11951c6fdbd8SKent Overstreet #endif /* _TRACE_BCACHEFS_H */
11961c6fdbd8SKent Overstreet 
11971c6fdbd8SKent Overstreet /* This part must be outside protection */
11981c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_PATH
11991c6fdbd8SKent Overstreet #define TRACE_INCLUDE_PATH ../../fs/bcachefs
12001c6fdbd8SKent Overstreet 
12011c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_FILE
12021c6fdbd8SKent Overstreet #define TRACE_INCLUDE_FILE trace
12031c6fdbd8SKent Overstreet 
12041c6fdbd8SKent Overstreet #include <trace/define_trace.h>
1205