2 #define TRACE_SYSTEM gfs2
4 #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/tracepoint.h>
10 #include <linux/buffer_head.h>
11 #include <linux/dlmconstants.h>
12 #include <linux/gfs2_ondisk.h>
13 #include <linux/writeback.h>
14 #include <linux/ktime.h>
19 #define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
20 #define glock_trace_name(x) __print_symbolic(x, \
29 #define block_state_name(x) __print_symbolic(x, \
30 { GFS2_BLKST_FREE, "free" }, \
31 { GFS2_BLKST_USED, "used" }, \
32 { GFS2_BLKST_DINODE, "dinode" }, \
33 { GFS2_BLKST_UNLINKED, "unlinked" })
35 #define TRACE_RS_DELETE 0
36 #define TRACE_RS_TREEDEL 1
37 #define TRACE_RS_INSERT 2
38 #define TRACE_RS_CLAIM 3
40 #define rs_func_name(x) __print_symbolic(x, \
46 #define show_glock_flags(flags) __print_flags(flags, "", \
47 {(1UL << GLF_LOCK), "l" }, \
48 {(1UL << GLF_DEMOTE), "D" }, \
49 {(1UL << GLF_PENDING_DEMOTE), "d" }, \
50 {(1UL << GLF_DEMOTE_IN_PROGRESS), "p" }, \
51 {(1UL << GLF_DIRTY), "y" }, \
52 {(1UL << GLF_LFLUSH), "f" }, \
53 {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \
54 {(1UL << GLF_REPLY_PENDING), "r" }, \
55 {(1UL << GLF_INITIAL), "I" }, \
56 {(1UL << GLF_FROZEN), "F" }, \
57 {(1UL << GLF_QUEUED), "q" }, \
58 {(1UL << GLF_LRU), "L" }, \
59 {(1UL << GLF_OBJECT), "o" }, \
60 {(1UL << GLF_BLOCKING), "b" })
64 static inline u8
glock_trace_state(unsigned int state
)
78 /* Section 1 - Locking
81 * Latency: Remote demote request to state change
82 * Latency: Local lock request to state change
83 * Latency: State change to lock grant
84 * Correctness: Ordering of local lock state vs. I/O requests
85 * Correctness: Responses to remote demote requests
88 /* General glock state change (DLM lock request completes) */
89 TRACE_EVENT(gfs2_glock_state_change
,
91 TP_PROTO(const struct gfs2_glock
*gl
, unsigned int new_state
),
93 TP_ARGS(gl
, new_state
),
98 __field( u32
, gltype
)
99 __field( u8
, cur_state
)
100 __field( u8
, new_state
)
101 __field( u8
, dmt_state
)
102 __field( u8
, tgt_state
)
103 __field( unsigned long, flags
)
107 __entry
->dev
= gl
->gl_sbd
->sd_vfs
->s_dev
;
108 __entry
->glnum
= gl
->gl_name
.ln_number
;
109 __entry
->gltype
= gl
->gl_name
.ln_type
;
110 __entry
->cur_state
= glock_trace_state(gl
->gl_state
);
111 __entry
->new_state
= glock_trace_state(new_state
);
112 __entry
->tgt_state
= glock_trace_state(gl
->gl_target
);
113 __entry
->dmt_state
= glock_trace_state(gl
->gl_demote_state
);
114 __entry
->flags
= gl
->gl_flags
| (gl
->gl_object
? (1UL<<GLF_OBJECT
) : 0);
117 TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
118 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
119 (unsigned long long)__entry
->glnum
,
120 glock_trace_name(__entry
->cur_state
),
121 glock_trace_name(__entry
->new_state
),
122 glock_trace_name(__entry
->tgt_state
),
123 glock_trace_name(__entry
->dmt_state
),
124 show_glock_flags(__entry
->flags
))
127 /* State change -> unlocked, glock is being deallocated */
128 TRACE_EVENT(gfs2_glock_put
,
130 TP_PROTO(const struct gfs2_glock
*gl
),
135 __field( dev_t
, dev
)
136 __field( u64
, glnum
)
137 __field( u32
, gltype
)
138 __field( u8
, cur_state
)
139 __field( unsigned long, flags
)
143 __entry
->dev
= gl
->gl_sbd
->sd_vfs
->s_dev
;
144 __entry
->gltype
= gl
->gl_name
.ln_type
;
145 __entry
->glnum
= gl
->gl_name
.ln_number
;
146 __entry
->cur_state
= glock_trace_state(gl
->gl_state
);
147 __entry
->flags
= gl
->gl_flags
| (gl
->gl_object
? (1UL<<GLF_OBJECT
) : 0);
150 TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
151 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
152 __entry
->gltype
, (unsigned long long)__entry
->glnum
,
153 glock_trace_name(__entry
->cur_state
),
154 glock_trace_name(DLM_LOCK_IV
),
155 show_glock_flags(__entry
->flags
))
159 /* Callback (local or remote) requesting lock demotion */
160 TRACE_EVENT(gfs2_demote_rq
,
162 TP_PROTO(const struct gfs2_glock
*gl
),
167 __field( dev_t
, dev
)
168 __field( u64
, glnum
)
169 __field( u32
, gltype
)
170 __field( u8
, cur_state
)
171 __field( u8
, dmt_state
)
172 __field( unsigned long, flags
)
176 __entry
->dev
= gl
->gl_sbd
->sd_vfs
->s_dev
;
177 __entry
->gltype
= gl
->gl_name
.ln_type
;
178 __entry
->glnum
= gl
->gl_name
.ln_number
;
179 __entry
->cur_state
= glock_trace_state(gl
->gl_state
);
180 __entry
->dmt_state
= glock_trace_state(gl
->gl_demote_state
);
181 __entry
->flags
= gl
->gl_flags
| (gl
->gl_object
? (1UL<<GLF_OBJECT
) : 0);
184 TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s",
185 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
186 (unsigned long long)__entry
->glnum
,
187 glock_trace_name(__entry
->cur_state
),
188 glock_trace_name(__entry
->dmt_state
),
189 show_glock_flags(__entry
->flags
))
193 /* Promotion/grant of a glock */
194 TRACE_EVENT(gfs2_promote
,
196 TP_PROTO(const struct gfs2_holder
*gh
, int first
),
201 __field( dev_t
, dev
)
202 __field( u64
, glnum
)
203 __field( u32
, gltype
)
204 __field( int, first
)
209 __entry
->dev
= gh
->gh_gl
->gl_sbd
->sd_vfs
->s_dev
;
210 __entry
->glnum
= gh
->gh_gl
->gl_name
.ln_number
;
211 __entry
->gltype
= gh
->gh_gl
->gl_name
.ln_type
;
212 __entry
->first
= first
;
213 __entry
->state
= glock_trace_state(gh
->gh_state
);
216 TP_printk("%u,%u glock %u:%llu promote %s %s",
217 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
218 (unsigned long long)__entry
->glnum
,
219 __entry
->first
? "first": "other",
220 glock_trace_name(__entry
->state
))
223 /* Queue/dequeue a lock request */
224 TRACE_EVENT(gfs2_glock_queue
,
226 TP_PROTO(const struct gfs2_holder
*gh
, int queue
),
231 __field( dev_t
, dev
)
232 __field( u64
, glnum
)
233 __field( u32
, gltype
)
234 __field( int, queue
)
239 __entry
->dev
= gh
->gh_gl
->gl_sbd
->sd_vfs
->s_dev
;
240 __entry
->glnum
= gh
->gh_gl
->gl_name
.ln_number
;
241 __entry
->gltype
= gh
->gh_gl
->gl_name
.ln_type
;
242 __entry
->queue
= queue
;
243 __entry
->state
= glock_trace_state(gh
->gh_state
);
246 TP_printk("%u,%u glock %u:%llu %squeue %s",
247 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
248 (unsigned long long)__entry
->glnum
,
249 __entry
->queue
? "" : "de",
250 glock_trace_name(__entry
->state
))
253 /* DLM sends a reply to GFS2 */
254 TRACE_EVENT(gfs2_glock_lock_time
,
256 TP_PROTO(const struct gfs2_glock
*gl
, s64 tdiff
),
261 __field( dev_t
, dev
)
262 __field( u64
, glnum
)
263 __field( u32
, gltype
)
264 __field( int, status
)
265 __field( char, flags
)
266 __field( s64
, tdiff
)
268 __field( s64
, srttvar
)
269 __field( s64
, srttb
)
270 __field( s64
, srttvarb
)
272 __field( s64
, sirtvar
)
273 __field( s64
, dcount
)
274 __field( s64
, qcount
)
278 __entry
->dev
= gl
->gl_sbd
->sd_vfs
->s_dev
;
279 __entry
->glnum
= gl
->gl_name
.ln_number
;
280 __entry
->gltype
= gl
->gl_name
.ln_type
;
281 __entry
->status
= gl
->gl_lksb
.sb_status
;
282 __entry
->flags
= gl
->gl_lksb
.sb_flags
;
283 __entry
->tdiff
= tdiff
;
284 __entry
->srtt
= gl
->gl_stats
.stats
[GFS2_LKS_SRTT
];
285 __entry
->srttvar
= gl
->gl_stats
.stats
[GFS2_LKS_SRTTVAR
];
286 __entry
->srttb
= gl
->gl_stats
.stats
[GFS2_LKS_SRTTB
];
287 __entry
->srttvarb
= gl
->gl_stats
.stats
[GFS2_LKS_SRTTVARB
];
288 __entry
->sirt
= gl
->gl_stats
.stats
[GFS2_LKS_SIRT
];
289 __entry
->sirtvar
= gl
->gl_stats
.stats
[GFS2_LKS_SIRTVAR
];
290 __entry
->dcount
= gl
->gl_stats
.stats
[GFS2_LKS_DCOUNT
];
291 __entry
->qcount
= gl
->gl_stats
.stats
[GFS2_LKS_QCOUNT
];
294 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",
295 MAJOR(__entry
->dev
), MINOR(__entry
->dev
), __entry
->gltype
,
296 (unsigned long long)__entry
->glnum
,
297 __entry
->status
, __entry
->flags
,
298 (long long)__entry
->tdiff
,
299 (long long)__entry
->srtt
,
300 (long long)__entry
->srttvar
,
301 (long long)__entry
->srttb
,
302 (long long)__entry
->srttvarb
,
303 (long long)__entry
->sirt
,
304 (long long)__entry
->sirtvar
,
305 (long long)__entry
->dcount
,
306 (long long)__entry
->qcount
)
309 /* Section 2 - Log/journal
312 * Latency: Log flush time
313 * Correctness: pin/unpin vs. disk I/O ordering
314 * Performance: Log usage stats
317 /* Pin/unpin a block in the log */
318 TRACE_EVENT(gfs2_pin
,
320 TP_PROTO(const struct gfs2_bufdata
*bd
, int pin
),
325 __field( dev_t
, dev
)
328 __field( sector_t
, block
)
333 __entry
->dev
= bd
->bd_gl
->gl_sbd
->sd_vfs
->s_dev
;
335 __entry
->len
= bd
->bd_bh
->b_size
;
336 __entry
->block
= bd
->bd_bh
->b_blocknr
;
337 __entry
->ino
= bd
->bd_gl
->gl_name
.ln_number
;
340 TP_printk("%u,%u log %s %llu/%lu inode %llu",
341 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
342 __entry
->pin
? "pin" : "unpin",
343 (unsigned long long)__entry
->block
,
344 (unsigned long)__entry
->len
,
345 (unsigned long long)__entry
->ino
)
348 /* Flushing the log */
349 TRACE_EVENT(gfs2_log_flush
,
351 TP_PROTO(const struct gfs2_sbd
*sdp
, int start
),
356 __field( dev_t
, dev
)
357 __field( int, start
)
358 __field( u64
, log_seq
)
362 __entry
->dev
= sdp
->sd_vfs
->s_dev
;
363 __entry
->start
= start
;
364 __entry
->log_seq
= sdp
->sd_log_sequence
;
367 TP_printk("%u,%u log flush %s %llu",
368 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
369 __entry
->start
? "start" : "end",
370 (unsigned long long)__entry
->log_seq
)
373 /* Reserving/releasing blocks in the log */
374 TRACE_EVENT(gfs2_log_blocks
,
376 TP_PROTO(const struct gfs2_sbd
*sdp
, int blocks
),
378 TP_ARGS(sdp
, blocks
),
381 __field( dev_t
, dev
)
382 __field( int, blocks
)
386 __entry
->dev
= sdp
->sd_vfs
->s_dev
;
387 __entry
->blocks
= blocks
;
390 TP_printk("%u,%u log reserve %d", MAJOR(__entry
->dev
),
391 MINOR(__entry
->dev
), __entry
->blocks
)
394 /* Writing back the AIL */
395 TRACE_EVENT(gfs2_ail_flush
,
397 TP_PROTO(const struct gfs2_sbd
*sdp
, const struct writeback_control
*wbc
, int start
),
399 TP_ARGS(sdp
, wbc
, start
),
402 __field( dev_t
, dev
)
403 __field( int, start
)
404 __field( int, sync_mode
)
405 __field( long, nr_to_write
)
409 __entry
->dev
= sdp
->sd_vfs
->s_dev
;
410 __entry
->start
= start
;
411 __entry
->sync_mode
= wbc
->sync_mode
;
412 __entry
->nr_to_write
= wbc
->nr_to_write
;
415 TP_printk("%u,%u ail flush %s %s %ld", MAJOR(__entry
->dev
),
416 MINOR(__entry
->dev
), __entry
->start
? "start" : "end",
417 __entry
->sync_mode
== WB_SYNC_ALL
? "all" : "none",
418 __entry
->nr_to_write
)
424 * Latency: Bmap request time
425 * Performance: Block allocator tracing
426 * Correctness: Test of disard generation vs. blocks allocated
429 /* Map an extent of blocks, possibly a new allocation */
430 TRACE_EVENT(gfs2_bmap
,
432 TP_PROTO(const struct gfs2_inode
*ip
, const struct buffer_head
*bh
,
433 sector_t lblock
, int create
, int errno
),
435 TP_ARGS(ip
, bh
, lblock
, create
, errno
),
438 __field( dev_t
, dev
)
439 __field( sector_t
, lblock
)
440 __field( sector_t
, pblock
)
442 __field( unsigned long, state
)
444 __field( int, create
)
445 __field( int, errno
)
449 __entry
->dev
= ip
->i_gl
->gl_sbd
->sd_vfs
->s_dev
;
450 __entry
->lblock
= lblock
;
451 __entry
->pblock
= buffer_mapped(bh
) ? bh
->b_blocknr
: 0;
452 __entry
->inum
= ip
->i_no_addr
;
453 __entry
->state
= bh
->b_state
;
454 __entry
->len
= bh
->b_size
;
455 __entry
->create
= create
;
456 __entry
->errno
= errno
;
459 TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
460 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
461 (unsigned long long)__entry
->inum
,
462 (unsigned long long)__entry
->lblock
,
463 (unsigned long)__entry
->len
,
464 (unsigned long long)__entry
->pblock
,
465 __entry
->state
, __entry
->create
? "create " : "nocreate",
469 /* Keep track of blocks as they are allocated/freed */
470 TRACE_EVENT(gfs2_block_alloc
,
472 TP_PROTO(const struct gfs2_inode
*ip
, struct gfs2_rgrpd
*rgd
,
473 u64 block
, unsigned len
, u8 block_state
),
475 TP_ARGS(ip
, rgd
, block
, len
, block_state
),
478 __field( dev_t
, dev
)
479 __field( u64
, start
)
482 __field( u8
, block_state
)
483 __field( u64
, rd_addr
)
484 __field( u32
, rd_free_clone
)
485 __field( u32
, rd_reserved
)
489 __entry
->dev
= rgd
->rd_gl
->gl_sbd
->sd_vfs
->s_dev
;
490 __entry
->start
= block
;
491 __entry
->inum
= ip
->i_no_addr
;
493 __entry
->block_state
= block_state
;
494 __entry
->rd_addr
= rgd
->rd_addr
;
495 __entry
->rd_free_clone
= rgd
->rd_free_clone
;
496 __entry
->rd_reserved
= rgd
->rd_reserved
;
499 TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
500 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
501 (unsigned long long)__entry
->inum
,
502 (unsigned long long)__entry
->start
,
503 (unsigned long)__entry
->len
,
504 block_state_name(__entry
->block_state
),
505 (unsigned long long)__entry
->rd_addr
,
506 __entry
->rd_free_clone
, (unsigned long)__entry
->rd_reserved
)
509 /* Keep track of multi-block reservations as they are allocated/freed */
512 TP_PROTO(const struct gfs2_blkreserv
*rs
, u8 func
),
517 __field( dev_t
, dev
)
518 __field( u64
, rd_addr
)
519 __field( u32
, rd_free_clone
)
520 __field( u32
, rd_reserved
)
522 __field( u64
, start
)
528 __entry
->dev
= rs
->rs_rbm
.rgd
->rd_sbd
->sd_vfs
->s_dev
;
529 __entry
->rd_addr
= rs
->rs_rbm
.rgd
->rd_addr
;
530 __entry
->rd_free_clone
= rs
->rs_rbm
.rgd
->rd_free_clone
;
531 __entry
->rd_reserved
= rs
->rs_rbm
.rgd
->rd_reserved
;
532 __entry
->inum
= rs
->rs_inum
;
533 __entry
->start
= gfs2_rbm_to_block(&rs
->rs_rbm
);
534 __entry
->free
= rs
->rs_free
;
535 __entry
->func
= func
;
538 TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s f:%lu",
539 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
540 (unsigned long long)__entry
->inum
,
541 (unsigned long long)__entry
->start
,
542 (unsigned long long)__entry
->rd_addr
,
543 (unsigned long)__entry
->rd_free_clone
,
544 (unsigned long)__entry
->rd_reserved
,
545 rs_func_name(__entry
->func
), (unsigned long)__entry
->free
)
548 #endif /* _TRACE_GFS2_H */
550 /* This part must be outside protection */
551 #undef TRACE_INCLUDE_PATH
552 #define TRACE_INCLUDE_PATH .
553 #define TRACE_INCLUDE_FILE trace_gfs2
554 #include <trace/define_trace.h>