11c6fdbd8SKent Overstreet /* SPDX-License-Identifier: GPL-2.0 */ 21c6fdbd8SKent Overstreet #undef TRACE_SYSTEM 31c6fdbd8SKent Overstreet #define TRACE_SYSTEM bcachefs 41c6fdbd8SKent Overstreet 51c6fdbd8SKent Overstreet #if !defined(_TRACE_BCACHEFS_H) || defined(TRACE_HEADER_MULTI_READ) 61c6fdbd8SKent Overstreet #define _TRACE_BCACHEFS_H 71c6fdbd8SKent Overstreet 81c6fdbd8SKent Overstreet #include <linux/tracepoint.h> 91c6fdbd8SKent Overstreet 109f96568cSKent Overstreet #define TRACE_BPOS_entries(name) \ 119f96568cSKent Overstreet __field(u64, name##_inode ) \ 129f96568cSKent Overstreet __field(u64, name##_offset ) \ 139f96568cSKent Overstreet __field(u32, name##_snapshot ) 149f96568cSKent Overstreet 159f96568cSKent Overstreet #define TRACE_BPOS_assign(dst, src) \ 169f96568cSKent Overstreet __entry->dst##_inode = (src).inode; \ 179f96568cSKent Overstreet __entry->dst##_offset = (src).offset; \ 189f96568cSKent Overstreet __entry->dst##_snapshot = (src).snapshot 199f96568cSKent Overstreet 201c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bpos, 2112043cf1SKent Overstreet TP_PROTO(const struct bpos *p), 221c6fdbd8SKent Overstreet TP_ARGS(p), 231c6fdbd8SKent Overstreet 241c6fdbd8SKent Overstreet TP_STRUCT__entry( 259f96568cSKent Overstreet TRACE_BPOS_entries(p) 261c6fdbd8SKent Overstreet ), 271c6fdbd8SKent Overstreet 281c6fdbd8SKent Overstreet TP_fast_assign( 299f96568cSKent Overstreet TRACE_BPOS_assign(p, *p); 301c6fdbd8SKent Overstreet ), 311c6fdbd8SKent Overstreet 329f96568cSKent Overstreet TP_printk("%llu:%llu:%u", __entry->p_inode, __entry->p_offset, __entry->p_snapshot) 331c6fdbd8SKent Overstreet ); 341c6fdbd8SKent Overstreet 351c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bkey, 361c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 371c6fdbd8SKent Overstreet TP_ARGS(k), 381c6fdbd8SKent Overstreet 391c6fdbd8SKent Overstreet TP_STRUCT__entry( 401c6fdbd8SKent Overstreet __field(u64, inode ) 411c6fdbd8SKent Overstreet __field(u64, offset ) 421c6fdbd8SKent Overstreet __field(u32, size ) 431c6fdbd8SKent Overstreet ), 441c6fdbd8SKent Overstreet 451c6fdbd8SKent Overstreet TP_fast_assign( 461c6fdbd8SKent Overstreet __entry->inode = k->p.inode; 471c6fdbd8SKent Overstreet __entry->offset = k->p.offset; 481c6fdbd8SKent Overstreet __entry->size = k->size; 491c6fdbd8SKent Overstreet ), 501c6fdbd8SKent Overstreet 511c6fdbd8SKent Overstreet TP_printk("%llu:%llu len %u", __entry->inode, 521c6fdbd8SKent Overstreet __entry->offset, __entry->size) 531c6fdbd8SKent Overstreet ); 541c6fdbd8SKent Overstreet 55674cfc26SKent Overstreet DECLARE_EVENT_CLASS(btree_node, 56674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 57674cfc26SKent Overstreet TP_ARGS(c, b), 58674cfc26SKent Overstreet 59674cfc26SKent Overstreet TP_STRUCT__entry( 60674cfc26SKent Overstreet __field(dev_t, dev ) 61674cfc26SKent Overstreet __field(u8, level ) 62674cfc26SKent Overstreet __field(u8, btree_id ) 63674cfc26SKent Overstreet TRACE_BPOS_entries(pos) 64674cfc26SKent Overstreet ), 65674cfc26SKent Overstreet 66674cfc26SKent Overstreet TP_fast_assign( 67674cfc26SKent Overstreet __entry->dev = c->dev; 68674cfc26SKent Overstreet __entry->level = b->c.level; 69674cfc26SKent Overstreet __entry->btree_id = b->c.btree_id; 70674cfc26SKent Overstreet TRACE_BPOS_assign(pos, b->key.k.p); 71674cfc26SKent Overstreet ), 72674cfc26SKent Overstreet 73674cfc26SKent Overstreet TP_printk("%d,%d %u %s %llu:%llu:%u", 74674cfc26SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 75674cfc26SKent Overstreet __entry->level, 76674cfc26SKent Overstreet bch2_btree_ids[__entry->btree_id], 77674cfc26SKent Overstreet __entry->pos_inode, __entry->pos_offset, __entry->pos_snapshot) 78674cfc26SKent Overstreet ); 79674cfc26SKent Overstreet 801c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bch_fs, 811c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 821c6fdbd8SKent Overstreet TP_ARGS(c), 831c6fdbd8SKent Overstreet 841c6fdbd8SKent Overstreet TP_STRUCT__entry( 85ddc7dd62SKent Overstreet __field(dev_t, dev ) 861c6fdbd8SKent Overstreet ), 871c6fdbd8SKent Overstreet 881c6fdbd8SKent Overstreet TP_fast_assign( 89ddc7dd62SKent Overstreet __entry->dev = c->dev; 901c6fdbd8SKent Overstreet ), 911c6fdbd8SKent Overstreet 92ddc7dd62SKent Overstreet TP_printk("%d,%d", MAJOR(__entry->dev), MINOR(__entry->dev)) 931c6fdbd8SKent Overstreet ); 941c6fdbd8SKent Overstreet 951c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bio, 961c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 971c6fdbd8SKent Overstreet TP_ARGS(bio), 981c6fdbd8SKent Overstreet 991c6fdbd8SKent Overstreet TP_STRUCT__entry( 1001c6fdbd8SKent Overstreet __field(dev_t, dev ) 1011c6fdbd8SKent Overstreet __field(sector_t, sector ) 1021c6fdbd8SKent Overstreet __field(unsigned int, nr_sector ) 1031c6fdbd8SKent Overstreet __array(char, rwbs, 6 ) 1041c6fdbd8SKent Overstreet ), 1051c6fdbd8SKent Overstreet 1061c6fdbd8SKent Overstreet TP_fast_assign( 1071c6fdbd8SKent Overstreet __entry->dev = bio->bi_bdev ? bio_dev(bio) : 0; 1081c6fdbd8SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 1091c6fdbd8SKent Overstreet __entry->nr_sector = bio->bi_iter.bi_size >> 9; 1101c6fdbd8SKent Overstreet blk_fill_rwbs(__entry->rwbs, bio->bi_opf); 1111c6fdbd8SKent Overstreet ), 1121c6fdbd8SKent Overstreet 1131c6fdbd8SKent Overstreet TP_printk("%d,%d %s %llu + %u", 1141c6fdbd8SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 1151c6fdbd8SKent Overstreet (unsigned long long)__entry->sector, __entry->nr_sector) 1161c6fdbd8SKent Overstreet ); 1171c6fdbd8SKent Overstreet 1184254f5bfSKent Overstreet /* super-io.c: */ 1194254f5bfSKent Overstreet TRACE_EVENT(write_super, 1204254f5bfSKent Overstreet TP_PROTO(struct bch_fs *c, unsigned long ip), 1214254f5bfSKent Overstreet TP_ARGS(c, ip), 1224254f5bfSKent Overstreet 1234254f5bfSKent Overstreet TP_STRUCT__entry( 1244254f5bfSKent Overstreet __field(dev_t, dev ) 1254254f5bfSKent Overstreet __field(unsigned long, ip ) 1264254f5bfSKent Overstreet ), 1274254f5bfSKent Overstreet 1284254f5bfSKent Overstreet TP_fast_assign( 1294254f5bfSKent Overstreet __entry->dev = c->dev; 1304254f5bfSKent Overstreet __entry->ip = ip; 1314254f5bfSKent Overstreet ), 1324254f5bfSKent Overstreet 1334254f5bfSKent Overstreet TP_printk("%d,%d for %pS", 1344254f5bfSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 1354254f5bfSKent Overstreet (void *) __entry->ip) 1364254f5bfSKent Overstreet ); 1374254f5bfSKent Overstreet 1381c6fdbd8SKent Overstreet /* io.c: */ 1391c6fdbd8SKent Overstreet 140674cfc26SKent Overstreet DEFINE_EVENT(bio, read_promote, 1411c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1421c6fdbd8SKent Overstreet TP_ARGS(bio) 1431c6fdbd8SKent Overstreet ); 1441c6fdbd8SKent Overstreet 1451c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_bounce, 1461c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1471c6fdbd8SKent Overstreet TP_ARGS(bio) 1481c6fdbd8SKent Overstreet ); 1491c6fdbd8SKent Overstreet 150674cfc26SKent Overstreet DEFINE_EVENT(bio, read_split, 151674cfc26SKent Overstreet TP_PROTO(struct bio *bio), 152674cfc26SKent Overstreet TP_ARGS(bio) 153674cfc26SKent Overstreet ); 154674cfc26SKent Overstreet 1551c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_retry, 1561c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1571c6fdbd8SKent Overstreet TP_ARGS(bio) 1581c6fdbd8SKent Overstreet ); 1591c6fdbd8SKent Overstreet 160674cfc26SKent Overstreet DEFINE_EVENT(bio, read_reuse_race, 1611c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1621c6fdbd8SKent Overstreet TP_ARGS(bio) 1631c6fdbd8SKent Overstreet ); 1641c6fdbd8SKent Overstreet 1651c6fdbd8SKent Overstreet /* Journal */ 1661c6fdbd8SKent Overstreet 1671c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_full, 1681c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 1691c6fdbd8SKent Overstreet TP_ARGS(c) 1701c6fdbd8SKent Overstreet ); 1711c6fdbd8SKent Overstreet 1721c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_entry_full, 1731c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 1741c6fdbd8SKent Overstreet TP_ARGS(c) 1751c6fdbd8SKent Overstreet ); 1761c6fdbd8SKent Overstreet 1771c6fdbd8SKent Overstreet DEFINE_EVENT(bio, journal_write, 1781c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1791c6fdbd8SKent Overstreet TP_ARGS(bio) 1801c6fdbd8SKent Overstreet ); 1811c6fdbd8SKent Overstreet 1828a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_start, 1831f93726eSKent Overstreet TP_PROTO(struct bch_fs *c, bool direct, bool kicked, 1841f93726eSKent Overstreet u64 min_nr, u64 min_key_cache, 1858a92e545SKent Overstreet u64 prereserved, u64 prereserved_total, 1868a92e545SKent Overstreet u64 btree_cache_dirty, u64 btree_cache_total, 1878a92e545SKent Overstreet u64 btree_key_cache_dirty, u64 btree_key_cache_total), 1881f93726eSKent Overstreet TP_ARGS(c, direct, kicked, min_nr, min_key_cache, prereserved, prereserved_total, 1898a92e545SKent Overstreet btree_cache_dirty, btree_cache_total, 1908a92e545SKent Overstreet btree_key_cache_dirty, btree_key_cache_total), 1918a92e545SKent Overstreet 1928a92e545SKent Overstreet TP_STRUCT__entry( 193ddc7dd62SKent Overstreet __field(dev_t, dev ) 1941f93726eSKent Overstreet __field(bool, direct ) 1951f93726eSKent Overstreet __field(bool, kicked ) 1968a92e545SKent Overstreet __field(u64, min_nr ) 1971f93726eSKent Overstreet __field(u64, min_key_cache ) 1988a92e545SKent Overstreet __field(u64, prereserved ) 1998a92e545SKent Overstreet __field(u64, prereserved_total ) 2008a92e545SKent Overstreet __field(u64, btree_cache_dirty ) 2018a92e545SKent Overstreet __field(u64, btree_cache_total ) 2028a92e545SKent Overstreet __field(u64, btree_key_cache_dirty ) 2038a92e545SKent Overstreet __field(u64, btree_key_cache_total ) 2048a92e545SKent Overstreet ), 2058a92e545SKent Overstreet 2068a92e545SKent Overstreet TP_fast_assign( 207ddc7dd62SKent Overstreet __entry->dev = c->dev; 2081f93726eSKent Overstreet __entry->direct = direct; 2091f93726eSKent Overstreet __entry->kicked = kicked; 2108a92e545SKent Overstreet __entry->min_nr = min_nr; 2111f93726eSKent Overstreet __entry->min_key_cache = min_key_cache; 2128a92e545SKent Overstreet __entry->prereserved = prereserved; 2138a92e545SKent Overstreet __entry->prereserved_total = prereserved_total; 2148a92e545SKent Overstreet __entry->btree_cache_dirty = btree_cache_dirty; 2158a92e545SKent Overstreet __entry->btree_cache_total = btree_cache_total; 2168a92e545SKent Overstreet __entry->btree_key_cache_dirty = btree_key_cache_dirty; 2178a92e545SKent Overstreet __entry->btree_key_cache_total = btree_key_cache_total; 2188a92e545SKent Overstreet ), 2198a92e545SKent Overstreet 2201f93726eSKent Overstreet TP_printk("%d,%d direct %u kicked %u min %llu key cache %llu prereserved %llu/%llu btree cache %llu/%llu key cache %llu/%llu", 221ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 2221f93726eSKent Overstreet __entry->direct, 2231f93726eSKent Overstreet __entry->kicked, 2248a92e545SKent Overstreet __entry->min_nr, 2251f93726eSKent Overstreet __entry->min_key_cache, 2268a92e545SKent Overstreet __entry->prereserved, 2278a92e545SKent Overstreet __entry->prereserved_total, 2288a92e545SKent Overstreet __entry->btree_cache_dirty, 2298a92e545SKent Overstreet __entry->btree_cache_total, 2308a92e545SKent Overstreet __entry->btree_key_cache_dirty, 2318a92e545SKent Overstreet __entry->btree_key_cache_total) 2328a92e545SKent Overstreet ); 2338a92e545SKent Overstreet 2348a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_finish, 2358a92e545SKent Overstreet TP_PROTO(struct bch_fs *c, u64 nr_flushed), 2368a92e545SKent Overstreet TP_ARGS(c, nr_flushed), 2378a92e545SKent Overstreet 2388a92e545SKent Overstreet TP_STRUCT__entry( 239ddc7dd62SKent Overstreet __field(dev_t, dev ) 2408a92e545SKent Overstreet __field(u64, nr_flushed ) 2418a92e545SKent Overstreet ), 2428a92e545SKent Overstreet 2438a92e545SKent Overstreet TP_fast_assign( 244ddc7dd62SKent Overstreet __entry->dev = c->dev; 2458a92e545SKent Overstreet __entry->nr_flushed = nr_flushed; 2468a92e545SKent Overstreet ), 2478a92e545SKent Overstreet 2481f93726eSKent Overstreet TP_printk("%d,%d flushed %llu", 249ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 250ddc7dd62SKent Overstreet __entry->nr_flushed) 2518a92e545SKent Overstreet ); 2528a92e545SKent Overstreet 2531c6fdbd8SKent Overstreet /* bset.c: */ 2541c6fdbd8SKent Overstreet 2551c6fdbd8SKent Overstreet DEFINE_EVENT(bpos, bkey_pack_pos_fail, 25612043cf1SKent Overstreet TP_PROTO(const struct bpos *p), 2571c6fdbd8SKent Overstreet TP_ARGS(p) 2581c6fdbd8SKent Overstreet ); 2591c6fdbd8SKent Overstreet 260674cfc26SKent Overstreet /* Btree cache: */ 2611c6fdbd8SKent Overstreet 262674cfc26SKent Overstreet TRACE_EVENT(btree_cache_scan, 263674cfc26SKent Overstreet TP_PROTO(long nr_to_scan, long can_free, long ret), 264674cfc26SKent Overstreet TP_ARGS(nr_to_scan, can_free, ret), 2651c6fdbd8SKent Overstreet 2661c6fdbd8SKent Overstreet TP_STRUCT__entry( 267674cfc26SKent Overstreet __field(long, nr_to_scan ) 268674cfc26SKent Overstreet __field(long, can_free ) 269674cfc26SKent Overstreet __field(long, ret ) 2701c6fdbd8SKent Overstreet ), 2711c6fdbd8SKent Overstreet 2721c6fdbd8SKent Overstreet TP_fast_assign( 273674cfc26SKent Overstreet __entry->nr_to_scan = nr_to_scan; 274674cfc26SKent Overstreet __entry->can_free = can_free; 275674cfc26SKent Overstreet __entry->ret = ret; 2761c6fdbd8SKent Overstreet ), 2771c6fdbd8SKent Overstreet 278674cfc26SKent Overstreet TP_printk("scanned for %li nodes, can free %li, ret %li", 279674cfc26SKent Overstreet __entry->nr_to_scan, __entry->can_free, __entry->ret) 2801c6fdbd8SKent Overstreet ); 2811c6fdbd8SKent Overstreet 282674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_cache_reap, 2831c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 2841c6fdbd8SKent Overstreet TP_ARGS(c, b) 2851c6fdbd8SKent Overstreet ); 2861c6fdbd8SKent Overstreet 287674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_lock_fail, 288674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 289674cfc26SKent Overstreet TP_ARGS(c) 290674cfc26SKent Overstreet ); 291674cfc26SKent Overstreet 292674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_lock, 293674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 294674cfc26SKent Overstreet TP_ARGS(c) 295674cfc26SKent Overstreet ); 296674cfc26SKent Overstreet 297674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize, 298674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 299674cfc26SKent Overstreet TP_ARGS(c) 300674cfc26SKent Overstreet ); 301674cfc26SKent Overstreet 302674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_unlock, 303674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 304674cfc26SKent Overstreet TP_ARGS(c) 305674cfc26SKent Overstreet ); 306674cfc26SKent Overstreet 307674cfc26SKent Overstreet /* Btree */ 308674cfc26SKent Overstreet 309674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_read, 310674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 311674cfc26SKent Overstreet TP_ARGS(c, b) 312674cfc26SKent Overstreet ); 313674cfc26SKent Overstreet 314674cfc26SKent Overstreet TRACE_EVENT(btree_node_write, 3151c6fdbd8SKent Overstreet TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors), 3161c6fdbd8SKent Overstreet TP_ARGS(b, bytes, sectors), 3171c6fdbd8SKent Overstreet 3181c6fdbd8SKent Overstreet TP_STRUCT__entry( 31926609b61SKent Overstreet __field(enum btree_node_type, type) 3201c6fdbd8SKent Overstreet __field(unsigned, bytes ) 3211c6fdbd8SKent Overstreet __field(unsigned, sectors ) 3221c6fdbd8SKent Overstreet ), 3231c6fdbd8SKent Overstreet 3241c6fdbd8SKent Overstreet TP_fast_assign( 3251c6fdbd8SKent Overstreet __entry->type = btree_node_type(b); 3261c6fdbd8SKent Overstreet __entry->bytes = bytes; 3271c6fdbd8SKent Overstreet __entry->sectors = sectors; 3281c6fdbd8SKent Overstreet ), 3291c6fdbd8SKent Overstreet 3301c6fdbd8SKent Overstreet TP_printk("bkey type %u bytes %u sectors %u", 3311c6fdbd8SKent Overstreet __entry->type , __entry->bytes, __entry->sectors) 3321c6fdbd8SKent Overstreet ); 3331c6fdbd8SKent Overstreet 3341c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_alloc, 3351c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3361c6fdbd8SKent Overstreet TP_ARGS(c, b) 3371c6fdbd8SKent Overstreet ); 3381c6fdbd8SKent Overstreet 3391c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_free, 3401c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3411c6fdbd8SKent Overstreet TP_ARGS(c, b) 3421c6fdbd8SKent Overstreet ); 3431c6fdbd8SKent Overstreet 3441c6fdbd8SKent Overstreet TRACE_EVENT(btree_reserve_get_fail, 3455f417394SKent Overstreet TP_PROTO(const char *trans_fn, 3465f417394SKent Overstreet unsigned long caller_ip, 347adf6360bSKent Overstreet size_t required, 348adf6360bSKent Overstreet int ret), 349adf6360bSKent Overstreet TP_ARGS(trans_fn, caller_ip, required, ret), 3501c6fdbd8SKent Overstreet 3511c6fdbd8SKent Overstreet TP_STRUCT__entry( 3525f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 3535f417394SKent Overstreet __field(unsigned long, caller_ip ) 3541c6fdbd8SKent Overstreet __field(size_t, required ) 355adf6360bSKent Overstreet __array(char, ret, 32 ) 3561c6fdbd8SKent Overstreet ), 3571c6fdbd8SKent Overstreet 3581c6fdbd8SKent Overstreet TP_fast_assign( 359a1019576SKent Overstreet strscpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 3605f417394SKent Overstreet __entry->caller_ip = caller_ip; 3611c6fdbd8SKent Overstreet __entry->required = required; 362adf6360bSKent Overstreet strscpy(__entry->ret, bch2_err_str(ret), sizeof(__entry->ret)); 3631c6fdbd8SKent Overstreet ), 3641c6fdbd8SKent Overstreet 365adf6360bSKent Overstreet TP_printk("%s %pS required %zu ret %s", 3665f417394SKent Overstreet __entry->trans_fn, 3675f417394SKent Overstreet (void *) __entry->caller_ip, 368adf6360bSKent Overstreet __entry->required, 369adf6360bSKent Overstreet __entry->ret) 3701c6fdbd8SKent Overstreet ); 3711c6fdbd8SKent Overstreet 372674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_compact, 3731c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3741c6fdbd8SKent Overstreet TP_ARGS(c, b) 3751c6fdbd8SKent Overstreet ); 3761c6fdbd8SKent Overstreet 377674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_merge, 3781c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3791c6fdbd8SKent Overstreet TP_ARGS(c, b) 3801c6fdbd8SKent Overstreet ); 3811c6fdbd8SKent Overstreet 382674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_split, 3831c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3841c6fdbd8SKent Overstreet TP_ARGS(c, b) 3851c6fdbd8SKent Overstreet ); 3861c6fdbd8SKent Overstreet 387674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_rewrite, 3881f93726eSKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3891f93726eSKent Overstreet TP_ARGS(c, b) 3901f93726eSKent Overstreet ); 3911f93726eSKent Overstreet 392674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_set_root, 3931c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3941c6fdbd8SKent Overstreet TP_ARGS(c, b) 3951c6fdbd8SKent Overstreet ); 3961c6fdbd8SKent Overstreet 397674cfc26SKent Overstreet TRACE_EVENT(btree_path_relock_fail, 3989f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 399bc82d08bSKent Overstreet unsigned long caller_ip, 4009f96568cSKent Overstreet struct btree_path *path, 4019f96568cSKent Overstreet unsigned level), 4029f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path, level), 403bc82d08bSKent Overstreet 404bc82d08bSKent Overstreet TP_STRUCT__entry( 4055f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 4064b59a319SKent Overstreet __field(unsigned long, caller_ip ) 407bc82d08bSKent Overstreet __field(u8, btree_id ) 408367d72ddSKent Overstreet __field(u8, level ) 4099f96568cSKent Overstreet TRACE_BPOS_entries(pos) 4105f1dd9a6SKent Overstreet __array(char, node, 24 ) 411bc82d08bSKent Overstreet __field(u32, iter_lock_seq ) 412bc82d08bSKent Overstreet __field(u32, node_lock_seq ) 413bc82d08bSKent Overstreet ), 414bc82d08bSKent Overstreet 415bc82d08bSKent Overstreet TP_fast_assign( 4165f1dd9a6SKent Overstreet struct btree *b = btree_path_node(path, level); 4175f1dd9a6SKent Overstreet 418a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 4194b59a319SKent Overstreet __entry->caller_ip = caller_ip; 4209f96568cSKent Overstreet __entry->btree_id = path->btree_id; 421367d72ddSKent Overstreet __entry->level = path->level; 4229f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 4235f1dd9a6SKent Overstreet if (IS_ERR(b)) 4245f1dd9a6SKent Overstreet strscpy(__entry->node, bch2_err_str(PTR_ERR(b)), sizeof(__entry->node)); 4255f1dd9a6SKent Overstreet else 4265f1dd9a6SKent Overstreet scnprintf(__entry->node, sizeof(__entry->node), "%px", b); 4279f96568cSKent Overstreet __entry->iter_lock_seq = path->l[level].lock_seq; 4289f96568cSKent Overstreet __entry->node_lock_seq = is_btree_node(path, level) ? path->l[level].b->c.lock.state.seq : 0; 429bc82d08bSKent Overstreet ), 430bc82d08bSKent Overstreet 431367d72ddSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u level %u node %s iter seq %u lock seq %u", 432bc82d08bSKent Overstreet __entry->trans_fn, 4334b59a319SKent Overstreet (void *) __entry->caller_ip, 4349f96568cSKent Overstreet bch2_btree_ids[__entry->btree_id], 435bc82d08bSKent Overstreet __entry->pos_inode, 436bc82d08bSKent Overstreet __entry->pos_offset, 437bc82d08bSKent Overstreet __entry->pos_snapshot, 438367d72ddSKent Overstreet __entry->level, 439bc82d08bSKent Overstreet __entry->node, 440bc82d08bSKent Overstreet __entry->iter_lock_seq, 441bc82d08bSKent Overstreet __entry->node_lock_seq) 442bc82d08bSKent Overstreet ); 443bc82d08bSKent Overstreet 444674cfc26SKent Overstreet TRACE_EVENT(btree_path_upgrade_fail, 4459f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 44649e401faSKent Overstreet unsigned long caller_ip, 4479f96568cSKent Overstreet struct btree_path *path, 4489f96568cSKent Overstreet unsigned level), 4499f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path, level), 45049e401faSKent Overstreet 45149e401faSKent Overstreet TP_STRUCT__entry( 4525f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 45349e401faSKent Overstreet __field(unsigned long, caller_ip ) 45449e401faSKent Overstreet __field(u8, btree_id ) 455367d72ddSKent Overstreet __field(u8, level ) 4569f96568cSKent Overstreet TRACE_BPOS_entries(pos) 45749e401faSKent Overstreet __field(u8, locked ) 45849e401faSKent Overstreet __field(u8, self_read_count ) 45949e401faSKent Overstreet __field(u8, self_intent_count) 4609f96568cSKent Overstreet __field(u8, read_count ) 46149e401faSKent Overstreet __field(u8, intent_count ) 462367d72ddSKent Overstreet __field(u32, iter_lock_seq ) 463367d72ddSKent Overstreet __field(u32, node_lock_seq ) 46449e401faSKent Overstreet ), 46549e401faSKent Overstreet 46649e401faSKent Overstreet TP_fast_assign( 4679f96568cSKent Overstreet struct six_lock_count c; 4689f96568cSKent Overstreet 469a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 47049e401faSKent Overstreet __entry->caller_ip = caller_ip; 4719f96568cSKent Overstreet __entry->btree_id = path->btree_id; 472367d72ddSKent Overstreet __entry->level = level; 4739f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 4749f96568cSKent Overstreet __entry->locked = btree_node_locked(path, level); 4759f96568cSKent Overstreet 47614599cceSKent Overstreet c = bch2_btree_node_lock_counts(trans, NULL, &path->l[level].b->c, level), 477e3738c69SKent Overstreet __entry->self_read_count = c.n[SIX_LOCK_read]; 478e3738c69SKent Overstreet __entry->self_intent_count = c.n[SIX_LOCK_intent]; 4799f96568cSKent Overstreet c = six_lock_counts(&path->l[level].b->c.lock); 480e3738c69SKent Overstreet __entry->read_count = c.n[SIX_LOCK_read]; 481e3738c69SKent Overstreet __entry->intent_count = c.n[SIX_LOCK_read]; 482367d72ddSKent Overstreet __entry->iter_lock_seq = path->l[level].lock_seq; 483367d72ddSKent Overstreet __entry->node_lock_seq = is_btree_node(path, level) ? path->l[level].b->c.lock.state.seq : 0; 48449e401faSKent Overstreet ), 48549e401faSKent Overstreet 486367d72ddSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u level %u locked %u held %u:%u lock count %u:%u iter seq %u lock seq %u", 48749e401faSKent Overstreet __entry->trans_fn, 48849e401faSKent Overstreet (void *) __entry->caller_ip, 4899f96568cSKent Overstreet bch2_btree_ids[__entry->btree_id], 49049e401faSKent Overstreet __entry->pos_inode, 49149e401faSKent Overstreet __entry->pos_offset, 49249e401faSKent Overstreet __entry->pos_snapshot, 493367d72ddSKent Overstreet __entry->level, 49449e401faSKent Overstreet __entry->locked, 49549e401faSKent Overstreet __entry->self_read_count, 49649e401faSKent Overstreet __entry->self_intent_count, 49749e401faSKent Overstreet __entry->read_count, 498367d72ddSKent Overstreet __entry->intent_count, 499367d72ddSKent Overstreet __entry->iter_lock_seq, 500367d72ddSKent Overstreet __entry->node_lock_seq) 50149e401faSKent Overstreet ); 50249e401faSKent Overstreet 5031c6fdbd8SKent Overstreet /* Garbage collection */ 5041c6fdbd8SKent Overstreet 5051f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_start, 5061c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 5071c6fdbd8SKent Overstreet TP_ARGS(c) 5081c6fdbd8SKent Overstreet ); 5091c6fdbd8SKent Overstreet 5101f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_end, 5111c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 5121c6fdbd8SKent Overstreet TP_ARGS(c) 5131c6fdbd8SKent Overstreet ); 5141c6fdbd8SKent Overstreet 5151c6fdbd8SKent Overstreet /* Allocator */ 5161c6fdbd8SKent Overstreet 5171c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bucket_alloc, 518f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 51968b6cd19SKent Overstreet u64 bucket, 5208ef98313SKent Overstreet u64 free, 521f25d8215SKent Overstreet u64 avail, 5228ef98313SKent Overstreet u64 copygc_wait_amount, 5238ef98313SKent Overstreet s64 copygc_waiting_for, 524ae10fe01SKent Overstreet struct bucket_alloc_state *s, 525f25d8215SKent Overstreet bool nonblocking, 526615f867cSKent Overstreet const char *err), 5277635e1a6SKent Overstreet TP_ARGS(ca, alloc_reserve, bucket, free, avail, 52868b6cd19SKent Overstreet copygc_wait_amount, copygc_waiting_for, 529ae10fe01SKent Overstreet s, nonblocking, err), 5301c6fdbd8SKent Overstreet 5311c6fdbd8SKent Overstreet TP_STRUCT__entry( 5321a14e255SKent Overstreet __field(u8, dev ) 5333e154711SKent Overstreet __array(char, reserve, 16 ) 53468b6cd19SKent Overstreet __field(u64, bucket ) 5358ef98313SKent Overstreet __field(u64, free ) 536f25d8215SKent Overstreet __field(u64, avail ) 5378ef98313SKent Overstreet __field(u64, copygc_wait_amount ) 5388ef98313SKent Overstreet __field(s64, copygc_waiting_for ) 539f25d8215SKent Overstreet __field(u64, seen ) 540f25d8215SKent Overstreet __field(u64, open ) 541f25d8215SKent Overstreet __field(u64, need_journal_commit ) 542f25d8215SKent Overstreet __field(u64, nouse ) 543f25d8215SKent Overstreet __field(bool, nonblocking ) 544a8b3a677SKent Overstreet __field(u64, nocow ) 54568b6cd19SKent Overstreet __array(char, err, 32 ) 5461c6fdbd8SKent Overstreet ), 5471c6fdbd8SKent Overstreet 5481c6fdbd8SKent Overstreet TP_fast_assign( 5491a14e255SKent Overstreet __entry->dev = ca->dev_idx; 550a1019576SKent Overstreet strscpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); 55168b6cd19SKent Overstreet __entry->bucket = bucket; 5528ef98313SKent Overstreet __entry->free = free; 553f25d8215SKent Overstreet __entry->avail = avail; 5548ef98313SKent Overstreet __entry->copygc_wait_amount = copygc_wait_amount; 5558ef98313SKent Overstreet __entry->copygc_waiting_for = copygc_waiting_for; 556ae10fe01SKent Overstreet __entry->seen = s->buckets_seen; 557ae10fe01SKent Overstreet __entry->open = s->skipped_open; 558ae10fe01SKent Overstreet __entry->need_journal_commit = s->skipped_need_journal_commit; 559ae10fe01SKent Overstreet __entry->nouse = s->skipped_nouse; 560f25d8215SKent Overstreet __entry->nonblocking = nonblocking; 561a8b3a677SKent Overstreet __entry->nocow = s->skipped_nocow; 562a1019576SKent Overstreet strscpy(__entry->err, err, sizeof(__entry->err)); 5631c6fdbd8SKent Overstreet ), 5641c6fdbd8SKent Overstreet 5657635e1a6SKent Overstreet TP_printk("reserve %s bucket %u:%llu free %llu avail %llu copygc_wait %llu/%lli seen %llu open %llu need_journal_commit %llu nouse %llu nocow %llu nonblocking %u err %s", 566f25d8215SKent Overstreet __entry->reserve, 5671a14e255SKent Overstreet __entry->dev, 56868b6cd19SKent Overstreet __entry->bucket, 5698ef98313SKent Overstreet __entry->free, 570f25d8215SKent Overstreet __entry->avail, 5718ef98313SKent Overstreet __entry->copygc_wait_amount, 5728ef98313SKent Overstreet __entry->copygc_waiting_for, 573f25d8215SKent Overstreet __entry->seen, 574f25d8215SKent Overstreet __entry->open, 575f25d8215SKent Overstreet __entry->need_journal_commit, 576f25d8215SKent Overstreet __entry->nouse, 577a8b3a677SKent Overstreet __entry->nocow, 578f25d8215SKent Overstreet __entry->nonblocking, 579615f867cSKent Overstreet __entry->err) 5801c6fdbd8SKent Overstreet ); 5811c6fdbd8SKent Overstreet 5821c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc, 583f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 58468b6cd19SKent Overstreet u64 bucket, 5858ef98313SKent Overstreet u64 free, 586f25d8215SKent Overstreet u64 avail, 5878ef98313SKent Overstreet u64 copygc_wait_amount, 5888ef98313SKent Overstreet s64 copygc_waiting_for, 589ae10fe01SKent Overstreet struct bucket_alloc_state *s, 590f25d8215SKent Overstreet bool nonblocking, 591615f867cSKent Overstreet const char *err), 5927635e1a6SKent Overstreet TP_ARGS(ca, alloc_reserve, bucket, free, avail, 59368b6cd19SKent Overstreet copygc_wait_amount, copygc_waiting_for, 594ae10fe01SKent Overstreet s, nonblocking, err) 5951c6fdbd8SKent Overstreet ); 5961c6fdbd8SKent Overstreet 5971c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc_fail, 598f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 59968b6cd19SKent Overstreet u64 bucket, 6008ef98313SKent Overstreet u64 free, 601f25d8215SKent Overstreet u64 avail, 6028ef98313SKent Overstreet u64 copygc_wait_amount, 6038ef98313SKent Overstreet s64 copygc_waiting_for, 604ae10fe01SKent Overstreet struct bucket_alloc_state *s, 605f25d8215SKent Overstreet bool nonblocking, 606615f867cSKent Overstreet const char *err), 6077635e1a6SKent Overstreet TP_ARGS(ca, alloc_reserve, bucket, free, avail, 60868b6cd19SKent Overstreet copygc_wait_amount, copygc_waiting_for, 609ae10fe01SKent Overstreet s, nonblocking, err) 6101c6fdbd8SKent Overstreet ); 6111c6fdbd8SKent Overstreet 6121f93726eSKent Overstreet TRACE_EVENT(discard_buckets, 6131f93726eSKent Overstreet TP_PROTO(struct bch_fs *c, u64 seen, u64 open, 614615f867cSKent Overstreet u64 need_journal_commit, u64 discarded, const char *err), 615615f867cSKent Overstreet TP_ARGS(c, seen, open, need_journal_commit, discarded, err), 6161f93726eSKent Overstreet 6171f93726eSKent Overstreet TP_STRUCT__entry( 6181f93726eSKent Overstreet __field(dev_t, dev ) 6191f93726eSKent Overstreet __field(u64, seen ) 6201f93726eSKent Overstreet __field(u64, open ) 6211f93726eSKent Overstreet __field(u64, need_journal_commit ) 6221f93726eSKent Overstreet __field(u64, discarded ) 623615f867cSKent Overstreet __array(char, err, 16 ) 6241f93726eSKent Overstreet ), 6251f93726eSKent Overstreet 6261f93726eSKent Overstreet TP_fast_assign( 6271f93726eSKent Overstreet __entry->dev = c->dev; 6281f93726eSKent Overstreet __entry->seen = seen; 6291f93726eSKent Overstreet __entry->open = open; 6301f93726eSKent Overstreet __entry->need_journal_commit = need_journal_commit; 6311f93726eSKent Overstreet __entry->discarded = discarded; 632a1019576SKent Overstreet strscpy(__entry->err, err, sizeof(__entry->err)); 6331f93726eSKent Overstreet ), 6341f93726eSKent Overstreet 635615f867cSKent Overstreet TP_printk("%d%d seen %llu open %llu need_journal_commit %llu discarded %llu err %s", 6361f93726eSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 6371f93726eSKent Overstreet __entry->seen, 6381f93726eSKent Overstreet __entry->open, 6391f93726eSKent Overstreet __entry->need_journal_commit, 6401f93726eSKent Overstreet __entry->discarded, 641615f867cSKent Overstreet __entry->err) 6421f93726eSKent Overstreet ); 6431f93726eSKent Overstreet 644674cfc26SKent Overstreet TRACE_EVENT(bucket_invalidate, 64538585367SKent Overstreet TP_PROTO(struct bch_fs *c, unsigned dev, u64 bucket, u32 sectors), 64638585367SKent Overstreet TP_ARGS(c, dev, bucket, sectors), 6471f93726eSKent Overstreet 6481f93726eSKent Overstreet TP_STRUCT__entry( 6491f93726eSKent Overstreet __field(dev_t, dev ) 6501f93726eSKent Overstreet __field(u32, dev_idx ) 65138585367SKent Overstreet __field(u32, sectors ) 6521f93726eSKent Overstreet __field(u64, bucket ) 6531f93726eSKent Overstreet ), 6541f93726eSKent Overstreet 6551f93726eSKent Overstreet TP_fast_assign( 6561f93726eSKent Overstreet __entry->dev = c->dev; 6571f93726eSKent Overstreet __entry->dev_idx = dev; 65838585367SKent Overstreet __entry->sectors = sectors; 6591f93726eSKent Overstreet __entry->bucket = bucket; 6601f93726eSKent Overstreet ), 6611f93726eSKent Overstreet 66238585367SKent Overstreet TP_printk("%d:%d invalidated %u:%llu cached sectors %u", 6631f93726eSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 66438585367SKent Overstreet __entry->dev_idx, __entry->bucket, 66538585367SKent Overstreet __entry->sectors) 6661f93726eSKent Overstreet ); 6671f93726eSKent Overstreet 6681c6fdbd8SKent Overstreet /* Moving IO */ 6691c6fdbd8SKent Overstreet 670674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_read, 6711c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 6721c6fdbd8SKent Overstreet TP_ARGS(k) 6731c6fdbd8SKent Overstreet ); 6741c6fdbd8SKent Overstreet 675674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_write, 6761c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 6771c6fdbd8SKent Overstreet TP_ARGS(k) 6781c6fdbd8SKent Overstreet ); 6791c6fdbd8SKent Overstreet 680674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_finish, 681674cfc26SKent Overstreet TP_PROTO(const struct bkey *k), 682674cfc26SKent Overstreet TP_ARGS(k) 683674cfc26SKent Overstreet ); 684674cfc26SKent Overstreet 685*bb6c4b92SKent Overstreet TRACE_EVENT(move_extent_fail, 686*bb6c4b92SKent Overstreet TP_PROTO(struct bch_fs *c, const char *msg), 687*bb6c4b92SKent Overstreet TP_ARGS(c, msg), 688*bb6c4b92SKent Overstreet 689*bb6c4b92SKent Overstreet TP_STRUCT__entry( 690*bb6c4b92SKent Overstreet __field(dev_t, dev ) 691*bb6c4b92SKent Overstreet __string(msg, msg ) 692*bb6c4b92SKent Overstreet ), 693*bb6c4b92SKent Overstreet 694*bb6c4b92SKent Overstreet TP_fast_assign( 695*bb6c4b92SKent Overstreet __entry->dev = c->dev; 696*bb6c4b92SKent Overstreet __assign_str(msg, msg); 697*bb6c4b92SKent Overstreet ), 698*bb6c4b92SKent Overstreet 699*bb6c4b92SKent Overstreet TP_printk("%d:%d %s", MAJOR(__entry->dev), MINOR(__entry->dev), __get_str(msg)) 700674cfc26SKent Overstreet ); 701674cfc26SKent Overstreet 702674cfc26SKent Overstreet DEFINE_EVENT(bkey, move_extent_alloc_mem_fail, 7031c6fdbd8SKent Overstreet TP_PROTO(const struct bkey *k), 7041c6fdbd8SKent Overstreet TP_ARGS(k) 7051c6fdbd8SKent Overstreet ); 7061c6fdbd8SKent Overstreet 7071c6fdbd8SKent Overstreet TRACE_EVENT(move_data, 7081c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, u64 sectors_moved, 7091c6fdbd8SKent Overstreet u64 keys_moved), 7101c6fdbd8SKent Overstreet TP_ARGS(c, sectors_moved, keys_moved), 7111c6fdbd8SKent Overstreet 7121c6fdbd8SKent Overstreet TP_STRUCT__entry( 713ddc7dd62SKent Overstreet __field(dev_t, dev ) 7141c6fdbd8SKent Overstreet __field(u64, sectors_moved ) 7151c6fdbd8SKent Overstreet __field(u64, keys_moved ) 7161c6fdbd8SKent Overstreet ), 7171c6fdbd8SKent Overstreet 7181c6fdbd8SKent Overstreet TP_fast_assign( 719ddc7dd62SKent Overstreet __entry->dev = c->dev; 7201c6fdbd8SKent Overstreet __entry->sectors_moved = sectors_moved; 7211c6fdbd8SKent Overstreet __entry->keys_moved = keys_moved; 7221c6fdbd8SKent Overstreet ), 7231c6fdbd8SKent Overstreet 724ddc7dd62SKent Overstreet TP_printk("%d,%d sectors_moved %llu keys_moved %llu", 725ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 726ddc7dd62SKent Overstreet __entry->sectors_moved, __entry->keys_moved) 7271c6fdbd8SKent Overstreet ); 7281c6fdbd8SKent Overstreet 7298e3f913eSKent Overstreet TRACE_EVENT(evacuate_bucket, 7308e3f913eSKent Overstreet TP_PROTO(struct bch_fs *c, struct bpos *bucket, 7318e3f913eSKent Overstreet unsigned sectors, unsigned bucket_size, 73280c33085SKent Overstreet u64 fragmentation, int ret), 73380c33085SKent Overstreet TP_ARGS(c, bucket, sectors, bucket_size, fragmentation, ret), 7348e3f913eSKent Overstreet 7358e3f913eSKent Overstreet TP_STRUCT__entry( 7368e3f913eSKent Overstreet __field(dev_t, dev ) 7378e3f913eSKent Overstreet __field(u64, member ) 7388e3f913eSKent Overstreet __field(u64, bucket ) 7398e3f913eSKent Overstreet __field(u32, sectors ) 7408e3f913eSKent Overstreet __field(u32, bucket_size ) 74180c33085SKent Overstreet __field(u64, fragmentation ) 7428e3f913eSKent Overstreet __field(int, ret ) 7438e3f913eSKent Overstreet ), 7448e3f913eSKent Overstreet 7458e3f913eSKent Overstreet TP_fast_assign( 7468e3f913eSKent Overstreet __entry->dev = c->dev; 7478e3f913eSKent Overstreet __entry->member = bucket->inode; 7488e3f913eSKent Overstreet __entry->bucket = bucket->offset; 7498e3f913eSKent Overstreet __entry->sectors = sectors; 7508e3f913eSKent Overstreet __entry->bucket_size = bucket_size; 75180c33085SKent Overstreet __entry->fragmentation = fragmentation; 7528e3f913eSKent Overstreet __entry->ret = ret; 7538e3f913eSKent Overstreet ), 7548e3f913eSKent Overstreet 75580c33085SKent Overstreet TP_printk("%d,%d %llu:%llu sectors %u/%u fragmentation %llu ret %i", 7568e3f913eSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 7578e3f913eSKent Overstreet __entry->member, __entry->bucket, 7588e3f913eSKent Overstreet __entry->sectors, __entry->bucket_size, 75980c33085SKent Overstreet __entry->fragmentation, __entry->ret) 7608e3f913eSKent Overstreet ); 7618e3f913eSKent Overstreet 7621c6fdbd8SKent Overstreet TRACE_EVENT(copygc, 763e6d11615SKent Overstreet TP_PROTO(struct bch_fs *c, 7641c6fdbd8SKent Overstreet u64 sectors_moved, u64 sectors_not_moved, 7651c6fdbd8SKent Overstreet u64 buckets_moved, u64 buckets_not_moved), 766e6d11615SKent Overstreet TP_ARGS(c, 7671c6fdbd8SKent Overstreet sectors_moved, sectors_not_moved, 7681c6fdbd8SKent Overstreet buckets_moved, buckets_not_moved), 7691c6fdbd8SKent Overstreet 7701c6fdbd8SKent Overstreet TP_STRUCT__entry( 771ddc7dd62SKent Overstreet __field(dev_t, dev ) 7721c6fdbd8SKent Overstreet __field(u64, sectors_moved ) 7731c6fdbd8SKent Overstreet __field(u64, sectors_not_moved ) 7741c6fdbd8SKent Overstreet __field(u64, buckets_moved ) 7751c6fdbd8SKent Overstreet __field(u64, buckets_not_moved ) 7761c6fdbd8SKent Overstreet ), 7771c6fdbd8SKent Overstreet 7781c6fdbd8SKent Overstreet TP_fast_assign( 779ddc7dd62SKent Overstreet __entry->dev = c->dev; 7801c6fdbd8SKent Overstreet __entry->sectors_moved = sectors_moved; 7811c6fdbd8SKent Overstreet __entry->sectors_not_moved = sectors_not_moved; 7821c6fdbd8SKent Overstreet __entry->buckets_moved = buckets_moved; 7831c6fdbd8SKent Overstreet __entry->buckets_not_moved = buckets_moved; 7841c6fdbd8SKent Overstreet ), 7851c6fdbd8SKent Overstreet 786ddc7dd62SKent Overstreet TP_printk("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu", 787ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 7881c6fdbd8SKent Overstreet __entry->sectors_moved, __entry->sectors_not_moved, 7891c6fdbd8SKent Overstreet __entry->buckets_moved, __entry->buckets_not_moved) 7901c6fdbd8SKent Overstreet ); 7911c6fdbd8SKent Overstreet 79219d2819dSKent Overstreet TRACE_EVENT(copygc_wait, 79319d2819dSKent Overstreet TP_PROTO(struct bch_fs *c, 79419d2819dSKent Overstreet u64 wait_amount, u64 until), 79519d2819dSKent Overstreet TP_ARGS(c, wait_amount, until), 79619d2819dSKent Overstreet 79719d2819dSKent Overstreet TP_STRUCT__entry( 798ddc7dd62SKent Overstreet __field(dev_t, dev ) 79919d2819dSKent Overstreet __field(u64, wait_amount ) 80019d2819dSKent Overstreet __field(u64, until ) 80119d2819dSKent Overstreet ), 80219d2819dSKent Overstreet 80319d2819dSKent Overstreet TP_fast_assign( 804ddc7dd62SKent Overstreet __entry->dev = c->dev; 80519d2819dSKent Overstreet __entry->wait_amount = wait_amount; 80619d2819dSKent Overstreet __entry->until = until; 80719d2819dSKent Overstreet ), 80819d2819dSKent Overstreet 809ddc7dd62SKent Overstreet TP_printk("%d,%u waiting for %llu sectors until %llu", 810ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 811ddc7dd62SKent Overstreet __entry->wait_amount, __entry->until) 81219d2819dSKent Overstreet ); 81319d2819dSKent Overstreet 81412043cf1SKent Overstreet /* btree transactions: */ 81512043cf1SKent Overstreet 8161f93726eSKent Overstreet DECLARE_EVENT_CLASS(transaction_event, 8179f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 818531a0095SKent Overstreet unsigned long caller_ip), 8199f96568cSKent Overstreet TP_ARGS(trans, caller_ip), 820ba5c6557SKent Overstreet 821ba5c6557SKent Overstreet TP_STRUCT__entry( 8225f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 823531a0095SKent Overstreet __field(unsigned long, caller_ip ) 824ba5c6557SKent Overstreet ), 825ba5c6557SKent Overstreet 826ba5c6557SKent Overstreet TP_fast_assign( 827a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 828531a0095SKent Overstreet __entry->caller_ip = caller_ip; 829ba5c6557SKent Overstreet ), 830ba5c6557SKent Overstreet 831669f87a5SKent Overstreet TP_printk("%s %pS", __entry->trans_fn, (void *) __entry->caller_ip) 832669f87a5SKent Overstreet ); 833669f87a5SKent Overstreet 8341f93726eSKent Overstreet DEFINE_EVENT(transaction_event, transaction_commit, 8359f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 836669f87a5SKent Overstreet unsigned long caller_ip), 8379f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 838ba5c6557SKent Overstreet ); 839ba5c6557SKent Overstreet 840674cfc26SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_injected, 8419f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 842a0cb8d78SKent Overstreet unsigned long caller_ip), 8439f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 844a0cb8d78SKent Overstreet ); 845a0cb8d78SKent Overstreet 8463d86f13dSKent Overstreet TRACE_EVENT(trans_restart_split_race, 847e151580dSKent Overstreet TP_PROTO(struct btree_trans *trans, 8483d86f13dSKent Overstreet unsigned long caller_ip, 8493d86f13dSKent Overstreet struct btree *b), 8503d86f13dSKent Overstreet TP_ARGS(trans, caller_ip, b), 8513d86f13dSKent Overstreet 8523d86f13dSKent Overstreet TP_STRUCT__entry( 8533d86f13dSKent Overstreet __array(char, trans_fn, 32 ) 8543d86f13dSKent Overstreet __field(unsigned long, caller_ip ) 8553d86f13dSKent Overstreet __field(u8, level ) 8563d86f13dSKent Overstreet __field(u16, written ) 8573d86f13dSKent Overstreet __field(u16, blocks ) 8583d86f13dSKent Overstreet __field(u16, u64s_remaining ) 8593d86f13dSKent Overstreet ), 8603d86f13dSKent Overstreet 8613d86f13dSKent Overstreet TP_fast_assign( 8623d86f13dSKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 8633d86f13dSKent Overstreet __entry->caller_ip = caller_ip; 8643d86f13dSKent Overstreet __entry->level = b->c.level; 8653d86f13dSKent Overstreet __entry->written = b->written; 8663d86f13dSKent Overstreet __entry->blocks = btree_blocks(trans->c); 8673d86f13dSKent Overstreet __entry->u64s_remaining = bch_btree_keys_u64s_remaining(trans->c, b); 8683d86f13dSKent Overstreet ), 8693d86f13dSKent Overstreet 8703d86f13dSKent Overstreet TP_printk("%s %pS l=%u written %u/%u u64s remaining %u", 8713d86f13dSKent Overstreet __entry->trans_fn, (void *) __entry->caller_ip, 8723d86f13dSKent Overstreet __entry->level, 8733d86f13dSKent Overstreet __entry->written, __entry->blocks, 8743d86f13dSKent Overstreet __entry->u64s_remaining) 875e151580dSKent Overstreet ); 876e151580dSKent Overstreet 8771f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_blocked_journal_reclaim, 8789f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 879531a0095SKent Overstreet unsigned long caller_ip), 8809f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 881531a0095SKent Overstreet ); 882531a0095SKent Overstreet 8831f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_journal_res_get, 8849f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 885531a0095SKent Overstreet unsigned long caller_ip), 8869f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 887531a0095SKent Overstreet ); 888531a0095SKent Overstreet 889ce56bf7fSKent Overstreet 890ce56bf7fSKent Overstreet TRACE_EVENT(trans_restart_journal_preres_get, 8919f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 892ce56bf7fSKent Overstreet unsigned long caller_ip, 893ce56bf7fSKent Overstreet unsigned flags), 894ce56bf7fSKent Overstreet TP_ARGS(trans, caller_ip, flags), 895ce56bf7fSKent Overstreet 896ce56bf7fSKent Overstreet TP_STRUCT__entry( 897ce56bf7fSKent Overstreet __array(char, trans_fn, 32 ) 898ce56bf7fSKent Overstreet __field(unsigned long, caller_ip ) 899ce56bf7fSKent Overstreet __field(unsigned, flags ) 900ce56bf7fSKent Overstreet ), 901ce56bf7fSKent Overstreet 902ce56bf7fSKent Overstreet TP_fast_assign( 903a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 904ce56bf7fSKent Overstreet __entry->caller_ip = caller_ip; 905ce56bf7fSKent Overstreet __entry->flags = flags; 906ce56bf7fSKent Overstreet ), 907ce56bf7fSKent Overstreet 908ce56bf7fSKent Overstreet TP_printk("%s %pS %x", __entry->trans_fn, 909ce56bf7fSKent Overstreet (void *) __entry->caller_ip, 910ce56bf7fSKent Overstreet __entry->flags) 911531a0095SKent Overstreet ); 912531a0095SKent Overstreet 9131f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_journal_reclaim, 9149f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 915531a0095SKent Overstreet unsigned long caller_ip), 9169f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 917531a0095SKent Overstreet ); 918531a0095SKent Overstreet 9191f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_fault_inject, 9209f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 921531a0095SKent Overstreet unsigned long caller_ip), 9229f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 923531a0095SKent Overstreet ); 924531a0095SKent Overstreet 9251f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_traverse_all, 9269f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 927531a0095SKent Overstreet unsigned long caller_ip), 9289f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 929531a0095SKent Overstreet ); 930531a0095SKent Overstreet 9311f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_mark_replicas, 9329f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 9331f93726eSKent Overstreet unsigned long caller_ip), 9349f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 9351f93726eSKent Overstreet ); 9361f93726eSKent Overstreet 9371f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_key_cache_raced, 9389f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 93912ce5b7dSKent Overstreet unsigned long caller_ip), 9409f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 94112ce5b7dSKent Overstreet ); 94212ce5b7dSKent Overstreet 9430990efaeSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_too_many_iters, 9449f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 9450990efaeSKent Overstreet unsigned long caller_ip), 9469f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 9470990efaeSKent Overstreet ); 9480990efaeSKent Overstreet 949531a0095SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart_iter, 9509f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 951531a0095SKent Overstreet unsigned long caller_ip, 9529f96568cSKent Overstreet struct btree_path *path), 9539f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path), 954531a0095SKent Overstreet 955531a0095SKent Overstreet TP_STRUCT__entry( 9565f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 9574b59a319SKent Overstreet __field(unsigned long, caller_ip ) 958531a0095SKent Overstreet __field(u8, btree_id ) 9599f96568cSKent Overstreet TRACE_BPOS_entries(pos) 960531a0095SKent Overstreet ), 961531a0095SKent Overstreet 962531a0095SKent Overstreet TP_fast_assign( 963a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 9644b59a319SKent Overstreet __entry->caller_ip = caller_ip; 9659f96568cSKent Overstreet __entry->btree_id = path->btree_id; 9669f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos) 967531a0095SKent Overstreet ), 968531a0095SKent Overstreet 9699f96568cSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u", 970669f87a5SKent Overstreet __entry->trans_fn, 9714b59a319SKent Overstreet (void *) __entry->caller_ip, 9729f96568cSKent Overstreet bch2_btree_ids[__entry->btree_id], 973531a0095SKent Overstreet __entry->pos_inode, 974531a0095SKent Overstreet __entry->pos_offset, 975531a0095SKent Overstreet __entry->pos_snapshot) 976531a0095SKent Overstreet ); 977531a0095SKent Overstreet 978531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_reused, 9799f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 980531a0095SKent Overstreet unsigned long caller_ip, 9819f96568cSKent Overstreet struct btree_path *path), 9829f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 983531a0095SKent Overstreet ); 984531a0095SKent Overstreet 985531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_split, 9869f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 987531a0095SKent Overstreet unsigned long caller_ip, 9889f96568cSKent Overstreet struct btree_path *path), 9899f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 990531a0095SKent Overstreet ); 991531a0095SKent Overstreet 992367d72ddSKent Overstreet TRACE_EVENT(trans_restart_upgrade, 9939f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 994531a0095SKent Overstreet unsigned long caller_ip, 995367d72ddSKent Overstreet struct btree_path *path, 996367d72ddSKent Overstreet unsigned old_locks_want, 997367d72ddSKent Overstreet unsigned new_locks_want), 998367d72ddSKent Overstreet TP_ARGS(trans, caller_ip, path, old_locks_want, new_locks_want), 999531a0095SKent Overstreet 1000367d72ddSKent Overstreet TP_STRUCT__entry( 1001367d72ddSKent Overstreet __array(char, trans_fn, 32 ) 1002367d72ddSKent Overstreet __field(unsigned long, caller_ip ) 1003367d72ddSKent Overstreet __field(u8, btree_id ) 1004367d72ddSKent Overstreet __field(u8, old_locks_want ) 1005367d72ddSKent Overstreet __field(u8, new_locks_want ) 1006367d72ddSKent Overstreet TRACE_BPOS_entries(pos) 1007367d72ddSKent Overstreet ), 1008367d72ddSKent Overstreet 1009367d72ddSKent Overstreet TP_fast_assign( 1010a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 1011367d72ddSKent Overstreet __entry->caller_ip = caller_ip; 1012367d72ddSKent Overstreet __entry->btree_id = path->btree_id; 1013367d72ddSKent Overstreet __entry->old_locks_want = old_locks_want; 1014367d72ddSKent Overstreet __entry->new_locks_want = new_locks_want; 1015367d72ddSKent Overstreet TRACE_BPOS_assign(pos, path->pos) 1016367d72ddSKent Overstreet ), 1017367d72ddSKent Overstreet 1018367d72ddSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u locks_want %u -> %u", 1019367d72ddSKent Overstreet __entry->trans_fn, 1020367d72ddSKent Overstreet (void *) __entry->caller_ip, 1021367d72ddSKent Overstreet bch2_btree_ids[__entry->btree_id], 1022367d72ddSKent Overstreet __entry->pos_inode, 1023367d72ddSKent Overstreet __entry->pos_offset, 1024367d72ddSKent Overstreet __entry->pos_snapshot, 1025367d72ddSKent Overstreet __entry->old_locks_want, 1026367d72ddSKent Overstreet __entry->new_locks_want) 1027531a0095SKent Overstreet ); 1028531a0095SKent Overstreet 1029531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock, 10309f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1031531a0095SKent Overstreet unsigned long caller_ip, 10329f96568cSKent Overstreet struct btree_path *path), 10339f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1034531a0095SKent Overstreet ); 1035531a0095SKent Overstreet 1036bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_next_node, 10379f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1038bc82d08bSKent Overstreet unsigned long caller_ip, 10399f96568cSKent Overstreet struct btree_path *path), 10409f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1041bc82d08bSKent Overstreet ); 1042bc82d08bSKent Overstreet 1043bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_parent_for_fill, 10449f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1045bc82d08bSKent Overstreet unsigned long caller_ip, 10469f96568cSKent Overstreet struct btree_path *path), 10479f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1048bc82d08bSKent Overstreet ); 1049bc82d08bSKent Overstreet 1050bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_after_fill, 10519f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1052bc82d08bSKent Overstreet unsigned long caller_ip, 10539f96568cSKent Overstreet struct btree_path *path), 10549f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1055bc82d08bSKent Overstreet ); 1056bc82d08bSKent Overstreet 1057674cfc26SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_key_cache_upgrade, 10589f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 105949e401faSKent Overstreet unsigned long caller_ip), 10609f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 106149e401faSKent Overstreet ); 106249e401faSKent Overstreet 1063bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_key_cache_fill, 10649f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1065bc82d08bSKent Overstreet unsigned long caller_ip, 10669f96568cSKent Overstreet struct btree_path *path), 10679f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1068bc82d08bSKent Overstreet ); 1069bc82d08bSKent Overstreet 1070bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_path, 10719f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1072bc82d08bSKent Overstreet unsigned long caller_ip, 10739f96568cSKent Overstreet struct btree_path *path), 10749f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1075bc82d08bSKent Overstreet ); 1076bc82d08bSKent Overstreet 1077bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_path_intent, 10789f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1079bc82d08bSKent Overstreet unsigned long caller_ip, 10809f96568cSKent Overstreet struct btree_path *path), 10819f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1082bc82d08bSKent Overstreet ); 1083bc82d08bSKent Overstreet 1084531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_traverse, 10859f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1086531a0095SKent Overstreet unsigned long caller_ip, 10879f96568cSKent Overstreet struct btree_path *path), 10889f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1089531a0095SKent Overstreet ); 1090531a0095SKent Overstreet 10918f9ad91aSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_memory_allocation_failure, 10929f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 10938f9ad91aSKent Overstreet unsigned long caller_ip, 10949f96568cSKent Overstreet struct btree_path *path), 10959f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 10968f9ad91aSKent Overstreet ); 10978f9ad91aSKent Overstreet 10980d7009d7SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_would_deadlock, 10999f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 11000d7009d7SKent Overstreet unsigned long caller_ip), 11010d7009d7SKent Overstreet TP_ARGS(trans, caller_ip) 1102ba5c6557SKent Overstreet ); 1103ba5c6557SKent Overstreet 110433bd5d06SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_would_deadlock_recursion_limit, 110533bd5d06SKent Overstreet TP_PROTO(struct btree_trans *trans, 110633bd5d06SKent Overstreet unsigned long caller_ip), 110733bd5d06SKent Overstreet TP_ARGS(trans, caller_ip) 110833bd5d06SKent Overstreet ); 110933bd5d06SKent Overstreet 1110caaa66aaSKent Overstreet TRACE_EVENT(trans_restart_would_deadlock_write, 11119f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans), 11129f96568cSKent Overstreet TP_ARGS(trans), 1113caaa66aaSKent Overstreet 1114caaa66aaSKent Overstreet TP_STRUCT__entry( 11155f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 1116caaa66aaSKent Overstreet ), 1117caaa66aaSKent Overstreet 1118caaa66aaSKent Overstreet TP_fast_assign( 1119a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 1120caaa66aaSKent Overstreet ), 1121caaa66aaSKent Overstreet 1122669f87a5SKent Overstreet TP_printk("%s", __entry->trans_fn) 1123caaa66aaSKent Overstreet ); 1124caaa66aaSKent Overstreet 112520bceecbSKent Overstreet TRACE_EVENT(trans_restart_mem_realloced, 11269f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1127669f87a5SKent Overstreet unsigned long caller_ip, 112873a117d2SKent Overstreet unsigned long bytes), 11299f96568cSKent Overstreet TP_ARGS(trans, caller_ip, bytes), 113020bceecbSKent Overstreet 113120bceecbSKent Overstreet TP_STRUCT__entry( 11325f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 113373a117d2SKent Overstreet __field(unsigned long, caller_ip ) 113420bceecbSKent Overstreet __field(unsigned long, bytes ) 113520bceecbSKent Overstreet ), 113620bceecbSKent Overstreet 113720bceecbSKent Overstreet TP_fast_assign( 1138a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 113973a117d2SKent Overstreet __entry->caller_ip = caller_ip; 114020bceecbSKent Overstreet __entry->bytes = bytes; 114120bceecbSKent Overstreet ), 114220bceecbSKent Overstreet 1143669f87a5SKent Overstreet TP_printk("%s %pS bytes %lu", 1144669f87a5SKent Overstreet __entry->trans_fn, 114573a117d2SKent Overstreet (void *) __entry->caller_ip, 114673a117d2SKent Overstreet __entry->bytes) 1147ba5c6557SKent Overstreet ); 1148ba5c6557SKent Overstreet 11493a306f3cSKent Overstreet TRACE_EVENT(trans_restart_key_cache_key_realloced, 11509f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1151ddf11d8cSKent Overstreet unsigned long caller_ip, 11529f96568cSKent Overstreet struct btree_path *path, 11533a306f3cSKent Overstreet unsigned old_u64s, 11543a306f3cSKent Overstreet unsigned new_u64s), 11559f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path, old_u64s, new_u64s), 11563a306f3cSKent Overstreet 11573a306f3cSKent Overstreet TP_STRUCT__entry( 11585f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 11593a306f3cSKent Overstreet __field(unsigned long, caller_ip ) 11603a306f3cSKent Overstreet __field(enum btree_id, btree_id ) 11619f96568cSKent Overstreet TRACE_BPOS_entries(pos) 11623a306f3cSKent Overstreet __field(u32, old_u64s ) 11633a306f3cSKent Overstreet __field(u32, new_u64s ) 11643a306f3cSKent Overstreet ), 11653a306f3cSKent Overstreet 11663a306f3cSKent Overstreet TP_fast_assign( 1167a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 11683a306f3cSKent Overstreet __entry->caller_ip = caller_ip; 11699f96568cSKent Overstreet 11709f96568cSKent Overstreet __entry->btree_id = path->btree_id; 11719f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 11723a306f3cSKent Overstreet __entry->old_u64s = old_u64s; 11733a306f3cSKent Overstreet __entry->new_u64s = new_u64s; 11743a306f3cSKent Overstreet ), 11753a306f3cSKent Overstreet 11763a306f3cSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u old_u64s %u new_u64s %u", 11773a306f3cSKent Overstreet __entry->trans_fn, 11783a306f3cSKent Overstreet (void *) __entry->caller_ip, 11793a306f3cSKent Overstreet bch2_btree_ids[__entry->btree_id], 118049e401faSKent Overstreet __entry->pos_inode, 118149e401faSKent Overstreet __entry->pos_offset, 11829f96568cSKent Overstreet __entry->pos_snapshot, 11839f96568cSKent Overstreet __entry->old_u64s, 11849f96568cSKent Overstreet __entry->new_u64s) 118549e401faSKent Overstreet ); 118649e401faSKent Overstreet 1187920e69bcSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_write_buffer_flush, 1188920e69bcSKent Overstreet TP_PROTO(struct btree_trans *trans, 1189920e69bcSKent Overstreet unsigned long caller_ip), 1190920e69bcSKent Overstreet TP_ARGS(trans, caller_ip) 1191920e69bcSKent Overstreet ); 1192920e69bcSKent Overstreet 1193920e69bcSKent Overstreet TRACE_EVENT(write_buffer_flush, 1194920e69bcSKent Overstreet TP_PROTO(struct btree_trans *trans, size_t nr, size_t skipped, size_t fast, size_t size), 1195920e69bcSKent Overstreet TP_ARGS(trans, nr, skipped, fast, size), 1196920e69bcSKent Overstreet 1197920e69bcSKent Overstreet TP_STRUCT__entry( 1198920e69bcSKent Overstreet __field(size_t, nr ) 1199920e69bcSKent Overstreet __field(size_t, skipped ) 1200920e69bcSKent Overstreet __field(size_t, fast ) 1201920e69bcSKent Overstreet __field(size_t, size ) 1202920e69bcSKent Overstreet ), 1203920e69bcSKent Overstreet 1204920e69bcSKent Overstreet TP_fast_assign( 1205920e69bcSKent Overstreet __entry->nr = nr; 1206920e69bcSKent Overstreet __entry->skipped = skipped; 1207920e69bcSKent Overstreet __entry->fast = fast; 1208920e69bcSKent Overstreet __entry->size = size; 1209920e69bcSKent Overstreet ), 1210920e69bcSKent Overstreet 1211920e69bcSKent Overstreet TP_printk("%zu/%zu skipped %zu fast %zu", 1212920e69bcSKent Overstreet __entry->nr, __entry->size, __entry->skipped, __entry->fast) 1213920e69bcSKent Overstreet ); 1214920e69bcSKent Overstreet 1215920e69bcSKent Overstreet TRACE_EVENT(write_buffer_flush_slowpath, 1216920e69bcSKent Overstreet TP_PROTO(struct btree_trans *trans, size_t nr, size_t size), 1217920e69bcSKent Overstreet TP_ARGS(trans, nr, size), 1218920e69bcSKent Overstreet 1219920e69bcSKent Overstreet TP_STRUCT__entry( 1220920e69bcSKent Overstreet __field(size_t, nr ) 1221920e69bcSKent Overstreet __field(size_t, size ) 1222920e69bcSKent Overstreet ), 1223920e69bcSKent Overstreet 1224920e69bcSKent Overstreet TP_fast_assign( 1225920e69bcSKent Overstreet __entry->nr = nr; 1226920e69bcSKent Overstreet __entry->size = size; 1227920e69bcSKent Overstreet ), 1228920e69bcSKent Overstreet 1229920e69bcSKent Overstreet TP_printk("%zu/%zu", __entry->nr, __entry->size) 1230920e69bcSKent Overstreet ); 1231920e69bcSKent Overstreet 12321c6fdbd8SKent Overstreet #endif /* _TRACE_BCACHEFS_H */ 12331c6fdbd8SKent Overstreet 12341c6fdbd8SKent Overstreet /* This part must be outside protection */ 12351c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_PATH 12361c6fdbd8SKent Overstreet #define TRACE_INCLUDE_PATH ../../fs/bcachefs 12371c6fdbd8SKent Overstreet 12381c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_FILE 12391c6fdbd8SKent Overstreet #define TRACE_INCLUDE_FILE trace 12401c6fdbd8SKent Overstreet 12411c6fdbd8SKent Overstreet #include <trace/define_trace.h> 1242