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 185*59cc38b8SKent Overstreet /* allocator: */ 186*59cc38b8SKent Overstreet 187*59cc38b8SKent Overstreet TRACE_EVENT(do_discards, 188*59cc38b8SKent Overstreet TP_PROTO(struct bch_fs *c, u64 seen, u64 open, 189*59cc38b8SKent Overstreet u64 need_journal_commit, u64 discarded, int ret), 190*59cc38b8SKent Overstreet TP_ARGS(c, seen, open, need_journal_commit, discarded, ret), 191*59cc38b8SKent Overstreet 192*59cc38b8SKent Overstreet TP_STRUCT__entry( 193*59cc38b8SKent Overstreet __field(dev_t, dev ) 194*59cc38b8SKent Overstreet __field(u64, seen ) 195*59cc38b8SKent Overstreet __field(u64, open ) 196*59cc38b8SKent Overstreet __field(u64, need_journal_commit ) 197*59cc38b8SKent Overstreet __field(u64, discarded ) 198*59cc38b8SKent Overstreet __field(int, ret ) 199*59cc38b8SKent Overstreet ), 200*59cc38b8SKent Overstreet 201*59cc38b8SKent Overstreet TP_fast_assign( 202*59cc38b8SKent Overstreet __entry->dev = c->dev; 203*59cc38b8SKent Overstreet __entry->seen = seen; 204*59cc38b8SKent Overstreet __entry->open = open; 205*59cc38b8SKent Overstreet __entry->need_journal_commit = need_journal_commit; 206*59cc38b8SKent Overstreet __entry->discarded = discarded; 207*59cc38b8SKent Overstreet __entry->ret = ret; 208*59cc38b8SKent Overstreet ), 209*59cc38b8SKent Overstreet 210*59cc38b8SKent Overstreet TP_printk("%d%d seen %llu open %llu need_journal_commit %llu discarded %llu ret %i", 211*59cc38b8SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 212*59cc38b8SKent Overstreet __entry->seen, 213*59cc38b8SKent Overstreet __entry->open, 214*59cc38b8SKent Overstreet __entry->need_journal_commit, 215*59cc38b8SKent Overstreet __entry->discarded, 216*59cc38b8SKent Overstreet __entry->ret) 217*59cc38b8SKent Overstreet ); 218*59cc38b8SKent Overstreet 2191c6fdbd8SKent Overstreet /* bset.c: */ 2201c6fdbd8SKent Overstreet 2211c6fdbd8SKent Overstreet DEFINE_EVENT(bpos, bkey_pack_pos_fail, 2221c6fdbd8SKent Overstreet TP_PROTO(struct bpos *p), 2231c6fdbd8SKent Overstreet TP_ARGS(p) 2241c6fdbd8SKent Overstreet ); 2251c6fdbd8SKent Overstreet 2261c6fdbd8SKent Overstreet /* Btree */ 2271c6fdbd8SKent Overstreet 2281c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(btree_node, 2291c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 2301c6fdbd8SKent Overstreet TP_ARGS(c, b), 2311c6fdbd8SKent Overstreet 2321c6fdbd8SKent Overstreet TP_STRUCT__entry( 233ddc7dd62SKent Overstreet __field(dev_t, dev ) 2341c6fdbd8SKent Overstreet __field(u8, level ) 2351c6fdbd8SKent Overstreet __field(u8, id ) 2361c6fdbd8SKent Overstreet __field(u64, inode ) 2371c6fdbd8SKent Overstreet __field(u64, offset ) 2381c6fdbd8SKent Overstreet ), 2391c6fdbd8SKent Overstreet 2401c6fdbd8SKent Overstreet TP_fast_assign( 241ddc7dd62SKent Overstreet __entry->dev = c->dev; 242c43a6ef9SKent Overstreet __entry->level = b->c.level; 243c43a6ef9SKent Overstreet __entry->id = b->c.btree_id; 2441c6fdbd8SKent Overstreet __entry->inode = b->key.k.p.inode; 2451c6fdbd8SKent Overstreet __entry->offset = b->key.k.p.offset; 2461c6fdbd8SKent Overstreet ), 2471c6fdbd8SKent Overstreet 248ddc7dd62SKent Overstreet TP_printk("%d,%d %u id %u %llu:%llu", 249ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 250ddc7dd62SKent Overstreet __entry->level, __entry->id, 2511c6fdbd8SKent Overstreet __entry->inode, __entry->offset) 2521c6fdbd8SKent Overstreet ); 2531c6fdbd8SKent Overstreet 2541c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_read, 2551c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 2561c6fdbd8SKent Overstreet TP_ARGS(c, b) 2571c6fdbd8SKent Overstreet ); 2581c6fdbd8SKent Overstreet 2591c6fdbd8SKent Overstreet TRACE_EVENT(btree_write, 2601c6fdbd8SKent Overstreet TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors), 2611c6fdbd8SKent Overstreet TP_ARGS(b, bytes, sectors), 2621c6fdbd8SKent Overstreet 2631c6fdbd8SKent Overstreet TP_STRUCT__entry( 26426609b61SKent Overstreet __field(enum btree_node_type, type) 2651c6fdbd8SKent Overstreet __field(unsigned, bytes ) 2661c6fdbd8SKent Overstreet __field(unsigned, sectors ) 2671c6fdbd8SKent Overstreet ), 2681c6fdbd8SKent Overstreet 2691c6fdbd8SKent Overstreet TP_fast_assign( 2701c6fdbd8SKent Overstreet __entry->type = btree_node_type(b); 2711c6fdbd8SKent Overstreet __entry->bytes = bytes; 2721c6fdbd8SKent Overstreet __entry->sectors = sectors; 2731c6fdbd8SKent Overstreet ), 2741c6fdbd8SKent Overstreet 2751c6fdbd8SKent Overstreet TP_printk("bkey type %u bytes %u sectors %u", 2761c6fdbd8SKent Overstreet __entry->type , __entry->bytes, __entry->sectors) 2771c6fdbd8SKent Overstreet ); 2781c6fdbd8SKent Overstreet 2791c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_alloc, 2801c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 2811c6fdbd8SKent Overstreet TP_ARGS(c, b) 2821c6fdbd8SKent Overstreet ); 2831c6fdbd8SKent Overstreet 2841c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_free, 2851c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 2861c6fdbd8SKent Overstreet TP_ARGS(c, b) 2871c6fdbd8SKent Overstreet ); 2881c6fdbd8SKent Overstreet 2891c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_reap, 2901c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 2911c6fdbd8SKent Overstreet TP_ARGS(c, b) 2921c6fdbd8SKent Overstreet ); 2931c6fdbd8SKent Overstreet 294ddc7dd62SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize_lock_fail, 2951c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 2961c6fdbd8SKent Overstreet TP_ARGS(c) 2971c6fdbd8SKent Overstreet ); 2981c6fdbd8SKent Overstreet 299ddc7dd62SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize_lock, 3001c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 3011c6fdbd8SKent Overstreet TP_ARGS(c) 3021c6fdbd8SKent Overstreet ); 3031c6fdbd8SKent Overstreet 304ddc7dd62SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize, 3051c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 3061c6fdbd8SKent Overstreet TP_ARGS(c) 3071c6fdbd8SKent Overstreet ); 3081c6fdbd8SKent Overstreet 3091c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock, 3101c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 3111c6fdbd8SKent Overstreet TP_ARGS(c) 3121c6fdbd8SKent Overstreet ); 3131c6fdbd8SKent Overstreet 3141c6fdbd8SKent Overstreet TRACE_EVENT(btree_reserve_get_fail, 3155f417394SKent Overstreet TP_PROTO(const char *trans_fn, 3165f417394SKent Overstreet unsigned long caller_ip, 3175f417394SKent Overstreet size_t required), 3185f417394SKent Overstreet TP_ARGS(trans_fn, caller_ip, required), 3191c6fdbd8SKent Overstreet 3201c6fdbd8SKent Overstreet TP_STRUCT__entry( 3215f417394SKent Overstreet __array(char, trans_fn, 24 ) 3225f417394SKent Overstreet __field(unsigned long, caller_ip ) 3231c6fdbd8SKent Overstreet __field(size_t, required ) 3241c6fdbd8SKent Overstreet ), 3251c6fdbd8SKent Overstreet 3261c6fdbd8SKent Overstreet TP_fast_assign( 3275f417394SKent Overstreet strlcpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 3285f417394SKent Overstreet __entry->caller_ip = caller_ip; 3291c6fdbd8SKent Overstreet __entry->required = required; 3301c6fdbd8SKent Overstreet ), 3311c6fdbd8SKent Overstreet 3325f417394SKent Overstreet TP_printk("%s %pS required %zu", 3335f417394SKent Overstreet __entry->trans_fn, 3345f417394SKent Overstreet (void *) __entry->caller_ip, 3355f417394SKent Overstreet __entry->required) 3361c6fdbd8SKent Overstreet ); 3371c6fdbd8SKent Overstreet 3381c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_split, 3391c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3401c6fdbd8SKent Overstreet TP_ARGS(c, b) 3411c6fdbd8SKent Overstreet ); 3421c6fdbd8SKent Overstreet 3431c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_compact, 3441c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3451c6fdbd8SKent Overstreet TP_ARGS(c, b) 3461c6fdbd8SKent Overstreet ); 3471c6fdbd8SKent Overstreet 3481c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_merge, 3491c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3501c6fdbd8SKent Overstreet TP_ARGS(c, b) 3511c6fdbd8SKent Overstreet ); 3521c6fdbd8SKent Overstreet 3531c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_set_root, 3541c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3551c6fdbd8SKent Overstreet TP_ARGS(c, b) 3561c6fdbd8SKent Overstreet ); 3571c6fdbd8SKent Overstreet 358c7ce813fSKent Overstreet TRACE_EVENT(btree_cache_scan, 359c7ce813fSKent Overstreet TP_PROTO(unsigned long nr_to_scan_pages, 360c7ce813fSKent Overstreet unsigned long nr_to_scan_nodes, 361c7ce813fSKent Overstreet unsigned long can_free_nodes, 362c7ce813fSKent Overstreet long ret), 363c7ce813fSKent Overstreet TP_ARGS(nr_to_scan_pages, nr_to_scan_nodes, can_free_nodes, ret), 364c7ce813fSKent Overstreet 365c7ce813fSKent Overstreet TP_STRUCT__entry( 366c7ce813fSKent Overstreet __field(unsigned long, nr_to_scan_pages ) 367c7ce813fSKent Overstreet __field(unsigned long, nr_to_scan_nodes ) 368c7ce813fSKent Overstreet __field(unsigned long, can_free_nodes ) 369c7ce813fSKent Overstreet __field(long, ret ) 370c7ce813fSKent Overstreet ), 371c7ce813fSKent Overstreet 372c7ce813fSKent Overstreet TP_fast_assign( 373c7ce813fSKent Overstreet __entry->nr_to_scan_pages = nr_to_scan_pages; 374c7ce813fSKent Overstreet __entry->nr_to_scan_nodes = nr_to_scan_nodes; 375c7ce813fSKent Overstreet __entry->can_free_nodes = can_free_nodes; 376c7ce813fSKent Overstreet __entry->ret = ret; 377c7ce813fSKent Overstreet ), 378c7ce813fSKent Overstreet 379c7ce813fSKent Overstreet TP_printk("scanned for %lu pages, %lu nodes, can free %lu nodes, ret %li", 380c7ce813fSKent Overstreet __entry->nr_to_scan_pages, 381c7ce813fSKent Overstreet __entry->nr_to_scan_nodes, 382c7ce813fSKent Overstreet __entry->can_free_nodes, 383c7ce813fSKent Overstreet __entry->ret) 384c7ce813fSKent Overstreet ); 385c7ce813fSKent Overstreet 386bc82d08bSKent Overstreet TRACE_EVENT(btree_node_relock_fail, 387bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 388bc82d08bSKent Overstreet unsigned long caller_ip, 389bc82d08bSKent Overstreet enum btree_id btree_id, 390bc82d08bSKent Overstreet struct bpos *pos, 391bc82d08bSKent Overstreet unsigned long node, 392bc82d08bSKent Overstreet u32 iter_lock_seq, 393bc82d08bSKent Overstreet u32 node_lock_seq), 394bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos, node, iter_lock_seq, node_lock_seq), 395bc82d08bSKent Overstreet 396bc82d08bSKent Overstreet TP_STRUCT__entry( 397bc82d08bSKent Overstreet __array(char, trans_fn, 24 ) 3984b59a319SKent Overstreet __field(unsigned long, caller_ip ) 399bc82d08bSKent Overstreet __field(u8, btree_id ) 400bc82d08bSKent Overstreet __field(u64, pos_inode ) 401bc82d08bSKent Overstreet __field(u64, pos_offset ) 402bc82d08bSKent Overstreet __field(u32, pos_snapshot ) 403bc82d08bSKent Overstreet __field(unsigned long, node ) 404bc82d08bSKent Overstreet __field(u32, iter_lock_seq ) 405bc82d08bSKent Overstreet __field(u32, node_lock_seq ) 406bc82d08bSKent Overstreet ), 407bc82d08bSKent Overstreet 408bc82d08bSKent Overstreet TP_fast_assign( 409bc82d08bSKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 4104b59a319SKent Overstreet __entry->caller_ip = caller_ip; 411bc82d08bSKent Overstreet __entry->btree_id = btree_id; 412bc82d08bSKent Overstreet __entry->pos_inode = pos->inode; 413bc82d08bSKent Overstreet __entry->pos_offset = pos->offset; 414bc82d08bSKent Overstreet __entry->pos_snapshot = pos->snapshot; 415bc82d08bSKent Overstreet __entry->node = node; 416bc82d08bSKent Overstreet __entry->iter_lock_seq = iter_lock_seq; 417bc82d08bSKent Overstreet __entry->node_lock_seq = node_lock_seq; 418bc82d08bSKent Overstreet ), 419bc82d08bSKent Overstreet 4204b59a319SKent Overstreet TP_printk("%s %pS btree %u pos %llu:%llu:%u, node %lu iter seq %u lock seq %u", 421bc82d08bSKent Overstreet __entry->trans_fn, 4224b59a319SKent Overstreet (void *) __entry->caller_ip, 423bc82d08bSKent Overstreet __entry->btree_id, 424bc82d08bSKent Overstreet __entry->pos_inode, 425bc82d08bSKent Overstreet __entry->pos_offset, 426bc82d08bSKent Overstreet __entry->pos_snapshot, 427bc82d08bSKent Overstreet __entry->node, 428bc82d08bSKent Overstreet __entry->iter_lock_seq, 429bc82d08bSKent Overstreet __entry->node_lock_seq) 430bc82d08bSKent Overstreet ); 431bc82d08bSKent Overstreet 4321c6fdbd8SKent Overstreet /* Garbage collection */ 4331c6fdbd8SKent Overstreet 4341c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_gc_rewrite_node, 4351c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4361c6fdbd8SKent Overstreet TP_ARGS(c, b) 4371c6fdbd8SKent Overstreet ); 4381c6fdbd8SKent Overstreet 4391c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail, 4401c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4411c6fdbd8SKent Overstreet TP_ARGS(c, b) 4421c6fdbd8SKent Overstreet ); 4431c6fdbd8SKent Overstreet 4441c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, gc_start, 4451c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 4461c6fdbd8SKent Overstreet TP_ARGS(c) 4471c6fdbd8SKent Overstreet ); 4481c6fdbd8SKent Overstreet 4491c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, gc_end, 4501c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 4511c6fdbd8SKent Overstreet TP_ARGS(c) 4521c6fdbd8SKent Overstreet ); 4531c6fdbd8SKent Overstreet 4541c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, gc_cannot_inc_gens, 4551c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 4561c6fdbd8SKent Overstreet TP_ARGS(c) 4571c6fdbd8SKent Overstreet ); 4581c6fdbd8SKent Overstreet 4591c6fdbd8SKent Overstreet /* Allocator */ 4601c6fdbd8SKent Overstreet 46189baec78SKent Overstreet TRACE_EVENT(alloc_scan, 46289baec78SKent Overstreet TP_PROTO(struct bch_dev *ca, u64 found, u64 inc_gen, u64 inc_gen_skipped), 46389baec78SKent Overstreet TP_ARGS(ca, found, inc_gen, inc_gen_skipped), 4641c6fdbd8SKent Overstreet 4651c6fdbd8SKent Overstreet TP_STRUCT__entry( 46689baec78SKent Overstreet __field(dev_t, dev ) 46789baec78SKent Overstreet __field(u64, found ) 46889baec78SKent Overstreet __field(u64, inc_gen ) 46989baec78SKent Overstreet __field(u64, inc_gen_skipped ) 4701c6fdbd8SKent Overstreet ), 4711c6fdbd8SKent Overstreet 4721c6fdbd8SKent Overstreet TP_fast_assign( 473eacb2574SKent Overstreet __entry->dev = ca->dev; 47489baec78SKent Overstreet __entry->found = found; 47589baec78SKent Overstreet __entry->inc_gen = inc_gen; 47689baec78SKent Overstreet __entry->inc_gen_skipped = inc_gen_skipped; 4771c6fdbd8SKent Overstreet ), 4781c6fdbd8SKent Overstreet 47989baec78SKent Overstreet TP_printk("%d,%d found %llu inc_gen %llu inc_gen_skipped %llu", 48089baec78SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 48189baec78SKent Overstreet __entry->found, __entry->inc_gen, __entry->inc_gen_skipped) 4821c6fdbd8SKent Overstreet ); 4831c6fdbd8SKent Overstreet 4841c6fdbd8SKent Overstreet TRACE_EVENT(invalidate, 4851c6fdbd8SKent Overstreet TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors), 4861c6fdbd8SKent Overstreet TP_ARGS(ca, offset, sectors), 4871c6fdbd8SKent Overstreet 4881c6fdbd8SKent Overstreet TP_STRUCT__entry( 4891c6fdbd8SKent Overstreet __field(unsigned, sectors ) 4901c6fdbd8SKent Overstreet __field(dev_t, dev ) 4911c6fdbd8SKent Overstreet __field(__u64, offset ) 4921c6fdbd8SKent Overstreet ), 4931c6fdbd8SKent Overstreet 4941c6fdbd8SKent Overstreet TP_fast_assign( 495eacb2574SKent Overstreet __entry->dev = ca->dev; 4961c6fdbd8SKent Overstreet __entry->offset = offset, 4971c6fdbd8SKent Overstreet __entry->sectors = sectors; 4981c6fdbd8SKent Overstreet ), 4991c6fdbd8SKent Overstreet 5001c6fdbd8SKent Overstreet TP_printk("invalidated %u sectors at %d,%d sector=%llu", 50189baec78SKent Overstreet __entry->sectors, 50289baec78SKent Overstreet MAJOR(__entry->dev), 50389baec78SKent Overstreet MINOR(__entry->dev), 50489baec78SKent Overstreet __entry->offset) 5051c6fdbd8SKent Overstreet ); 5061c6fdbd8SKent Overstreet 5071c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bucket_alloc, 508f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 509f25d8215SKent Overstreet u64 avail, 510f25d8215SKent Overstreet u64 seen, 511f25d8215SKent Overstreet u64 open, 512f25d8215SKent Overstreet u64 need_journal_commit, 513f25d8215SKent Overstreet u64 nouse, 514f25d8215SKent Overstreet bool nonblocking, 515f25d8215SKent Overstreet int ret), 516f25d8215SKent Overstreet TP_ARGS(ca, alloc_reserve, avail, seen, open, need_journal_commit, nouse, nonblocking, ret), 5171c6fdbd8SKent Overstreet 5181c6fdbd8SKent Overstreet TP_STRUCT__entry( 51989baec78SKent Overstreet __field(dev_t, dev ) 5203e154711SKent Overstreet __array(char, reserve, 16 ) 521f25d8215SKent Overstreet __field(u64, avail ) 522f25d8215SKent Overstreet __field(u64, seen ) 523f25d8215SKent Overstreet __field(u64, open ) 524f25d8215SKent Overstreet __field(u64, need_journal_commit ) 525f25d8215SKent Overstreet __field(u64, nouse ) 526f25d8215SKent Overstreet __field(bool, nonblocking ) 527f25d8215SKent Overstreet __field(int, ret ) 5281c6fdbd8SKent Overstreet ), 5291c6fdbd8SKent Overstreet 5301c6fdbd8SKent Overstreet TP_fast_assign( 531eacb2574SKent Overstreet __entry->dev = ca->dev; 5323e154711SKent Overstreet strlcpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); 533f25d8215SKent Overstreet __entry->avail = avail; 534f25d8215SKent Overstreet __entry->seen = seen; 535f25d8215SKent Overstreet __entry->open = open; 536f25d8215SKent Overstreet __entry->need_journal_commit = need_journal_commit; 537f25d8215SKent Overstreet __entry->nouse = nouse; 538f25d8215SKent Overstreet __entry->nonblocking = nonblocking; 539f25d8215SKent Overstreet __entry->ret = ret; 5401c6fdbd8SKent Overstreet ), 5411c6fdbd8SKent Overstreet 542f25d8215SKent Overstreet TP_printk("%d,%d reserve %s avail %llu seen %llu open %llu need_journal_commit %llu nouse %llu nonblocking %u ret %i", 54389baec78SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 544f25d8215SKent Overstreet __entry->reserve, 545f25d8215SKent Overstreet __entry->avail, 546f25d8215SKent Overstreet __entry->seen, 547f25d8215SKent Overstreet __entry->open, 548f25d8215SKent Overstreet __entry->need_journal_commit, 549f25d8215SKent Overstreet __entry->nouse, 550f25d8215SKent Overstreet __entry->nonblocking, 551f25d8215SKent Overstreet __entry->ret) 5521c6fdbd8SKent Overstreet ); 5531c6fdbd8SKent Overstreet 5541c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc, 555f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 556f25d8215SKent Overstreet u64 avail, 557f25d8215SKent Overstreet u64 seen, 558f25d8215SKent Overstreet u64 open, 559f25d8215SKent Overstreet u64 need_journal_commit, 560f25d8215SKent Overstreet u64 nouse, 561f25d8215SKent Overstreet bool nonblocking, 562f25d8215SKent Overstreet int ret), 563f25d8215SKent Overstreet TP_ARGS(ca, alloc_reserve, avail, seen, open, need_journal_commit, nouse, nonblocking, ret) 5641c6fdbd8SKent Overstreet ); 5651c6fdbd8SKent Overstreet 5661c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc_fail, 567f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 568f25d8215SKent Overstreet u64 avail, 569f25d8215SKent Overstreet u64 seen, 570f25d8215SKent Overstreet u64 open, 571f25d8215SKent Overstreet u64 need_journal_commit, 572f25d8215SKent Overstreet u64 nouse, 573f25d8215SKent Overstreet bool nonblocking, 574f25d8215SKent Overstreet int ret), 575f25d8215SKent Overstreet TP_ARGS(ca, alloc_reserve, avail, seen, open, need_journal_commit, nouse, nonblocking, ret) 5761c6fdbd8SKent Overstreet ); 5771c6fdbd8SKent Overstreet 5781c6fdbd8SKent Overstreet /* Moving IO */ 5791c6fdbd8SKent Overstreet 5801c6fdbd8SKent Overstreet DEFINE_EVENT(bkey, move_extent, 5811c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 5821c6fdbd8SKent Overstreet TP_ARGS(k) 5831c6fdbd8SKent Overstreet ); 5841c6fdbd8SKent Overstreet 5851c6fdbd8SKent Overstreet DEFINE_EVENT(bkey, move_alloc_fail, 5861c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 5871c6fdbd8SKent Overstreet TP_ARGS(k) 5881c6fdbd8SKent Overstreet ); 5891c6fdbd8SKent Overstreet 5901c6fdbd8SKent Overstreet DEFINE_EVENT(bkey, move_race, 5911c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 5921c6fdbd8SKent Overstreet TP_ARGS(k) 5931c6fdbd8SKent Overstreet ); 5941c6fdbd8SKent Overstreet 5951c6fdbd8SKent Overstreet TRACE_EVENT(move_data, 5961c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, u64 sectors_moved, 5971c6fdbd8SKent Overstreet u64 keys_moved), 5981c6fdbd8SKent Overstreet TP_ARGS(c, sectors_moved, keys_moved), 5991c6fdbd8SKent Overstreet 6001c6fdbd8SKent Overstreet TP_STRUCT__entry( 601ddc7dd62SKent Overstreet __field(dev_t, dev ) 6021c6fdbd8SKent Overstreet __field(u64, sectors_moved ) 6031c6fdbd8SKent Overstreet __field(u64, keys_moved ) 6041c6fdbd8SKent Overstreet ), 6051c6fdbd8SKent Overstreet 6061c6fdbd8SKent Overstreet TP_fast_assign( 607ddc7dd62SKent Overstreet __entry->dev = c->dev; 6081c6fdbd8SKent Overstreet __entry->sectors_moved = sectors_moved; 6091c6fdbd8SKent Overstreet __entry->keys_moved = keys_moved; 6101c6fdbd8SKent Overstreet ), 6111c6fdbd8SKent Overstreet 612ddc7dd62SKent Overstreet TP_printk("%d,%d sectors_moved %llu keys_moved %llu", 613ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 614ddc7dd62SKent Overstreet __entry->sectors_moved, __entry->keys_moved) 6151c6fdbd8SKent Overstreet ); 6161c6fdbd8SKent Overstreet 6171c6fdbd8SKent Overstreet TRACE_EVENT(copygc, 618e6d11615SKent Overstreet TP_PROTO(struct bch_fs *c, 6191c6fdbd8SKent Overstreet u64 sectors_moved, u64 sectors_not_moved, 6201c6fdbd8SKent Overstreet u64 buckets_moved, u64 buckets_not_moved), 621e6d11615SKent Overstreet TP_ARGS(c, 6221c6fdbd8SKent Overstreet sectors_moved, sectors_not_moved, 6231c6fdbd8SKent Overstreet buckets_moved, buckets_not_moved), 6241c6fdbd8SKent Overstreet 6251c6fdbd8SKent Overstreet TP_STRUCT__entry( 626ddc7dd62SKent Overstreet __field(dev_t, dev ) 6271c6fdbd8SKent Overstreet __field(u64, sectors_moved ) 6281c6fdbd8SKent Overstreet __field(u64, sectors_not_moved ) 6291c6fdbd8SKent Overstreet __field(u64, buckets_moved ) 6301c6fdbd8SKent Overstreet __field(u64, buckets_not_moved ) 6311c6fdbd8SKent Overstreet ), 6321c6fdbd8SKent Overstreet 6331c6fdbd8SKent Overstreet TP_fast_assign( 634ddc7dd62SKent Overstreet __entry->dev = c->dev; 6351c6fdbd8SKent Overstreet __entry->sectors_moved = sectors_moved; 6361c6fdbd8SKent Overstreet __entry->sectors_not_moved = sectors_not_moved; 6371c6fdbd8SKent Overstreet __entry->buckets_moved = buckets_moved; 6381c6fdbd8SKent Overstreet __entry->buckets_not_moved = buckets_moved; 6391c6fdbd8SKent Overstreet ), 6401c6fdbd8SKent Overstreet 641ddc7dd62SKent Overstreet TP_printk("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu", 642ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 6431c6fdbd8SKent Overstreet __entry->sectors_moved, __entry->sectors_not_moved, 6441c6fdbd8SKent Overstreet __entry->buckets_moved, __entry->buckets_not_moved) 6451c6fdbd8SKent Overstreet ); 6461c6fdbd8SKent Overstreet 64719d2819dSKent Overstreet TRACE_EVENT(copygc_wait, 64819d2819dSKent Overstreet TP_PROTO(struct bch_fs *c, 64919d2819dSKent Overstreet u64 wait_amount, u64 until), 65019d2819dSKent Overstreet TP_ARGS(c, wait_amount, until), 65119d2819dSKent Overstreet 65219d2819dSKent Overstreet TP_STRUCT__entry( 653ddc7dd62SKent Overstreet __field(dev_t, dev ) 65419d2819dSKent Overstreet __field(u64, wait_amount ) 65519d2819dSKent Overstreet __field(u64, until ) 65619d2819dSKent Overstreet ), 65719d2819dSKent Overstreet 65819d2819dSKent Overstreet TP_fast_assign( 659ddc7dd62SKent Overstreet __entry->dev = c->dev; 66019d2819dSKent Overstreet __entry->wait_amount = wait_amount; 66119d2819dSKent Overstreet __entry->until = until; 66219d2819dSKent Overstreet ), 66319d2819dSKent Overstreet 664ddc7dd62SKent Overstreet TP_printk("%d,%u waiting for %llu sectors until %llu", 665ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 666ddc7dd62SKent Overstreet __entry->wait_amount, __entry->until) 66719d2819dSKent Overstreet ); 66819d2819dSKent Overstreet 669ba5c6557SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart, 670669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 671531a0095SKent Overstreet unsigned long caller_ip), 672669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip), 673ba5c6557SKent Overstreet 674ba5c6557SKent Overstreet TP_STRUCT__entry( 675669f87a5SKent Overstreet __array(char, trans_fn, 24 ) 676531a0095SKent Overstreet __field(unsigned long, caller_ip ) 677ba5c6557SKent Overstreet ), 678ba5c6557SKent Overstreet 679ba5c6557SKent Overstreet TP_fast_assign( 680669f87a5SKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 681531a0095SKent Overstreet __entry->caller_ip = caller_ip; 682ba5c6557SKent Overstreet ), 683ba5c6557SKent Overstreet 684669f87a5SKent Overstreet TP_printk("%s %pS", __entry->trans_fn, (void *) __entry->caller_ip) 685669f87a5SKent Overstreet ); 686669f87a5SKent Overstreet 687669f87a5SKent Overstreet DEFINE_EVENT(transaction_restart, transaction_restart_ip, 688669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 689669f87a5SKent Overstreet unsigned long caller_ip), 690669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 691ba5c6557SKent Overstreet ); 692ba5c6557SKent Overstreet 6934f6dad46SKent Overstreet DEFINE_EVENT(transaction_restart, trans_blocked_journal_reclaim, 694669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 695531a0095SKent Overstreet unsigned long caller_ip), 696669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 697531a0095SKent Overstreet ); 698531a0095SKent Overstreet 699531a0095SKent Overstreet DEFINE_EVENT(transaction_restart, trans_restart_journal_res_get, 700669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 701531a0095SKent Overstreet unsigned long caller_ip), 702669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 703531a0095SKent Overstreet ); 704531a0095SKent Overstreet 705531a0095SKent Overstreet DEFINE_EVENT(transaction_restart, trans_restart_journal_preres_get, 706669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 707531a0095SKent Overstreet unsigned long caller_ip), 708669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 709531a0095SKent Overstreet ); 710531a0095SKent Overstreet 711531a0095SKent Overstreet DEFINE_EVENT(transaction_restart, trans_restart_journal_reclaim, 712669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 713531a0095SKent Overstreet unsigned long caller_ip), 714669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 715531a0095SKent Overstreet ); 716531a0095SKent Overstreet 717531a0095SKent Overstreet DEFINE_EVENT(transaction_restart, trans_restart_fault_inject, 718669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 719531a0095SKent Overstreet unsigned long caller_ip), 720669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 721531a0095SKent Overstreet ); 722531a0095SKent Overstreet 723531a0095SKent Overstreet DEFINE_EVENT(transaction_restart, trans_traverse_all, 724669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 725531a0095SKent Overstreet unsigned long caller_ip), 726669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 727531a0095SKent Overstreet ); 728531a0095SKent Overstreet 729531a0095SKent Overstreet DEFINE_EVENT(transaction_restart, trans_restart_mark_replicas, 730669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 731531a0095SKent Overstreet unsigned long caller_ip), 732669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip) 733531a0095SKent Overstreet ); 734531a0095SKent Overstreet 73512ce5b7dSKent Overstreet DEFINE_EVENT(transaction_restart, trans_restart_key_cache_raced, 73612ce5b7dSKent Overstreet TP_PROTO(const char *trans_fn, 73712ce5b7dSKent Overstreet unsigned long caller_ip), 73812ce5b7dSKent Overstreet TP_ARGS(trans_fn, caller_ip) 73912ce5b7dSKent Overstreet ); 74012ce5b7dSKent Overstreet 741531a0095SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart_iter, 742669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 743531a0095SKent Overstreet unsigned long caller_ip, 744531a0095SKent Overstreet enum btree_id btree_id, 745531a0095SKent Overstreet struct bpos *pos), 746669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos), 747531a0095SKent Overstreet 748531a0095SKent Overstreet TP_STRUCT__entry( 749669f87a5SKent Overstreet __array(char, trans_fn, 24 ) 7504b59a319SKent Overstreet __field(unsigned long, caller_ip ) 751531a0095SKent Overstreet __field(u8, btree_id ) 752531a0095SKent Overstreet __field(u64, pos_inode ) 753531a0095SKent Overstreet __field(u64, pos_offset ) 754531a0095SKent Overstreet __field(u32, pos_snapshot ) 755531a0095SKent Overstreet ), 756531a0095SKent Overstreet 757531a0095SKent Overstreet TP_fast_assign( 758669f87a5SKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 7594b59a319SKent Overstreet __entry->caller_ip = caller_ip; 760531a0095SKent Overstreet __entry->btree_id = btree_id; 761531a0095SKent Overstreet __entry->pos_inode = pos->inode; 762531a0095SKent Overstreet __entry->pos_offset = pos->offset; 763531a0095SKent Overstreet __entry->pos_snapshot = pos->snapshot; 764531a0095SKent Overstreet ), 765531a0095SKent Overstreet 7664b59a319SKent Overstreet TP_printk("%s %pS btree %u pos %llu:%llu:%u", 767669f87a5SKent Overstreet __entry->trans_fn, 7684b59a319SKent Overstreet (void *) __entry->caller_ip, 769531a0095SKent Overstreet __entry->btree_id, 770531a0095SKent Overstreet __entry->pos_inode, 771531a0095SKent Overstreet __entry->pos_offset, 772531a0095SKent Overstreet __entry->pos_snapshot) 773531a0095SKent Overstreet ); 774531a0095SKent Overstreet 775531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_reused, 776669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 777531a0095SKent Overstreet unsigned long caller_ip, 778531a0095SKent Overstreet enum btree_id btree_id, 779531a0095SKent Overstreet struct bpos *pos), 780669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 781531a0095SKent Overstreet ); 782531a0095SKent Overstreet 783531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_split, 784669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 785531a0095SKent Overstreet unsigned long caller_ip, 786531a0095SKent Overstreet enum btree_id btree_id, 787531a0095SKent Overstreet struct bpos *pos), 788669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 789531a0095SKent Overstreet ); 790531a0095SKent Overstreet 791531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_upgrade, 792669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 793531a0095SKent Overstreet unsigned long caller_ip, 794531a0095SKent Overstreet enum btree_id btree_id, 795531a0095SKent Overstreet struct bpos *pos), 796669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 797531a0095SKent Overstreet ); 798531a0095SKent Overstreet 799531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_iter_upgrade, 800669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 801531a0095SKent Overstreet unsigned long caller_ip, 802531a0095SKent Overstreet enum btree_id btree_id, 803531a0095SKent Overstreet struct bpos *pos), 804669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 805531a0095SKent Overstreet ); 806531a0095SKent Overstreet 807531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock, 808669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 809531a0095SKent Overstreet unsigned long caller_ip, 810531a0095SKent Overstreet enum btree_id btree_id, 811531a0095SKent Overstreet struct bpos *pos), 812669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 813531a0095SKent Overstreet ); 814531a0095SKent Overstreet 815bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_next_node, 816bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 817bc82d08bSKent Overstreet unsigned long caller_ip, 818bc82d08bSKent Overstreet enum btree_id btree_id, 819bc82d08bSKent Overstreet struct bpos *pos), 820bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 821bc82d08bSKent Overstreet ); 822bc82d08bSKent Overstreet 823bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_parent_for_fill, 824bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 825bc82d08bSKent Overstreet unsigned long caller_ip, 826bc82d08bSKent Overstreet enum btree_id btree_id, 827bc82d08bSKent Overstreet struct bpos *pos), 828bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 829bc82d08bSKent Overstreet ); 830bc82d08bSKent Overstreet 831bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_after_fill, 832bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 833bc82d08bSKent Overstreet unsigned long caller_ip, 834bc82d08bSKent Overstreet enum btree_id btree_id, 835bc82d08bSKent Overstreet struct bpos *pos), 836bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 837bc82d08bSKent Overstreet ); 838bc82d08bSKent Overstreet 839bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_key_cache_fill, 840bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 841bc82d08bSKent Overstreet unsigned long caller_ip, 842bc82d08bSKent Overstreet enum btree_id btree_id, 843bc82d08bSKent Overstreet struct bpos *pos), 844bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 845bc82d08bSKent Overstreet ); 846bc82d08bSKent Overstreet 847bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_path, 848bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 849bc82d08bSKent Overstreet unsigned long caller_ip, 850bc82d08bSKent Overstreet enum btree_id btree_id, 851bc82d08bSKent Overstreet struct bpos *pos), 852bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 853bc82d08bSKent Overstreet ); 854bc82d08bSKent Overstreet 855bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_path_intent, 856bc82d08bSKent Overstreet TP_PROTO(const char *trans_fn, 857bc82d08bSKent Overstreet unsigned long caller_ip, 858bc82d08bSKent Overstreet enum btree_id btree_id, 859bc82d08bSKent Overstreet struct bpos *pos), 860bc82d08bSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 861bc82d08bSKent Overstreet ); 862bc82d08bSKent Overstreet 863531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_traverse, 864669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 865531a0095SKent Overstreet unsigned long caller_ip, 866531a0095SKent Overstreet enum btree_id btree_id, 867531a0095SKent Overstreet struct bpos *pos), 868669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 869531a0095SKent Overstreet ); 870531a0095SKent Overstreet 8718f9ad91aSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_memory_allocation_failure, 8728f9ad91aSKent Overstreet TP_PROTO(const char *trans_fn, 8738f9ad91aSKent Overstreet unsigned long caller_ip, 8748f9ad91aSKent Overstreet enum btree_id btree_id, 8758f9ad91aSKent Overstreet struct bpos *pos), 8768f9ad91aSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos) 8778f9ad91aSKent Overstreet ); 8788f9ad91aSKent Overstreet 879a301dc38SKent Overstreet TRACE_EVENT(trans_restart_would_deadlock, 880669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 881a301dc38SKent Overstreet unsigned long caller_ip, 8822527dd91SKent Overstreet bool in_traverse_all, 883a301dc38SKent Overstreet unsigned reason, 884a301dc38SKent Overstreet enum btree_id have_btree_id, 885a301dc38SKent Overstreet unsigned have_iter_type, 8862527dd91SKent Overstreet struct bpos *have_pos, 887a301dc38SKent Overstreet enum btree_id want_btree_id, 8882527dd91SKent Overstreet unsigned want_iter_type, 8892527dd91SKent Overstreet struct bpos *want_pos), 890669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, in_traverse_all, reason, 8912527dd91SKent Overstreet have_btree_id, have_iter_type, have_pos, 8922527dd91SKent Overstreet want_btree_id, want_iter_type, want_pos), 893a301dc38SKent Overstreet 894a301dc38SKent Overstreet TP_STRUCT__entry( 895669f87a5SKent Overstreet __array(char, trans_fn, 24 ) 896a301dc38SKent Overstreet __field(unsigned long, caller_ip ) 8972527dd91SKent Overstreet __field(u8, in_traverse_all ) 898a301dc38SKent Overstreet __field(u8, reason ) 899a301dc38SKent Overstreet __field(u8, have_btree_id ) 900a301dc38SKent Overstreet __field(u8, have_iter_type ) 901a301dc38SKent Overstreet __field(u8, want_btree_id ) 902a301dc38SKent Overstreet __field(u8, want_iter_type ) 9032527dd91SKent Overstreet 9042527dd91SKent Overstreet __field(u64, have_pos_inode ) 9052527dd91SKent Overstreet __field(u64, have_pos_offset ) 9062527dd91SKent Overstreet __field(u32, have_pos_snapshot) 9072527dd91SKent Overstreet __field(u32, want_pos_snapshot) 9082527dd91SKent Overstreet __field(u64, want_pos_inode ) 9092527dd91SKent Overstreet __field(u64, want_pos_offset ) 910a301dc38SKent Overstreet ), 911a301dc38SKent Overstreet 912a301dc38SKent Overstreet TP_fast_assign( 913669f87a5SKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 914a301dc38SKent Overstreet __entry->caller_ip = caller_ip; 9152527dd91SKent Overstreet __entry->in_traverse_all = in_traverse_all; 916a301dc38SKent Overstreet __entry->reason = reason; 917a301dc38SKent Overstreet __entry->have_btree_id = have_btree_id; 918a301dc38SKent Overstreet __entry->have_iter_type = have_iter_type; 919a301dc38SKent Overstreet __entry->want_btree_id = want_btree_id; 920a301dc38SKent Overstreet __entry->want_iter_type = want_iter_type; 9212527dd91SKent Overstreet 9222527dd91SKent Overstreet __entry->have_pos_inode = have_pos->inode; 9232527dd91SKent Overstreet __entry->have_pos_offset = have_pos->offset; 9242527dd91SKent Overstreet __entry->have_pos_snapshot = have_pos->snapshot; 9252527dd91SKent Overstreet 9262527dd91SKent Overstreet __entry->want_pos_inode = want_pos->inode; 9272527dd91SKent Overstreet __entry->want_pos_offset = want_pos->offset; 9282527dd91SKent Overstreet __entry->want_pos_snapshot = want_pos->snapshot; 929a301dc38SKent Overstreet ), 930a301dc38SKent Overstreet 931669f87a5SKent Overstreet TP_printk("%s %pS traverse_all %u because %u have %u:%u %llu:%llu:%u want %u:%u %llu:%llu:%u", 932669f87a5SKent Overstreet __entry->trans_fn, 933a301dc38SKent Overstreet (void *) __entry->caller_ip, 9342527dd91SKent Overstreet __entry->in_traverse_all, 935a301dc38SKent Overstreet __entry->reason, 936a301dc38SKent Overstreet __entry->have_btree_id, 937a301dc38SKent Overstreet __entry->have_iter_type, 9382527dd91SKent Overstreet __entry->have_pos_inode, 9392527dd91SKent Overstreet __entry->have_pos_offset, 9402527dd91SKent Overstreet __entry->have_pos_snapshot, 941a301dc38SKent Overstreet __entry->want_btree_id, 9422527dd91SKent Overstreet __entry->want_iter_type, 9432527dd91SKent Overstreet __entry->want_pos_inode, 9442527dd91SKent Overstreet __entry->want_pos_offset, 9452527dd91SKent Overstreet __entry->want_pos_snapshot) 946ba5c6557SKent Overstreet ); 947ba5c6557SKent Overstreet 948caaa66aaSKent Overstreet TRACE_EVENT(trans_restart_would_deadlock_write, 949669f87a5SKent Overstreet TP_PROTO(const char *trans_fn), 950669f87a5SKent Overstreet TP_ARGS(trans_fn), 951caaa66aaSKent Overstreet 952caaa66aaSKent Overstreet TP_STRUCT__entry( 953669f87a5SKent Overstreet __array(char, trans_fn, 24 ) 954caaa66aaSKent Overstreet ), 955caaa66aaSKent Overstreet 956caaa66aaSKent Overstreet TP_fast_assign( 957669f87a5SKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 958caaa66aaSKent Overstreet ), 959caaa66aaSKent Overstreet 960669f87a5SKent Overstreet TP_printk("%s", __entry->trans_fn) 961caaa66aaSKent Overstreet ); 962caaa66aaSKent Overstreet 96320bceecbSKent Overstreet TRACE_EVENT(trans_restart_mem_realloced, 964669f87a5SKent Overstreet TP_PROTO(const char *trans_fn, 965669f87a5SKent Overstreet unsigned long caller_ip, 96673a117d2SKent Overstreet unsigned long bytes), 967669f87a5SKent Overstreet TP_ARGS(trans_fn, caller_ip, bytes), 96820bceecbSKent Overstreet 96920bceecbSKent Overstreet TP_STRUCT__entry( 970669f87a5SKent Overstreet __array(char, trans_fn, 24 ) 97173a117d2SKent Overstreet __field(unsigned long, caller_ip ) 97220bceecbSKent Overstreet __field(unsigned long, bytes ) 97320bceecbSKent Overstreet ), 97420bceecbSKent Overstreet 97520bceecbSKent Overstreet TP_fast_assign( 976669f87a5SKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 97773a117d2SKent Overstreet __entry->caller_ip = caller_ip; 97820bceecbSKent Overstreet __entry->bytes = bytes; 97920bceecbSKent Overstreet ), 98020bceecbSKent Overstreet 981669f87a5SKent Overstreet TP_printk("%s %pS bytes %lu", 982669f87a5SKent Overstreet __entry->trans_fn, 98373a117d2SKent Overstreet (void *) __entry->caller_ip, 98473a117d2SKent Overstreet __entry->bytes) 985ba5c6557SKent Overstreet ); 986ba5c6557SKent Overstreet 9873a306f3cSKent Overstreet TRACE_EVENT(trans_restart_key_cache_key_realloced, 988ddf11d8cSKent Overstreet TP_PROTO(const char *trans_fn, 989ddf11d8cSKent Overstreet unsigned long caller_ip, 990ddf11d8cSKent Overstreet enum btree_id btree_id, 9913a306f3cSKent Overstreet struct bpos *pos, 9923a306f3cSKent Overstreet unsigned old_u64s, 9933a306f3cSKent Overstreet unsigned new_u64s), 9943a306f3cSKent Overstreet TP_ARGS(trans_fn, caller_ip, btree_id, pos, old_u64s, new_u64s), 9953a306f3cSKent Overstreet 9963a306f3cSKent Overstreet TP_STRUCT__entry( 9973a306f3cSKent Overstreet __array(char, trans_fn, 24 ) 9983a306f3cSKent Overstreet __field(unsigned long, caller_ip ) 9993a306f3cSKent Overstreet __field(enum btree_id, btree_id ) 10003a306f3cSKent Overstreet __field(u64, inode ) 10013a306f3cSKent Overstreet __field(u64, offset ) 10023a306f3cSKent Overstreet __field(u32, snapshot ) 10033a306f3cSKent Overstreet __field(u32, old_u64s ) 10043a306f3cSKent Overstreet __field(u32, new_u64s ) 10053a306f3cSKent Overstreet ), 10063a306f3cSKent Overstreet 10073a306f3cSKent Overstreet TP_fast_assign( 10083a306f3cSKent Overstreet strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 10093a306f3cSKent Overstreet __entry->caller_ip = caller_ip; 10103a306f3cSKent Overstreet __entry->btree_id = btree_id; 10113a306f3cSKent Overstreet __entry->inode = pos->inode; 10123a306f3cSKent Overstreet __entry->offset = pos->offset; 10133a306f3cSKent Overstreet __entry->snapshot = pos->snapshot; 10143a306f3cSKent Overstreet __entry->old_u64s = old_u64s; 10153a306f3cSKent Overstreet __entry->new_u64s = new_u64s; 10163a306f3cSKent Overstreet ), 10173a306f3cSKent Overstreet 10183a306f3cSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u old_u64s %u new_u64s %u", 10193a306f3cSKent Overstreet __entry->trans_fn, 10203a306f3cSKent Overstreet (void *) __entry->caller_ip, 10213a306f3cSKent Overstreet bch2_btree_ids[__entry->btree_id], 10223a306f3cSKent Overstreet __entry->inode, 10233a306f3cSKent Overstreet __entry->offset, 10243a306f3cSKent Overstreet __entry->snapshot, 10253a306f3cSKent Overstreet __entry->old_u64s, 10263a306f3cSKent Overstreet __entry->new_u64s) 1027ddf11d8cSKent Overstreet ); 1028ddf11d8cSKent Overstreet 10291c6fdbd8SKent Overstreet #endif /* _TRACE_BCACHEFS_H */ 10301c6fdbd8SKent Overstreet 10311c6fdbd8SKent Overstreet /* This part must be outside protection */ 10321c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_PATH 10331c6fdbd8SKent Overstreet #define TRACE_INCLUDE_PATH ../../fs/bcachefs 10341c6fdbd8SKent Overstreet 10351c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_FILE 10361c6fdbd8SKent Overstreet #define TRACE_INCLUDE_FILE trace 10371c6fdbd8SKent Overstreet 10381c6fdbd8SKent Overstreet #include <trace/define_trace.h> 1039