2 #define TRACE_SYSTEM bcachefs
4 #if !defined(_TRACE_BCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BCACHE_H
7 #include <linux/tracepoint.h>
9 DECLARE_EVENT_CLASS(bpos,
10 TP_PROTO(struct bpos *p),
19 __entry->inode = p->inode;
20 __entry->offset = p->offset;
23 TP_printk("%llu:%llu", __entry->inode, __entry->offset)
26 DECLARE_EVENT_CLASS(bkey,
27 TP_PROTO(const struct bkey *k),
37 __entry->inode = k->p.inode;
38 __entry->offset = k->p.offset;
39 __entry->size = k->size;
42 TP_printk("%llu:%llu len %u", __entry->inode,
43 __entry->offset, __entry->size)
46 DECLARE_EVENT_CLASS(bch_fs,
47 TP_PROTO(struct bch_fs *c),
51 __array(char, uuid, 16 )
55 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
58 TP_printk("%pU", __entry->uuid)
61 DECLARE_EVENT_CLASS(bio,
62 TP_PROTO(struct bio *bio),
67 __field(sector_t, sector )
68 __field(unsigned int, nr_sector )
69 __array(char, rwbs, 6 )
73 __entry->dev = bio->bi_disk ? bio_dev(bio) : 0;
74 __entry->sector = bio->bi_iter.bi_sector;
75 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
76 blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
79 TP_printk("%d,%d %s %llu + %u",
80 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
81 (unsigned long long)__entry->sector, __entry->nr_sector)
86 DEFINE_EVENT(bio, read_split,
87 TP_PROTO(struct bio *bio),
91 DEFINE_EVENT(bio, read_bounce,
92 TP_PROTO(struct bio *bio),
96 DEFINE_EVENT(bio, read_retry,
97 TP_PROTO(struct bio *bio),
101 DEFINE_EVENT(bio, promote,
102 TP_PROTO(struct bio *bio),
108 DEFINE_EVENT(bch_fs, journal_full,
109 TP_PROTO(struct bch_fs *c),
113 DEFINE_EVENT(bch_fs, journal_entry_full,
114 TP_PROTO(struct bch_fs *c),
118 DEFINE_EVENT(bio, journal_write,
119 TP_PROTO(struct bio *bio),
125 DEFINE_EVENT(bpos, bkey_pack_pos_fail,
126 TP_PROTO(struct bpos *p),
132 DECLARE_EVENT_CLASS(btree_node,
133 TP_PROTO(struct bch_fs *c, struct btree *b),
137 __array(char, uuid, 16 )
141 __field(u64, offset )
145 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
146 __entry->level = b->level;
147 __entry->id = b->btree_id;
148 __entry->inode = b->key.k.p.inode;
149 __entry->offset = b->key.k.p.offset;
152 TP_printk("%pU %u id %u %llu:%llu",
153 __entry->uuid, __entry->level, __entry->id,
154 __entry->inode, __entry->offset)
157 DEFINE_EVENT(btree_node, btree_read,
158 TP_PROTO(struct bch_fs *c, struct btree *b),
162 TRACE_EVENT(btree_write,
163 TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
164 TP_ARGS(b, bytes, sectors),
167 __field(enum btree_node_type, type)
168 __field(unsigned, bytes )
169 __field(unsigned, sectors )
173 __entry->type = btree_node_type(b);
174 __entry->bytes = bytes;
175 __entry->sectors = sectors;
178 TP_printk("bkey type %u bytes %u sectors %u",
179 __entry->type , __entry->bytes, __entry->sectors)
182 DEFINE_EVENT(btree_node, btree_node_alloc,
183 TP_PROTO(struct bch_fs *c, struct btree *b),
187 DEFINE_EVENT(btree_node, btree_node_free,
188 TP_PROTO(struct bch_fs *c, struct btree *b),
192 DEFINE_EVENT(btree_node, btree_node_reap,
193 TP_PROTO(struct bch_fs *c, struct btree *b),
197 DECLARE_EVENT_CLASS(btree_node_cannibalize_lock,
198 TP_PROTO(struct bch_fs *c),
202 __array(char, uuid, 16 )
206 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
209 TP_printk("%pU", __entry->uuid)
212 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock_fail,
213 TP_PROTO(struct bch_fs *c),
217 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock,
218 TP_PROTO(struct bch_fs *c),
222 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize,
223 TP_PROTO(struct bch_fs *c),
227 DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock,
228 TP_PROTO(struct bch_fs *c),
232 TRACE_EVENT(btree_reserve_get_fail,
233 TP_PROTO(struct bch_fs *c, size_t required, struct closure *cl),
234 TP_ARGS(c, required, cl),
237 __array(char, uuid, 16 )
238 __field(size_t, required )
239 __field(struct closure *, cl )
243 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
244 __entry->required = required;
248 TP_printk("%pU required %zu by %p", __entry->uuid,
249 __entry->required, __entry->cl)
252 TRACE_EVENT(btree_insert_key,
253 TP_PROTO(struct bch_fs *c, struct btree *b, struct bkey_i *k),
259 __field(u64, offset )
264 __entry->id = b->btree_id;
265 __entry->inode = k->k.p.inode;
266 __entry->offset = k->k.p.offset;
267 __entry->size = k->k.size;
270 TP_printk("btree %u: %llu:%llu len %u", __entry->id,
271 __entry->inode, __entry->offset, __entry->size)
274 DEFINE_EVENT(btree_node, btree_split,
275 TP_PROTO(struct bch_fs *c, struct btree *b),
279 DEFINE_EVENT(btree_node, btree_compact,
280 TP_PROTO(struct bch_fs *c, struct btree *b),
284 DEFINE_EVENT(btree_node, btree_merge,
285 TP_PROTO(struct bch_fs *c, struct btree *b),
289 DEFINE_EVENT(btree_node, btree_set_root,
290 TP_PROTO(struct bch_fs *c, struct btree *b),
294 /* Garbage collection */
296 DEFINE_EVENT(btree_node, btree_gc_coalesce,
297 TP_PROTO(struct bch_fs *c, struct btree *b),
301 TRACE_EVENT(btree_gc_coalesce_fail,
302 TP_PROTO(struct bch_fs *c, int reason),
307 __array(char, uuid, 16 )
311 __entry->reason = reason;
312 memcpy(__entry->uuid, c->disk_sb.sb->user_uuid.b, 16);
315 TP_printk("%pU: %u", __entry->uuid, __entry->reason)
318 DEFINE_EVENT(btree_node, btree_gc_rewrite_node,
319 TP_PROTO(struct bch_fs *c, struct btree *b),
323 DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail,
324 TP_PROTO(struct bch_fs *c, struct btree *b),
328 DEFINE_EVENT(bch_fs, gc_start,
329 TP_PROTO(struct bch_fs *c),
333 DEFINE_EVENT(bch_fs, gc_end,
334 TP_PROTO(struct bch_fs *c),
338 DEFINE_EVENT(bch_fs, gc_coalesce_start,
339 TP_PROTO(struct bch_fs *c),
343 DEFINE_EVENT(bch_fs, gc_coalesce_end,
344 TP_PROTO(struct bch_fs *c),
348 DEFINE_EVENT(bch_fs, gc_cannot_inc_gens,
349 TP_PROTO(struct bch_fs *c),
355 TRACE_EVENT(alloc_batch,
356 TP_PROTO(struct bch_dev *ca, size_t free, size_t total),
357 TP_ARGS(ca, free, total),
360 __array(char, uuid, 16 )
361 __field(size_t, free )
362 __field(size_t, total )
366 memcpy(__entry->uuid, ca->uuid.b, 16);
367 __entry->free = free;
368 __entry->total = total;
371 TP_printk("%pU free %zu total %zu",
372 __entry->uuid, __entry->free, __entry->total)
375 TRACE_EVENT(invalidate,
376 TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors),
377 TP_ARGS(ca, offset, sectors),
380 __field(unsigned, sectors )
382 __field(__u64, offset )
386 __entry->dev = ca->disk_sb.bdev->bd_dev;
387 __entry->offset = offset,
388 __entry->sectors = sectors;
391 TP_printk("invalidated %u sectors at %d,%d sector=%llu",
392 __entry->sectors, MAJOR(__entry->dev),
393 MINOR(__entry->dev), __entry->offset)
396 DEFINE_EVENT(bch_fs, rescale_prios,
397 TP_PROTO(struct bch_fs *c),
401 DECLARE_EVENT_CLASS(bucket_alloc,
402 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
403 TP_ARGS(ca, reserve),
406 __array(char, uuid, 16)
407 __field(enum alloc_reserve, reserve )
411 memcpy(__entry->uuid, ca->uuid.b, 16);
412 __entry->reserve = reserve;
415 TP_printk("%pU reserve %d", __entry->uuid, __entry->reserve)
418 DEFINE_EVENT(bucket_alloc, bucket_alloc,
419 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
423 DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
424 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
428 DEFINE_EVENT(bucket_alloc, open_bucket_alloc_fail,
429 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
435 DEFINE_EVENT(bkey, move_extent,
436 TP_PROTO(const struct bkey *k),
440 DEFINE_EVENT(bkey, move_alloc_fail,
441 TP_PROTO(const struct bkey *k),
445 DEFINE_EVENT(bkey, move_race,
446 TP_PROTO(const struct bkey *k),
450 TRACE_EVENT(move_data,
451 TP_PROTO(struct bch_fs *c, u64 sectors_moved,
453 TP_ARGS(c, sectors_moved, keys_moved),
456 __array(char, uuid, 16 )
457 __field(u64, sectors_moved )
458 __field(u64, keys_moved )
462 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
463 __entry->sectors_moved = sectors_moved;
464 __entry->keys_moved = keys_moved;
467 TP_printk("%pU sectors_moved %llu keys_moved %llu",
468 __entry->uuid, __entry->sectors_moved, __entry->keys_moved)
472 TP_PROTO(struct bch_dev *ca,
473 u64 sectors_moved, u64 sectors_not_moved,
474 u64 buckets_moved, u64 buckets_not_moved),
476 sectors_moved, sectors_not_moved,
477 buckets_moved, buckets_not_moved),
480 __array(char, uuid, 16 )
481 __field(u64, sectors_moved )
482 __field(u64, sectors_not_moved )
483 __field(u64, buckets_moved )
484 __field(u64, buckets_not_moved )
488 memcpy(__entry->uuid, ca->uuid.b, 16);
489 __entry->sectors_moved = sectors_moved;
490 __entry->sectors_not_moved = sectors_not_moved;
491 __entry->buckets_moved = buckets_moved;
492 __entry->buckets_not_moved = buckets_moved;
495 TP_printk("%pU sectors moved %llu remain %llu buckets moved %llu remain %llu",
497 __entry->sectors_moved, __entry->sectors_not_moved,
498 __entry->buckets_moved, __entry->buckets_not_moved)
501 DECLARE_EVENT_CLASS(transaction_restart,
502 TP_PROTO(struct bch_fs *c, unsigned long ip),
506 __array(char, name, 16)
507 __field(unsigned long, ip )
511 memcpy(__entry->name, c->name, 16);
515 TP_printk("%pf", (void *) __entry->ip)
518 DEFINE_EVENT(transaction_restart, trans_restart_btree_node_reused,
519 TP_PROTO(struct bch_fs *c, unsigned long ip),
523 DEFINE_EVENT(transaction_restart, trans_restart_would_deadlock,
524 TP_PROTO(struct bch_fs *c, unsigned long ip),
528 DEFINE_EVENT(transaction_restart, trans_restart_iters_realloced,
529 TP_PROTO(struct bch_fs *c, unsigned long ip),
533 DEFINE_EVENT(transaction_restart, trans_restart_mem_realloced,
534 TP_PROTO(struct bch_fs *c, unsigned long ip),
538 DEFINE_EVENT(transaction_restart, trans_restart_journal_res_get,
539 TP_PROTO(struct bch_fs *c, unsigned long ip),
543 DEFINE_EVENT(transaction_restart, trans_restart_journal_preres_get,
544 TP_PROTO(struct bch_fs *c, unsigned long ip),
548 DEFINE_EVENT(transaction_restart, trans_restart_mark_replicas,
549 TP_PROTO(struct bch_fs *c, unsigned long ip),
553 DEFINE_EVENT(transaction_restart, trans_restart_fault_inject,
554 TP_PROTO(struct bch_fs *c, unsigned long ip),
558 DEFINE_EVENT(transaction_restart, trans_restart_btree_node_split,
559 TP_PROTO(struct bch_fs *c, unsigned long ip),
563 DEFINE_EVENT(transaction_restart, trans_restart_traverse,
564 TP_PROTO(struct bch_fs *c, unsigned long ip),
568 DEFINE_EVENT(transaction_restart, trans_restart_atomic,
569 TP_PROTO(struct bch_fs *c, unsigned long ip),
573 #endif /* _TRACE_BCACHE_H */
575 /* This part must be outside protection */
576 #include <trace/define_trace.h>