xref: /linux/fs/bcachefs/trace.h (revision eacb2574f09f5b71acc468d44e7a1633847fd08d)
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 
101c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bpos,
111c6fdbd8SKent Overstreet 	TP_PROTO(struct bpos *p),
121c6fdbd8SKent Overstreet 	TP_ARGS(p),
131c6fdbd8SKent Overstreet 
141c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
151c6fdbd8SKent Overstreet 		__field(u64,	inode				)
161c6fdbd8SKent Overstreet 		__field(u64,	offset				)
171c6fdbd8SKent Overstreet 	),
181c6fdbd8SKent Overstreet 
191c6fdbd8SKent Overstreet 	TP_fast_assign(
201c6fdbd8SKent Overstreet 		__entry->inode	= p->inode;
211c6fdbd8SKent Overstreet 		__entry->offset	= p->offset;
221c6fdbd8SKent Overstreet 	),
231c6fdbd8SKent Overstreet 
241c6fdbd8SKent Overstreet 	TP_printk("%llu:%llu", __entry->inode, __entry->offset)
251c6fdbd8SKent Overstreet );
261c6fdbd8SKent Overstreet 
271c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bkey,
281c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
291c6fdbd8SKent Overstreet 	TP_ARGS(k),
301c6fdbd8SKent Overstreet 
311c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
321c6fdbd8SKent Overstreet 		__field(u64,	inode				)
331c6fdbd8SKent Overstreet 		__field(u64,	offset				)
341c6fdbd8SKent Overstreet 		__field(u32,	size				)
351c6fdbd8SKent Overstreet 	),
361c6fdbd8SKent Overstreet 
371c6fdbd8SKent Overstreet 	TP_fast_assign(
381c6fdbd8SKent Overstreet 		__entry->inode	= k->p.inode;
391c6fdbd8SKent Overstreet 		__entry->offset	= k->p.offset;
401c6fdbd8SKent Overstreet 		__entry->size	= k->size;
411c6fdbd8SKent Overstreet 	),
421c6fdbd8SKent Overstreet 
431c6fdbd8SKent Overstreet 	TP_printk("%llu:%llu len %u", __entry->inode,
441c6fdbd8SKent Overstreet 		  __entry->offset, __entry->size)
451c6fdbd8SKent Overstreet );
461c6fdbd8SKent Overstreet 
471c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bch_fs,
481c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
491c6fdbd8SKent Overstreet 	TP_ARGS(c),
501c6fdbd8SKent Overstreet 
511c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
52ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
531c6fdbd8SKent Overstreet 	),
541c6fdbd8SKent Overstreet 
551c6fdbd8SKent Overstreet 	TP_fast_assign(
56ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
571c6fdbd8SKent Overstreet 	),
581c6fdbd8SKent Overstreet 
59ddc7dd62SKent Overstreet 	TP_printk("%d,%d", MAJOR(__entry->dev), MINOR(__entry->dev))
601c6fdbd8SKent Overstreet );
611c6fdbd8SKent Overstreet 
621c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bio,
631c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
641c6fdbd8SKent Overstreet 	TP_ARGS(bio),
651c6fdbd8SKent Overstreet 
661c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
671c6fdbd8SKent Overstreet 		__field(dev_t,		dev			)
681c6fdbd8SKent Overstreet 		__field(sector_t,	sector			)
691c6fdbd8SKent Overstreet 		__field(unsigned int,	nr_sector		)
701c6fdbd8SKent Overstreet 		__array(char,		rwbs,	6		)
711c6fdbd8SKent Overstreet 	),
721c6fdbd8SKent Overstreet 
731c6fdbd8SKent Overstreet 	TP_fast_assign(
741c6fdbd8SKent Overstreet 		__entry->dev		= bio->bi_bdev ? bio_dev(bio) : 0;
751c6fdbd8SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
761c6fdbd8SKent Overstreet 		__entry->nr_sector	= bio->bi_iter.bi_size >> 9;
771c6fdbd8SKent Overstreet 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
781c6fdbd8SKent Overstreet 	),
791c6fdbd8SKent Overstreet 
801c6fdbd8SKent Overstreet 	TP_printk("%d,%d  %s %llu + %u",
811c6fdbd8SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
821c6fdbd8SKent Overstreet 		  (unsigned long long)__entry->sector, __entry->nr_sector)
831c6fdbd8SKent Overstreet );
841c6fdbd8SKent Overstreet 
851c6fdbd8SKent Overstreet /* io.c: */
861c6fdbd8SKent Overstreet 
871c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_split,
881c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
891c6fdbd8SKent Overstreet 	TP_ARGS(bio)
901c6fdbd8SKent Overstreet );
911c6fdbd8SKent Overstreet 
921c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_bounce,
931c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
941c6fdbd8SKent Overstreet 	TP_ARGS(bio)
951c6fdbd8SKent Overstreet );
961c6fdbd8SKent Overstreet 
971c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_retry,
981c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
991c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1001c6fdbd8SKent Overstreet );
1011c6fdbd8SKent Overstreet 
1021c6fdbd8SKent Overstreet DEFINE_EVENT(bio, promote,
1031c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1041c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1051c6fdbd8SKent Overstreet );
1061c6fdbd8SKent Overstreet 
1071c6fdbd8SKent Overstreet /* Journal */
1081c6fdbd8SKent Overstreet 
1091c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_full,
1101c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
1111c6fdbd8SKent Overstreet 	TP_ARGS(c)
1121c6fdbd8SKent Overstreet );
1131c6fdbd8SKent Overstreet 
1141c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_entry_full,
1151c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
1161c6fdbd8SKent Overstreet 	TP_ARGS(c)
1171c6fdbd8SKent Overstreet );
1181c6fdbd8SKent Overstreet 
1191c6fdbd8SKent Overstreet DEFINE_EVENT(bio, journal_write,
1201c6fdbd8SKent Overstreet 	TP_PROTO(struct bio *bio),
1211c6fdbd8SKent Overstreet 	TP_ARGS(bio)
1221c6fdbd8SKent Overstreet );
1231c6fdbd8SKent Overstreet 
1248a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_start,
1258a92e545SKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 min_nr,
1268a92e545SKent Overstreet 		 u64 prereserved, u64 prereserved_total,
1278a92e545SKent Overstreet 		 u64 btree_cache_dirty, u64 btree_cache_total,
1288a92e545SKent Overstreet 		 u64 btree_key_cache_dirty, u64 btree_key_cache_total),
1298a92e545SKent Overstreet 	TP_ARGS(c, min_nr, prereserved, prereserved_total,
1308a92e545SKent Overstreet 		btree_cache_dirty, btree_cache_total,
1318a92e545SKent Overstreet 		btree_key_cache_dirty, btree_key_cache_total),
1328a92e545SKent Overstreet 
1338a92e545SKent Overstreet 	TP_STRUCT__entry(
134ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
1358a92e545SKent Overstreet 		__field(u64,		min_nr			)
1368a92e545SKent Overstreet 		__field(u64,		prereserved		)
1378a92e545SKent Overstreet 		__field(u64,		prereserved_total	)
1388a92e545SKent Overstreet 		__field(u64,		btree_cache_dirty	)
1398a92e545SKent Overstreet 		__field(u64,		btree_cache_total	)
1408a92e545SKent Overstreet 		__field(u64,		btree_key_cache_dirty	)
1418a92e545SKent Overstreet 		__field(u64,		btree_key_cache_total	)
1428a92e545SKent Overstreet 	),
1438a92e545SKent Overstreet 
1448a92e545SKent Overstreet 	TP_fast_assign(
145ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
1468a92e545SKent Overstreet 		__entry->min_nr			= min_nr;
1478a92e545SKent Overstreet 		__entry->prereserved		= prereserved;
1488a92e545SKent Overstreet 		__entry->prereserved_total	= prereserved_total;
1498a92e545SKent Overstreet 		__entry->btree_cache_dirty	= btree_cache_dirty;
1508a92e545SKent Overstreet 		__entry->btree_cache_total	= btree_cache_total;
1518a92e545SKent Overstreet 		__entry->btree_key_cache_dirty	= btree_key_cache_dirty;
1528a92e545SKent Overstreet 		__entry->btree_key_cache_total	= btree_key_cache_total;
1538a92e545SKent Overstreet 	),
1548a92e545SKent Overstreet 
155ddc7dd62SKent Overstreet 	TP_printk("%d,%d min %llu prereserved %llu/%llu btree cache %llu/%llu key cache %llu/%llu",
156ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1578a92e545SKent Overstreet 		  __entry->min_nr,
1588a92e545SKent Overstreet 		  __entry->prereserved,
1598a92e545SKent Overstreet 		  __entry->prereserved_total,
1608a92e545SKent Overstreet 		  __entry->btree_cache_dirty,
1618a92e545SKent Overstreet 		  __entry->btree_cache_total,
1628a92e545SKent Overstreet 		  __entry->btree_key_cache_dirty,
1638a92e545SKent Overstreet 		  __entry->btree_key_cache_total)
1648a92e545SKent Overstreet );
1658a92e545SKent Overstreet 
1668a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_finish,
1678a92e545SKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 nr_flushed),
1688a92e545SKent Overstreet 	TP_ARGS(c, nr_flushed),
1698a92e545SKent Overstreet 
1708a92e545SKent Overstreet 	TP_STRUCT__entry(
171ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
1728a92e545SKent Overstreet 		__field(u64,		nr_flushed		)
1738a92e545SKent Overstreet 	),
1748a92e545SKent Overstreet 
1758a92e545SKent Overstreet 	TP_fast_assign(
176ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
1778a92e545SKent Overstreet 		__entry->nr_flushed	= nr_flushed;
1788a92e545SKent Overstreet 	),
1798a92e545SKent Overstreet 
180ddc7dd62SKent Overstreet 	TP_printk("%d%d flushed %llu",
181ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
182ddc7dd62SKent Overstreet 		  __entry->nr_flushed)
1838a92e545SKent Overstreet );
1848a92e545SKent Overstreet 
1851c6fdbd8SKent Overstreet /* bset.c: */
1861c6fdbd8SKent Overstreet 
1871c6fdbd8SKent Overstreet DEFINE_EVENT(bpos, bkey_pack_pos_fail,
1881c6fdbd8SKent Overstreet 	TP_PROTO(struct bpos *p),
1891c6fdbd8SKent Overstreet 	TP_ARGS(p)
1901c6fdbd8SKent Overstreet );
1911c6fdbd8SKent Overstreet 
1921c6fdbd8SKent Overstreet /* Btree */
1931c6fdbd8SKent Overstreet 
1941c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(btree_node,
1951c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
1961c6fdbd8SKent Overstreet 	TP_ARGS(c, b),
1971c6fdbd8SKent Overstreet 
1981c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
199ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
2001c6fdbd8SKent Overstreet 		__field(u8,		level			)
2011c6fdbd8SKent Overstreet 		__field(u8,		id			)
2021c6fdbd8SKent Overstreet 		__field(u64,		inode			)
2031c6fdbd8SKent Overstreet 		__field(u64,		offset			)
2041c6fdbd8SKent Overstreet 	),
2051c6fdbd8SKent Overstreet 
2061c6fdbd8SKent Overstreet 	TP_fast_assign(
207ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
208c43a6ef9SKent Overstreet 		__entry->level		= b->c.level;
209c43a6ef9SKent Overstreet 		__entry->id		= b->c.btree_id;
2101c6fdbd8SKent Overstreet 		__entry->inode		= b->key.k.p.inode;
2111c6fdbd8SKent Overstreet 		__entry->offset		= b->key.k.p.offset;
2121c6fdbd8SKent Overstreet 	),
2131c6fdbd8SKent Overstreet 
214ddc7dd62SKent Overstreet 	TP_printk("%d,%d  %u id %u %llu:%llu",
215ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
216ddc7dd62SKent Overstreet 		  __entry->level, __entry->id,
2171c6fdbd8SKent Overstreet 		  __entry->inode, __entry->offset)
2181c6fdbd8SKent Overstreet );
2191c6fdbd8SKent Overstreet 
2201c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_read,
2211c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
2221c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
2231c6fdbd8SKent Overstreet );
2241c6fdbd8SKent Overstreet 
2251c6fdbd8SKent Overstreet TRACE_EVENT(btree_write,
2261c6fdbd8SKent Overstreet 	TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
2271c6fdbd8SKent Overstreet 	TP_ARGS(b, bytes, sectors),
2281c6fdbd8SKent Overstreet 
2291c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
23026609b61SKent Overstreet 		__field(enum btree_node_type,	type)
2311c6fdbd8SKent Overstreet 		__field(unsigned,	bytes			)
2321c6fdbd8SKent Overstreet 		__field(unsigned,	sectors			)
2331c6fdbd8SKent Overstreet 	),
2341c6fdbd8SKent Overstreet 
2351c6fdbd8SKent Overstreet 	TP_fast_assign(
2361c6fdbd8SKent Overstreet 		__entry->type	= btree_node_type(b);
2371c6fdbd8SKent Overstreet 		__entry->bytes	= bytes;
2381c6fdbd8SKent Overstreet 		__entry->sectors = sectors;
2391c6fdbd8SKent Overstreet 	),
2401c6fdbd8SKent Overstreet 
2411c6fdbd8SKent Overstreet 	TP_printk("bkey type %u bytes %u sectors %u",
2421c6fdbd8SKent Overstreet 		  __entry->type , __entry->bytes, __entry->sectors)
2431c6fdbd8SKent Overstreet );
2441c6fdbd8SKent Overstreet 
2451c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_alloc,
2461c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
2471c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
2481c6fdbd8SKent Overstreet );
2491c6fdbd8SKent Overstreet 
2501c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_free,
2511c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
2521c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
2531c6fdbd8SKent Overstreet );
2541c6fdbd8SKent Overstreet 
2551c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_reap,
2561c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
2571c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
2581c6fdbd8SKent Overstreet );
2591c6fdbd8SKent Overstreet 
260ddc7dd62SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize_lock_fail,
2611c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
2621c6fdbd8SKent Overstreet 	TP_ARGS(c)
2631c6fdbd8SKent Overstreet );
2641c6fdbd8SKent Overstreet 
265ddc7dd62SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize_lock,
2661c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
2671c6fdbd8SKent Overstreet 	TP_ARGS(c)
2681c6fdbd8SKent Overstreet );
2691c6fdbd8SKent Overstreet 
270ddc7dd62SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize,
2711c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
2721c6fdbd8SKent Overstreet 	TP_ARGS(c)
2731c6fdbd8SKent Overstreet );
2741c6fdbd8SKent Overstreet 
2751c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock,
2761c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
2771c6fdbd8SKent Overstreet 	TP_ARGS(c)
2781c6fdbd8SKent Overstreet );
2791c6fdbd8SKent Overstreet 
2801c6fdbd8SKent Overstreet TRACE_EVENT(btree_reserve_get_fail,
2811c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, size_t required, struct closure *cl),
2821c6fdbd8SKent Overstreet 	TP_ARGS(c, required, cl),
2831c6fdbd8SKent Overstreet 
2841c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
285ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
2861c6fdbd8SKent Overstreet 		__field(size_t,			required	)
2871c6fdbd8SKent Overstreet 		__field(struct closure *,	cl		)
2881c6fdbd8SKent Overstreet 	),
2891c6fdbd8SKent Overstreet 
2901c6fdbd8SKent Overstreet 	TP_fast_assign(
291ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
2921c6fdbd8SKent Overstreet 		__entry->required = required;
2931c6fdbd8SKent Overstreet 		__entry->cl = cl;
2941c6fdbd8SKent Overstreet 	),
2951c6fdbd8SKent Overstreet 
296ddc7dd62SKent Overstreet 	TP_printk("%d,%d required %zu by %p",
297ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2981c6fdbd8SKent Overstreet 		  __entry->required, __entry->cl)
2991c6fdbd8SKent Overstreet );
3001c6fdbd8SKent Overstreet 
3011c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_split,
3021c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3031c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3041c6fdbd8SKent Overstreet );
3051c6fdbd8SKent Overstreet 
3061c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_compact,
3071c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3081c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3091c6fdbd8SKent Overstreet );
3101c6fdbd8SKent Overstreet 
3111c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_merge,
3121c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3131c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3141c6fdbd8SKent Overstreet );
3151c6fdbd8SKent Overstreet 
3161c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_set_root,
3171c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3181c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3191c6fdbd8SKent Overstreet );
3201c6fdbd8SKent Overstreet 
321c7ce813fSKent Overstreet TRACE_EVENT(btree_cache_scan,
322c7ce813fSKent Overstreet 	TP_PROTO(unsigned long nr_to_scan_pages,
323c7ce813fSKent Overstreet 		 unsigned long nr_to_scan_nodes,
324c7ce813fSKent Overstreet 		 unsigned long can_free_nodes,
325c7ce813fSKent Overstreet 		 long ret),
326c7ce813fSKent Overstreet 	TP_ARGS(nr_to_scan_pages, nr_to_scan_nodes, can_free_nodes, ret),
327c7ce813fSKent Overstreet 
328c7ce813fSKent Overstreet 	TP_STRUCT__entry(
329c7ce813fSKent Overstreet 		__field(unsigned long,	nr_to_scan_pages	)
330c7ce813fSKent Overstreet 		__field(unsigned long,	nr_to_scan_nodes	)
331c7ce813fSKent Overstreet 		__field(unsigned long,	can_free_nodes		)
332c7ce813fSKent Overstreet 		__field(long,		ret			)
333c7ce813fSKent Overstreet 	),
334c7ce813fSKent Overstreet 
335c7ce813fSKent Overstreet 	TP_fast_assign(
336c7ce813fSKent Overstreet 		__entry->nr_to_scan_pages	= nr_to_scan_pages;
337c7ce813fSKent Overstreet 		__entry->nr_to_scan_nodes	= nr_to_scan_nodes;
338c7ce813fSKent Overstreet 		__entry->can_free_nodes		= can_free_nodes;
339c7ce813fSKent Overstreet 		__entry->ret			= ret;
340c7ce813fSKent Overstreet 	),
341c7ce813fSKent Overstreet 
342c7ce813fSKent Overstreet 	TP_printk("scanned for %lu pages, %lu nodes, can free %lu nodes, ret %li",
343c7ce813fSKent Overstreet 		  __entry->nr_to_scan_pages,
344c7ce813fSKent Overstreet 		  __entry->nr_to_scan_nodes,
345c7ce813fSKent Overstreet 		  __entry->can_free_nodes,
346c7ce813fSKent Overstreet 		  __entry->ret)
347c7ce813fSKent Overstreet );
348c7ce813fSKent Overstreet 
3491c6fdbd8SKent Overstreet /* Garbage collection */
3501c6fdbd8SKent Overstreet 
3511c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_gc_rewrite_node,
3521c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3531c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3541c6fdbd8SKent Overstreet );
3551c6fdbd8SKent Overstreet 
3561c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail,
3571c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, struct btree *b),
3581c6fdbd8SKent Overstreet 	TP_ARGS(c, b)
3591c6fdbd8SKent Overstreet );
3601c6fdbd8SKent Overstreet 
3611c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, gc_start,
3621c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
3631c6fdbd8SKent Overstreet 	TP_ARGS(c)
3641c6fdbd8SKent Overstreet );
3651c6fdbd8SKent Overstreet 
3661c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, gc_end,
3671c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
3681c6fdbd8SKent Overstreet 	TP_ARGS(c)
3691c6fdbd8SKent Overstreet );
3701c6fdbd8SKent Overstreet 
3711c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, gc_cannot_inc_gens,
3721c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c),
3731c6fdbd8SKent Overstreet 	TP_ARGS(c)
3741c6fdbd8SKent Overstreet );
3751c6fdbd8SKent Overstreet 
3761c6fdbd8SKent Overstreet /* Allocator */
3771c6fdbd8SKent Overstreet 
37889baec78SKent Overstreet TRACE_EVENT(alloc_scan,
37989baec78SKent Overstreet 	TP_PROTO(struct bch_dev *ca, u64 found, u64 inc_gen, u64 inc_gen_skipped),
38089baec78SKent Overstreet 	TP_ARGS(ca, found, inc_gen, inc_gen_skipped),
3811c6fdbd8SKent Overstreet 
3821c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
38389baec78SKent Overstreet 		__field(dev_t,		dev		)
38489baec78SKent Overstreet 		__field(u64,		found		)
38589baec78SKent Overstreet 		__field(u64,		inc_gen		)
38689baec78SKent Overstreet 		__field(u64,		inc_gen_skipped	)
3871c6fdbd8SKent Overstreet 	),
3881c6fdbd8SKent Overstreet 
3891c6fdbd8SKent Overstreet 	TP_fast_assign(
390*eacb2574SKent Overstreet 		__entry->dev		= ca->dev;
39189baec78SKent Overstreet 		__entry->found		= found;
39289baec78SKent Overstreet 		__entry->inc_gen	= inc_gen;
39389baec78SKent Overstreet 		__entry->inc_gen_skipped = inc_gen_skipped;
3941c6fdbd8SKent Overstreet 	),
3951c6fdbd8SKent Overstreet 
39689baec78SKent Overstreet 	TP_printk("%d,%d found %llu inc_gen %llu inc_gen_skipped %llu",
39789baec78SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
39889baec78SKent Overstreet 		  __entry->found, __entry->inc_gen, __entry->inc_gen_skipped)
3991c6fdbd8SKent Overstreet );
4001c6fdbd8SKent Overstreet 
4011c6fdbd8SKent Overstreet TRACE_EVENT(invalidate,
4021c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors),
4031c6fdbd8SKent Overstreet 	TP_ARGS(ca, offset, sectors),
4041c6fdbd8SKent Overstreet 
4051c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
4061c6fdbd8SKent Overstreet 		__field(unsigned,	sectors			)
4071c6fdbd8SKent Overstreet 		__field(dev_t,		dev			)
4081c6fdbd8SKent Overstreet 		__field(__u64,		offset			)
4091c6fdbd8SKent Overstreet 	),
4101c6fdbd8SKent Overstreet 
4111c6fdbd8SKent Overstreet 	TP_fast_assign(
412*eacb2574SKent Overstreet 		__entry->dev		= ca->dev;
4131c6fdbd8SKent Overstreet 		__entry->offset		= offset,
4141c6fdbd8SKent Overstreet 		__entry->sectors	= sectors;
4151c6fdbd8SKent Overstreet 	),
4161c6fdbd8SKent Overstreet 
4171c6fdbd8SKent Overstreet 	TP_printk("invalidated %u sectors at %d,%d sector=%llu",
41889baec78SKent Overstreet 		  __entry->sectors,
41989baec78SKent Overstreet 		  MAJOR(__entry->dev),
42089baec78SKent Overstreet 		  MINOR(__entry->dev),
42189baec78SKent Overstreet 		  __entry->offset)
4221c6fdbd8SKent Overstreet );
4231c6fdbd8SKent Overstreet 
4241c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bucket_alloc,
4251c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
4261c6fdbd8SKent Overstreet 	TP_ARGS(ca, reserve),
4271c6fdbd8SKent Overstreet 
4281c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
42989baec78SKent Overstreet 		__field(dev_t,			dev	)
4301c6fdbd8SKent Overstreet 		__field(enum alloc_reserve,	reserve	)
4311c6fdbd8SKent Overstreet 	),
4321c6fdbd8SKent Overstreet 
4331c6fdbd8SKent Overstreet 	TP_fast_assign(
434*eacb2574SKent Overstreet 		__entry->dev		= ca->dev;
4351c6fdbd8SKent Overstreet 		__entry->reserve	= reserve;
4361c6fdbd8SKent Overstreet 	),
4371c6fdbd8SKent Overstreet 
43889baec78SKent Overstreet 	TP_printk("%d,%d reserve %d",
43989baec78SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
44089baec78SKent Overstreet 		  __entry->reserve)
4411c6fdbd8SKent Overstreet );
4421c6fdbd8SKent Overstreet 
4431c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc,
4441c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
4451c6fdbd8SKent Overstreet 	TP_ARGS(ca, reserve)
4461c6fdbd8SKent Overstreet );
4471c6fdbd8SKent Overstreet 
4481c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
4491c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
4501c6fdbd8SKent Overstreet 	TP_ARGS(ca, reserve)
4511c6fdbd8SKent Overstreet );
4521c6fdbd8SKent Overstreet 
4531c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, open_bucket_alloc_fail,
4541c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
4551c6fdbd8SKent Overstreet 	TP_ARGS(ca, reserve)
4561c6fdbd8SKent Overstreet );
4571c6fdbd8SKent Overstreet 
4581c6fdbd8SKent Overstreet /* Moving IO */
4591c6fdbd8SKent Overstreet 
4601c6fdbd8SKent Overstreet DEFINE_EVENT(bkey, move_extent,
4611c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
4621c6fdbd8SKent Overstreet 	TP_ARGS(k)
4631c6fdbd8SKent Overstreet );
4641c6fdbd8SKent Overstreet 
4651c6fdbd8SKent Overstreet DEFINE_EVENT(bkey, move_alloc_fail,
4661c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
4671c6fdbd8SKent Overstreet 	TP_ARGS(k)
4681c6fdbd8SKent Overstreet );
4691c6fdbd8SKent Overstreet 
4701c6fdbd8SKent Overstreet DEFINE_EVENT(bkey, move_race,
4711c6fdbd8SKent Overstreet 	TP_PROTO(const struct bkey *k),
4721c6fdbd8SKent Overstreet 	TP_ARGS(k)
4731c6fdbd8SKent Overstreet );
4741c6fdbd8SKent Overstreet 
4751c6fdbd8SKent Overstreet TRACE_EVENT(move_data,
4761c6fdbd8SKent Overstreet 	TP_PROTO(struct bch_fs *c, u64 sectors_moved,
4771c6fdbd8SKent Overstreet 		 u64 keys_moved),
4781c6fdbd8SKent Overstreet 	TP_ARGS(c, sectors_moved, keys_moved),
4791c6fdbd8SKent Overstreet 
4801c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
481ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
4821c6fdbd8SKent Overstreet 		__field(u64,		sectors_moved	)
4831c6fdbd8SKent Overstreet 		__field(u64,		keys_moved	)
4841c6fdbd8SKent Overstreet 	),
4851c6fdbd8SKent Overstreet 
4861c6fdbd8SKent Overstreet 	TP_fast_assign(
487ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
4881c6fdbd8SKent Overstreet 		__entry->sectors_moved = sectors_moved;
4891c6fdbd8SKent Overstreet 		__entry->keys_moved = keys_moved;
4901c6fdbd8SKent Overstreet 	),
4911c6fdbd8SKent Overstreet 
492ddc7dd62SKent Overstreet 	TP_printk("%d,%d sectors_moved %llu keys_moved %llu",
493ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
494ddc7dd62SKent Overstreet 		  __entry->sectors_moved, __entry->keys_moved)
4951c6fdbd8SKent Overstreet );
4961c6fdbd8SKent Overstreet 
4971c6fdbd8SKent Overstreet TRACE_EVENT(copygc,
498e6d11615SKent Overstreet 	TP_PROTO(struct bch_fs *c,
4991c6fdbd8SKent Overstreet 		 u64 sectors_moved, u64 sectors_not_moved,
5001c6fdbd8SKent Overstreet 		 u64 buckets_moved, u64 buckets_not_moved),
501e6d11615SKent Overstreet 	TP_ARGS(c,
5021c6fdbd8SKent Overstreet 		sectors_moved, sectors_not_moved,
5031c6fdbd8SKent Overstreet 		buckets_moved, buckets_not_moved),
5041c6fdbd8SKent Overstreet 
5051c6fdbd8SKent Overstreet 	TP_STRUCT__entry(
506ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
5071c6fdbd8SKent Overstreet 		__field(u64,		sectors_moved		)
5081c6fdbd8SKent Overstreet 		__field(u64,		sectors_not_moved	)
5091c6fdbd8SKent Overstreet 		__field(u64,		buckets_moved		)
5101c6fdbd8SKent Overstreet 		__field(u64,		buckets_not_moved	)
5111c6fdbd8SKent Overstreet 	),
5121c6fdbd8SKent Overstreet 
5131c6fdbd8SKent Overstreet 	TP_fast_assign(
514ddc7dd62SKent Overstreet 		__entry->dev			= c->dev;
5151c6fdbd8SKent Overstreet 		__entry->sectors_moved		= sectors_moved;
5161c6fdbd8SKent Overstreet 		__entry->sectors_not_moved	= sectors_not_moved;
5171c6fdbd8SKent Overstreet 		__entry->buckets_moved		= buckets_moved;
5181c6fdbd8SKent Overstreet 		__entry->buckets_not_moved = buckets_moved;
5191c6fdbd8SKent Overstreet 	),
5201c6fdbd8SKent Overstreet 
521ddc7dd62SKent Overstreet 	TP_printk("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu",
522ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
5231c6fdbd8SKent Overstreet 		  __entry->sectors_moved, __entry->sectors_not_moved,
5241c6fdbd8SKent Overstreet 		  __entry->buckets_moved, __entry->buckets_not_moved)
5251c6fdbd8SKent Overstreet );
5261c6fdbd8SKent Overstreet 
52719d2819dSKent Overstreet TRACE_EVENT(copygc_wait,
52819d2819dSKent Overstreet 	TP_PROTO(struct bch_fs *c,
52919d2819dSKent Overstreet 		 u64 wait_amount, u64 until),
53019d2819dSKent Overstreet 	TP_ARGS(c, wait_amount, until),
53119d2819dSKent Overstreet 
53219d2819dSKent Overstreet 	TP_STRUCT__entry(
533ddc7dd62SKent Overstreet 		__field(dev_t,		dev			)
53419d2819dSKent Overstreet 		__field(u64,		wait_amount		)
53519d2819dSKent Overstreet 		__field(u64,		until			)
53619d2819dSKent Overstreet 	),
53719d2819dSKent Overstreet 
53819d2819dSKent Overstreet 	TP_fast_assign(
539ddc7dd62SKent Overstreet 		__entry->dev		= c->dev;
54019d2819dSKent Overstreet 		__entry->wait_amount	= wait_amount;
54119d2819dSKent Overstreet 		__entry->until		= until;
54219d2819dSKent Overstreet 	),
54319d2819dSKent Overstreet 
544ddc7dd62SKent Overstreet 	TP_printk("%d,%u waiting for %llu sectors until %llu",
545ddc7dd62SKent Overstreet 		  MAJOR(__entry->dev), MINOR(__entry->dev),
546ddc7dd62SKent Overstreet 		  __entry->wait_amount, __entry->until)
54719d2819dSKent Overstreet );
54819d2819dSKent Overstreet 
549297604c9SKent Overstreet TRACE_EVENT(transaction_restart_ip,
550297604c9SKent Overstreet 	TP_PROTO(unsigned long caller, unsigned long ip),
551297604c9SKent Overstreet 	TP_ARGS(caller, ip),
552297604c9SKent Overstreet 
553297604c9SKent Overstreet 	TP_STRUCT__entry(
554297604c9SKent Overstreet 		__field(unsigned long,		caller	)
555297604c9SKent Overstreet 		__field(unsigned long,		ip	)
556297604c9SKent Overstreet 	),
557297604c9SKent Overstreet 
558297604c9SKent Overstreet 	TP_fast_assign(
559297604c9SKent Overstreet 		__entry->caller	= caller;
560297604c9SKent Overstreet 		__entry->ip	= ip;
561297604c9SKent Overstreet 	),
562297604c9SKent Overstreet 
5633dc5fcfcSKent Overstreet 	TP_printk("%pS %pS", (void *) __entry->caller, (void *) __entry->ip)
564297604c9SKent Overstreet );
565297604c9SKent Overstreet 
566ba5c6557SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart,
567531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
568531a0095SKent Overstreet 		 unsigned long caller_ip),
569531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip),
570ba5c6557SKent Overstreet 
571ba5c6557SKent Overstreet 	TP_STRUCT__entry(
572531a0095SKent Overstreet 		__field(unsigned long,		trans_ip	)
573531a0095SKent Overstreet 		__field(unsigned long,		caller_ip	)
574ba5c6557SKent Overstreet 	),
575ba5c6557SKent Overstreet 
576ba5c6557SKent Overstreet 	TP_fast_assign(
577531a0095SKent Overstreet 		__entry->trans_ip		= trans_ip;
578531a0095SKent Overstreet 		__entry->caller_ip		= caller_ip;
579ba5c6557SKent Overstreet 	),
580ba5c6557SKent Overstreet 
581531a0095SKent Overstreet 	TP_printk("%pS %pS",
582531a0095SKent Overstreet 		  (void *) __entry->trans_ip,
583531a0095SKent Overstreet 		  (void *) __entry->caller_ip)
584ba5c6557SKent Overstreet );
585ba5c6557SKent Overstreet 
5864f6dad46SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_blocked_journal_reclaim,
587531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
588531a0095SKent Overstreet 		 unsigned long caller_ip),
589531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
590531a0095SKent Overstreet );
591531a0095SKent Overstreet 
592531a0095SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_restart_journal_res_get,
593531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
594531a0095SKent Overstreet 		 unsigned long caller_ip),
595531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
596531a0095SKent Overstreet );
597531a0095SKent Overstreet 
598531a0095SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_restart_journal_preres_get,
599531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
600531a0095SKent Overstreet 		 unsigned long caller_ip),
601531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
602531a0095SKent Overstreet );
603531a0095SKent Overstreet 
604531a0095SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_restart_journal_reclaim,
605531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
606531a0095SKent Overstreet 		 unsigned long caller_ip),
607531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
608531a0095SKent Overstreet );
609531a0095SKent Overstreet 
610531a0095SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_restart_fault_inject,
611531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
612531a0095SKent Overstreet 		 unsigned long caller_ip),
613531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
614531a0095SKent Overstreet );
615531a0095SKent Overstreet 
616531a0095SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_traverse_all,
617531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
618531a0095SKent Overstreet 		 unsigned long caller_ip),
619531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
620531a0095SKent Overstreet );
621531a0095SKent Overstreet 
622531a0095SKent Overstreet DEFINE_EVENT(transaction_restart,	trans_restart_mark_replicas,
623531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
624531a0095SKent Overstreet 		 unsigned long caller_ip),
625531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip)
626531a0095SKent Overstreet );
627531a0095SKent Overstreet 
628531a0095SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart_iter,
629531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
630531a0095SKent Overstreet 		 unsigned long caller_ip,
631531a0095SKent Overstreet 		 enum btree_id btree_id,
632531a0095SKent Overstreet 		 struct bpos *pos),
633531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos),
634531a0095SKent Overstreet 
635531a0095SKent Overstreet 	TP_STRUCT__entry(
636531a0095SKent Overstreet 		__field(unsigned long,		trans_ip	)
637531a0095SKent Overstreet 		__field(unsigned long,		caller_ip	)
638531a0095SKent Overstreet 		__field(u8,			btree_id	)
639531a0095SKent Overstreet 		__field(u64,			pos_inode	)
640531a0095SKent Overstreet 		__field(u64,			pos_offset	)
641531a0095SKent Overstreet 		__field(u32,			pos_snapshot	)
642531a0095SKent Overstreet 	),
643531a0095SKent Overstreet 
644531a0095SKent Overstreet 	TP_fast_assign(
645531a0095SKent Overstreet 		__entry->trans_ip		= trans_ip;
646531a0095SKent Overstreet 		__entry->caller_ip		= caller_ip;
647531a0095SKent Overstreet 		__entry->btree_id		= btree_id;
648531a0095SKent Overstreet 		__entry->pos_inode		= pos->inode;
649531a0095SKent Overstreet 		__entry->pos_offset		= pos->offset;
650531a0095SKent Overstreet 		__entry->pos_snapshot		= pos->snapshot;
651531a0095SKent Overstreet 	),
652531a0095SKent Overstreet 
653531a0095SKent Overstreet 	TP_printk("%ps %pS btree %u pos %llu:%llu:%u",
654531a0095SKent Overstreet 		  (void *) __entry->trans_ip,
655531a0095SKent Overstreet 		  (void *) __entry->caller_ip,
656531a0095SKent Overstreet 		  __entry->btree_id,
657531a0095SKent Overstreet 		  __entry->pos_inode,
658531a0095SKent Overstreet 		  __entry->pos_offset,
659531a0095SKent Overstreet 		  __entry->pos_snapshot)
660531a0095SKent Overstreet );
661531a0095SKent Overstreet 
662531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_btree_node_reused,
663531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
664531a0095SKent Overstreet 		 unsigned long caller_ip,
665531a0095SKent Overstreet 		 enum btree_id btree_id,
666531a0095SKent Overstreet 		 struct bpos *pos),
667531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
668531a0095SKent Overstreet );
669531a0095SKent Overstreet 
670531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_btree_node_split,
671531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
672531a0095SKent Overstreet 		 unsigned long caller_ip,
673531a0095SKent Overstreet 		 enum btree_id btree_id,
674531a0095SKent Overstreet 		 struct bpos *pos),
675531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
676531a0095SKent Overstreet );
677531a0095SKent Overstreet 
678531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_mark,
679531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
680531a0095SKent Overstreet 		 unsigned long caller_ip,
681531a0095SKent Overstreet 		 enum btree_id btree_id,
682531a0095SKent Overstreet 		 struct bpos *pos),
683531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
684531a0095SKent Overstreet );
685531a0095SKent Overstreet 
686531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_upgrade,
687531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
688531a0095SKent Overstreet 		 unsigned long caller_ip,
689531a0095SKent Overstreet 		 enum btree_id btree_id,
690531a0095SKent Overstreet 		 struct bpos *pos),
691531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
692531a0095SKent Overstreet );
693531a0095SKent Overstreet 
694531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_iter_upgrade,
695531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
696531a0095SKent Overstreet 		 unsigned long caller_ip,
697531a0095SKent Overstreet 		 enum btree_id btree_id,
698531a0095SKent Overstreet 		 struct bpos *pos),
699531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
700531a0095SKent Overstreet );
701531a0095SKent Overstreet 
702531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_relock,
703531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
704531a0095SKent Overstreet 		 unsigned long caller_ip,
705531a0095SKent Overstreet 		 enum btree_id btree_id,
706531a0095SKent Overstreet 		 struct bpos *pos),
707531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
708531a0095SKent Overstreet );
709531a0095SKent Overstreet 
710531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter,	trans_restart_traverse,
711531a0095SKent Overstreet 	TP_PROTO(unsigned long trans_ip,
712531a0095SKent Overstreet 		 unsigned long caller_ip,
713531a0095SKent Overstreet 		 enum btree_id btree_id,
714531a0095SKent Overstreet 		 struct bpos *pos),
715531a0095SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, btree_id, pos)
716531a0095SKent Overstreet );
717531a0095SKent Overstreet 
718a301dc38SKent Overstreet TRACE_EVENT(trans_restart_would_deadlock,
719a301dc38SKent Overstreet 	TP_PROTO(unsigned long	trans_ip,
720a301dc38SKent Overstreet 		 unsigned long	caller_ip,
7212527dd91SKent Overstreet 		 bool		in_traverse_all,
722a301dc38SKent Overstreet 		 unsigned	reason,
723a301dc38SKent Overstreet 		 enum btree_id	have_btree_id,
724a301dc38SKent Overstreet 		 unsigned	have_iter_type,
7252527dd91SKent Overstreet 		 struct bpos	*have_pos,
726a301dc38SKent Overstreet 		 enum btree_id	want_btree_id,
7272527dd91SKent Overstreet 		 unsigned	want_iter_type,
7282527dd91SKent Overstreet 		 struct bpos	*want_pos),
7292527dd91SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, in_traverse_all, reason,
7302527dd91SKent Overstreet 		have_btree_id, have_iter_type, have_pos,
7312527dd91SKent Overstreet 		want_btree_id, want_iter_type, want_pos),
732a301dc38SKent Overstreet 
733a301dc38SKent Overstreet 	TP_STRUCT__entry(
734a301dc38SKent Overstreet 		__field(unsigned long,		trans_ip	)
735a301dc38SKent Overstreet 		__field(unsigned long,		caller_ip	)
7362527dd91SKent Overstreet 		__field(u8,			in_traverse_all	)
737a301dc38SKent Overstreet 		__field(u8,			reason		)
738a301dc38SKent Overstreet 		__field(u8,			have_btree_id	)
739a301dc38SKent Overstreet 		__field(u8,			have_iter_type	)
740a301dc38SKent Overstreet 		__field(u8,			want_btree_id	)
741a301dc38SKent Overstreet 		__field(u8,			want_iter_type	)
7422527dd91SKent Overstreet 
7432527dd91SKent Overstreet 		__field(u64,			have_pos_inode	)
7442527dd91SKent Overstreet 		__field(u64,			have_pos_offset	)
7452527dd91SKent Overstreet 		__field(u32,			have_pos_snapshot)
7462527dd91SKent Overstreet 		__field(u32,			want_pos_snapshot)
7472527dd91SKent Overstreet 		__field(u64,			want_pos_inode	)
7482527dd91SKent Overstreet 		__field(u64,			want_pos_offset	)
749a301dc38SKent Overstreet 	),
750a301dc38SKent Overstreet 
751a301dc38SKent Overstreet 	TP_fast_assign(
752a301dc38SKent Overstreet 		__entry->trans_ip		= trans_ip;
753a301dc38SKent Overstreet 		__entry->caller_ip		= caller_ip;
7542527dd91SKent Overstreet 		__entry->in_traverse_all	= in_traverse_all;
755a301dc38SKent Overstreet 		__entry->reason			= reason;
756a301dc38SKent Overstreet 		__entry->have_btree_id		= have_btree_id;
757a301dc38SKent Overstreet 		__entry->have_iter_type		= have_iter_type;
758a301dc38SKent Overstreet 		__entry->want_btree_id		= want_btree_id;
759a301dc38SKent Overstreet 		__entry->want_iter_type		= want_iter_type;
7602527dd91SKent Overstreet 
7612527dd91SKent Overstreet 		__entry->have_pos_inode		= have_pos->inode;
7622527dd91SKent Overstreet 		__entry->have_pos_offset	= have_pos->offset;
7632527dd91SKent Overstreet 		__entry->have_pos_snapshot	= have_pos->snapshot;
7642527dd91SKent Overstreet 
7652527dd91SKent Overstreet 		__entry->want_pos_inode		= want_pos->inode;
7662527dd91SKent Overstreet 		__entry->want_pos_offset	= want_pos->offset;
7672527dd91SKent Overstreet 		__entry->want_pos_snapshot	= want_pos->snapshot;
768a301dc38SKent Overstreet 	),
769a301dc38SKent Overstreet 
7702527dd91SKent Overstreet 	TP_printk("%pS %pS traverse_all %u because %u have %u:%u %llu:%llu:%u want %u:%u %llu:%llu:%u",
771a301dc38SKent Overstreet 		  (void *) __entry->trans_ip,
772a301dc38SKent Overstreet 		  (void *) __entry->caller_ip,
7732527dd91SKent Overstreet 		  __entry->in_traverse_all,
774a301dc38SKent Overstreet 		  __entry->reason,
775a301dc38SKent Overstreet 		  __entry->have_btree_id,
776a301dc38SKent Overstreet 		  __entry->have_iter_type,
7772527dd91SKent Overstreet 		  __entry->have_pos_inode,
7782527dd91SKent Overstreet 		  __entry->have_pos_offset,
7792527dd91SKent Overstreet 		  __entry->have_pos_snapshot,
780a301dc38SKent Overstreet 		  __entry->want_btree_id,
7812527dd91SKent Overstreet 		  __entry->want_iter_type,
7822527dd91SKent Overstreet 		  __entry->want_pos_inode,
7832527dd91SKent Overstreet 		  __entry->want_pos_offset,
7842527dd91SKent Overstreet 		  __entry->want_pos_snapshot)
785ba5c6557SKent Overstreet );
786ba5c6557SKent Overstreet 
787caaa66aaSKent Overstreet TRACE_EVENT(trans_restart_would_deadlock_write,
788caaa66aaSKent Overstreet 	TP_PROTO(unsigned long trans_ip),
789caaa66aaSKent Overstreet 	TP_ARGS(trans_ip),
790caaa66aaSKent Overstreet 
791caaa66aaSKent Overstreet 	TP_STRUCT__entry(
792caaa66aaSKent Overstreet 		__field(unsigned long,		trans_ip	)
793caaa66aaSKent Overstreet 	),
794caaa66aaSKent Overstreet 
795caaa66aaSKent Overstreet 	TP_fast_assign(
796caaa66aaSKent Overstreet 		__entry->trans_ip	= trans_ip;
797caaa66aaSKent Overstreet 	),
798caaa66aaSKent Overstreet 
799caaa66aaSKent Overstreet 	TP_printk("%ps", (void *) __entry->trans_ip)
800caaa66aaSKent Overstreet );
801caaa66aaSKent Overstreet 
80220bceecbSKent Overstreet TRACE_EVENT(trans_restart_mem_realloced,
80373a117d2SKent Overstreet 	TP_PROTO(unsigned long trans_ip, unsigned long caller_ip,
80473a117d2SKent Overstreet 		 unsigned long bytes),
80573a117d2SKent Overstreet 	TP_ARGS(trans_ip, caller_ip, bytes),
80620bceecbSKent Overstreet 
80720bceecbSKent Overstreet 	TP_STRUCT__entry(
80873a117d2SKent Overstreet 		__field(unsigned long,		trans_ip	)
80973a117d2SKent Overstreet 		__field(unsigned long,		caller_ip	)
81020bceecbSKent Overstreet 		__field(unsigned long,		bytes		)
81120bceecbSKent Overstreet 	),
81220bceecbSKent Overstreet 
81320bceecbSKent Overstreet 	TP_fast_assign(
81473a117d2SKent Overstreet 		__entry->trans_ip	= trans_ip;
81573a117d2SKent Overstreet 		__entry->caller_ip	= caller_ip;
81620bceecbSKent Overstreet 		__entry->bytes		= bytes;
81720bceecbSKent Overstreet 	),
81820bceecbSKent Overstreet 
81973a117d2SKent Overstreet 	TP_printk("%pS %pS bytes %lu",
82073a117d2SKent Overstreet 		  (void *) __entry->trans_ip,
82173a117d2SKent Overstreet 		  (void *) __entry->caller_ip,
82273a117d2SKent Overstreet 		  __entry->bytes)
823ba5c6557SKent Overstreet );
824ba5c6557SKent Overstreet 
8251c6fdbd8SKent Overstreet #endif /* _TRACE_BCACHEFS_H */
8261c6fdbd8SKent Overstreet 
8271c6fdbd8SKent Overstreet /* This part must be outside protection */
8281c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_PATH
8291c6fdbd8SKent Overstreet #define TRACE_INCLUDE_PATH ../../fs/bcachefs
8301c6fdbd8SKent Overstreet 
8311c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_FILE
8321c6fdbd8SKent Overstreet #define TRACE_INCLUDE_FILE trace
8331c6fdbd8SKent Overstreet 
8341c6fdbd8SKent Overstreet #include <trace/define_trace.h>
835