]> git.sesse.net Git - bcachefs-tools-debian/blob - include/trace/events/bcachefs.h
Update bcachefs sources to 454bd4f82d bcachefs: Fix for the stripes mark path and gc
[bcachefs-tools-debian] / include / trace / events / bcachefs.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM bcachefs
3
4 #if !defined(_TRACE_BCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BCACHE_H
6
7 #include <linux/tracepoint.h>
8
9 DECLARE_EVENT_CLASS(bpos,
10         TP_PROTO(struct bpos *p),
11         TP_ARGS(p),
12
13         TP_STRUCT__entry(
14                 __field(u64,    inode                           )
15                 __field(u64,    offset                          )
16         ),
17
18         TP_fast_assign(
19                 __entry->inode  = p->inode;
20                 __entry->offset = p->offset;
21         ),
22
23         TP_printk("%llu:%llu", __entry->inode, __entry->offset)
24 );
25
26 DECLARE_EVENT_CLASS(bkey,
27         TP_PROTO(const struct bkey *k),
28         TP_ARGS(k),
29
30         TP_STRUCT__entry(
31                 __field(u64,    inode                           )
32                 __field(u64,    offset                          )
33                 __field(u32,    size                            )
34         ),
35
36         TP_fast_assign(
37                 __entry->inode  = k->p.inode;
38                 __entry->offset = k->p.offset;
39                 __entry->size   = k->size;
40         ),
41
42         TP_printk("%llu:%llu len %u", __entry->inode,
43                   __entry->offset, __entry->size)
44 );
45
46 DECLARE_EVENT_CLASS(bch_fs,
47         TP_PROTO(struct bch_fs *c),
48         TP_ARGS(c),
49
50         TP_STRUCT__entry(
51                 __array(char,           uuid,   16 )
52         ),
53
54         TP_fast_assign(
55                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
56         ),
57
58         TP_printk("%pU", __entry->uuid)
59 );
60
61 DECLARE_EVENT_CLASS(bio,
62         TP_PROTO(struct bio *bio),
63         TP_ARGS(bio),
64
65         TP_STRUCT__entry(
66                 __field(dev_t,          dev                     )
67                 __field(sector_t,       sector                  )
68                 __field(unsigned int,   nr_sector               )
69                 __array(char,           rwbs,   6               )
70         ),
71
72         TP_fast_assign(
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);
77         ),
78
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)
82 );
83
84 /* io.c: */
85
86 DEFINE_EVENT(bio, read_split,
87         TP_PROTO(struct bio *bio),
88         TP_ARGS(bio)
89 );
90
91 DEFINE_EVENT(bio, read_bounce,
92         TP_PROTO(struct bio *bio),
93         TP_ARGS(bio)
94 );
95
96 DEFINE_EVENT(bio, read_retry,
97         TP_PROTO(struct bio *bio),
98         TP_ARGS(bio)
99 );
100
101 DEFINE_EVENT(bio, promote,
102         TP_PROTO(struct bio *bio),
103         TP_ARGS(bio)
104 );
105
106 /* Journal */
107
108 DEFINE_EVENT(bch_fs, journal_full,
109         TP_PROTO(struct bch_fs *c),
110         TP_ARGS(c)
111 );
112
113 DEFINE_EVENT(bch_fs, journal_entry_full,
114         TP_PROTO(struct bch_fs *c),
115         TP_ARGS(c)
116 );
117
118 DEFINE_EVENT(bio, journal_write,
119         TP_PROTO(struct bio *bio),
120         TP_ARGS(bio)
121 );
122
123 /* bset.c: */
124
125 DEFINE_EVENT(bpos, bkey_pack_pos_fail,
126         TP_PROTO(struct bpos *p),
127         TP_ARGS(p)
128 );
129
130 /* Btree */
131
132 DECLARE_EVENT_CLASS(btree_node,
133         TP_PROTO(struct bch_fs *c, struct btree *b),
134         TP_ARGS(c, b),
135
136         TP_STRUCT__entry(
137                 __array(char,           uuid,           16      )
138                 __field(u8,             level                   )
139                 __field(u8,             id                      )
140                 __field(u64,            inode                   )
141                 __field(u64,            offset                  )
142         ),
143
144         TP_fast_assign(
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;
150         ),
151
152         TP_printk("%pU  %u id %u %llu:%llu",
153                   __entry->uuid, __entry->level, __entry->id,
154                   __entry->inode, __entry->offset)
155 );
156
157 DEFINE_EVENT(btree_node, btree_read,
158         TP_PROTO(struct bch_fs *c, struct btree *b),
159         TP_ARGS(c, b)
160 );
161
162 TRACE_EVENT(btree_write,
163         TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
164         TP_ARGS(b, bytes, sectors),
165
166         TP_STRUCT__entry(
167                 __field(enum btree_node_type,   type)
168                 __field(unsigned,       bytes                   )
169                 __field(unsigned,       sectors                 )
170         ),
171
172         TP_fast_assign(
173                 __entry->type   = btree_node_type(b);
174                 __entry->bytes  = bytes;
175                 __entry->sectors = sectors;
176         ),
177
178         TP_printk("bkey type %u bytes %u sectors %u",
179                   __entry->type , __entry->bytes, __entry->sectors)
180 );
181
182 DEFINE_EVENT(btree_node, btree_node_alloc,
183         TP_PROTO(struct bch_fs *c, struct btree *b),
184         TP_ARGS(c, b)
185 );
186
187 DEFINE_EVENT(btree_node, btree_node_free,
188         TP_PROTO(struct bch_fs *c, struct btree *b),
189         TP_ARGS(c, b)
190 );
191
192 DEFINE_EVENT(btree_node, btree_node_reap,
193         TP_PROTO(struct bch_fs *c, struct btree *b),
194         TP_ARGS(c, b)
195 );
196
197 DECLARE_EVENT_CLASS(btree_node_cannibalize_lock,
198         TP_PROTO(struct bch_fs *c),
199         TP_ARGS(c),
200
201         TP_STRUCT__entry(
202                 __array(char,                   uuid,   16      )
203         ),
204
205         TP_fast_assign(
206                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
207         ),
208
209         TP_printk("%pU", __entry->uuid)
210 );
211
212 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock_fail,
213         TP_PROTO(struct bch_fs *c),
214         TP_ARGS(c)
215 );
216
217 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock,
218         TP_PROTO(struct bch_fs *c),
219         TP_ARGS(c)
220 );
221
222 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize,
223         TP_PROTO(struct bch_fs *c),
224         TP_ARGS(c)
225 );
226
227 DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock,
228         TP_PROTO(struct bch_fs *c),
229         TP_ARGS(c)
230 );
231
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),
235
236         TP_STRUCT__entry(
237                 __array(char,                   uuid,   16      )
238                 __field(size_t,                 required        )
239                 __field(struct closure *,       cl              )
240         ),
241
242         TP_fast_assign(
243                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
244                 __entry->required = required;
245                 __entry->cl = cl;
246         ),
247
248         TP_printk("%pU required %zu by %p", __entry->uuid,
249                   __entry->required, __entry->cl)
250 );
251
252 TRACE_EVENT(btree_insert_key,
253         TP_PROTO(struct bch_fs *c, struct btree *b, struct bkey_i *k),
254         TP_ARGS(c, b, k),
255
256         TP_STRUCT__entry(
257                 __field(u8,             id                      )
258                 __field(u64,            inode                   )
259                 __field(u64,            offset                  )
260                 __field(u32,            size                    )
261         ),
262
263         TP_fast_assign(
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;
268         ),
269
270         TP_printk("btree %u: %llu:%llu len %u", __entry->id,
271                   __entry->inode, __entry->offset, __entry->size)
272 );
273
274 DEFINE_EVENT(btree_node, btree_split,
275         TP_PROTO(struct bch_fs *c, struct btree *b),
276         TP_ARGS(c, b)
277 );
278
279 DEFINE_EVENT(btree_node, btree_compact,
280         TP_PROTO(struct bch_fs *c, struct btree *b),
281         TP_ARGS(c, b)
282 );
283
284 DEFINE_EVENT(btree_node, btree_merge,
285         TP_PROTO(struct bch_fs *c, struct btree *b),
286         TP_ARGS(c, b)
287 );
288
289 DEFINE_EVENT(btree_node, btree_set_root,
290         TP_PROTO(struct bch_fs *c, struct btree *b),
291         TP_ARGS(c, b)
292 );
293
294 /* Garbage collection */
295
296 DEFINE_EVENT(btree_node, btree_gc_coalesce,
297         TP_PROTO(struct bch_fs *c, struct btree *b),
298         TP_ARGS(c, b)
299 );
300
301 TRACE_EVENT(btree_gc_coalesce_fail,
302         TP_PROTO(struct bch_fs *c, int reason),
303         TP_ARGS(c, reason),
304
305         TP_STRUCT__entry(
306                 __field(u8,             reason                  )
307                 __array(char,           uuid,   16              )
308         ),
309
310         TP_fast_assign(
311                 __entry->reason         = reason;
312                 memcpy(__entry->uuid, c->disk_sb.sb->user_uuid.b, 16);
313         ),
314
315         TP_printk("%pU: %u", __entry->uuid, __entry->reason)
316 );
317
318 DEFINE_EVENT(btree_node, btree_gc_rewrite_node,
319         TP_PROTO(struct bch_fs *c, struct btree *b),
320         TP_ARGS(c, b)
321 );
322
323 DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail,
324         TP_PROTO(struct bch_fs *c, struct btree *b),
325         TP_ARGS(c, b)
326 );
327
328 DEFINE_EVENT(bch_fs, gc_start,
329         TP_PROTO(struct bch_fs *c),
330         TP_ARGS(c)
331 );
332
333 DEFINE_EVENT(bch_fs, gc_end,
334         TP_PROTO(struct bch_fs *c),
335         TP_ARGS(c)
336 );
337
338 DEFINE_EVENT(bch_fs, gc_coalesce_start,
339         TP_PROTO(struct bch_fs *c),
340         TP_ARGS(c)
341 );
342
343 DEFINE_EVENT(bch_fs, gc_coalesce_end,
344         TP_PROTO(struct bch_fs *c),
345         TP_ARGS(c)
346 );
347
348 DEFINE_EVENT(bch_fs, gc_cannot_inc_gens,
349         TP_PROTO(struct bch_fs *c),
350         TP_ARGS(c)
351 );
352
353 /* Allocator */
354
355 TRACE_EVENT(alloc_batch,
356         TP_PROTO(struct bch_dev *ca, size_t free, size_t total),
357         TP_ARGS(ca, free, total),
358
359         TP_STRUCT__entry(
360                 __array(char,           uuid,   16      )
361                 __field(size_t,         free            )
362                 __field(size_t,         total           )
363         ),
364
365         TP_fast_assign(
366                 memcpy(__entry->uuid, ca->uuid.b, 16);
367                 __entry->free = free;
368                 __entry->total = total;
369         ),
370
371         TP_printk("%pU free %zu total %zu",
372                 __entry->uuid, __entry->free, __entry->total)
373 );
374
375 TRACE_EVENT(invalidate,
376         TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors),
377         TP_ARGS(ca, offset, sectors),
378
379         TP_STRUCT__entry(
380                 __field(unsigned,       sectors                 )
381                 __field(dev_t,          dev                     )
382                 __field(__u64,          offset                  )
383         ),
384
385         TP_fast_assign(
386                 __entry->dev            = ca->disk_sb.bdev->bd_dev;
387                 __entry->offset         = offset,
388                 __entry->sectors        = sectors;
389         ),
390
391         TP_printk("invalidated %u sectors at %d,%d sector=%llu",
392                   __entry->sectors, MAJOR(__entry->dev),
393                   MINOR(__entry->dev), __entry->offset)
394 );
395
396 DEFINE_EVENT(bch_fs, rescale_prios,
397         TP_PROTO(struct bch_fs *c),
398         TP_ARGS(c)
399 );
400
401 DECLARE_EVENT_CLASS(bucket_alloc,
402         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
403         TP_ARGS(ca, reserve),
404
405         TP_STRUCT__entry(
406                 __array(char,                   uuid,   16)
407                 __field(enum alloc_reserve,     reserve   )
408         ),
409
410         TP_fast_assign(
411                 memcpy(__entry->uuid, ca->uuid.b, 16);
412                 __entry->reserve = reserve;
413         ),
414
415         TP_printk("%pU reserve %d", __entry->uuid, __entry->reserve)
416 );
417
418 DEFINE_EVENT(bucket_alloc, bucket_alloc,
419         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
420         TP_ARGS(ca, reserve)
421 );
422
423 DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
424         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
425         TP_ARGS(ca, reserve)
426 );
427
428 DEFINE_EVENT(bucket_alloc, open_bucket_alloc_fail,
429         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
430         TP_ARGS(ca, reserve)
431 );
432
433 /* Moving IO */
434
435 DEFINE_EVENT(bkey, move_extent,
436         TP_PROTO(const struct bkey *k),
437         TP_ARGS(k)
438 );
439
440 DEFINE_EVENT(bkey, move_alloc_fail,
441         TP_PROTO(const struct bkey *k),
442         TP_ARGS(k)
443 );
444
445 DEFINE_EVENT(bkey, move_race,
446         TP_PROTO(const struct bkey *k),
447         TP_ARGS(k)
448 );
449
450 TRACE_EVENT(move_data,
451         TP_PROTO(struct bch_fs *c, u64 sectors_moved,
452                  u64 keys_moved),
453         TP_ARGS(c, sectors_moved, keys_moved),
454
455         TP_STRUCT__entry(
456                 __array(char,           uuid,   16      )
457                 __field(u64,            sectors_moved   )
458                 __field(u64,            keys_moved      )
459         ),
460
461         TP_fast_assign(
462                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
463                 __entry->sectors_moved = sectors_moved;
464                 __entry->keys_moved = keys_moved;
465         ),
466
467         TP_printk("%pU sectors_moved %llu keys_moved %llu",
468                 __entry->uuid, __entry->sectors_moved, __entry->keys_moved)
469 );
470
471 TRACE_EVENT(copygc,
472         TP_PROTO(struct bch_dev *ca,
473                  u64 sectors_moved, u64 sectors_not_moved,
474                  u64 buckets_moved, u64 buckets_not_moved),
475         TP_ARGS(ca,
476                 sectors_moved, sectors_not_moved,
477                 buckets_moved, buckets_not_moved),
478
479         TP_STRUCT__entry(
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       )
485         ),
486
487         TP_fast_assign(
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;
493         ),
494
495         TP_printk("%pU sectors moved %llu remain %llu buckets moved %llu remain %llu",
496                 __entry->uuid,
497                 __entry->sectors_moved, __entry->sectors_not_moved,
498                 __entry->buckets_moved, __entry->buckets_not_moved)
499 );
500
501 DECLARE_EVENT_CLASS(transaction_restart,
502         TP_PROTO(struct bch_fs *c, unsigned long ip),
503         TP_ARGS(c, ip),
504
505         TP_STRUCT__entry(
506                 __array(char,                   name,   16)
507                 __field(unsigned long,          ip      )
508         ),
509
510         TP_fast_assign(
511                 memcpy(__entry->name, c->name, 16);
512                 __entry->ip = ip;
513         ),
514
515         TP_printk("%pf", (void *) __entry->ip)
516 );
517
518 DEFINE_EVENT(transaction_restart,       trans_restart_btree_node_reused,
519         TP_PROTO(struct bch_fs *c, unsigned long ip),
520         TP_ARGS(c, ip)
521 );
522
523 DEFINE_EVENT(transaction_restart,       trans_restart_would_deadlock,
524         TP_PROTO(struct bch_fs *c, unsigned long ip),
525         TP_ARGS(c, ip)
526 );
527
528 DEFINE_EVENT(transaction_restart,       trans_restart_iters_realloced,
529         TP_PROTO(struct bch_fs *c, unsigned long ip),
530         TP_ARGS(c, ip)
531 );
532
533 DEFINE_EVENT(transaction_restart,       trans_restart_mem_realloced,
534         TP_PROTO(struct bch_fs *c, unsigned long ip),
535         TP_ARGS(c, ip)
536 );
537
538 DEFINE_EVENT(transaction_restart,       trans_restart_journal_res_get,
539         TP_PROTO(struct bch_fs *c, unsigned long ip),
540         TP_ARGS(c, ip)
541 );
542
543 DEFINE_EVENT(transaction_restart,       trans_restart_journal_preres_get,
544         TP_PROTO(struct bch_fs *c, unsigned long ip),
545         TP_ARGS(c, ip)
546 );
547
548 DEFINE_EVENT(transaction_restart,       trans_restart_mark_replicas,
549         TP_PROTO(struct bch_fs *c, unsigned long ip),
550         TP_ARGS(c, ip)
551 );
552
553 DEFINE_EVENT(transaction_restart,       trans_restart_fault_inject,
554         TP_PROTO(struct bch_fs *c, unsigned long ip),
555         TP_ARGS(c, ip)
556 );
557
558 DEFINE_EVENT(transaction_restart,       trans_restart_btree_node_split,
559         TP_PROTO(struct bch_fs *c, unsigned long ip),
560         TP_ARGS(c, ip)
561 );
562
563 DEFINE_EVENT(transaction_restart,       trans_restart_traverse,
564         TP_PROTO(struct bch_fs *c, unsigned long ip),
565         TP_ARGS(c, ip)
566 );
567
568 DEFINE_EVENT(transaction_restart,       trans_restart_atomic,
569         TP_PROTO(struct bch_fs *c, unsigned long ip),
570         TP_ARGS(c, ip)
571 );
572
573 #endif /* _TRACE_BCACHE_H */
574
575 /* This part must be outside protection */
576 #include <trace/define_trace.h>