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