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 35*25d1e39dSKent Overstreet DECLARE_EVENT_CLASS(str, 36*25d1e39dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *str), 37*25d1e39dSKent Overstreet TP_ARGS(c, str), 381c6fdbd8SKent Overstreet 391c6fdbd8SKent Overstreet TP_STRUCT__entry( 40*25d1e39dSKent Overstreet __field(dev_t, dev ) 41*25d1e39dSKent Overstreet __string(str, str ) 421c6fdbd8SKent Overstreet ), 431c6fdbd8SKent Overstreet 441c6fdbd8SKent Overstreet TP_fast_assign( 45*25d1e39dSKent Overstreet __entry->dev = c->dev; 46*25d1e39dSKent Overstreet __assign_str(str, str); 471c6fdbd8SKent Overstreet ), 481c6fdbd8SKent Overstreet 49*25d1e39dSKent Overstreet TP_printk("%d,%d %s", MAJOR(__entry->dev), MINOR(__entry->dev), __get_str(str)) 501c6fdbd8SKent Overstreet ); 511c6fdbd8SKent Overstreet 52674cfc26SKent Overstreet DECLARE_EVENT_CLASS(btree_node, 53674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 54674cfc26SKent Overstreet TP_ARGS(c, b), 55674cfc26SKent Overstreet 56674cfc26SKent Overstreet TP_STRUCT__entry( 57674cfc26SKent Overstreet __field(dev_t, dev ) 58674cfc26SKent Overstreet __field(u8, level ) 59674cfc26SKent Overstreet __field(u8, btree_id ) 60674cfc26SKent Overstreet TRACE_BPOS_entries(pos) 61674cfc26SKent Overstreet ), 62674cfc26SKent Overstreet 63674cfc26SKent Overstreet TP_fast_assign( 64674cfc26SKent Overstreet __entry->dev = c->dev; 65674cfc26SKent Overstreet __entry->level = b->c.level; 66674cfc26SKent Overstreet __entry->btree_id = b->c.btree_id; 67674cfc26SKent Overstreet TRACE_BPOS_assign(pos, b->key.k.p); 68674cfc26SKent Overstreet ), 69674cfc26SKent Overstreet 70674cfc26SKent Overstreet TP_printk("%d,%d %u %s %llu:%llu:%u", 71674cfc26SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 72674cfc26SKent Overstreet __entry->level, 7388dfe193SKent Overstreet bch2_btree_id_str(__entry->btree_id), 74674cfc26SKent Overstreet __entry->pos_inode, __entry->pos_offset, __entry->pos_snapshot) 75674cfc26SKent Overstreet ); 76674cfc26SKent Overstreet 771c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bch_fs, 781c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 791c6fdbd8SKent Overstreet TP_ARGS(c), 801c6fdbd8SKent Overstreet 811c6fdbd8SKent Overstreet TP_STRUCT__entry( 82ddc7dd62SKent Overstreet __field(dev_t, dev ) 831c6fdbd8SKent Overstreet ), 841c6fdbd8SKent Overstreet 851c6fdbd8SKent Overstreet TP_fast_assign( 86ddc7dd62SKent Overstreet __entry->dev = c->dev; 871c6fdbd8SKent Overstreet ), 881c6fdbd8SKent Overstreet 89ddc7dd62SKent Overstreet TP_printk("%d,%d", MAJOR(__entry->dev), MINOR(__entry->dev)) 901c6fdbd8SKent Overstreet ); 911c6fdbd8SKent Overstreet 921c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bio, 931c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 941c6fdbd8SKent Overstreet TP_ARGS(bio), 951c6fdbd8SKent Overstreet 961c6fdbd8SKent Overstreet TP_STRUCT__entry( 971c6fdbd8SKent Overstreet __field(dev_t, dev ) 981c6fdbd8SKent Overstreet __field(sector_t, sector ) 991c6fdbd8SKent Overstreet __field(unsigned int, nr_sector ) 1001c6fdbd8SKent Overstreet __array(char, rwbs, 6 ) 1011c6fdbd8SKent Overstreet ), 1021c6fdbd8SKent Overstreet 1031c6fdbd8SKent Overstreet TP_fast_assign( 1041c6fdbd8SKent Overstreet __entry->dev = bio->bi_bdev ? bio_dev(bio) : 0; 1051c6fdbd8SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 1061c6fdbd8SKent Overstreet __entry->nr_sector = bio->bi_iter.bi_size >> 9; 1071c6fdbd8SKent Overstreet blk_fill_rwbs(__entry->rwbs, bio->bi_opf); 1081c6fdbd8SKent Overstreet ), 1091c6fdbd8SKent Overstreet 1101c6fdbd8SKent Overstreet TP_printk("%d,%d %s %llu + %u", 1111c6fdbd8SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 1121c6fdbd8SKent Overstreet (unsigned long long)__entry->sector, __entry->nr_sector) 1131c6fdbd8SKent Overstreet ); 1141c6fdbd8SKent Overstreet 1154254f5bfSKent Overstreet /* super-io.c: */ 1164254f5bfSKent Overstreet TRACE_EVENT(write_super, 1174254f5bfSKent Overstreet TP_PROTO(struct bch_fs *c, unsigned long ip), 1184254f5bfSKent Overstreet TP_ARGS(c, ip), 1194254f5bfSKent Overstreet 1204254f5bfSKent Overstreet TP_STRUCT__entry( 1214254f5bfSKent Overstreet __field(dev_t, dev ) 1224254f5bfSKent Overstreet __field(unsigned long, ip ) 1234254f5bfSKent Overstreet ), 1244254f5bfSKent Overstreet 1254254f5bfSKent Overstreet TP_fast_assign( 1264254f5bfSKent Overstreet __entry->dev = c->dev; 1274254f5bfSKent Overstreet __entry->ip = ip; 1284254f5bfSKent Overstreet ), 1294254f5bfSKent Overstreet 1304254f5bfSKent Overstreet TP_printk("%d,%d for %pS", 1314254f5bfSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 1324254f5bfSKent Overstreet (void *) __entry->ip) 1334254f5bfSKent Overstreet ); 1344254f5bfSKent Overstreet 1351c6fdbd8SKent Overstreet /* io.c: */ 1361c6fdbd8SKent Overstreet 137674cfc26SKent Overstreet DEFINE_EVENT(bio, read_promote, 1381c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1391c6fdbd8SKent Overstreet TP_ARGS(bio) 1401c6fdbd8SKent Overstreet ); 1411c6fdbd8SKent Overstreet 142feb5cc39SKent Overstreet TRACE_EVENT(read_nopromote, 143feb5cc39SKent Overstreet TP_PROTO(struct bch_fs *c, int ret), 144feb5cc39SKent Overstreet TP_ARGS(c, ret), 145feb5cc39SKent Overstreet 146feb5cc39SKent Overstreet TP_STRUCT__entry( 147feb5cc39SKent Overstreet __field(dev_t, dev ) 148feb5cc39SKent Overstreet __array(char, ret, 32 ) 149feb5cc39SKent Overstreet ), 150feb5cc39SKent Overstreet 151feb5cc39SKent Overstreet TP_fast_assign( 152feb5cc39SKent Overstreet __entry->dev = c->dev; 153feb5cc39SKent Overstreet strscpy(__entry->ret, bch2_err_str(ret), sizeof(__entry->ret)); 154feb5cc39SKent Overstreet ), 155feb5cc39SKent Overstreet 156feb5cc39SKent Overstreet TP_printk("%d,%d ret %s", 157feb5cc39SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 158feb5cc39SKent Overstreet __entry->ret) 159feb5cc39SKent Overstreet ); 160feb5cc39SKent Overstreet 1611c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_bounce, 1621c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1631c6fdbd8SKent Overstreet TP_ARGS(bio) 1641c6fdbd8SKent Overstreet ); 1651c6fdbd8SKent Overstreet 166674cfc26SKent Overstreet DEFINE_EVENT(bio, read_split, 167674cfc26SKent Overstreet TP_PROTO(struct bio *bio), 168674cfc26SKent Overstreet TP_ARGS(bio) 169674cfc26SKent Overstreet ); 170674cfc26SKent Overstreet 1711c6fdbd8SKent Overstreet DEFINE_EVENT(bio, read_retry, 1721c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1731c6fdbd8SKent Overstreet TP_ARGS(bio) 1741c6fdbd8SKent Overstreet ); 1751c6fdbd8SKent Overstreet 176674cfc26SKent Overstreet DEFINE_EVENT(bio, read_reuse_race, 1771c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 1781c6fdbd8SKent Overstreet TP_ARGS(bio) 1791c6fdbd8SKent Overstreet ); 1801c6fdbd8SKent Overstreet 1811c6fdbd8SKent Overstreet /* Journal */ 1821c6fdbd8SKent Overstreet 1831c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_full, 1841c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 1851c6fdbd8SKent Overstreet TP_ARGS(c) 1861c6fdbd8SKent Overstreet ); 1871c6fdbd8SKent Overstreet 1881c6fdbd8SKent Overstreet DEFINE_EVENT(bch_fs, journal_entry_full, 1891c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 1901c6fdbd8SKent Overstreet TP_ARGS(c) 1911c6fdbd8SKent Overstreet ); 1921c6fdbd8SKent Overstreet 193ae0e6117SKent Overstreet TRACE_EVENT(journal_entry_close, 194ae0e6117SKent Overstreet TP_PROTO(struct bch_fs *c, unsigned bytes), 195ae0e6117SKent Overstreet TP_ARGS(c, bytes), 196ae0e6117SKent Overstreet 197ae0e6117SKent Overstreet TP_STRUCT__entry( 198ae0e6117SKent Overstreet __field(dev_t, dev ) 199ae0e6117SKent Overstreet __field(u32, bytes ) 200ae0e6117SKent Overstreet ), 201ae0e6117SKent Overstreet 202ae0e6117SKent Overstreet TP_fast_assign( 203ae0e6117SKent Overstreet __entry->dev = c->dev; 204ae0e6117SKent Overstreet __entry->bytes = bytes; 205ae0e6117SKent Overstreet ), 206ae0e6117SKent Overstreet 207ae0e6117SKent Overstreet TP_printk("%d,%d entry bytes %u", 208ae0e6117SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 209ae0e6117SKent Overstreet __entry->bytes) 210ae0e6117SKent Overstreet ); 211ae0e6117SKent Overstreet 2121c6fdbd8SKent Overstreet DEFINE_EVENT(bio, journal_write, 2131c6fdbd8SKent Overstreet TP_PROTO(struct bio *bio), 2141c6fdbd8SKent Overstreet TP_ARGS(bio) 2151c6fdbd8SKent Overstreet ); 2161c6fdbd8SKent Overstreet 2178a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_start, 2181f93726eSKent Overstreet TP_PROTO(struct bch_fs *c, bool direct, bool kicked, 2191f93726eSKent Overstreet u64 min_nr, u64 min_key_cache, 2208a92e545SKent Overstreet u64 btree_cache_dirty, u64 btree_cache_total, 2218a92e545SKent Overstreet u64 btree_key_cache_dirty, u64 btree_key_cache_total), 222006ccc30SKent Overstreet TP_ARGS(c, direct, kicked, min_nr, min_key_cache, 2238a92e545SKent Overstreet btree_cache_dirty, btree_cache_total, 2248a92e545SKent Overstreet btree_key_cache_dirty, btree_key_cache_total), 2258a92e545SKent Overstreet 2268a92e545SKent Overstreet TP_STRUCT__entry( 227ddc7dd62SKent Overstreet __field(dev_t, dev ) 2281f93726eSKent Overstreet __field(bool, direct ) 2291f93726eSKent Overstreet __field(bool, kicked ) 2308a92e545SKent Overstreet __field(u64, min_nr ) 2311f93726eSKent Overstreet __field(u64, min_key_cache ) 2328a92e545SKent Overstreet __field(u64, btree_cache_dirty ) 2338a92e545SKent Overstreet __field(u64, btree_cache_total ) 2348a92e545SKent Overstreet __field(u64, btree_key_cache_dirty ) 2358a92e545SKent Overstreet __field(u64, btree_key_cache_total ) 2368a92e545SKent Overstreet ), 2378a92e545SKent Overstreet 2388a92e545SKent Overstreet TP_fast_assign( 239ddc7dd62SKent Overstreet __entry->dev = c->dev; 2401f93726eSKent Overstreet __entry->direct = direct; 2411f93726eSKent Overstreet __entry->kicked = kicked; 2428a92e545SKent Overstreet __entry->min_nr = min_nr; 2431f93726eSKent Overstreet __entry->min_key_cache = min_key_cache; 2448a92e545SKent Overstreet __entry->btree_cache_dirty = btree_cache_dirty; 2458a92e545SKent Overstreet __entry->btree_cache_total = btree_cache_total; 2468a92e545SKent Overstreet __entry->btree_key_cache_dirty = btree_key_cache_dirty; 2478a92e545SKent Overstreet __entry->btree_key_cache_total = btree_key_cache_total; 2488a92e545SKent Overstreet ), 2498a92e545SKent Overstreet 250006ccc30SKent Overstreet TP_printk("%d,%d direct %u kicked %u min %llu key cache %llu btree cache %llu/%llu key cache %llu/%llu", 251ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 2521f93726eSKent Overstreet __entry->direct, 2531f93726eSKent Overstreet __entry->kicked, 2548a92e545SKent Overstreet __entry->min_nr, 2551f93726eSKent Overstreet __entry->min_key_cache, 2568a92e545SKent Overstreet __entry->btree_cache_dirty, 2578a92e545SKent Overstreet __entry->btree_cache_total, 2588a92e545SKent Overstreet __entry->btree_key_cache_dirty, 2598a92e545SKent Overstreet __entry->btree_key_cache_total) 2608a92e545SKent Overstreet ); 2618a92e545SKent Overstreet 2628a92e545SKent Overstreet TRACE_EVENT(journal_reclaim_finish, 2638a92e545SKent Overstreet TP_PROTO(struct bch_fs *c, u64 nr_flushed), 2648a92e545SKent Overstreet TP_ARGS(c, nr_flushed), 2658a92e545SKent Overstreet 2668a92e545SKent Overstreet TP_STRUCT__entry( 267ddc7dd62SKent Overstreet __field(dev_t, dev ) 2688a92e545SKent Overstreet __field(u64, nr_flushed ) 2698a92e545SKent Overstreet ), 2708a92e545SKent Overstreet 2718a92e545SKent Overstreet TP_fast_assign( 272ddc7dd62SKent Overstreet __entry->dev = c->dev; 2738a92e545SKent Overstreet __entry->nr_flushed = nr_flushed; 2748a92e545SKent Overstreet ), 2758a92e545SKent Overstreet 2761f93726eSKent Overstreet TP_printk("%d,%d flushed %llu", 277ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 278ddc7dd62SKent Overstreet __entry->nr_flushed) 2798a92e545SKent Overstreet ); 2808a92e545SKent Overstreet 2811c6fdbd8SKent Overstreet /* bset.c: */ 2821c6fdbd8SKent Overstreet 2831c6fdbd8SKent Overstreet DEFINE_EVENT(bpos, bkey_pack_pos_fail, 28412043cf1SKent Overstreet TP_PROTO(const struct bpos *p), 2851c6fdbd8SKent Overstreet TP_ARGS(p) 2861c6fdbd8SKent Overstreet ); 2871c6fdbd8SKent Overstreet 288674cfc26SKent Overstreet /* Btree cache: */ 2891c6fdbd8SKent Overstreet 290674cfc26SKent Overstreet TRACE_EVENT(btree_cache_scan, 291674cfc26SKent Overstreet TP_PROTO(long nr_to_scan, long can_free, long ret), 292674cfc26SKent Overstreet TP_ARGS(nr_to_scan, can_free, ret), 2931c6fdbd8SKent Overstreet 2941c6fdbd8SKent Overstreet TP_STRUCT__entry( 295674cfc26SKent Overstreet __field(long, nr_to_scan ) 296674cfc26SKent Overstreet __field(long, can_free ) 297674cfc26SKent Overstreet __field(long, ret ) 2981c6fdbd8SKent Overstreet ), 2991c6fdbd8SKent Overstreet 3001c6fdbd8SKent Overstreet TP_fast_assign( 301674cfc26SKent Overstreet __entry->nr_to_scan = nr_to_scan; 302674cfc26SKent Overstreet __entry->can_free = can_free; 303674cfc26SKent Overstreet __entry->ret = ret; 3041c6fdbd8SKent Overstreet ), 3051c6fdbd8SKent Overstreet 306674cfc26SKent Overstreet TP_printk("scanned for %li nodes, can free %li, ret %li", 307674cfc26SKent Overstreet __entry->nr_to_scan, __entry->can_free, __entry->ret) 3081c6fdbd8SKent Overstreet ); 3091c6fdbd8SKent Overstreet 310674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_cache_reap, 3111c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3121c6fdbd8SKent Overstreet TP_ARGS(c, b) 3131c6fdbd8SKent Overstreet ); 3141c6fdbd8SKent Overstreet 315674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_lock_fail, 316674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 317674cfc26SKent Overstreet TP_ARGS(c) 318674cfc26SKent Overstreet ); 319674cfc26SKent Overstreet 320674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_lock, 321674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 322674cfc26SKent Overstreet TP_ARGS(c) 323674cfc26SKent Overstreet ); 324674cfc26SKent Overstreet 325674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize, 326674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 327674cfc26SKent Overstreet TP_ARGS(c) 328674cfc26SKent Overstreet ); 329674cfc26SKent Overstreet 330674cfc26SKent Overstreet DEFINE_EVENT(bch_fs, btree_cache_cannibalize_unlock, 331674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c), 332674cfc26SKent Overstreet TP_ARGS(c) 333674cfc26SKent Overstreet ); 334674cfc26SKent Overstreet 335674cfc26SKent Overstreet /* Btree */ 336674cfc26SKent Overstreet 337674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_read, 338674cfc26SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 339674cfc26SKent Overstreet TP_ARGS(c, b) 340674cfc26SKent Overstreet ); 341674cfc26SKent Overstreet 342674cfc26SKent Overstreet TRACE_EVENT(btree_node_write, 3431c6fdbd8SKent Overstreet TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors), 3441c6fdbd8SKent Overstreet TP_ARGS(b, bytes, sectors), 3451c6fdbd8SKent Overstreet 3461c6fdbd8SKent Overstreet TP_STRUCT__entry( 34726609b61SKent Overstreet __field(enum btree_node_type, type) 3481c6fdbd8SKent Overstreet __field(unsigned, bytes ) 3491c6fdbd8SKent Overstreet __field(unsigned, sectors ) 3501c6fdbd8SKent Overstreet ), 3511c6fdbd8SKent Overstreet 3521c6fdbd8SKent Overstreet TP_fast_assign( 3531c6fdbd8SKent Overstreet __entry->type = btree_node_type(b); 3541c6fdbd8SKent Overstreet __entry->bytes = bytes; 3551c6fdbd8SKent Overstreet __entry->sectors = sectors; 3561c6fdbd8SKent Overstreet ), 3571c6fdbd8SKent Overstreet 3581c6fdbd8SKent Overstreet TP_printk("bkey type %u bytes %u sectors %u", 3591c6fdbd8SKent Overstreet __entry->type , __entry->bytes, __entry->sectors) 3601c6fdbd8SKent Overstreet ); 3611c6fdbd8SKent Overstreet 3621c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_alloc, 3631c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3641c6fdbd8SKent Overstreet TP_ARGS(c, b) 3651c6fdbd8SKent Overstreet ); 3661c6fdbd8SKent Overstreet 3671c6fdbd8SKent Overstreet DEFINE_EVENT(btree_node, btree_node_free, 3681c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 3691c6fdbd8SKent Overstreet TP_ARGS(c, b) 3701c6fdbd8SKent Overstreet ); 3711c6fdbd8SKent Overstreet 3721c6fdbd8SKent Overstreet TRACE_EVENT(btree_reserve_get_fail, 3735f417394SKent Overstreet TP_PROTO(const char *trans_fn, 3745f417394SKent Overstreet unsigned long caller_ip, 375adf6360bSKent Overstreet size_t required, 376adf6360bSKent Overstreet int ret), 377adf6360bSKent Overstreet TP_ARGS(trans_fn, caller_ip, required, ret), 3781c6fdbd8SKent Overstreet 3791c6fdbd8SKent Overstreet TP_STRUCT__entry( 3805f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 3815f417394SKent Overstreet __field(unsigned long, caller_ip ) 3821c6fdbd8SKent Overstreet __field(size_t, required ) 383adf6360bSKent Overstreet __array(char, ret, 32 ) 3841c6fdbd8SKent Overstreet ), 3851c6fdbd8SKent Overstreet 3861c6fdbd8SKent Overstreet TP_fast_assign( 387a1019576SKent Overstreet strscpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); 3885f417394SKent Overstreet __entry->caller_ip = caller_ip; 3891c6fdbd8SKent Overstreet __entry->required = required; 390adf6360bSKent Overstreet strscpy(__entry->ret, bch2_err_str(ret), sizeof(__entry->ret)); 3911c6fdbd8SKent Overstreet ), 3921c6fdbd8SKent Overstreet 393adf6360bSKent Overstreet TP_printk("%s %pS required %zu ret %s", 3945f417394SKent Overstreet __entry->trans_fn, 3955f417394SKent Overstreet (void *) __entry->caller_ip, 396adf6360bSKent Overstreet __entry->required, 397adf6360bSKent Overstreet __entry->ret) 3981c6fdbd8SKent Overstreet ); 3991c6fdbd8SKent Overstreet 400674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_compact, 4011c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4021c6fdbd8SKent Overstreet TP_ARGS(c, b) 4031c6fdbd8SKent Overstreet ); 4041c6fdbd8SKent Overstreet 405674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_merge, 4061c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4071c6fdbd8SKent Overstreet TP_ARGS(c, b) 4081c6fdbd8SKent Overstreet ); 4091c6fdbd8SKent Overstreet 410674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_split, 4111c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4121c6fdbd8SKent Overstreet TP_ARGS(c, b) 4131c6fdbd8SKent Overstreet ); 4141c6fdbd8SKent Overstreet 415674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_rewrite, 4161f93726eSKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4171f93726eSKent Overstreet TP_ARGS(c, b) 4181f93726eSKent Overstreet ); 4191f93726eSKent Overstreet 420674cfc26SKent Overstreet DEFINE_EVENT(btree_node, btree_node_set_root, 4211c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c, struct btree *b), 4221c6fdbd8SKent Overstreet TP_ARGS(c, b) 4231c6fdbd8SKent Overstreet ); 4241c6fdbd8SKent Overstreet 425674cfc26SKent Overstreet TRACE_EVENT(btree_path_relock_fail, 4269f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 427bc82d08bSKent Overstreet unsigned long caller_ip, 4289f96568cSKent Overstreet struct btree_path *path, 4299f96568cSKent Overstreet unsigned level), 4309f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path, level), 431bc82d08bSKent Overstreet 432bc82d08bSKent Overstreet TP_STRUCT__entry( 4335f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 4344b59a319SKent Overstreet __field(unsigned long, caller_ip ) 435bc82d08bSKent Overstreet __field(u8, btree_id ) 436367d72ddSKent Overstreet __field(u8, level ) 4379f96568cSKent Overstreet TRACE_BPOS_entries(pos) 4385f1dd9a6SKent Overstreet __array(char, node, 24 ) 43955d5276dSKent Overstreet __field(u8, self_read_count ) 44055d5276dSKent Overstreet __field(u8, self_intent_count) 44155d5276dSKent Overstreet __field(u8, read_count ) 44255d5276dSKent Overstreet __field(u8, intent_count ) 443bc82d08bSKent Overstreet __field(u32, iter_lock_seq ) 444bc82d08bSKent Overstreet __field(u32, node_lock_seq ) 445bc82d08bSKent Overstreet ), 446bc82d08bSKent Overstreet 447bc82d08bSKent Overstreet TP_fast_assign( 4485f1dd9a6SKent Overstreet struct btree *b = btree_path_node(path, level); 44955d5276dSKent Overstreet struct six_lock_count c; 4505f1dd9a6SKent Overstreet 451a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 4524b59a319SKent Overstreet __entry->caller_ip = caller_ip; 4539f96568cSKent Overstreet __entry->btree_id = path->btree_id; 454367d72ddSKent Overstreet __entry->level = path->level; 4559f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 45655d5276dSKent Overstreet 45755d5276dSKent Overstreet c = bch2_btree_node_lock_counts(trans, NULL, &path->l[level].b->c, level), 45855d5276dSKent Overstreet __entry->self_read_count = c.n[SIX_LOCK_read]; 45955d5276dSKent Overstreet __entry->self_intent_count = c.n[SIX_LOCK_intent]; 46055d5276dSKent Overstreet 46155d5276dSKent Overstreet if (IS_ERR(b)) { 4625f1dd9a6SKent Overstreet strscpy(__entry->node, bch2_err_str(PTR_ERR(b)), sizeof(__entry->node)); 46355d5276dSKent Overstreet } else { 46455d5276dSKent Overstreet c = six_lock_counts(&path->l[level].b->c.lock); 46555d5276dSKent Overstreet __entry->read_count = c.n[SIX_LOCK_read]; 46655d5276dSKent Overstreet __entry->intent_count = c.n[SIX_LOCK_intent]; 4675f1dd9a6SKent Overstreet scnprintf(__entry->node, sizeof(__entry->node), "%px", b); 46855d5276dSKent Overstreet } 4699f96568cSKent Overstreet __entry->iter_lock_seq = path->l[level].lock_seq; 4701fb4fe63SKent Overstreet __entry->node_lock_seq = is_btree_node(path, level) 4711fb4fe63SKent Overstreet ? six_lock_seq(&path->l[level].b->c.lock) 4721fb4fe63SKent Overstreet : 0; 473bc82d08bSKent Overstreet ), 474bc82d08bSKent Overstreet 47555d5276dSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u level %u node %s held %u:%u lock count %u:%u iter seq %u lock seq %u", 476bc82d08bSKent Overstreet __entry->trans_fn, 4774b59a319SKent Overstreet (void *) __entry->caller_ip, 47888dfe193SKent Overstreet bch2_btree_id_str(__entry->btree_id), 479bc82d08bSKent Overstreet __entry->pos_inode, 480bc82d08bSKent Overstreet __entry->pos_offset, 481bc82d08bSKent Overstreet __entry->pos_snapshot, 482367d72ddSKent Overstreet __entry->level, 483bc82d08bSKent Overstreet __entry->node, 48455d5276dSKent Overstreet __entry->self_read_count, 48555d5276dSKent Overstreet __entry->self_intent_count, 48655d5276dSKent Overstreet __entry->read_count, 48755d5276dSKent Overstreet __entry->intent_count, 488bc82d08bSKent Overstreet __entry->iter_lock_seq, 489bc82d08bSKent Overstreet __entry->node_lock_seq) 490bc82d08bSKent Overstreet ); 491bc82d08bSKent Overstreet 492674cfc26SKent Overstreet TRACE_EVENT(btree_path_upgrade_fail, 4939f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 49449e401faSKent Overstreet unsigned long caller_ip, 4959f96568cSKent Overstreet struct btree_path *path, 4969f96568cSKent Overstreet unsigned level), 4979f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path, level), 49849e401faSKent Overstreet 49949e401faSKent Overstreet TP_STRUCT__entry( 5005f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 50149e401faSKent Overstreet __field(unsigned long, caller_ip ) 50249e401faSKent Overstreet __field(u8, btree_id ) 503367d72ddSKent Overstreet __field(u8, level ) 5049f96568cSKent Overstreet TRACE_BPOS_entries(pos) 50549e401faSKent Overstreet __field(u8, locked ) 50649e401faSKent Overstreet __field(u8, self_read_count ) 50749e401faSKent Overstreet __field(u8, self_intent_count) 5089f96568cSKent Overstreet __field(u8, read_count ) 50949e401faSKent Overstreet __field(u8, intent_count ) 510367d72ddSKent Overstreet __field(u32, iter_lock_seq ) 511367d72ddSKent Overstreet __field(u32, node_lock_seq ) 51249e401faSKent Overstreet ), 51349e401faSKent Overstreet 51449e401faSKent Overstreet TP_fast_assign( 5159f96568cSKent Overstreet struct six_lock_count c; 5169f96568cSKent Overstreet 517a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 51849e401faSKent Overstreet __entry->caller_ip = caller_ip; 5199f96568cSKent Overstreet __entry->btree_id = path->btree_id; 520367d72ddSKent Overstreet __entry->level = level; 5219f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 5229f96568cSKent Overstreet __entry->locked = btree_node_locked(path, level); 5239f96568cSKent Overstreet 52414599cceSKent Overstreet c = bch2_btree_node_lock_counts(trans, NULL, &path->l[level].b->c, level), 525e3738c69SKent Overstreet __entry->self_read_count = c.n[SIX_LOCK_read]; 526e3738c69SKent Overstreet __entry->self_intent_count = c.n[SIX_LOCK_intent]; 5279f96568cSKent Overstreet c = six_lock_counts(&path->l[level].b->c.lock); 528e3738c69SKent Overstreet __entry->read_count = c.n[SIX_LOCK_read]; 52955d5276dSKent Overstreet __entry->intent_count = c.n[SIX_LOCK_intent]; 530367d72ddSKent Overstreet __entry->iter_lock_seq = path->l[level].lock_seq; 5311fb4fe63SKent Overstreet __entry->node_lock_seq = is_btree_node(path, level) 5321fb4fe63SKent Overstreet ? six_lock_seq(&path->l[level].b->c.lock) 5331fb4fe63SKent Overstreet : 0; 53449e401faSKent Overstreet ), 53549e401faSKent Overstreet 536367d72ddSKent 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", 53749e401faSKent Overstreet __entry->trans_fn, 53849e401faSKent Overstreet (void *) __entry->caller_ip, 53988dfe193SKent Overstreet bch2_btree_id_str(__entry->btree_id), 54049e401faSKent Overstreet __entry->pos_inode, 54149e401faSKent Overstreet __entry->pos_offset, 54249e401faSKent Overstreet __entry->pos_snapshot, 543367d72ddSKent Overstreet __entry->level, 54449e401faSKent Overstreet __entry->locked, 54549e401faSKent Overstreet __entry->self_read_count, 54649e401faSKent Overstreet __entry->self_intent_count, 54749e401faSKent Overstreet __entry->read_count, 548367d72ddSKent Overstreet __entry->intent_count, 549367d72ddSKent Overstreet __entry->iter_lock_seq, 550367d72ddSKent Overstreet __entry->node_lock_seq) 55149e401faSKent Overstreet ); 55249e401faSKent Overstreet 5531c6fdbd8SKent Overstreet /* Garbage collection */ 5541c6fdbd8SKent Overstreet 5551f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_start, 5561c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 5571c6fdbd8SKent Overstreet TP_ARGS(c) 5581c6fdbd8SKent Overstreet ); 5591c6fdbd8SKent Overstreet 5601f93726eSKent Overstreet DEFINE_EVENT(bch_fs, gc_gens_end, 5611c6fdbd8SKent Overstreet TP_PROTO(struct bch_fs *c), 5621c6fdbd8SKent Overstreet TP_ARGS(c) 5631c6fdbd8SKent Overstreet ); 5641c6fdbd8SKent Overstreet 5651c6fdbd8SKent Overstreet /* Allocator */ 5661c6fdbd8SKent Overstreet 5671c6fdbd8SKent Overstreet DECLARE_EVENT_CLASS(bucket_alloc, 568f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 56968b6cd19SKent Overstreet u64 bucket, 5708ef98313SKent Overstreet u64 free, 571f25d8215SKent Overstreet u64 avail, 5728ef98313SKent Overstreet u64 copygc_wait_amount, 5738ef98313SKent Overstreet s64 copygc_waiting_for, 574ae10fe01SKent Overstreet struct bucket_alloc_state *s, 575f25d8215SKent Overstreet bool nonblocking, 576615f867cSKent Overstreet const char *err), 5777635e1a6SKent Overstreet TP_ARGS(ca, alloc_reserve, bucket, free, avail, 57868b6cd19SKent Overstreet copygc_wait_amount, copygc_waiting_for, 579ae10fe01SKent Overstreet s, nonblocking, err), 5801c6fdbd8SKent Overstreet 5811c6fdbd8SKent Overstreet TP_STRUCT__entry( 5821a14e255SKent Overstreet __field(u8, dev ) 5833e154711SKent Overstreet __array(char, reserve, 16 ) 58468b6cd19SKent Overstreet __field(u64, bucket ) 5858ef98313SKent Overstreet __field(u64, free ) 586f25d8215SKent Overstreet __field(u64, avail ) 5878ef98313SKent Overstreet __field(u64, copygc_wait_amount ) 5888ef98313SKent Overstreet __field(s64, copygc_waiting_for ) 589f25d8215SKent Overstreet __field(u64, seen ) 590f25d8215SKent Overstreet __field(u64, open ) 591f25d8215SKent Overstreet __field(u64, need_journal_commit ) 592f25d8215SKent Overstreet __field(u64, nouse ) 593f25d8215SKent Overstreet __field(bool, nonblocking ) 594a8b3a677SKent Overstreet __field(u64, nocow ) 59568b6cd19SKent Overstreet __array(char, err, 32 ) 5961c6fdbd8SKent Overstreet ), 5971c6fdbd8SKent Overstreet 5981c6fdbd8SKent Overstreet TP_fast_assign( 5991a14e255SKent Overstreet __entry->dev = ca->dev_idx; 600a1019576SKent Overstreet strscpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); 60168b6cd19SKent Overstreet __entry->bucket = bucket; 6028ef98313SKent Overstreet __entry->free = free; 603f25d8215SKent Overstreet __entry->avail = avail; 6048ef98313SKent Overstreet __entry->copygc_wait_amount = copygc_wait_amount; 6058ef98313SKent Overstreet __entry->copygc_waiting_for = copygc_waiting_for; 606ae10fe01SKent Overstreet __entry->seen = s->buckets_seen; 607ae10fe01SKent Overstreet __entry->open = s->skipped_open; 608ae10fe01SKent Overstreet __entry->need_journal_commit = s->skipped_need_journal_commit; 609ae10fe01SKent Overstreet __entry->nouse = s->skipped_nouse; 610f25d8215SKent Overstreet __entry->nonblocking = nonblocking; 611a8b3a677SKent Overstreet __entry->nocow = s->skipped_nocow; 612a1019576SKent Overstreet strscpy(__entry->err, err, sizeof(__entry->err)); 6131c6fdbd8SKent Overstreet ), 6141c6fdbd8SKent Overstreet 6157635e1a6SKent 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", 616f25d8215SKent Overstreet __entry->reserve, 6171a14e255SKent Overstreet __entry->dev, 61868b6cd19SKent Overstreet __entry->bucket, 6198ef98313SKent Overstreet __entry->free, 620f25d8215SKent Overstreet __entry->avail, 6218ef98313SKent Overstreet __entry->copygc_wait_amount, 6228ef98313SKent Overstreet __entry->copygc_waiting_for, 623f25d8215SKent Overstreet __entry->seen, 624f25d8215SKent Overstreet __entry->open, 625f25d8215SKent Overstreet __entry->need_journal_commit, 626f25d8215SKent Overstreet __entry->nouse, 627a8b3a677SKent Overstreet __entry->nocow, 628f25d8215SKent Overstreet __entry->nonblocking, 629615f867cSKent Overstreet __entry->err) 6301c6fdbd8SKent Overstreet ); 6311c6fdbd8SKent Overstreet 6321c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc, 633f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 63468b6cd19SKent Overstreet u64 bucket, 6358ef98313SKent Overstreet u64 free, 636f25d8215SKent Overstreet u64 avail, 6378ef98313SKent Overstreet u64 copygc_wait_amount, 6388ef98313SKent Overstreet s64 copygc_waiting_for, 639ae10fe01SKent Overstreet struct bucket_alloc_state *s, 640f25d8215SKent Overstreet bool nonblocking, 641615f867cSKent Overstreet const char *err), 6427635e1a6SKent Overstreet TP_ARGS(ca, alloc_reserve, bucket, free, avail, 64368b6cd19SKent Overstreet copygc_wait_amount, copygc_waiting_for, 644ae10fe01SKent Overstreet s, nonblocking, err) 6451c6fdbd8SKent Overstreet ); 6461c6fdbd8SKent Overstreet 6471c6fdbd8SKent Overstreet DEFINE_EVENT(bucket_alloc, bucket_alloc_fail, 648f25d8215SKent Overstreet TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, 64968b6cd19SKent Overstreet u64 bucket, 6508ef98313SKent Overstreet u64 free, 651f25d8215SKent Overstreet u64 avail, 6528ef98313SKent Overstreet u64 copygc_wait_amount, 6538ef98313SKent Overstreet s64 copygc_waiting_for, 654ae10fe01SKent Overstreet struct bucket_alloc_state *s, 655f25d8215SKent Overstreet bool nonblocking, 656615f867cSKent Overstreet const char *err), 6577635e1a6SKent Overstreet TP_ARGS(ca, alloc_reserve, bucket, free, avail, 65868b6cd19SKent Overstreet copygc_wait_amount, copygc_waiting_for, 659ae10fe01SKent Overstreet s, nonblocking, err) 6601c6fdbd8SKent Overstreet ); 6611c6fdbd8SKent Overstreet 6621f93726eSKent Overstreet TRACE_EVENT(discard_buckets, 6631f93726eSKent Overstreet TP_PROTO(struct bch_fs *c, u64 seen, u64 open, 664615f867cSKent Overstreet u64 need_journal_commit, u64 discarded, const char *err), 665615f867cSKent Overstreet TP_ARGS(c, seen, open, need_journal_commit, discarded, err), 6661f93726eSKent Overstreet 6671f93726eSKent Overstreet TP_STRUCT__entry( 6681f93726eSKent Overstreet __field(dev_t, dev ) 6691f93726eSKent Overstreet __field(u64, seen ) 6701f93726eSKent Overstreet __field(u64, open ) 6711f93726eSKent Overstreet __field(u64, need_journal_commit ) 6721f93726eSKent Overstreet __field(u64, discarded ) 673615f867cSKent Overstreet __array(char, err, 16 ) 6741f93726eSKent Overstreet ), 6751f93726eSKent Overstreet 6761f93726eSKent Overstreet TP_fast_assign( 6771f93726eSKent Overstreet __entry->dev = c->dev; 6781f93726eSKent Overstreet __entry->seen = seen; 6791f93726eSKent Overstreet __entry->open = open; 6801f93726eSKent Overstreet __entry->need_journal_commit = need_journal_commit; 6811f93726eSKent Overstreet __entry->discarded = discarded; 682a1019576SKent Overstreet strscpy(__entry->err, err, sizeof(__entry->err)); 6831f93726eSKent Overstreet ), 6841f93726eSKent Overstreet 685615f867cSKent Overstreet TP_printk("%d%d seen %llu open %llu need_journal_commit %llu discarded %llu err %s", 6861f93726eSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 6871f93726eSKent Overstreet __entry->seen, 6881f93726eSKent Overstreet __entry->open, 6891f93726eSKent Overstreet __entry->need_journal_commit, 6901f93726eSKent Overstreet __entry->discarded, 691615f867cSKent Overstreet __entry->err) 6921f93726eSKent Overstreet ); 6931f93726eSKent Overstreet 694674cfc26SKent Overstreet TRACE_EVENT(bucket_invalidate, 69538585367SKent Overstreet TP_PROTO(struct bch_fs *c, unsigned dev, u64 bucket, u32 sectors), 69638585367SKent Overstreet TP_ARGS(c, dev, bucket, sectors), 6971f93726eSKent Overstreet 6981f93726eSKent Overstreet TP_STRUCT__entry( 6991f93726eSKent Overstreet __field(dev_t, dev ) 7001f93726eSKent Overstreet __field(u32, dev_idx ) 70138585367SKent Overstreet __field(u32, sectors ) 7021f93726eSKent Overstreet __field(u64, bucket ) 7031f93726eSKent Overstreet ), 7041f93726eSKent Overstreet 7051f93726eSKent Overstreet TP_fast_assign( 7061f93726eSKent Overstreet __entry->dev = c->dev; 7071f93726eSKent Overstreet __entry->dev_idx = dev; 70838585367SKent Overstreet __entry->sectors = sectors; 7091f93726eSKent Overstreet __entry->bucket = bucket; 7101f93726eSKent Overstreet ), 7111f93726eSKent Overstreet 71238585367SKent Overstreet TP_printk("%d:%d invalidated %u:%llu cached sectors %u", 7131f93726eSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 71438585367SKent Overstreet __entry->dev_idx, __entry->bucket, 71538585367SKent Overstreet __entry->sectors) 7161f93726eSKent Overstreet ); 7171f93726eSKent Overstreet 7181c6fdbd8SKent Overstreet /* Moving IO */ 7191c6fdbd8SKent Overstreet 7205a21764dSKent Overstreet TRACE_EVENT(bucket_evacuate, 7215a21764dSKent Overstreet TP_PROTO(struct bch_fs *c, struct bpos *bucket), 7225a21764dSKent Overstreet TP_ARGS(c, bucket), 7235a21764dSKent Overstreet 7245a21764dSKent Overstreet TP_STRUCT__entry( 7255a21764dSKent Overstreet __field(dev_t, dev ) 7265a21764dSKent Overstreet __field(u32, dev_idx ) 7275a21764dSKent Overstreet __field(u64, bucket ) 7285a21764dSKent Overstreet ), 7295a21764dSKent Overstreet 7305a21764dSKent Overstreet TP_fast_assign( 7315a21764dSKent Overstreet __entry->dev = c->dev; 7325a21764dSKent Overstreet __entry->dev_idx = bucket->inode; 7335a21764dSKent Overstreet __entry->bucket = bucket->offset; 7345a21764dSKent Overstreet ), 7355a21764dSKent Overstreet 7365a21764dSKent Overstreet TP_printk("%d:%d %u:%llu", 7375a21764dSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 7385a21764dSKent Overstreet __entry->dev_idx, __entry->bucket) 7395a21764dSKent Overstreet ); 7405a21764dSKent Overstreet 741*25d1e39dSKent Overstreet DEFINE_EVENT(str, move_extent, 7425a21764dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *k), 7435a21764dSKent Overstreet TP_ARGS(c, k) 7445a21764dSKent Overstreet ); 7455a21764dSKent Overstreet 746*25d1e39dSKent Overstreet DEFINE_EVENT(str, move_extent_read, 7475a21764dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *k), 7485a21764dSKent Overstreet TP_ARGS(c, k) 7491c6fdbd8SKent Overstreet ); 7501c6fdbd8SKent Overstreet 751*25d1e39dSKent Overstreet DEFINE_EVENT(str, move_extent_write, 7525a21764dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *k), 7535a21764dSKent Overstreet TP_ARGS(c, k) 7541c6fdbd8SKent Overstreet ); 7551c6fdbd8SKent Overstreet 756*25d1e39dSKent Overstreet DEFINE_EVENT(str, move_extent_finish, 7575a21764dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *k), 7585a21764dSKent Overstreet TP_ARGS(c, k) 759674cfc26SKent Overstreet ); 760674cfc26SKent Overstreet 761bb6c4b92SKent Overstreet TRACE_EVENT(move_extent_fail, 762bb6c4b92SKent Overstreet TP_PROTO(struct bch_fs *c, const char *msg), 763bb6c4b92SKent Overstreet TP_ARGS(c, msg), 764bb6c4b92SKent Overstreet 765bb6c4b92SKent Overstreet TP_STRUCT__entry( 766bb6c4b92SKent Overstreet __field(dev_t, dev ) 767bb6c4b92SKent Overstreet __string(msg, msg ) 768bb6c4b92SKent Overstreet ), 769bb6c4b92SKent Overstreet 770bb6c4b92SKent Overstreet TP_fast_assign( 771bb6c4b92SKent Overstreet __entry->dev = c->dev; 772bb6c4b92SKent Overstreet __assign_str(msg, msg); 773bb6c4b92SKent Overstreet ), 774bb6c4b92SKent Overstreet 775bb6c4b92SKent Overstreet TP_printk("%d:%d %s", MAJOR(__entry->dev), MINOR(__entry->dev), __get_str(msg)) 776674cfc26SKent Overstreet ); 777674cfc26SKent Overstreet 778*25d1e39dSKent Overstreet DEFINE_EVENT(str, move_extent_start_fail, 779ae4d612cSKent Overstreet TP_PROTO(struct bch_fs *c, const char *str), 780ae4d612cSKent Overstreet TP_ARGS(c, str) 7811c6fdbd8SKent Overstreet ); 7821c6fdbd8SKent Overstreet 7831c6fdbd8SKent Overstreet TRACE_EVENT(move_data, 78496a363a7SKent Overstreet TP_PROTO(struct bch_fs *c, 78596a363a7SKent Overstreet struct bch_move_stats *stats), 78696a363a7SKent Overstreet TP_ARGS(c, stats), 7871c6fdbd8SKent Overstreet 7881c6fdbd8SKent Overstreet TP_STRUCT__entry( 789ddc7dd62SKent Overstreet __field(dev_t, dev ) 7901c6fdbd8SKent Overstreet __field(u64, keys_moved ) 79196a363a7SKent Overstreet __field(u64, keys_raced ) 79296a363a7SKent Overstreet __field(u64, sectors_seen ) 79396a363a7SKent Overstreet __field(u64, sectors_moved ) 79496a363a7SKent Overstreet __field(u64, sectors_raced ) 7951c6fdbd8SKent Overstreet ), 7961c6fdbd8SKent Overstreet 7971c6fdbd8SKent Overstreet TP_fast_assign( 798ddc7dd62SKent Overstreet __entry->dev = c->dev; 79996a363a7SKent Overstreet __entry->keys_moved = atomic64_read(&stats->keys_moved); 80096a363a7SKent Overstreet __entry->keys_raced = atomic64_read(&stats->keys_raced); 80196a363a7SKent Overstreet __entry->sectors_seen = atomic64_read(&stats->sectors_seen); 80296a363a7SKent Overstreet __entry->sectors_moved = atomic64_read(&stats->sectors_moved); 80396a363a7SKent Overstreet __entry->sectors_raced = atomic64_read(&stats->sectors_raced); 8041c6fdbd8SKent Overstreet ), 8051c6fdbd8SKent Overstreet 80696a363a7SKent Overstreet TP_printk("%d,%d keys moved %llu raced %llu" 80796a363a7SKent Overstreet "sectors seen %llu moved %llu raced %llu", 808ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 80996a363a7SKent Overstreet __entry->keys_moved, 81096a363a7SKent Overstreet __entry->keys_raced, 81196a363a7SKent Overstreet __entry->sectors_seen, 81296a363a7SKent Overstreet __entry->sectors_moved, 81396a363a7SKent Overstreet __entry->sectors_raced) 8141c6fdbd8SKent Overstreet ); 8151c6fdbd8SKent Overstreet 8168e3f913eSKent Overstreet TRACE_EVENT(evacuate_bucket, 8178e3f913eSKent Overstreet TP_PROTO(struct bch_fs *c, struct bpos *bucket, 8188e3f913eSKent Overstreet unsigned sectors, unsigned bucket_size, 81980c33085SKent Overstreet u64 fragmentation, int ret), 82080c33085SKent Overstreet TP_ARGS(c, bucket, sectors, bucket_size, fragmentation, ret), 8218e3f913eSKent Overstreet 8228e3f913eSKent Overstreet TP_STRUCT__entry( 8238e3f913eSKent Overstreet __field(dev_t, dev ) 8248e3f913eSKent Overstreet __field(u64, member ) 8258e3f913eSKent Overstreet __field(u64, bucket ) 8268e3f913eSKent Overstreet __field(u32, sectors ) 8278e3f913eSKent Overstreet __field(u32, bucket_size ) 82880c33085SKent Overstreet __field(u64, fragmentation ) 8298e3f913eSKent Overstreet __field(int, ret ) 8308e3f913eSKent Overstreet ), 8318e3f913eSKent Overstreet 8328e3f913eSKent Overstreet TP_fast_assign( 8338e3f913eSKent Overstreet __entry->dev = c->dev; 8348e3f913eSKent Overstreet __entry->member = bucket->inode; 8358e3f913eSKent Overstreet __entry->bucket = bucket->offset; 8368e3f913eSKent Overstreet __entry->sectors = sectors; 8378e3f913eSKent Overstreet __entry->bucket_size = bucket_size; 83880c33085SKent Overstreet __entry->fragmentation = fragmentation; 8398e3f913eSKent Overstreet __entry->ret = ret; 8408e3f913eSKent Overstreet ), 8418e3f913eSKent Overstreet 84280c33085SKent Overstreet TP_printk("%d,%d %llu:%llu sectors %u/%u fragmentation %llu ret %i", 8438e3f913eSKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 8448e3f913eSKent Overstreet __entry->member, __entry->bucket, 8458e3f913eSKent Overstreet __entry->sectors, __entry->bucket_size, 84680c33085SKent Overstreet __entry->fragmentation, __entry->ret) 8478e3f913eSKent Overstreet ); 8488e3f913eSKent Overstreet 8491c6fdbd8SKent Overstreet TRACE_EVENT(copygc, 850e6d11615SKent Overstreet TP_PROTO(struct bch_fs *c, 8511c6fdbd8SKent Overstreet u64 sectors_moved, u64 sectors_not_moved, 8521c6fdbd8SKent Overstreet u64 buckets_moved, u64 buckets_not_moved), 853e6d11615SKent Overstreet TP_ARGS(c, 8541c6fdbd8SKent Overstreet sectors_moved, sectors_not_moved, 8551c6fdbd8SKent Overstreet buckets_moved, buckets_not_moved), 8561c6fdbd8SKent Overstreet 8571c6fdbd8SKent Overstreet TP_STRUCT__entry( 858ddc7dd62SKent Overstreet __field(dev_t, dev ) 8591c6fdbd8SKent Overstreet __field(u64, sectors_moved ) 8601c6fdbd8SKent Overstreet __field(u64, sectors_not_moved ) 8611c6fdbd8SKent Overstreet __field(u64, buckets_moved ) 8621c6fdbd8SKent Overstreet __field(u64, buckets_not_moved ) 8631c6fdbd8SKent Overstreet ), 8641c6fdbd8SKent Overstreet 8651c6fdbd8SKent Overstreet TP_fast_assign( 866ddc7dd62SKent Overstreet __entry->dev = c->dev; 8671c6fdbd8SKent Overstreet __entry->sectors_moved = sectors_moved; 8681c6fdbd8SKent Overstreet __entry->sectors_not_moved = sectors_not_moved; 8691c6fdbd8SKent Overstreet __entry->buckets_moved = buckets_moved; 8701c6fdbd8SKent Overstreet __entry->buckets_not_moved = buckets_moved; 8711c6fdbd8SKent Overstreet ), 8721c6fdbd8SKent Overstreet 873ddc7dd62SKent Overstreet TP_printk("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu", 874ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 8751c6fdbd8SKent Overstreet __entry->sectors_moved, __entry->sectors_not_moved, 8761c6fdbd8SKent Overstreet __entry->buckets_moved, __entry->buckets_not_moved) 8771c6fdbd8SKent Overstreet ); 8781c6fdbd8SKent Overstreet 87919d2819dSKent Overstreet TRACE_EVENT(copygc_wait, 88019d2819dSKent Overstreet TP_PROTO(struct bch_fs *c, 88119d2819dSKent Overstreet u64 wait_amount, u64 until), 88219d2819dSKent Overstreet TP_ARGS(c, wait_amount, until), 88319d2819dSKent Overstreet 88419d2819dSKent Overstreet TP_STRUCT__entry( 885ddc7dd62SKent Overstreet __field(dev_t, dev ) 88619d2819dSKent Overstreet __field(u64, wait_amount ) 88719d2819dSKent Overstreet __field(u64, until ) 88819d2819dSKent Overstreet ), 88919d2819dSKent Overstreet 89019d2819dSKent Overstreet TP_fast_assign( 891ddc7dd62SKent Overstreet __entry->dev = c->dev; 89219d2819dSKent Overstreet __entry->wait_amount = wait_amount; 89319d2819dSKent Overstreet __entry->until = until; 89419d2819dSKent Overstreet ), 89519d2819dSKent Overstreet 896ddc7dd62SKent Overstreet TP_printk("%d,%u waiting for %llu sectors until %llu", 897ddc7dd62SKent Overstreet MAJOR(__entry->dev), MINOR(__entry->dev), 898ddc7dd62SKent Overstreet __entry->wait_amount, __entry->until) 89919d2819dSKent Overstreet ); 90019d2819dSKent Overstreet 90112043cf1SKent Overstreet /* btree transactions: */ 90212043cf1SKent Overstreet 9031f93726eSKent Overstreet DECLARE_EVENT_CLASS(transaction_event, 9049f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 905531a0095SKent Overstreet unsigned long caller_ip), 9069f96568cSKent Overstreet TP_ARGS(trans, caller_ip), 907ba5c6557SKent Overstreet 908ba5c6557SKent Overstreet TP_STRUCT__entry( 9095f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 910531a0095SKent Overstreet __field(unsigned long, caller_ip ) 911ba5c6557SKent Overstreet ), 912ba5c6557SKent Overstreet 913ba5c6557SKent Overstreet TP_fast_assign( 914a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 915531a0095SKent Overstreet __entry->caller_ip = caller_ip; 916ba5c6557SKent Overstreet ), 917ba5c6557SKent Overstreet 918669f87a5SKent Overstreet TP_printk("%s %pS", __entry->trans_fn, (void *) __entry->caller_ip) 919669f87a5SKent Overstreet ); 920669f87a5SKent Overstreet 9211f93726eSKent Overstreet DEFINE_EVENT(transaction_event, transaction_commit, 9229f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 923669f87a5SKent Overstreet unsigned long caller_ip), 9249f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 925ba5c6557SKent Overstreet ); 926ba5c6557SKent Overstreet 927674cfc26SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_injected, 9289f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 929a0cb8d78SKent Overstreet unsigned long caller_ip), 9309f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 931a0cb8d78SKent Overstreet ); 932a0cb8d78SKent Overstreet 9333d86f13dSKent Overstreet TRACE_EVENT(trans_restart_split_race, 934e151580dSKent Overstreet TP_PROTO(struct btree_trans *trans, 9353d86f13dSKent Overstreet unsigned long caller_ip, 9363d86f13dSKent Overstreet struct btree *b), 9373d86f13dSKent Overstreet TP_ARGS(trans, caller_ip, b), 9383d86f13dSKent Overstreet 9393d86f13dSKent Overstreet TP_STRUCT__entry( 9403d86f13dSKent Overstreet __array(char, trans_fn, 32 ) 9413d86f13dSKent Overstreet __field(unsigned long, caller_ip ) 9423d86f13dSKent Overstreet __field(u8, level ) 9433d86f13dSKent Overstreet __field(u16, written ) 9443d86f13dSKent Overstreet __field(u16, blocks ) 9453d86f13dSKent Overstreet __field(u16, u64s_remaining ) 9463d86f13dSKent Overstreet ), 9473d86f13dSKent Overstreet 9483d86f13dSKent Overstreet TP_fast_assign( 9493d86f13dSKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 9503d86f13dSKent Overstreet __entry->caller_ip = caller_ip; 9513d86f13dSKent Overstreet __entry->level = b->c.level; 9523d86f13dSKent Overstreet __entry->written = b->written; 9533d86f13dSKent Overstreet __entry->blocks = btree_blocks(trans->c); 9543d86f13dSKent Overstreet __entry->u64s_remaining = bch_btree_keys_u64s_remaining(trans->c, b); 9553d86f13dSKent Overstreet ), 9563d86f13dSKent Overstreet 9573d86f13dSKent Overstreet TP_printk("%s %pS l=%u written %u/%u u64s remaining %u", 9583d86f13dSKent Overstreet __entry->trans_fn, (void *) __entry->caller_ip, 9593d86f13dSKent Overstreet __entry->level, 9603d86f13dSKent Overstreet __entry->written, __entry->blocks, 9613d86f13dSKent Overstreet __entry->u64s_remaining) 962e151580dSKent Overstreet ); 963e151580dSKent Overstreet 9641f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_blocked_journal_reclaim, 9659f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 966531a0095SKent Overstreet unsigned long caller_ip), 9679f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 968531a0095SKent Overstreet ); 969531a0095SKent Overstreet 970ce56bf7fSKent Overstreet TRACE_EVENT(trans_restart_journal_preres_get, 9719f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 972ce56bf7fSKent Overstreet unsigned long caller_ip, 973ce56bf7fSKent Overstreet unsigned flags), 974ce56bf7fSKent Overstreet TP_ARGS(trans, caller_ip, flags), 975ce56bf7fSKent Overstreet 976ce56bf7fSKent Overstreet TP_STRUCT__entry( 977ce56bf7fSKent Overstreet __array(char, trans_fn, 32 ) 978ce56bf7fSKent Overstreet __field(unsigned long, caller_ip ) 979ce56bf7fSKent Overstreet __field(unsigned, flags ) 980ce56bf7fSKent Overstreet ), 981ce56bf7fSKent Overstreet 982ce56bf7fSKent Overstreet TP_fast_assign( 983a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 984ce56bf7fSKent Overstreet __entry->caller_ip = caller_ip; 985ce56bf7fSKent Overstreet __entry->flags = flags; 986ce56bf7fSKent Overstreet ), 987ce56bf7fSKent Overstreet 988ce56bf7fSKent Overstreet TP_printk("%s %pS %x", __entry->trans_fn, 989ce56bf7fSKent Overstreet (void *) __entry->caller_ip, 990ce56bf7fSKent Overstreet __entry->flags) 991531a0095SKent Overstreet ); 992531a0095SKent Overstreet 9931f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_fault_inject, 9949f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 995531a0095SKent Overstreet unsigned long caller_ip), 9969f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 997531a0095SKent Overstreet ); 998531a0095SKent Overstreet 9991f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_traverse_all, 10009f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1001531a0095SKent Overstreet unsigned long caller_ip), 10029f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 1003531a0095SKent Overstreet ); 1004531a0095SKent Overstreet 10051f93726eSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_key_cache_raced, 10069f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 100712ce5b7dSKent Overstreet unsigned long caller_ip), 10089f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 100912ce5b7dSKent Overstreet ); 101012ce5b7dSKent Overstreet 10110990efaeSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_too_many_iters, 10129f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 10130990efaeSKent Overstreet unsigned long caller_ip), 10149f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 10150990efaeSKent Overstreet ); 10160990efaeSKent Overstreet 1017531a0095SKent Overstreet DECLARE_EVENT_CLASS(transaction_restart_iter, 10189f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1019531a0095SKent Overstreet unsigned long caller_ip, 10209f96568cSKent Overstreet struct btree_path *path), 10219f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path), 1022531a0095SKent Overstreet 1023531a0095SKent Overstreet TP_STRUCT__entry( 10245f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 10254b59a319SKent Overstreet __field(unsigned long, caller_ip ) 1026531a0095SKent Overstreet __field(u8, btree_id ) 10279f96568cSKent Overstreet TRACE_BPOS_entries(pos) 1028531a0095SKent Overstreet ), 1029531a0095SKent Overstreet 1030531a0095SKent Overstreet TP_fast_assign( 1031a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 10324b59a319SKent Overstreet __entry->caller_ip = caller_ip; 10339f96568cSKent Overstreet __entry->btree_id = path->btree_id; 10349f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos) 1035531a0095SKent Overstreet ), 1036531a0095SKent Overstreet 10379f96568cSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u", 1038669f87a5SKent Overstreet __entry->trans_fn, 10394b59a319SKent Overstreet (void *) __entry->caller_ip, 104088dfe193SKent Overstreet bch2_btree_id_str(__entry->btree_id), 1041531a0095SKent Overstreet __entry->pos_inode, 1042531a0095SKent Overstreet __entry->pos_offset, 1043531a0095SKent Overstreet __entry->pos_snapshot) 1044531a0095SKent Overstreet ); 1045531a0095SKent Overstreet 1046531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_reused, 10479f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1048531a0095SKent Overstreet unsigned long caller_ip, 10499f96568cSKent Overstreet struct btree_path *path), 10509f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1051531a0095SKent Overstreet ); 1052531a0095SKent Overstreet 1053531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_split, 10549f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1055531a0095SKent Overstreet unsigned long caller_ip, 10569f96568cSKent Overstreet struct btree_path *path), 10579f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1058531a0095SKent Overstreet ); 1059531a0095SKent Overstreet 1060be9e782dSKent Overstreet struct get_locks_fail; 1061be9e782dSKent Overstreet 1062367d72ddSKent Overstreet TRACE_EVENT(trans_restart_upgrade, 10639f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1064531a0095SKent Overstreet unsigned long caller_ip, 1065367d72ddSKent Overstreet struct btree_path *path, 1066367d72ddSKent Overstreet unsigned old_locks_want, 1067be9e782dSKent Overstreet unsigned new_locks_want, 1068be9e782dSKent Overstreet struct get_locks_fail *f), 1069be9e782dSKent Overstreet TP_ARGS(trans, caller_ip, path, old_locks_want, new_locks_want, f), 1070531a0095SKent Overstreet 1071367d72ddSKent Overstreet TP_STRUCT__entry( 1072367d72ddSKent Overstreet __array(char, trans_fn, 32 ) 1073367d72ddSKent Overstreet __field(unsigned long, caller_ip ) 1074367d72ddSKent Overstreet __field(u8, btree_id ) 1075367d72ddSKent Overstreet __field(u8, old_locks_want ) 1076367d72ddSKent Overstreet __field(u8, new_locks_want ) 1077be9e782dSKent Overstreet __field(u8, level ) 1078be9e782dSKent Overstreet __field(u32, path_seq ) 1079be9e782dSKent Overstreet __field(u32, node_seq ) 1080be9e782dSKent Overstreet __field(u32, path_alloc_seq ) 1081be9e782dSKent Overstreet __field(u32, downgrade_seq) 1082367d72ddSKent Overstreet TRACE_BPOS_entries(pos) 1083367d72ddSKent Overstreet ), 1084367d72ddSKent Overstreet 1085367d72ddSKent Overstreet TP_fast_assign( 1086a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 1087367d72ddSKent Overstreet __entry->caller_ip = caller_ip; 1088367d72ddSKent Overstreet __entry->btree_id = path->btree_id; 1089367d72ddSKent Overstreet __entry->old_locks_want = old_locks_want; 1090367d72ddSKent Overstreet __entry->new_locks_want = new_locks_want; 1091be9e782dSKent Overstreet __entry->level = f->l; 1092be9e782dSKent Overstreet __entry->path_seq = path->l[f->l].lock_seq; 1093be9e782dSKent Overstreet __entry->node_seq = IS_ERR_OR_NULL(f->b) ? 0 : f->b->c.lock.seq; 1094be9e782dSKent Overstreet __entry->path_alloc_seq = path->alloc_seq; 1095be9e782dSKent Overstreet __entry->downgrade_seq = path->downgrade_seq; 1096367d72ddSKent Overstreet TRACE_BPOS_assign(pos, path->pos) 1097367d72ddSKent Overstreet ), 1098367d72ddSKent Overstreet 1099be9e782dSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u locks_want %u -> %u level %u path seq %u node seq %u alloc_seq %u downgrade_seq %u", 1100367d72ddSKent Overstreet __entry->trans_fn, 1101367d72ddSKent Overstreet (void *) __entry->caller_ip, 110288dfe193SKent Overstreet bch2_btree_id_str(__entry->btree_id), 1103367d72ddSKent Overstreet __entry->pos_inode, 1104367d72ddSKent Overstreet __entry->pos_offset, 1105367d72ddSKent Overstreet __entry->pos_snapshot, 1106367d72ddSKent Overstreet __entry->old_locks_want, 1107be9e782dSKent Overstreet __entry->new_locks_want, 1108be9e782dSKent Overstreet __entry->level, 1109be9e782dSKent Overstreet __entry->path_seq, 1110be9e782dSKent Overstreet __entry->node_seq, 1111be9e782dSKent Overstreet __entry->path_alloc_seq, 1112be9e782dSKent Overstreet __entry->downgrade_seq) 1113531a0095SKent Overstreet ); 1114531a0095SKent Overstreet 1115531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock, 11169f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1117531a0095SKent Overstreet unsigned long caller_ip, 11189f96568cSKent Overstreet struct btree_path *path), 11199f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1120531a0095SKent Overstreet ); 1121531a0095SKent Overstreet 1122bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_next_node, 11239f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1124bc82d08bSKent Overstreet unsigned long caller_ip, 11259f96568cSKent Overstreet struct btree_path *path), 11269f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1127bc82d08bSKent Overstreet ); 1128bc82d08bSKent Overstreet 1129bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_parent_for_fill, 11309f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1131bc82d08bSKent Overstreet unsigned long caller_ip, 11329f96568cSKent Overstreet struct btree_path *path), 11339f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1134bc82d08bSKent Overstreet ); 1135bc82d08bSKent Overstreet 1136bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_after_fill, 11379f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1138bc82d08bSKent Overstreet unsigned long caller_ip, 11399f96568cSKent Overstreet struct btree_path *path), 11409f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1141bc82d08bSKent Overstreet ); 1142bc82d08bSKent Overstreet 1143674cfc26SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_key_cache_upgrade, 11449f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 114549e401faSKent Overstreet unsigned long caller_ip), 11469f96568cSKent Overstreet TP_ARGS(trans, caller_ip) 114749e401faSKent Overstreet ); 114849e401faSKent Overstreet 1149bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_key_cache_fill, 11509f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1151bc82d08bSKent Overstreet unsigned long caller_ip, 11529f96568cSKent Overstreet struct btree_path *path), 11539f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1154bc82d08bSKent Overstreet ); 1155bc82d08bSKent Overstreet 1156bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_path, 11579f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1158bc82d08bSKent Overstreet unsigned long caller_ip, 11599f96568cSKent Overstreet struct btree_path *path), 11609f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1161bc82d08bSKent Overstreet ); 1162bc82d08bSKent Overstreet 1163bc82d08bSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_relock_path_intent, 11649f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1165bc82d08bSKent Overstreet unsigned long caller_ip, 11669f96568cSKent Overstreet struct btree_path *path), 11679f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1168bc82d08bSKent Overstreet ); 1169bc82d08bSKent Overstreet 1170531a0095SKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_traverse, 11719f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1172531a0095SKent Overstreet unsigned long caller_ip, 11739f96568cSKent Overstreet struct btree_path *path), 11749f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 1175531a0095SKent Overstreet ); 1176531a0095SKent Overstreet 11778f9ad91aSKent Overstreet DEFINE_EVENT(transaction_restart_iter, trans_restart_memory_allocation_failure, 11789f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 11798f9ad91aSKent Overstreet unsigned long caller_ip, 11809f96568cSKent Overstreet struct btree_path *path), 11819f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path) 11828f9ad91aSKent Overstreet ); 11838f9ad91aSKent Overstreet 11840d7009d7SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_would_deadlock, 11859f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 11860d7009d7SKent Overstreet unsigned long caller_ip), 11870d7009d7SKent Overstreet TP_ARGS(trans, caller_ip) 1188ba5c6557SKent Overstreet ); 1189ba5c6557SKent Overstreet 119033bd5d06SKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_would_deadlock_recursion_limit, 119133bd5d06SKent Overstreet TP_PROTO(struct btree_trans *trans, 119233bd5d06SKent Overstreet unsigned long caller_ip), 119333bd5d06SKent Overstreet TP_ARGS(trans, caller_ip) 119433bd5d06SKent Overstreet ); 119533bd5d06SKent Overstreet 1196caaa66aaSKent Overstreet TRACE_EVENT(trans_restart_would_deadlock_write, 11979f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans), 11989f96568cSKent Overstreet TP_ARGS(trans), 1199caaa66aaSKent Overstreet 1200caaa66aaSKent Overstreet TP_STRUCT__entry( 12015f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 1202caaa66aaSKent Overstreet ), 1203caaa66aaSKent Overstreet 1204caaa66aaSKent Overstreet TP_fast_assign( 1205a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 1206caaa66aaSKent Overstreet ), 1207caaa66aaSKent Overstreet 1208669f87a5SKent Overstreet TP_printk("%s", __entry->trans_fn) 1209caaa66aaSKent Overstreet ); 1210caaa66aaSKent Overstreet 121120bceecbSKent Overstreet TRACE_EVENT(trans_restart_mem_realloced, 12129f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1213669f87a5SKent Overstreet unsigned long caller_ip, 121473a117d2SKent Overstreet unsigned long bytes), 12159f96568cSKent Overstreet TP_ARGS(trans, caller_ip, bytes), 121620bceecbSKent Overstreet 121720bceecbSKent Overstreet TP_STRUCT__entry( 12185f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 121973a117d2SKent Overstreet __field(unsigned long, caller_ip ) 122020bceecbSKent Overstreet __field(unsigned long, bytes ) 122120bceecbSKent Overstreet ), 122220bceecbSKent Overstreet 122320bceecbSKent Overstreet TP_fast_assign( 1224a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 122573a117d2SKent Overstreet __entry->caller_ip = caller_ip; 122620bceecbSKent Overstreet __entry->bytes = bytes; 122720bceecbSKent Overstreet ), 122820bceecbSKent Overstreet 1229669f87a5SKent Overstreet TP_printk("%s %pS bytes %lu", 1230669f87a5SKent Overstreet __entry->trans_fn, 123173a117d2SKent Overstreet (void *) __entry->caller_ip, 123273a117d2SKent Overstreet __entry->bytes) 1233ba5c6557SKent Overstreet ); 1234ba5c6557SKent Overstreet 12353a306f3cSKent Overstreet TRACE_EVENT(trans_restart_key_cache_key_realloced, 12369f96568cSKent Overstreet TP_PROTO(struct btree_trans *trans, 1237ddf11d8cSKent Overstreet unsigned long caller_ip, 12389f96568cSKent Overstreet struct btree_path *path, 12393a306f3cSKent Overstreet unsigned old_u64s, 12403a306f3cSKent Overstreet unsigned new_u64s), 12419f96568cSKent Overstreet TP_ARGS(trans, caller_ip, path, old_u64s, new_u64s), 12423a306f3cSKent Overstreet 12433a306f3cSKent Overstreet TP_STRUCT__entry( 12445f1dd9a6SKent Overstreet __array(char, trans_fn, 32 ) 12453a306f3cSKent Overstreet __field(unsigned long, caller_ip ) 12463a306f3cSKent Overstreet __field(enum btree_id, btree_id ) 12479f96568cSKent Overstreet TRACE_BPOS_entries(pos) 12483a306f3cSKent Overstreet __field(u32, old_u64s ) 12493a306f3cSKent Overstreet __field(u32, new_u64s ) 12503a306f3cSKent Overstreet ), 12513a306f3cSKent Overstreet 12523a306f3cSKent Overstreet TP_fast_assign( 1253a1019576SKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 12543a306f3cSKent Overstreet __entry->caller_ip = caller_ip; 12559f96568cSKent Overstreet 12569f96568cSKent Overstreet __entry->btree_id = path->btree_id; 12579f96568cSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 12583a306f3cSKent Overstreet __entry->old_u64s = old_u64s; 12593a306f3cSKent Overstreet __entry->new_u64s = new_u64s; 12603a306f3cSKent Overstreet ), 12613a306f3cSKent Overstreet 12623a306f3cSKent Overstreet TP_printk("%s %pS btree %s pos %llu:%llu:%u old_u64s %u new_u64s %u", 12633a306f3cSKent Overstreet __entry->trans_fn, 12643a306f3cSKent Overstreet (void *) __entry->caller_ip, 126588dfe193SKent Overstreet bch2_btree_id_str(__entry->btree_id), 126649e401faSKent Overstreet __entry->pos_inode, 126749e401faSKent Overstreet __entry->pos_offset, 12689f96568cSKent Overstreet __entry->pos_snapshot, 12699f96568cSKent Overstreet __entry->old_u64s, 12709f96568cSKent Overstreet __entry->new_u64s) 127149e401faSKent Overstreet ); 127249e401faSKent Overstreet 1273be9e782dSKent Overstreet TRACE_EVENT(path_downgrade, 1274be9e782dSKent Overstreet TP_PROTO(struct btree_trans *trans, 1275be9e782dSKent Overstreet unsigned long caller_ip, 1276eb54e81fSKent Overstreet struct btree_path *path, 1277eb54e81fSKent Overstreet unsigned old_locks_want), 1278eb54e81fSKent Overstreet TP_ARGS(trans, caller_ip, path, old_locks_want), 1279be9e782dSKent Overstreet 1280be9e782dSKent Overstreet TP_STRUCT__entry( 1281be9e782dSKent Overstreet __array(char, trans_fn, 32 ) 1282be9e782dSKent Overstreet __field(unsigned long, caller_ip ) 1283eb54e81fSKent Overstreet __field(unsigned, old_locks_want ) 1284eb54e81fSKent Overstreet __field(unsigned, new_locks_want ) 1285eb54e81fSKent Overstreet __field(unsigned, btree ) 1286eb54e81fSKent Overstreet TRACE_BPOS_entries(pos) 1287be9e782dSKent Overstreet ), 1288be9e782dSKent Overstreet 1289be9e782dSKent Overstreet TP_fast_assign( 1290be9e782dSKent Overstreet strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); 1291be9e782dSKent Overstreet __entry->caller_ip = caller_ip; 1292eb54e81fSKent Overstreet __entry->old_locks_want = old_locks_want; 1293eb54e81fSKent Overstreet __entry->new_locks_want = path->locks_want; 1294eb54e81fSKent Overstreet __entry->btree = path->btree_id; 1295eb54e81fSKent Overstreet TRACE_BPOS_assign(pos, path->pos); 1296be9e782dSKent Overstreet ), 1297be9e782dSKent Overstreet 1298eb54e81fSKent Overstreet TP_printk("%s %pS locks_want %u -> %u %s %llu:%llu:%u", 1299be9e782dSKent Overstreet __entry->trans_fn, 1300eb54e81fSKent Overstreet (void *) __entry->caller_ip, 1301eb54e81fSKent Overstreet __entry->old_locks_want, 1302eb54e81fSKent Overstreet __entry->new_locks_want, 1303eb54e81fSKent Overstreet bch2_btree_id_str(__entry->btree), 1304eb54e81fSKent Overstreet __entry->pos_inode, 1305eb54e81fSKent Overstreet __entry->pos_offset, 1306eb54e81fSKent Overstreet __entry->pos_snapshot) 1307be9e782dSKent Overstreet ); 1308be9e782dSKent Overstreet 1309920e69bcSKent Overstreet DEFINE_EVENT(transaction_event, trans_restart_write_buffer_flush, 1310920e69bcSKent Overstreet TP_PROTO(struct btree_trans *trans, 1311920e69bcSKent Overstreet unsigned long caller_ip), 1312920e69bcSKent Overstreet TP_ARGS(trans, caller_ip) 1313920e69bcSKent Overstreet ); 1314920e69bcSKent Overstreet 1315920e69bcSKent Overstreet TRACE_EVENT(write_buffer_flush, 1316920e69bcSKent Overstreet TP_PROTO(struct btree_trans *trans, size_t nr, size_t skipped, size_t fast, size_t size), 1317920e69bcSKent Overstreet TP_ARGS(trans, nr, skipped, fast, size), 1318920e69bcSKent Overstreet 1319920e69bcSKent Overstreet TP_STRUCT__entry( 1320920e69bcSKent Overstreet __field(size_t, nr ) 1321920e69bcSKent Overstreet __field(size_t, skipped ) 1322920e69bcSKent Overstreet __field(size_t, fast ) 1323920e69bcSKent Overstreet __field(size_t, size ) 1324920e69bcSKent Overstreet ), 1325920e69bcSKent Overstreet 1326920e69bcSKent Overstreet TP_fast_assign( 1327920e69bcSKent Overstreet __entry->nr = nr; 1328920e69bcSKent Overstreet __entry->skipped = skipped; 1329920e69bcSKent Overstreet __entry->fast = fast; 1330920e69bcSKent Overstreet __entry->size = size; 1331920e69bcSKent Overstreet ), 1332920e69bcSKent Overstreet 1333920e69bcSKent Overstreet TP_printk("%zu/%zu skipped %zu fast %zu", 1334920e69bcSKent Overstreet __entry->nr, __entry->size, __entry->skipped, __entry->fast) 1335920e69bcSKent Overstreet ); 1336920e69bcSKent Overstreet 1337920e69bcSKent Overstreet TRACE_EVENT(write_buffer_flush_slowpath, 1338920e69bcSKent Overstreet TP_PROTO(struct btree_trans *trans, size_t nr, size_t size), 1339920e69bcSKent Overstreet TP_ARGS(trans, nr, size), 1340920e69bcSKent Overstreet 1341920e69bcSKent Overstreet TP_STRUCT__entry( 1342920e69bcSKent Overstreet __field(size_t, nr ) 1343920e69bcSKent Overstreet __field(size_t, size ) 1344920e69bcSKent Overstreet ), 1345920e69bcSKent Overstreet 1346920e69bcSKent Overstreet TP_fast_assign( 1347920e69bcSKent Overstreet __entry->nr = nr; 1348920e69bcSKent Overstreet __entry->size = size; 1349920e69bcSKent Overstreet ), 1350920e69bcSKent Overstreet 1351920e69bcSKent Overstreet TP_printk("%zu/%zu", __entry->nr, __entry->size) 1352920e69bcSKent Overstreet ); 1353920e69bcSKent Overstreet 1354*25d1e39dSKent Overstreet DEFINE_EVENT(str, rebalance_extent, 1355*25d1e39dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *str), 1356*25d1e39dSKent Overstreet TP_ARGS(c, str) 1357*25d1e39dSKent Overstreet ); 1358*25d1e39dSKent Overstreet 1359*25d1e39dSKent Overstreet DEFINE_EVENT(str, data_update, 1360*25d1e39dSKent Overstreet TP_PROTO(struct bch_fs *c, const char *str), 1361*25d1e39dSKent Overstreet TP_ARGS(c, str) 1362*25d1e39dSKent Overstreet ); 1363*25d1e39dSKent Overstreet 13641c6fdbd8SKent Overstreet #endif /* _TRACE_BCACHEFS_H */ 13651c6fdbd8SKent Overstreet 13661c6fdbd8SKent Overstreet /* This part must be outside protection */ 13671c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_PATH 13681c6fdbd8SKent Overstreet #define TRACE_INCLUDE_PATH ../../fs/bcachefs 13691c6fdbd8SKent Overstreet 13701c6fdbd8SKent Overstreet #undef TRACE_INCLUDE_FILE 13711c6fdbd8SKent Overstreet #define TRACE_INCLUDE_FILE trace 13721c6fdbd8SKent Overstreet 13731c6fdbd8SKent Overstreet #include <trace/define_trace.h> 1374