1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM bcachefs
5 #if !defined(_TRACE_BCACHEFS_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_BCACHEFS_H
8 #include <linux/tracepoint.h>
10 DECLARE_EVENT_CLASS(bpos,
11 TP_PROTO(struct bpos *p),
20 __entry->inode = p->inode;
21 __entry->offset = p->offset;
24 TP_printk("%llu:%llu", __entry->inode, __entry->offset)
27 DECLARE_EVENT_CLASS(bkey,
28 TP_PROTO(const struct bkey *k),
38 __entry->inode = k->p.inode;
39 __entry->offset = k->p.offset;
40 __entry->size = k->size;
43 TP_printk("%llu:%llu len %u", __entry->inode,
44 __entry->offset, __entry->size)
47 DECLARE_EVENT_CLASS(bch_dev,
48 TP_PROTO(struct bch_dev *ca),
52 __array(char, uuid, 16 )
56 memcpy(__entry->uuid, ca->uuid.b, 16);
59 TP_printk("%pU", __entry->uuid)
62 DECLARE_EVENT_CLASS(bch_fs,
63 TP_PROTO(struct bch_fs *c),
67 __array(char, uuid, 16 )
71 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
74 TP_printk("%pU", __entry->uuid)
77 DECLARE_EVENT_CLASS(bio,
78 TP_PROTO(struct bio *bio),
83 __field(sector_t, sector )
84 __field(unsigned int, nr_sector )
85 __array(char, rwbs, 6 )
89 __entry->dev = bio->bi_bdev ? bio_dev(bio) : 0;
90 __entry->sector = bio->bi_iter.bi_sector;
91 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
92 blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
95 TP_printk("%d,%d %s %llu + %u",
96 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
97 (unsigned long long)__entry->sector, __entry->nr_sector)
102 DEFINE_EVENT(bio, read_split,
103 TP_PROTO(struct bio *bio),
107 DEFINE_EVENT(bio, read_bounce,
108 TP_PROTO(struct bio *bio),
112 DEFINE_EVENT(bio, read_retry,
113 TP_PROTO(struct bio *bio),
117 DEFINE_EVENT(bio, promote,
118 TP_PROTO(struct bio *bio),
124 DEFINE_EVENT(bch_fs, journal_full,
125 TP_PROTO(struct bch_fs *c),
129 DEFINE_EVENT(bch_fs, journal_entry_full,
130 TP_PROTO(struct bch_fs *c),
134 DEFINE_EVENT(bio, journal_write,
135 TP_PROTO(struct bio *bio),
141 DEFINE_EVENT(bpos, bkey_pack_pos_fail,
142 TP_PROTO(struct bpos *p),
148 DECLARE_EVENT_CLASS(btree_node,
149 TP_PROTO(struct bch_fs *c, struct btree *b),
153 __array(char, uuid, 16 )
157 __field(u64, offset )
161 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
162 __entry->level = b->level;
163 __entry->id = b->btree_id;
164 __entry->inode = b->key.k.p.inode;
165 __entry->offset = b->key.k.p.offset;
168 TP_printk("%pU %u id %u %llu:%llu",
169 __entry->uuid, __entry->level, __entry->id,
170 __entry->inode, __entry->offset)
173 DEFINE_EVENT(btree_node, btree_read,
174 TP_PROTO(struct bch_fs *c, struct btree *b),
178 TRACE_EVENT(btree_write,
179 TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
180 TP_ARGS(b, bytes, sectors),
183 __field(enum bkey_type, type)
184 __field(unsigned, bytes )
185 __field(unsigned, sectors )
189 __entry->type = btree_node_type(b);
190 __entry->bytes = bytes;
191 __entry->sectors = sectors;
194 TP_printk("bkey type %u bytes %u sectors %u",
195 __entry->type , __entry->bytes, __entry->sectors)
198 DEFINE_EVENT(btree_node, btree_node_alloc,
199 TP_PROTO(struct bch_fs *c, struct btree *b),
203 DEFINE_EVENT(btree_node, btree_node_free,
204 TP_PROTO(struct bch_fs *c, struct btree *b),
208 DEFINE_EVENT(btree_node, btree_node_reap,
209 TP_PROTO(struct bch_fs *c, struct btree *b),
213 DECLARE_EVENT_CLASS(btree_node_cannibalize_lock,
214 TP_PROTO(struct bch_fs *c),
218 __array(char, uuid, 16 )
222 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
225 TP_printk("%pU", __entry->uuid)
228 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock_fail,
229 TP_PROTO(struct bch_fs *c),
233 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock,
234 TP_PROTO(struct bch_fs *c),
238 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize,
239 TP_PROTO(struct bch_fs *c),
243 DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock,
244 TP_PROTO(struct bch_fs *c),
248 TRACE_EVENT(btree_reserve_get_fail,
249 TP_PROTO(struct bch_fs *c, size_t required, struct closure *cl),
250 TP_ARGS(c, required, cl),
253 __array(char, uuid, 16 )
254 __field(size_t, required )
255 __field(struct closure *, cl )
259 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
260 __entry->required = required;
264 TP_printk("%pU required %zu by %p", __entry->uuid,
265 __entry->required, __entry->cl)
268 TRACE_EVENT(btree_insert_key,
269 TP_PROTO(struct bch_fs *c, struct btree *b, struct bkey_i *k),
275 __field(u64, offset )
280 __entry->id = b->btree_id;
281 __entry->inode = k->k.p.inode;
282 __entry->offset = k->k.p.offset;
283 __entry->size = k->k.size;
286 TP_printk("btree %u: %llu:%llu len %u", __entry->id,
287 __entry->inode, __entry->offset, __entry->size)
290 DEFINE_EVENT(btree_node, btree_split,
291 TP_PROTO(struct bch_fs *c, struct btree *b),
295 DEFINE_EVENT(btree_node, btree_compact,
296 TP_PROTO(struct bch_fs *c, struct btree *b),
300 DEFINE_EVENT(btree_node, btree_merge,
301 TP_PROTO(struct bch_fs *c, struct btree *b),
305 DEFINE_EVENT(btree_node, btree_set_root,
306 TP_PROTO(struct bch_fs *c, struct btree *b),
310 /* Garbage collection */
312 DEFINE_EVENT(btree_node, btree_gc_coalesce,
313 TP_PROTO(struct bch_fs *c, struct btree *b),
317 TRACE_EVENT(btree_gc_coalesce_fail,
318 TP_PROTO(struct bch_fs *c, int reason),
323 __array(char, uuid, 16 )
327 __entry->reason = reason;
328 memcpy(__entry->uuid, c->disk_sb.sb->user_uuid.b, 16);
331 TP_printk("%pU: %u", __entry->uuid, __entry->reason)
334 DEFINE_EVENT(btree_node, btree_gc_rewrite_node,
335 TP_PROTO(struct bch_fs *c, struct btree *b),
339 DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail,
340 TP_PROTO(struct bch_fs *c, struct btree *b),
344 DEFINE_EVENT(bch_fs, gc_start,
345 TP_PROTO(struct bch_fs *c),
349 DEFINE_EVENT(bch_fs, gc_end,
350 TP_PROTO(struct bch_fs *c),
354 DEFINE_EVENT(bch_fs, gc_coalesce_start,
355 TP_PROTO(struct bch_fs *c),
359 DEFINE_EVENT(bch_fs, gc_coalesce_end,
360 TP_PROTO(struct bch_fs *c),
364 DEFINE_EVENT(bch_dev, sectors_saturated,
365 TP_PROTO(struct bch_dev *ca),
369 DEFINE_EVENT(bch_fs, gc_sectors_saturated,
370 TP_PROTO(struct bch_fs *c),
374 DEFINE_EVENT(bch_fs, gc_cannot_inc_gens,
375 TP_PROTO(struct bch_fs *c),
381 TRACE_EVENT(alloc_batch,
382 TP_PROTO(struct bch_dev *ca, size_t free, size_t total),
383 TP_ARGS(ca, free, total),
386 __array(char, uuid, 16 )
387 __field(size_t, free )
388 __field(size_t, total )
392 memcpy(__entry->uuid, ca->uuid.b, 16);
393 __entry->free = free;
394 __entry->total = total;
397 TP_printk("%pU free %zu total %zu",
398 __entry->uuid, __entry->free, __entry->total)
401 TRACE_EVENT(invalidate,
402 TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors),
403 TP_ARGS(ca, offset, sectors),
406 __field(unsigned, sectors )
408 __field(__u64, offset )
412 __entry->dev = ca->disk_sb.bdev->bd_dev;
413 __entry->offset = offset,
414 __entry->sectors = sectors;
417 TP_printk("invalidated %u sectors at %d,%d sector=%llu",
418 __entry->sectors, MAJOR(__entry->dev),
419 MINOR(__entry->dev), __entry->offset)
422 DEFINE_EVENT(bch_fs, rescale_prios,
423 TP_PROTO(struct bch_fs *c),
427 DECLARE_EVENT_CLASS(bucket_alloc,
428 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
429 TP_ARGS(ca, reserve),
432 __array(char, uuid, 16)
433 __field(enum alloc_reserve, reserve )
437 memcpy(__entry->uuid, ca->uuid.b, 16);
438 __entry->reserve = reserve;
441 TP_printk("%pU reserve %d", __entry->uuid, __entry->reserve)
444 DEFINE_EVENT(bucket_alloc, bucket_alloc,
445 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
449 DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
450 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
454 DEFINE_EVENT(bucket_alloc, open_bucket_alloc_fail,
455 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
461 DEFINE_EVENT(bkey, move_extent,
462 TP_PROTO(const struct bkey *k),
466 DEFINE_EVENT(bkey, move_alloc_fail,
467 TP_PROTO(const struct bkey *k),
471 DEFINE_EVENT(bkey, move_race,
472 TP_PROTO(const struct bkey *k),
476 TRACE_EVENT(move_data,
477 TP_PROTO(struct bch_fs *c, u64 sectors_moved,
479 TP_ARGS(c, sectors_moved, keys_moved),
482 __array(char, uuid, 16 )
483 __field(u64, sectors_moved )
484 __field(u64, keys_moved )
488 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
489 __entry->sectors_moved = sectors_moved;
490 __entry->keys_moved = keys_moved;
493 TP_printk("%pU sectors_moved %llu keys_moved %llu",
494 __entry->uuid, __entry->sectors_moved, __entry->keys_moved)
498 TP_PROTO(struct bch_dev *ca,
499 u64 sectors_moved, u64 sectors_not_moved,
500 u64 buckets_moved, u64 buckets_not_moved),
502 sectors_moved, sectors_not_moved,
503 buckets_moved, buckets_not_moved),
506 __array(char, uuid, 16 )
507 __field(u64, sectors_moved )
508 __field(u64, sectors_not_moved )
509 __field(u64, buckets_moved )
510 __field(u64, buckets_not_moved )
514 memcpy(__entry->uuid, ca->uuid.b, 16);
515 __entry->sectors_moved = sectors_moved;
516 __entry->sectors_not_moved = sectors_not_moved;
517 __entry->buckets_moved = buckets_moved;
518 __entry->buckets_not_moved = buckets_moved;
521 TP_printk("%pU sectors moved %llu remain %llu buckets moved %llu remain %llu",
523 __entry->sectors_moved, __entry->sectors_not_moved,
524 __entry->buckets_moved, __entry->buckets_not_moved)
527 #endif /* _TRACE_BCACHEFS_H */
529 /* This part must be outside protection */
530 #undef TRACE_INCLUDE_PATH
531 #define TRACE_INCLUDE_PATH ../../fs/bcachefs
533 #undef TRACE_INCLUDE_FILE
534 #define TRACE_INCLUDE_FILE trace
536 #include <trace/define_trace.h>