1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM gfs2
5 #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/tracepoint.h>
11 #include <linux/buffer_head.h>
12 #include <linux/dlmconstants.h>
13 #include <linux/gfs2_ondisk.h>
14 #include <linux/writeback.h>
15 #include <linux/ktime.h>
16 #include <linux/iomap.h>
21 #define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
22 #define glock_trace_name(x) __print_symbolic(x, \
31 #define block_state_name(x) __print_symbolic(x, \
32 { GFS2_BLKST_FREE, "free" }, \
33 { GFS2_BLKST_USED, "used" }, \
34 { GFS2_BLKST_DINODE, "dinode" }, \
35 { GFS2_BLKST_UNLINKED, "unlinked" })
37 #define TRACE_RS_DELETE 0
38 #define TRACE_RS_TREEDEL 1
39 #define TRACE_RS_INSERT 2
40 #define TRACE_RS_CLAIM 3
42 #define rs_func_name(x) __print_symbolic(x, \
48 #define show_glock_flags(flags) __print_flags(flags, "", \
49 {(1UL << GLF_LOCK), "l" }, \
50 {(1UL << GLF_DEMOTE), "D" }, \
51 {(1UL << GLF_PENDING_DEMOTE), "d" }, \
52 {(1UL << GLF_DEMOTE_IN_PROGRESS), "p" }, \
53 {(1UL << GLF_DIRTY), "y" }, \
54 {(1UL << GLF_LFLUSH), "f" }, \
55 {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \
56 {(1UL << GLF_REPLY_PENDING), "r" }, \
57 {(1UL << GLF_INITIAL), "I" }, \
58 {(1UL << GLF_FROZEN), "F" }, \
59 {(1UL << GLF_QUEUED), "q" }, \
60 {(1UL << GLF_LRU), "L" }, \
61 {(1UL << GLF_OBJECT), "o" }, \
62 {(1UL << GLF_BLOCKING), "b" })
66 static inline u8
glock_trace_state(unsigned int state
)
80 /* Section 1 - Locking
83 * Latency: Remote demote request to state change
84 * Latency: Local lock request to state change
85 * Latency: State change to lock grant
86 * Correctness: Ordering of local lock state vs. I/O requests
87 * Correctness: Responses to remote demote requests
90 /* General glock state change (DLM lock request completes) */
91 TRACE_EVENT(gfs2_glock_state_change
,
93 TP_PROTO(const struct gfs2_glock
*gl
, unsigned int new_state
),
95 TP_ARGS(gl
, new_state
),
100 __field( u32
, gltype
)
101 __field( u8
, cur_state
)
102 __field( u8
, new_state
)
103 __field( u8
, dmt_state
)
104 __field( u8
, tgt_state
)
105 __field( unsigned long, flags
)
109 __entry
->dev
= gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
110 __entry
->glnum
= gl
->gl_name
.ln_number
;
111 __entry
->gltype
= gl
->gl_name
.ln_type
;
112 __entry
->cur_state
= glock_trace_state(gl
->gl_state
);
113 __entry
->new_state
= glock_trace_state(new_state
);
114 __entry
->tgt_state
= glock_trace_state(gl
->gl_target
);
115 __entry
->dmt_state
= glock_trace_state(gl
->gl_demote_state
);
116 __entry
->flags
= gl
->gl_flags
| (gl
->gl_object
? (1UL<<GLF_OBJECT
) : 0);
119 TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
120 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
121 (unsigned long long)__entry
->glnum
,
122 glock_trace_name(__entry
->cur_state
),
123 glock_trace_name(__entry
->new_state
),
124 glock_trace_name(__entry
->tgt_state
),
125 glock_trace_name(__entry
->dmt_state
),
126 show_glock_flags(__entry
->flags
))
129 /* State change -> unlocked, glock is being deallocated */
130 TRACE_EVENT(gfs2_glock_put
,
132 TP_PROTO(const struct gfs2_glock
*gl
),
137 __field( dev_t
, dev
)
138 __field( u64
, glnum
)
139 __field( u32
, gltype
)
140 __field( u8
, cur_state
)
141 __field( unsigned long, flags
)
145 __entry
->dev
= gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
146 __entry
->gltype
= gl
->gl_name
.ln_type
;
147 __entry
->glnum
= gl
->gl_name
.ln_number
;
148 __entry
->cur_state
= glock_trace_state(gl
->gl_state
);
149 __entry
->flags
= gl
->gl_flags
| (gl
->gl_object
? (1UL<<GLF_OBJECT
) : 0);
152 TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
153 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
154 __entry
->gltype
, (unsigned long long)__entry
->glnum
,
155 glock_trace_name(__entry
->cur_state
),
156 glock_trace_name(DLM_LOCK_IV
),
157 show_glock_flags(__entry
->flags
))
161 /* Callback (local or remote) requesting lock demotion */
162 TRACE_EVENT(gfs2_demote_rq
,
164 TP_PROTO(const struct gfs2_glock
*gl
, bool remote
),
169 __field( dev_t
, dev
)
170 __field( u64
, glnum
)
171 __field( u32
, gltype
)
172 __field( u8
, cur_state
)
173 __field( u8
, dmt_state
)
174 __field( unsigned long, flags
)
175 __field( bool, remote
)
179 __entry
->dev
= gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
180 __entry
->gltype
= gl
->gl_name
.ln_type
;
181 __entry
->glnum
= gl
->gl_name
.ln_number
;
182 __entry
->cur_state
= glock_trace_state(gl
->gl_state
);
183 __entry
->dmt_state
= glock_trace_state(gl
->gl_demote_state
);
184 __entry
->flags
= gl
->gl_flags
| (gl
->gl_object
? (1UL<<GLF_OBJECT
) : 0);
185 __entry
->remote
= remote
;
188 TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s %s",
189 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
190 (unsigned long long)__entry
->glnum
,
191 glock_trace_name(__entry
->cur_state
),
192 glock_trace_name(__entry
->dmt_state
),
193 show_glock_flags(__entry
->flags
),
194 __entry
->remote
? "remote" : "local")
198 /* Promotion/grant of a glock */
199 TRACE_EVENT(gfs2_promote
,
201 TP_PROTO(const struct gfs2_holder
*gh
, int first
),
206 __field( dev_t
, dev
)
207 __field( u64
, glnum
)
208 __field( u32
, gltype
)
209 __field( int, first
)
214 __entry
->dev
= gh
->gh_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
215 __entry
->glnum
= gh
->gh_gl
->gl_name
.ln_number
;
216 __entry
->gltype
= gh
->gh_gl
->gl_name
.ln_type
;
217 __entry
->first
= first
;
218 __entry
->state
= glock_trace_state(gh
->gh_state
);
221 TP_printk("%u,%u glock %u:%llu promote %s %s",
222 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
223 (unsigned long long)__entry
->glnum
,
224 __entry
->first
? "first": "other",
225 glock_trace_name(__entry
->state
))
228 /* Queue/dequeue a lock request */
229 TRACE_EVENT(gfs2_glock_queue
,
231 TP_PROTO(const struct gfs2_holder
*gh
, int queue
),
236 __field( dev_t
, dev
)
237 __field( u64
, glnum
)
238 __field( u32
, gltype
)
239 __field( int, queue
)
244 __entry
->dev
= gh
->gh_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
245 __entry
->glnum
= gh
->gh_gl
->gl_name
.ln_number
;
246 __entry
->gltype
= gh
->gh_gl
->gl_name
.ln_type
;
247 __entry
->queue
= queue
;
248 __entry
->state
= glock_trace_state(gh
->gh_state
);
251 TP_printk("%u,%u glock %u:%llu %squeue %s",
252 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
253 (unsigned long long)__entry
->glnum
,
254 __entry
->queue
? "" : "de",
255 glock_trace_name(__entry
->state
))
258 /* DLM sends a reply to GFS2 */
259 TRACE_EVENT(gfs2_glock_lock_time
,
261 TP_PROTO(const struct gfs2_glock
*gl
, s64 tdiff
),
266 __field( dev_t
, dev
)
267 __field( u64
, glnum
)
268 __field( u32
, gltype
)
269 __field( int, status
)
270 __field( char, flags
)
271 __field( s64
, tdiff
)
273 __field( u64
, srttvar
)
274 __field( u64
, srttb
)
275 __field( u64
, srttvarb
)
277 __field( u64
, sirtvar
)
278 __field( u64
, dcount
)
279 __field( u64
, qcount
)
283 __entry
->dev
= gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
284 __entry
->glnum
= gl
->gl_name
.ln_number
;
285 __entry
->gltype
= gl
->gl_name
.ln_type
;
286 __entry
->status
= gl
->gl_lksb
.sb_status
;
287 __entry
->flags
= gl
->gl_lksb
.sb_flags
;
288 __entry
->tdiff
= tdiff
;
289 __entry
->srtt
= gl
->gl_stats
.stats
[GFS2_LKS_SRTT
];
290 __entry
->srttvar
= gl
->gl_stats
.stats
[GFS2_LKS_SRTTVAR
];
291 __entry
->srttb
= gl
->gl_stats
.stats
[GFS2_LKS_SRTTB
];
292 __entry
->srttvarb
= gl
->gl_stats
.stats
[GFS2_LKS_SRTTVARB
];
293 __entry
->sirt
= gl
->gl_stats
.stats
[GFS2_LKS_SIRT
];
294 __entry
->sirtvar
= gl
->gl_stats
.stats
[GFS2_LKS_SIRTVAR
];
295 __entry
->dcount
= gl
->gl_stats
.stats
[GFS2_LKS_DCOUNT
];
296 __entry
->qcount
= gl
->gl_stats
.stats
[GFS2_LKS_QCOUNT
];
299 TP_printk("%u,%u glock %d:%lld status:%d flags:%02x tdiff:%lld srtt:%lld/%lld srttb:%lld/%lld sirt:%lld/%lld dcnt:%lld qcnt:%lld",
300 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
301 (unsigned long long)__entry
->glnum
,
302 __entry
->status
, __entry
->flags
,
303 (long long)__entry
->tdiff
,
304 (long long)__entry
->srtt
,
305 (long long)__entry
->srttvar
,
306 (long long)__entry
->srttb
,
307 (long long)__entry
->srttvarb
,
308 (long long)__entry
->sirt
,
309 (long long)__entry
->sirtvar
,
310 (long long)__entry
->dcount
,
311 (long long)__entry
->qcount
)
314 /* Section 2 - Log/journal
317 * Latency: Log flush time
318 * Correctness: pin/unpin vs. disk I/O ordering
319 * Performance: Log usage stats
322 /* Pin/unpin a block in the log */
323 TRACE_EVENT(gfs2_pin
,
325 TP_PROTO(const struct gfs2_bufdata
*bd
, int pin
),
330 __field( dev_t
, dev
)
333 __field( sector_t
, block
)
338 __entry
->dev
= bd
->bd_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
340 __entry
->len
= bd
->bd_bh
->b_size
;
341 __entry
->block
= bd
->bd_bh
->b_blocknr
;
342 __entry
->ino
= bd
->bd_gl
->gl_name
.ln_number
;
345 TP_printk("%u,%u log %s %llu/%lu inode %llu",
346 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
347 __entry
->pin
? "pin" : "unpin",
348 (unsigned long long)__entry
->block
,
349 (unsigned long)__entry
->len
,
350 (unsigned long long)__entry
->ino
)
353 /* Flushing the log */
354 TRACE_EVENT(gfs2_log_flush
,
356 TP_PROTO(const struct gfs2_sbd
*sdp
, int start
, u32 flags
),
358 TP_ARGS(sdp
, start
, flags
),
361 __field( dev_t
, dev
)
362 __field( int, start
)
363 __field( u64
, log_seq
)
364 __field( u32
, flags
)
368 __entry
->dev
= sdp
->sd_vfs
->s_dev
;
369 __entry
->start
= start
;
370 __entry
->log_seq
= sdp
->sd_log_sequence
;
371 __entry
->flags
= flags
;
374 TP_printk("%u,%u log flush %s %llu %llx",
375 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
376 __entry
->start
? "start" : "end",
377 (unsigned long long)__entry
->log_seq
,
378 (unsigned long long)__entry
->flags
)
381 /* Reserving/releasing blocks in the log */
382 TRACE_EVENT(gfs2_log_blocks
,
384 TP_PROTO(const struct gfs2_sbd
*sdp
, int blocks
),
386 TP_ARGS(sdp
, blocks
),
389 __field( dev_t
, dev
)
390 __field( int, blocks
)
394 __entry
->dev
= sdp
->sd_vfs
->s_dev
;
395 __entry
->blocks
= blocks
;
398 TP_printk("%u,%u log reserve %d", MAJOR(__entry
->dev
),
399 MINOR(__entry
->dev
), __entry
->blocks
)
402 /* Writing back the AIL */
403 TRACE_EVENT(gfs2_ail_flush
,
405 TP_PROTO(const struct gfs2_sbd
*sdp
, const struct writeback_control
*wbc
, int start
),
407 TP_ARGS(sdp
, wbc
, start
),
410 __field( dev_t
, dev
)
411 __field( int, start
)
412 __field( int, sync_mode
)
413 __field( long, nr_to_write
)
417 __entry
->dev
= sdp
->sd_vfs
->s_dev
;
418 __entry
->start
= start
;
419 __entry
->sync_mode
= wbc
->sync_mode
;
420 __entry
->nr_to_write
= wbc
->nr_to_write
;
423 TP_printk("%u,%u ail flush %s %s %ld", MAJOR(__entry
->dev
),
424 MINOR(__entry
->dev
), __entry
->start
? "start" : "end",
425 __entry
->sync_mode
== WB_SYNC_ALL
? "all" : "none",
426 __entry
->nr_to_write
)
432 * Latency: Bmap request time
433 * Performance: Block allocator tracing
434 * Correctness: Test of disard generation vs. blocks allocated
437 /* Map an extent of blocks, possibly a new allocation */
438 TRACE_EVENT(gfs2_bmap
,
440 TP_PROTO(const struct gfs2_inode
*ip
, const struct buffer_head
*bh
,
441 sector_t lblock
, int create
, int errno
),
443 TP_ARGS(ip
, bh
, lblock
, create
, errno
),
446 __field( dev_t
, dev
)
447 __field( sector_t
, lblock
)
448 __field( sector_t
, pblock
)
450 __field( unsigned long, state
)
452 __field( int, create
)
453 __field( int, errno
)
457 __entry
->dev
= ip
->i_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
458 __entry
->lblock
= lblock
;
459 __entry
->pblock
= buffer_mapped(bh
) ? bh
->b_blocknr
: 0;
460 __entry
->inum
= ip
->i_no_addr
;
461 __entry
->state
= bh
->b_state
;
462 __entry
->len
= bh
->b_size
;
463 __entry
->create
= create
;
464 __entry
->errno
= errno
;
467 TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
468 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
469 (unsigned long long)__entry
->inum
,
470 (unsigned long long)__entry
->lblock
,
471 (unsigned long)__entry
->len
,
472 (unsigned long long)__entry
->pblock
,
473 __entry
->state
, __entry
->create
? "create " : "nocreate",
477 TRACE_EVENT(gfs2_iomap_start
,
479 TP_PROTO(const struct gfs2_inode
*ip
, loff_t pos
, ssize_t length
,
482 TP_ARGS(ip
, pos
, length
, flags
),
485 __field( dev_t
, dev
)
487 __field( loff_t
, pos
)
488 __field( ssize_t
, length
)
489 __field( u16
, flags
)
493 __entry
->dev
= ip
->i_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
494 __entry
->inum
= ip
->i_no_addr
;
496 __entry
->length
= length
;
497 __entry
->flags
= flags
;
500 TP_printk("%u,%u bmap %llu iomap start %llu/%lu flags:%08x",
501 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
502 (unsigned long long)__entry
->inum
,
503 (unsigned long long)__entry
->pos
,
504 (unsigned long)__entry
->length
, (u16
)__entry
->flags
)
507 TRACE_EVENT(gfs2_iomap_end
,
509 TP_PROTO(const struct gfs2_inode
*ip
, struct iomap
*iomap
, int ret
),
511 TP_ARGS(ip
, iomap
, ret
),
514 __field( dev_t
, dev
)
516 __field( loff_t
, offset
)
517 __field( ssize_t
, length
)
518 __field( sector_t
, pblock
)
519 __field( u16
, flags
)
525 __entry
->dev
= ip
->i_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
526 __entry
->inum
= ip
->i_no_addr
;
527 __entry
->offset
= iomap
->offset
;
528 __entry
->length
= iomap
->length
;
529 __entry
->pblock
= iomap
->addr
== IOMAP_NULL_ADDR
? 0 :
530 (iomap
->addr
>> ip
->i_inode
.i_blkbits
);
531 __entry
->flags
= iomap
->flags
;
532 __entry
->type
= iomap
->type
;
536 TP_printk("%u,%u bmap %llu iomap end %llu/%lu to %llu ty:%d flags:%08x rc:%d",
537 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
538 (unsigned long long)__entry
->inum
,
539 (unsigned long long)__entry
->offset
,
540 (unsigned long)__entry
->length
,
541 (long long)__entry
->pblock
,
543 (u16
)__entry
->flags
, __entry
->ret
)
546 /* Keep track of blocks as they are allocated/freed */
547 TRACE_EVENT(gfs2_block_alloc
,
549 TP_PROTO(const struct gfs2_inode
*ip
, struct gfs2_rgrpd
*rgd
,
550 u64 block
, unsigned len
, u8 block_state
),
552 TP_ARGS(ip
, rgd
, block
, len
, block_state
),
555 __field( dev_t
, dev
)
556 __field( u64
, start
)
559 __field( u8
, block_state
)
560 __field( u64
, rd_addr
)
561 __field( u32
, rd_free_clone
)
562 __field( u32
, rd_reserved
)
566 __entry
->dev
= rgd
->rd_gl
->gl_name
.ln_sbd
->sd_vfs
->s_dev
;
567 __entry
->start
= block
;
568 __entry
->inum
= ip
->i_no_addr
;
570 __entry
->block_state
= block_state
;
571 __entry
->rd_addr
= rgd
->rd_addr
;
572 __entry
->rd_free_clone
= rgd
->rd_free_clone
;
573 __entry
->rd_reserved
= rgd
->rd_reserved
;
576 TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
577 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
578 (unsigned long long)__entry
->inum
,
579 (unsigned long long)__entry
->start
,
580 (unsigned long)__entry
->len
,
581 block_state_name(__entry
->block_state
),
582 (unsigned long long)__entry
->rd_addr
,
583 __entry
->rd_free_clone
, (unsigned long)__entry
->rd_reserved
)
586 /* Keep track of multi-block reservations as they are allocated/freed */
589 TP_PROTO(const struct gfs2_blkreserv
*rs
, u8 func
),
594 __field( dev_t
, dev
)
595 __field( u64
, rd_addr
)
596 __field( u32
, rd_free_clone
)
597 __field( u32
, rd_reserved
)
599 __field( u64
, start
)
605 __entry
->dev
= rs
->rs_rbm
.rgd
->rd_sbd
->sd_vfs
->s_dev
;
606 __entry
->rd_addr
= rs
->rs_rbm
.rgd
->rd_addr
;
607 __entry
->rd_free_clone
= rs
->rs_rbm
.rgd
->rd_free_clone
;
608 __entry
->rd_reserved
= rs
->rs_rbm
.rgd
->rd_reserved
;
609 __entry
->inum
= container_of(rs
, struct gfs2_inode
,
611 __entry
->start
= gfs2_rbm_to_block(&rs
->rs_rbm
);
612 __entry
->free
= rs
->rs_free
;
613 __entry
->func
= func
;
616 TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s f:%lu",
617 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
618 (unsigned long long)__entry
->inum
,
619 (unsigned long long)__entry
->start
,
620 (unsigned long long)__entry
->rd_addr
,
621 (unsigned long)__entry
->rd_free_clone
,
622 (unsigned long)__entry
->rd_reserved
,
623 rs_func_name(__entry
->func
), (unsigned long)__entry
->free
)
626 #endif /* _TRACE_GFS2_H */
628 /* This part must be outside protection */
629 #undef TRACE_INCLUDE_PATH
630 #define TRACE_INCLUDE_PATH .
631 #define TRACE_INCLUDE_FILE trace_gfs2
632 #include <trace/define_trace.h>