]> git.sesse.net Git - bcachefs-tools-debian/blob - include/trace/events/bcachefs.h
Update bcachefs sources to 9abf628c70 bcachefs: Fix a spurious error in fsck
[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_dev,
47         TP_PROTO(struct bch_dev *ca),
48         TP_ARGS(ca),
49
50         TP_STRUCT__entry(
51                 __array(char,           uuid,   16      )
52         ),
53
54         TP_fast_assign(
55                 memcpy(__entry->uuid, ca->uuid.b, 16);
56         ),
57
58         TP_printk("%pU", __entry->uuid)
59 );
60
61 DECLARE_EVENT_CLASS(bch_fs,
62         TP_PROTO(struct bch_fs *c),
63         TP_ARGS(c),
64
65         TP_STRUCT__entry(
66                 __array(char,           uuid,   16 )
67         ),
68
69         TP_fast_assign(
70                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
71         ),
72
73         TP_printk("%pU", __entry->uuid)
74 );
75
76 DECLARE_EVENT_CLASS(bio,
77         TP_PROTO(struct bio *bio),
78         TP_ARGS(bio),
79
80         TP_STRUCT__entry(
81                 __field(dev_t,          dev                     )
82                 __field(sector_t,       sector                  )
83                 __field(unsigned int,   nr_sector               )
84                 __array(char,           rwbs,   6               )
85         ),
86
87         TP_fast_assign(
88                 __entry->dev            = bio->bi_disk ? bio_dev(bio) : 0;
89                 __entry->sector         = bio->bi_iter.bi_sector;
90                 __entry->nr_sector      = bio->bi_iter.bi_size >> 9;
91                 blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
92         ),
93
94         TP_printk("%d,%d  %s %llu + %u",
95                   MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
96                   (unsigned long long)__entry->sector, __entry->nr_sector)
97 );
98
99 /* io.c: */
100
101 DEFINE_EVENT(bio, read_split,
102         TP_PROTO(struct bio *bio),
103         TP_ARGS(bio)
104 );
105
106 DEFINE_EVENT(bio, read_bounce,
107         TP_PROTO(struct bio *bio),
108         TP_ARGS(bio)
109 );
110
111 DEFINE_EVENT(bio, read_retry,
112         TP_PROTO(struct bio *bio),
113         TP_ARGS(bio)
114 );
115
116 DEFINE_EVENT(bio, promote,
117         TP_PROTO(struct bio *bio),
118         TP_ARGS(bio)
119 );
120
121 /* Journal */
122
123 DEFINE_EVENT(bch_fs, journal_full,
124         TP_PROTO(struct bch_fs *c),
125         TP_ARGS(c)
126 );
127
128 DEFINE_EVENT(bch_fs, journal_entry_full,
129         TP_PROTO(struct bch_fs *c),
130         TP_ARGS(c)
131 );
132
133 DEFINE_EVENT(bio, journal_write,
134         TP_PROTO(struct bio *bio),
135         TP_ARGS(bio)
136 );
137
138 /* bset.c: */
139
140 DEFINE_EVENT(bpos, bkey_pack_pos_fail,
141         TP_PROTO(struct bpos p),
142         TP_ARGS(p)
143 );
144
145 /* Btree */
146
147 DECLARE_EVENT_CLASS(btree_node,
148         TP_PROTO(struct bch_fs *c, struct btree *b),
149         TP_ARGS(c, b),
150
151         TP_STRUCT__entry(
152                 __array(char,           uuid,           16      )
153                 __field(u8,             level                   )
154                 __field(u8,             id                      )
155                 __field(u64,            inode                   )
156                 __field(u64,            offset                  )
157         ),
158
159         TP_fast_assign(
160                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
161                 __entry->level          = b->level;
162                 __entry->id             = b->btree_id;
163                 __entry->inode          = b->key.k.p.inode;
164                 __entry->offset         = b->key.k.p.offset;
165         ),
166
167         TP_printk("%pU  %u id %u %llu:%llu",
168                   __entry->uuid, __entry->level, __entry->id,
169                   __entry->inode, __entry->offset)
170 );
171
172 DEFINE_EVENT(btree_node, btree_read,
173         TP_PROTO(struct bch_fs *c, struct btree *b),
174         TP_ARGS(c, b)
175 );
176
177 TRACE_EVENT(btree_write,
178         TP_PROTO(struct btree *b, unsigned bytes, unsigned sectors),
179         TP_ARGS(b, bytes, sectors),
180
181         TP_STRUCT__entry(
182                 __field(enum bkey_type, type)
183                 __field(unsigned,       bytes                   )
184                 __field(unsigned,       sectors                 )
185         ),
186
187         TP_fast_assign(
188                 __entry->type   = btree_node_type(b);
189                 __entry->bytes  = bytes;
190                 __entry->sectors = sectors;
191         ),
192
193         TP_printk("bkey type %u bytes %u sectors %u",
194                   __entry->type , __entry->bytes, __entry->sectors)
195 );
196
197 DEFINE_EVENT(btree_node, btree_node_alloc,
198         TP_PROTO(struct bch_fs *c, struct btree *b),
199         TP_ARGS(c, b)
200 );
201
202 DEFINE_EVENT(btree_node, btree_node_free,
203         TP_PROTO(struct bch_fs *c, struct btree *b),
204         TP_ARGS(c, b)
205 );
206
207 DEFINE_EVENT(btree_node, btree_node_reap,
208         TP_PROTO(struct bch_fs *c, struct btree *b),
209         TP_ARGS(c, b)
210 );
211
212 DECLARE_EVENT_CLASS(btree_node_cannibalize_lock,
213         TP_PROTO(struct bch_fs *c),
214         TP_ARGS(c),
215
216         TP_STRUCT__entry(
217                 __array(char,                   uuid,   16      )
218         ),
219
220         TP_fast_assign(
221                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
222         ),
223
224         TP_printk("%pU", __entry->uuid)
225 );
226
227 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock_fail,
228         TP_PROTO(struct bch_fs *c),
229         TP_ARGS(c)
230 );
231
232 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize_lock,
233         TP_PROTO(struct bch_fs *c),
234         TP_ARGS(c)
235 );
236
237 DEFINE_EVENT(btree_node_cannibalize_lock, btree_node_cannibalize,
238         TP_PROTO(struct bch_fs *c),
239         TP_ARGS(c)
240 );
241
242 DEFINE_EVENT(bch_fs, btree_node_cannibalize_unlock,
243         TP_PROTO(struct bch_fs *c),
244         TP_ARGS(c)
245 );
246
247 TRACE_EVENT(btree_reserve_get_fail,
248         TP_PROTO(struct bch_fs *c, size_t required, struct closure *cl),
249         TP_ARGS(c, required, cl),
250
251         TP_STRUCT__entry(
252                 __array(char,                   uuid,   16      )
253                 __field(size_t,                 required        )
254                 __field(struct closure *,       cl              )
255         ),
256
257         TP_fast_assign(
258                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
259                 __entry->required = required;
260                 __entry->cl = cl;
261         ),
262
263         TP_printk("%pU required %zu by %p", __entry->uuid,
264                   __entry->required, __entry->cl)
265 );
266
267 TRACE_EVENT(btree_insert_key,
268         TP_PROTO(struct bch_fs *c, struct btree *b, struct bkey_i *k),
269         TP_ARGS(c, b, k),
270
271         TP_STRUCT__entry(
272                 __field(u8,             id                      )
273                 __field(u64,            inode                   )
274                 __field(u64,            offset                  )
275                 __field(u32,            size                    )
276         ),
277
278         TP_fast_assign(
279                 __entry->id             = b->btree_id;
280                 __entry->inode          = k->k.p.inode;
281                 __entry->offset         = k->k.p.offset;
282                 __entry->size           = k->k.size;
283         ),
284
285         TP_printk("btree %u: %llu:%llu len %u", __entry->id,
286                   __entry->inode, __entry->offset, __entry->size)
287 );
288
289 DEFINE_EVENT(btree_node, btree_split,
290         TP_PROTO(struct bch_fs *c, struct btree *b),
291         TP_ARGS(c, b)
292 );
293
294 DEFINE_EVENT(btree_node, btree_compact,
295         TP_PROTO(struct bch_fs *c, struct btree *b),
296         TP_ARGS(c, b)
297 );
298
299 DEFINE_EVENT(btree_node, btree_merge,
300         TP_PROTO(struct bch_fs *c, struct btree *b),
301         TP_ARGS(c, b)
302 );
303
304 DEFINE_EVENT(btree_node, btree_set_root,
305         TP_PROTO(struct bch_fs *c, struct btree *b),
306         TP_ARGS(c, b)
307 );
308
309 /* Garbage collection */
310
311 DEFINE_EVENT(btree_node, btree_gc_coalesce,
312         TP_PROTO(struct bch_fs *c, struct btree *b),
313         TP_ARGS(c, b)
314 );
315
316 TRACE_EVENT(btree_gc_coalesce_fail,
317         TP_PROTO(struct bch_fs *c, int reason),
318         TP_ARGS(c, reason),
319
320         TP_STRUCT__entry(
321                 __field(u8,             reason                  )
322                 __array(char,           uuid,   16              )
323         ),
324
325         TP_fast_assign(
326                 __entry->reason         = reason;
327                 memcpy(__entry->uuid, c->disk_sb.sb->user_uuid.b, 16);
328         ),
329
330         TP_printk("%pU: %u", __entry->uuid, __entry->reason)
331 );
332
333 DEFINE_EVENT(btree_node, btree_gc_rewrite_node,
334         TP_PROTO(struct bch_fs *c, struct btree *b),
335         TP_ARGS(c, b)
336 );
337
338 DEFINE_EVENT(btree_node, btree_gc_rewrite_node_fail,
339         TP_PROTO(struct bch_fs *c, struct btree *b),
340         TP_ARGS(c, b)
341 );
342
343 DEFINE_EVENT(bch_fs, gc_start,
344         TP_PROTO(struct bch_fs *c),
345         TP_ARGS(c)
346 );
347
348 DEFINE_EVENT(bch_fs, gc_end,
349         TP_PROTO(struct bch_fs *c),
350         TP_ARGS(c)
351 );
352
353 DEFINE_EVENT(bch_fs, gc_coalesce_start,
354         TP_PROTO(struct bch_fs *c),
355         TP_ARGS(c)
356 );
357
358 DEFINE_EVENT(bch_fs, gc_coalesce_end,
359         TP_PROTO(struct bch_fs *c),
360         TP_ARGS(c)
361 );
362
363 DEFINE_EVENT(bch_dev, sectors_saturated,
364         TP_PROTO(struct bch_dev *ca),
365         TP_ARGS(ca)
366 );
367
368 DEFINE_EVENT(bch_fs, gc_sectors_saturated,
369         TP_PROTO(struct bch_fs *c),
370         TP_ARGS(c)
371 );
372
373 DEFINE_EVENT(bch_fs, gc_cannot_inc_gens,
374         TP_PROTO(struct bch_fs *c),
375         TP_ARGS(c)
376 );
377
378 /* Allocator */
379
380 TRACE_EVENT(alloc_batch,
381         TP_PROTO(struct bch_dev *ca, size_t free, size_t total),
382         TP_ARGS(ca, free, total),
383
384         TP_STRUCT__entry(
385                 __array(char,           uuid,   16      )
386                 __field(size_t,         free            )
387                 __field(size_t,         total           )
388         ),
389
390         TP_fast_assign(
391                 memcpy(__entry->uuid, ca->uuid.b, 16);
392                 __entry->free = free;
393                 __entry->total = total;
394         ),
395
396         TP_printk("%pU free %zu total %zu",
397                 __entry->uuid, __entry->free, __entry->total)
398 );
399
400 TRACE_EVENT(invalidate,
401         TP_PROTO(struct bch_dev *ca, u64 offset, unsigned sectors),
402         TP_ARGS(ca, offset, sectors),
403
404         TP_STRUCT__entry(
405                 __field(unsigned,       sectors                 )
406                 __field(dev_t,          dev                     )
407                 __field(__u64,          offset                  )
408         ),
409
410         TP_fast_assign(
411                 __entry->dev            = ca->disk_sb.bdev->bd_dev;
412                 __entry->offset         = offset,
413                 __entry->sectors        = sectors;
414         ),
415
416         TP_printk("invalidated %u sectors at %d,%d sector=%llu",
417                   __entry->sectors, MAJOR(__entry->dev),
418                   MINOR(__entry->dev), __entry->offset)
419 );
420
421 DEFINE_EVENT(bch_fs, rescale_prios,
422         TP_PROTO(struct bch_fs *c),
423         TP_ARGS(c)
424 );
425
426 DECLARE_EVENT_CLASS(bucket_alloc,
427         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
428         TP_ARGS(ca, reserve),
429
430         TP_STRUCT__entry(
431                 __array(char,                   uuid,   16)
432                 __field(enum alloc_reserve,     reserve   )
433         ),
434
435         TP_fast_assign(
436                 memcpy(__entry->uuid, ca->uuid.b, 16);
437                 __entry->reserve = reserve;
438         ),
439
440         TP_printk("%pU reserve %d", __entry->uuid, __entry->reserve)
441 );
442
443 DEFINE_EVENT(bucket_alloc, bucket_alloc,
444         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
445         TP_ARGS(ca, reserve)
446 );
447
448 DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
449         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
450         TP_ARGS(ca, reserve)
451 );
452
453 DEFINE_EVENT(bucket_alloc, open_bucket_alloc_fail,
454         TP_PROTO(struct bch_dev *ca, enum alloc_reserve reserve),
455         TP_ARGS(ca, reserve)
456 );
457
458 /* Moving IO */
459
460 DEFINE_EVENT(bkey, move_extent,
461         TP_PROTO(const struct bkey *k),
462         TP_ARGS(k)
463 );
464
465 DEFINE_EVENT(bkey, move_alloc_fail,
466         TP_PROTO(const struct bkey *k),
467         TP_ARGS(k)
468 );
469
470 DEFINE_EVENT(bkey, move_race,
471         TP_PROTO(const struct bkey *k),
472         TP_ARGS(k)
473 );
474
475 TRACE_EVENT(move_data,
476         TP_PROTO(struct bch_fs *c, u64 sectors_moved,
477                  u64 keys_moved),
478         TP_ARGS(c, sectors_moved, keys_moved),
479
480         TP_STRUCT__entry(
481                 __array(char,           uuid,   16      )
482                 __field(u64,            sectors_moved   )
483                 __field(u64,            keys_moved      )
484         ),
485
486         TP_fast_assign(
487                 memcpy(__entry->uuid, c->sb.user_uuid.b, 16);
488                 __entry->sectors_moved = sectors_moved;
489                 __entry->keys_moved = keys_moved;
490         ),
491
492         TP_printk("%pU sectors_moved %llu keys_moved %llu",
493                 __entry->uuid, __entry->sectors_moved, __entry->keys_moved)
494 );
495
496 TRACE_EVENT(copygc,
497         TP_PROTO(struct bch_dev *ca,
498                  u64 sectors_moved, u64 sectors_not_moved,
499                  u64 buckets_moved, u64 buckets_not_moved),
500         TP_ARGS(ca,
501                 sectors_moved, sectors_not_moved,
502                 buckets_moved, buckets_not_moved),
503
504         TP_STRUCT__entry(
505                 __array(char,           uuid,   16              )
506                 __field(u64,            sectors_moved           )
507                 __field(u64,            sectors_not_moved       )
508                 __field(u64,            buckets_moved           )
509                 __field(u64,            buckets_not_moved       )
510         ),
511
512         TP_fast_assign(
513                 memcpy(__entry->uuid, ca->uuid.b, 16);
514                 __entry->sectors_moved          = sectors_moved;
515                 __entry->sectors_not_moved      = sectors_not_moved;
516                 __entry->buckets_moved          = buckets_moved;
517                 __entry->buckets_not_moved = buckets_moved;
518         ),
519
520         TP_printk("%pU sectors moved %llu remain %llu buckets moved %llu remain %llu",
521                 __entry->uuid,
522                 __entry->sectors_moved, __entry->sectors_not_moved,
523                 __entry->buckets_moved, __entry->buckets_not_moved)
524 );
525
526 #endif /* _TRACE_BCACHE_H */
527
528 /* This part must be outside protection */
529 #include <trace/define_trace.h>