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_name.ln_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_name.ln_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, bool remote),
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 )
173 __field( bool, remote )
177 __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
178 __entry->gltype = gl->gl_name.ln_type;
179 __entry->glnum = gl->gl_name.ln_number;
180 __entry->cur_state = glock_trace_state(gl->gl_state);
181 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
182 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
183 __entry->remote = remote;
186 TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s %s",
187 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
188 (unsigned long long)__entry->glnum,
189 glock_trace_name(__entry->cur_state),
190 glock_trace_name(__entry->dmt_state),
191 show_glock_flags(__entry->flags),
192 __entry->remote ? "remote" : "local")
196 /* Promotion/grant of a glock */
197 TRACE_EVENT(gfs2_promote,
199 TP_PROTO(const struct gfs2_holder *gh, int first),
204 __field( dev_t, dev )
205 __field( u64, glnum )
206 __field( u32, gltype )
207 __field( int, first )
212 __entry->dev = gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
213 __entry->glnum = gh->gh_gl->gl_name.ln_number;
214 __entry->gltype = gh->gh_gl->gl_name.ln_type;
215 __entry->first = first;
216 __entry->state = glock_trace_state(gh->gh_state);
219 TP_printk("%u,%u glock %u:%llu promote %s %s",
220 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
221 (unsigned long long)__entry->glnum,
222 __entry->first ? "first": "other",
223 glock_trace_name(__entry->state))
226 /* Queue/dequeue a lock request */
227 TRACE_EVENT(gfs2_glock_queue,
229 TP_PROTO(const struct gfs2_holder *gh, int queue),
234 __field( dev_t, dev )
235 __field( u64, glnum )
236 __field( u32, gltype )
237 __field( int, queue )
242 __entry->dev = gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
243 __entry->glnum = gh->gh_gl->gl_name.ln_number;
244 __entry->gltype = gh->gh_gl->gl_name.ln_type;
245 __entry->queue = queue;
246 __entry->state = glock_trace_state(gh->gh_state);
249 TP_printk("%u,%u glock %u:%llu %squeue %s",
250 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
251 (unsigned long long)__entry->glnum,
252 __entry->queue ? "" : "de",
253 glock_trace_name(__entry->state))
256 /* DLM sends a reply to GFS2 */
257 TRACE_EVENT(gfs2_glock_lock_time,
259 TP_PROTO(const struct gfs2_glock *gl, s64 tdiff),
264 __field( dev_t, dev )
265 __field( u64, glnum )
266 __field( u32, gltype )
267 __field( int, status )
268 __field( char, flags )
269 __field( s64, tdiff )
271 __field( u64, srttvar )
272 __field( u64, srttb )
273 __field( u64, srttvarb )
275 __field( u64, sirtvar )
276 __field( u64, dcount )
277 __field( u64, qcount )
281 __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
282 __entry->glnum = gl->gl_name.ln_number;
283 __entry->gltype = gl->gl_name.ln_type;
284 __entry->status = gl->gl_lksb.sb_status;
285 __entry->flags = gl->gl_lksb.sb_flags;
286 __entry->tdiff = tdiff;
287 __entry->srtt = gl->gl_stats.stats[GFS2_LKS_SRTT];
288 __entry->srttvar = gl->gl_stats.stats[GFS2_LKS_SRTTVAR];
289 __entry->srttb = gl->gl_stats.stats[GFS2_LKS_SRTTB];
290 __entry->srttvarb = gl->gl_stats.stats[GFS2_LKS_SRTTVARB];
291 __entry->sirt = gl->gl_stats.stats[GFS2_LKS_SIRT];
292 __entry->sirtvar = gl->gl_stats.stats[GFS2_LKS_SIRTVAR];
293 __entry->dcount = gl->gl_stats.stats[GFS2_LKS_DCOUNT];
294 __entry->qcount = gl->gl_stats.stats[GFS2_LKS_QCOUNT];
297 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",
298 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
299 (unsigned long long)__entry->glnum,
300 __entry->status, __entry->flags,
301 (long long)__entry->tdiff,
302 (long long)__entry->srtt,
303 (long long)__entry->srttvar,
304 (long long)__entry->srttb,
305 (long long)__entry->srttvarb,
306 (long long)__entry->sirt,
307 (long long)__entry->sirtvar,
308 (long long)__entry->dcount,
309 (long long)__entry->qcount)
312 /* Section 2 - Log/journal
315 * Latency: Log flush time
316 * Correctness: pin/unpin vs. disk I/O ordering
317 * Performance: Log usage stats
320 /* Pin/unpin a block in the log */
321 TRACE_EVENT(gfs2_pin,
323 TP_PROTO(const struct gfs2_bufdata *bd, int pin),
328 __field( dev_t, dev )
331 __field( sector_t, block )
336 __entry->dev = bd->bd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
338 __entry->len = bd->bd_bh->b_size;
339 __entry->block = bd->bd_bh->b_blocknr;
340 __entry->ino = bd->bd_gl->gl_name.ln_number;
343 TP_printk("%u,%u log %s %llu/%lu inode %llu",
344 MAJOR(__entry->dev), MINOR(__entry->dev),
345 __entry->pin ? "pin" : "unpin",
346 (unsigned long long)__entry->block,
347 (unsigned long)__entry->len,
348 (unsigned long long)__entry->ino)
351 /* Flushing the log */
352 TRACE_EVENT(gfs2_log_flush,
354 TP_PROTO(const struct gfs2_sbd *sdp, int start),
359 __field( dev_t, dev )
360 __field( int, start )
361 __field( u64, log_seq )
365 __entry->dev = sdp->sd_vfs->s_dev;
366 __entry->start = start;
367 __entry->log_seq = sdp->sd_log_sequence;
370 TP_printk("%u,%u log flush %s %llu",
371 MAJOR(__entry->dev), MINOR(__entry->dev),
372 __entry->start ? "start" : "end",
373 (unsigned long long)__entry->log_seq)
376 /* Reserving/releasing blocks in the log */
377 TRACE_EVENT(gfs2_log_blocks,
379 TP_PROTO(const struct gfs2_sbd *sdp, int blocks),
381 TP_ARGS(sdp, blocks),
384 __field( dev_t, dev )
385 __field( int, blocks )
389 __entry->dev = sdp->sd_vfs->s_dev;
390 __entry->blocks = blocks;
393 TP_printk("%u,%u log reserve %d", MAJOR(__entry->dev),
394 MINOR(__entry->dev), __entry->blocks)
397 /* Writing back the AIL */
398 TRACE_EVENT(gfs2_ail_flush,
400 TP_PROTO(const struct gfs2_sbd *sdp, const struct writeback_control *wbc, int start),
402 TP_ARGS(sdp, wbc, start),
405 __field( dev_t, dev )
406 __field( int, start )
407 __field( int, sync_mode )
408 __field( long, nr_to_write )
412 __entry->dev = sdp->sd_vfs->s_dev;
413 __entry->start = start;
414 __entry->sync_mode = wbc->sync_mode;
415 __entry->nr_to_write = wbc->nr_to_write;
418 TP_printk("%u,%u ail flush %s %s %ld", MAJOR(__entry->dev),
419 MINOR(__entry->dev), __entry->start ? "start" : "end",
420 __entry->sync_mode == WB_SYNC_ALL ? "all" : "none",
421 __entry->nr_to_write)
427 * Latency: Bmap request time
428 * Performance: Block allocator tracing
429 * Correctness: Test of disard generation vs. blocks allocated
432 /* Map an extent of blocks, possibly a new allocation */
433 TRACE_EVENT(gfs2_bmap,
435 TP_PROTO(const struct gfs2_inode *ip, const struct buffer_head *bh,
436 sector_t lblock, int create, int errno),
438 TP_ARGS(ip, bh, lblock, create, errno),
441 __field( dev_t, dev )
442 __field( sector_t, lblock )
443 __field( sector_t, pblock )
445 __field( unsigned long, state )
447 __field( int, create )
448 __field( int, errno )
452 __entry->dev = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
453 __entry->lblock = lblock;
454 __entry->pblock = buffer_mapped(bh) ? bh->b_blocknr : 0;
455 __entry->inum = ip->i_no_addr;
456 __entry->state = bh->b_state;
457 __entry->len = bh->b_size;
458 __entry->create = create;
459 __entry->errno = errno;
462 TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
463 MAJOR(__entry->dev), MINOR(__entry->dev),
464 (unsigned long long)__entry->inum,
465 (unsigned long long)__entry->lblock,
466 (unsigned long)__entry->len,
467 (unsigned long long)__entry->pblock,
468 __entry->state, __entry->create ? "create " : "nocreate",
472 /* Keep track of blocks as they are allocated/freed */
473 TRACE_EVENT(gfs2_block_alloc,
475 TP_PROTO(const struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
476 u64 block, unsigned len, u8 block_state),
478 TP_ARGS(ip, rgd, block, len, block_state),
481 __field( dev_t, dev )
482 __field( u64, start )
485 __field( u8, block_state )
486 __field( u64, rd_addr )
487 __field( u32, rd_free_clone )
488 __field( u32, rd_reserved )
492 __entry->dev = rgd->rd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
493 __entry->start = block;
494 __entry->inum = ip->i_no_addr;
496 __entry->block_state = block_state;
497 __entry->rd_addr = rgd->rd_addr;
498 __entry->rd_free_clone = rgd->rd_free_clone;
499 __entry->rd_reserved = rgd->rd_reserved;
502 TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
503 MAJOR(__entry->dev), MINOR(__entry->dev),
504 (unsigned long long)__entry->inum,
505 (unsigned long long)__entry->start,
506 (unsigned long)__entry->len,
507 block_state_name(__entry->block_state),
508 (unsigned long long)__entry->rd_addr,
509 __entry->rd_free_clone, (unsigned long)__entry->rd_reserved)
512 /* Keep track of multi-block reservations as they are allocated/freed */
515 TP_PROTO(const struct gfs2_blkreserv *rs, u8 func),
520 __field( dev_t, dev )
521 __field( u64, rd_addr )
522 __field( u32, rd_free_clone )
523 __field( u32, rd_reserved )
525 __field( u64, start )
531 __entry->dev = rs->rs_rbm.rgd->rd_sbd->sd_vfs->s_dev;
532 __entry->rd_addr = rs->rs_rbm.rgd->rd_addr;
533 __entry->rd_free_clone = rs->rs_rbm.rgd->rd_free_clone;
534 __entry->rd_reserved = rs->rs_rbm.rgd->rd_reserved;
535 __entry->inum = rs->rs_inum;
536 __entry->start = gfs2_rbm_to_block(&rs->rs_rbm);
537 __entry->free = rs->rs_free;
538 __entry->func = func;
541 TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s f:%lu",
542 MAJOR(__entry->dev), MINOR(__entry->dev),
543 (unsigned long long)__entry->inum,
544 (unsigned long long)__entry->start,
545 (unsigned long long)__entry->rd_addr,
546 (unsigned long)__entry->rd_free_clone,
547 (unsigned long)__entry->rd_reserved,
548 rs_func_name(__entry->func), (unsigned long)__entry->free)
551 #endif /* _TRACE_GFS2_H */
553 /* This part must be outside protection */
554 #undef TRACE_INCLUDE_PATH
555 #define TRACE_INCLUDE_PATH .
556 #define TRACE_INCLUDE_FILE trace_gfs2
557 #include <trace/define_trace.h>