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_fs,
48 TP_PROTO(struct bch_fs *c),
52 __array(char, uuid, 16 )
56 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
59 TP_printk("%pU", __entry->uuid)
62 DECLARE_EVENT_CLASS(bio,
63 TP_PROTO(struct bio *bio),
68 __field(sector_t, sector )
69 __field(unsigned int, nr_sector )
70 __array(char, rwbs, 6 )
74 __entry->dev = bio->bi_bdev ? bio_dev(bio) : 0;
75 __entry->sector = bio->bi_iter.bi_sector;
76 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
77 blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
80 TP_printk("%d,%d %s %llu + %u",
81 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
82 (unsigned long long)__entry->sector, __entry->nr_sector)
87 DEFINE_EVENT(bio, read_split,
88 TP_PROTO(struct bio *bio),
92 DEFINE_EVENT(bio, read_bounce,
93 TP_PROTO(struct bio *bio),
97 DEFINE_EVENT(bio, read_retry,
98 TP_PROTO(struct bio *bio),
102 DEFINE_EVENT(bio, promote,
103 TP_PROTO(struct bio *bio),
109 DEFINE_EVENT(bch_fs, journal_full,
110 TP_PROTO(struct bch_fs *c),
114 DEFINE_EVENT(bch_fs, journal_entry_full,
115 TP_PROTO(struct bch_fs *c),
119 DEFINE_EVENT(bio, journal_write,
120 TP_PROTO(struct bio *bio),
126 DEFINE_EVENT(bpos, bkey_pack_pos_fail,
127 TP_PROTO(struct bpos *p),
133 DECLARE_EVENT_CLASS(btree_node,
134 TP_PROTO(struct bch_fs *c, struct btree *b),
138 __array(char, uuid, 16 )
142 __field(u64, offset )
146 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
147 __entry->level = b->level;
148 __entry->id = b->btree_id;
149 __entry->inode = b->key.k.p.inode;
150 __entry->offset = b->key.k.p.offset;
153 TP_printk("%pU %u id %u %llu:%llu",
154 __entry->uuid, __entry->level, __entry->id,
155 __entry->inode, __entry->offset)
158 DEFINE_EVENT(btree_node, btree_read,
159 TP_PROTO(struct bch_fs *c, struct btree *b),
163 TRACE_EVENT(btree_write,
164 TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
165 TP_ARGS(b, bytes, sectors),
168 __field(enum btree_node_type, type)
169 __field(unsigned, bytes )
170 __field(unsigned, sectors )
174 __entry->type = btree_node_type(b);
175 __entry->bytes = bytes;
176 __entry->sectors = sectors;
179 TP_printk("bkey type %u bytes %u sectors %u",
180 __entry->type , __entry->bytes, __entry->sectors)
183 DEFINE_EVENT(btree_node, btree_node_alloc,
184 TP_PROTO(struct bch_fs *c, struct btree *b),
188 DEFINE_EVENT(btree_node, btree_node_free,
189 TP_PROTO(struct bch_fs *c, struct btree *b),
193 DEFINE_EVENT(btree_node, btree_node_reap,
194 TP_PROTO(struct bch_fs *c, struct btree *b),
198 DECLARE_EVENT_CLASS(btree_node_cannibalize_lock,
199 TP_PROTO(struct bch_fs *c),
203 __array(char, uuid, 16 )
207 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
210 TP_printk("%pU", __entry->uuid)
213 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock_fail,
214 TP_PROTO(struct bch_fs *c),
218 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock,
219 TP_PROTO(struct bch_fs *c),
223 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize,
224 TP_PROTO(struct bch_fs *c),
228 DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock,
229 TP_PROTO(struct bch_fs *c),
233 TRACE_EVENT(btree_reserve_get_fail,
234 TP_PROTO(struct bch_fs *c, size_t required, struct closure *cl),
235 TP_ARGS(c, required, cl),
238 __array(char, uuid, 16 )
239 __field(size_t, required )
240 __field(struct closure *, cl )
244 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
245 __entry->required = required;
249 TP_printk("%pU required %zu by %p", __entry->uuid,
250 __entry->required, __entry->cl)
253 TRACE_EVENT(btree_insert_key,
254 TP_PROTO(struct bch_fs *c, struct btree *b, struct bkey_i *k),
260 __field(u64, offset )
265 __entry->id = b->btree_id;
266 __entry->inode = k->k.p.inode;
267 __entry->offset = k->k.p.offset;
268 __entry->size = k->k.size;
271 TP_printk("btree %u: %llu:%llu len %u", __entry->id,
272 __entry->inode, __entry->offset, __entry->size)
275 DEFINE_EVENT(btree_node, btree_split,
276 TP_PROTO(struct bch_fs *c, struct btree *b),
280 DEFINE_EVENT(btree_node, btree_compact,
281 TP_PROTO(struct bch_fs *c, struct btree *b),
285 DEFINE_EVENT(btree_node, btree_merge,
286 TP_PROTO(struct bch_fs *c, struct btree *b),
290 DEFINE_EVENT(btree_node, btree_set_root,
291 TP_PROTO(struct bch_fs *c, struct btree *b),
295 /* Garbage collection */
297 DEFINE_EVENT(btree_node, btree_gc_coalesce,
298 TP_PROTO(struct bch_fs *c, struct btree *b),
302 TRACE_EVENT(btree_gc_coalesce_fail,
303 TP_PROTO(struct bch_fs *c, int reason),
308 __array(char, uuid, 16 )
312 __entry->reason = reason;
313 memcpy(__entry->uuid, c->disk_sb.sb->user_uuid.b, 16);
316 TP_printk("%pU: %u", __entry->uuid, __entry->reason)
319 DEFINE_EVENT(btree_node, btree_gc_rewrite_node,
320 TP_PROTO(struct bch_fs *c, struct btree *b),
324 DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail,
325 TP_PROTO(struct bch_fs *c, struct btree *b),
329 DEFINE_EVENT(bch_fs, gc_start,
330 TP_PROTO(struct bch_fs *c),
334 DEFINE_EVENT(bch_fs, gc_end,
335 TP_PROTO(struct bch_fs *c),
339 DEFINE_EVENT(bch_fs, gc_coalesce_start,
340 TP_PROTO(struct bch_fs *c),
344 DEFINE_EVENT(bch_fs, gc_coalesce_end,
345 TP_PROTO(struct bch_fs *c),
349 DEFINE_EVENT(bch_fs, gc_cannot_inc_gens,
350 TP_PROTO(struct bch_fs *c),
356 TRACE_EVENT(alloc_batch,
357 TP_PROTO(struct bch_dev *ca, size_t free, size_t total),
358 TP_ARGS(ca, free, total),
361 __array(char, uuid, 16 )
362 __field(size_t, free )
363 __field(size_t, total )
367 memcpy(__entry->uuid, ca->uuid.b, 16);
368 __entry->free = free;
369 __entry->total = total;
372 TP_printk("%pU free %zu total %zu",
373 __entry->uuid, __entry->free, __entry->total)
376 TRACE_EVENT(invalidate,
377 TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors),
378 TP_ARGS(ca, offset, sectors),
381 __field(unsigned, sectors )
383 __field(__u64, offset )
387 __entry->dev = ca->disk_sb.bdev->bd_dev;
388 __entry->offset = offset,
389 __entry->sectors = sectors;
392 TP_printk("invalidated %u sectors at %d,%d sector=%llu",
393 __entry->sectors, MAJOR(__entry->dev),
394 MINOR(__entry->dev), __entry->offset)
397 DEFINE_EVENT(bch_fs, rescale_prios,
398 TP_PROTO(struct bch_fs *c),
402 DECLARE_EVENT_CLASS(bucket_alloc,
403 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
404 TP_ARGS(ca, reserve),
407 __array(char, uuid, 16)
408 __field(enum alloc_reserve, reserve )
412 memcpy(__entry->uuid, ca->uuid.b, 16);
413 __entry->reserve = reserve;
416 TP_printk("%pU reserve %d", __entry->uuid, __entry->reserve)
419 DEFINE_EVENT(bucket_alloc, bucket_alloc,
420 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
424 DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
425 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
429 DEFINE_EVENT(bucket_alloc, open_bucket_alloc_fail,
430 TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
436 DEFINE_EVENT(bkey, move_extent,
437 TP_PROTO(const struct bkey *k),
441 DEFINE_EVENT(bkey, move_alloc_fail,
442 TP_PROTO(const struct bkey *k),
446 DEFINE_EVENT(bkey, move_race,
447 TP_PROTO(const struct bkey *k),
451 TRACE_EVENT(move_data,
452 TP_PROTO(struct bch_fs *c, u64 sectors_moved,
454 TP_ARGS(c, sectors_moved, keys_moved),
457 __array(char, uuid, 16 )
458 __field(u64, sectors_moved )
459 __field(u64, keys_moved )
463 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
464 __entry->sectors_moved = sectors_moved;
465 __entry->keys_moved = keys_moved;
468 TP_printk("%pU sectors_moved %llu keys_moved %llu",
469 __entry->uuid, __entry->sectors_moved, __entry->keys_moved)
473 TP_PROTO(struct bch_dev *ca,
474 u64 sectors_moved, u64 sectors_not_moved,
475 u64 buckets_moved, u64 buckets_not_moved),
477 sectors_moved, sectors_not_moved,
478 buckets_moved, buckets_not_moved),
481 __array(char, uuid, 16 )
482 __field(u64, sectors_moved )
483 __field(u64, sectors_not_moved )
484 __field(u64, buckets_moved )
485 __field(u64, buckets_not_moved )
489 memcpy(__entry->uuid, ca->uuid.b, 16);
490 __entry->sectors_moved = sectors_moved;
491 __entry->sectors_not_moved = sectors_not_moved;
492 __entry->buckets_moved = buckets_moved;
493 __entry->buckets_not_moved = buckets_moved;
496 TP_printk("%pU sectors moved %llu remain %llu buckets moved %llu remain %llu",
498 __entry->sectors_moved, __entry->sectors_not_moved,
499 __entry->buckets_moved, __entry->buckets_not_moved)
502 #endif /* _TRACE_BCACHEFS_H */
504 /* This part must be outside protection */
505 #undef TRACE_INCLUDE_PATH
506 #define TRACE_INCLUDE_PATH ../../fs/bcachefs
508 #undef TRACE_INCLUDE_FILE
509 #define TRACE_INCLUDE_FILE trace
511 #include <trace/define_trace.h>