ext3: Replace lock/unlock_super() with an explicit lock for resizing
[linux-2.6.git] / fs / gfs2 / trace_gfs2.h
blob148d55c14171dee39435c83d56c906c09dcd0cf8
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM gfs2
4 #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_GFS2_H
7 #include <linux/tracepoint.h>
9 #include <linux/fs.h>
10 #include <linux/buffer_head.h>
11 #include <linux/dlmconstants.h>
12 #include <linux/gfs2_ondisk.h>
13 #include "incore.h"
14 #include "glock.h"
16 #define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
17 #define glock_trace_name(x) __print_symbolic(x, \
18 dlm_state_name(IV), \
19 dlm_state_name(NL), \
20 dlm_state_name(CR), \
21 dlm_state_name(CW), \
22 dlm_state_name(PR), \
23 dlm_state_name(PW), \
24 dlm_state_name(EX))
26 #define block_state_name(x) __print_symbolic(x, \
27 { GFS2_BLKST_FREE, "free" }, \
28 { GFS2_BLKST_USED, "used" }, \
29 { GFS2_BLKST_DINODE, "dinode" }, \
30 { GFS2_BLKST_UNLINKED, "unlinked" })
32 #define show_glock_flags(flags) __print_flags(flags, "", \
33 {(1UL << GLF_LOCK), "l" }, \
34 {(1UL << GLF_DEMOTE), "D" }, \
35 {(1UL << GLF_PENDING_DEMOTE), "d" }, \
36 {(1UL << GLF_DEMOTE_IN_PROGRESS), "p" }, \
37 {(1UL << GLF_DIRTY), "y" }, \
38 {(1UL << GLF_LFLUSH), "f" }, \
39 {(1UL << GLF_INVALIDATE_IN_PROGRESS), "i" }, \
40 {(1UL << GLF_REPLY_PENDING), "r" }, \
41 {(1UL << GLF_INITIAL), "I" }, \
42 {(1UL << GLF_FROZEN), "F" })
44 #ifndef NUMPTY
45 #define NUMPTY
46 static inline u8 glock_trace_state(unsigned int state)
48 switch(state) {
49 case LM_ST_SHARED:
50 return DLM_LOCK_PR;
51 case LM_ST_DEFERRED:
52 return DLM_LOCK_CW;
53 case LM_ST_EXCLUSIVE:
54 return DLM_LOCK_EX;
56 return DLM_LOCK_NL;
58 #endif
60 /* Section 1 - Locking
62 * Objectives:
63 * Latency: Remote demote request to state change
64 * Latency: Local lock request to state change
65 * Latency: State change to lock grant
66 * Correctness: Ordering of local lock state vs. I/O requests
67 * Correctness: Responses to remote demote requests
70 /* General glock state change (DLM lock request completes) */
71 TRACE_EVENT(gfs2_glock_state_change,
73 TP_PROTO(const struct gfs2_glock *gl, unsigned int new_state),
75 TP_ARGS(gl, new_state),
77 TP_STRUCT__entry(
78 __field( dev_t, dev )
79 __field( u64, glnum )
80 __field( u32, gltype )
81 __field( u8, cur_state )
82 __field( u8, new_state )
83 __field( u8, dmt_state )
84 __field( u8, tgt_state )
85 __field( unsigned long, flags )
88 TP_fast_assign(
89 __entry->dev = gl->gl_sbd->sd_vfs->s_dev;
90 __entry->glnum = gl->gl_name.ln_number;
91 __entry->gltype = gl->gl_name.ln_type;
92 __entry->cur_state = glock_trace_state(gl->gl_state);
93 __entry->new_state = glock_trace_state(new_state);
94 __entry->tgt_state = glock_trace_state(gl->gl_target);
95 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
96 __entry->flags = gl->gl_flags;
99 TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
100 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
101 (unsigned long long)__entry->glnum,
102 glock_trace_name(__entry->cur_state),
103 glock_trace_name(__entry->new_state),
104 glock_trace_name(__entry->tgt_state),
105 glock_trace_name(__entry->dmt_state),
106 show_glock_flags(__entry->flags))
109 /* State change -> unlocked, glock is being deallocated */
110 TRACE_EVENT(gfs2_glock_put,
112 TP_PROTO(const struct gfs2_glock *gl),
114 TP_ARGS(gl),
116 TP_STRUCT__entry(
117 __field( dev_t, dev )
118 __field( u64, glnum )
119 __field( u32, gltype )
120 __field( u8, cur_state )
121 __field( unsigned long, flags )
124 TP_fast_assign(
125 __entry->dev = gl->gl_sbd->sd_vfs->s_dev;
126 __entry->gltype = gl->gl_name.ln_type;
127 __entry->glnum = gl->gl_name.ln_number;
128 __entry->cur_state = glock_trace_state(gl->gl_state);
129 __entry->flags = gl->gl_flags;
132 TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
133 MAJOR(__entry->dev), MINOR(__entry->dev),
134 __entry->gltype, (unsigned long long)__entry->glnum,
135 glock_trace_name(__entry->cur_state),
136 glock_trace_name(DLM_LOCK_IV),
137 show_glock_flags(__entry->flags))
141 /* Callback (local or remote) requesting lock demotion */
142 TRACE_EVENT(gfs2_demote_rq,
144 TP_PROTO(const struct gfs2_glock *gl),
146 TP_ARGS(gl),
148 TP_STRUCT__entry(
149 __field( dev_t, dev )
150 __field( u64, glnum )
151 __field( u32, gltype )
152 __field( u8, cur_state )
153 __field( u8, dmt_state )
154 __field( unsigned long, flags )
157 TP_fast_assign(
158 __entry->dev = gl->gl_sbd->sd_vfs->s_dev;
159 __entry->gltype = gl->gl_name.ln_type;
160 __entry->glnum = gl->gl_name.ln_number;
161 __entry->cur_state = glock_trace_state(gl->gl_state);
162 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
163 __entry->flags = gl->gl_flags;
166 TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s",
167 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
168 (unsigned long long)__entry->glnum,
169 glock_trace_name(__entry->cur_state),
170 glock_trace_name(__entry->dmt_state),
171 show_glock_flags(__entry->flags))
175 /* Promotion/grant of a glock */
176 TRACE_EVENT(gfs2_promote,
178 TP_PROTO(const struct gfs2_holder *gh, int first),
180 TP_ARGS(gh, first),
182 TP_STRUCT__entry(
183 __field( dev_t, dev )
184 __field( u64, glnum )
185 __field( u32, gltype )
186 __field( int, first )
187 __field( u8, state )
190 TP_fast_assign(
191 __entry->dev = gh->gh_gl->gl_sbd->sd_vfs->s_dev;
192 __entry->glnum = gh->gh_gl->gl_name.ln_number;
193 __entry->gltype = gh->gh_gl->gl_name.ln_type;
194 __entry->first = first;
195 __entry->state = glock_trace_state(gh->gh_state);
198 TP_printk("%u,%u glock %u:%llu promote %s %s",
199 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
200 (unsigned long long)__entry->glnum,
201 __entry->first ? "first": "other",
202 glock_trace_name(__entry->state))
205 /* Queue/dequeue a lock request */
206 TRACE_EVENT(gfs2_glock_queue,
208 TP_PROTO(const struct gfs2_holder *gh, int queue),
210 TP_ARGS(gh, queue),
212 TP_STRUCT__entry(
213 __field( dev_t, dev )
214 __field( u64, glnum )
215 __field( u32, gltype )
216 __field( int, queue )
217 __field( u8, state )
220 TP_fast_assign(
221 __entry->dev = gh->gh_gl->gl_sbd->sd_vfs->s_dev;
222 __entry->glnum = gh->gh_gl->gl_name.ln_number;
223 __entry->gltype = gh->gh_gl->gl_name.ln_type;
224 __entry->queue = queue;
225 __entry->state = glock_trace_state(gh->gh_state);
228 TP_printk("%u,%u glock %u:%llu %squeue %s",
229 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
230 (unsigned long long)__entry->glnum,
231 __entry->queue ? "" : "de",
232 glock_trace_name(__entry->state))
235 /* Section 2 - Log/journal
237 * Objectives:
238 * Latency: Log flush time
239 * Correctness: pin/unpin vs. disk I/O ordering
240 * Performance: Log usage stats
243 /* Pin/unpin a block in the log */
244 TRACE_EVENT(gfs2_pin,
246 TP_PROTO(const struct gfs2_bufdata *bd, int pin),
248 TP_ARGS(bd, pin),
250 TP_STRUCT__entry(
251 __field( dev_t, dev )
252 __field( int, pin )
253 __field( u32, len )
254 __field( sector_t, block )
255 __field( u64, ino )
258 TP_fast_assign(
259 __entry->dev = bd->bd_gl->gl_sbd->sd_vfs->s_dev;
260 __entry->pin = pin;
261 __entry->len = bd->bd_bh->b_size;
262 __entry->block = bd->bd_bh->b_blocknr;
263 __entry->ino = bd->bd_gl->gl_name.ln_number;
266 TP_printk("%u,%u log %s %llu/%lu inode %llu",
267 MAJOR(__entry->dev), MINOR(__entry->dev),
268 __entry->pin ? "pin" : "unpin",
269 (unsigned long long)__entry->block,
270 (unsigned long)__entry->len,
271 (unsigned long long)__entry->ino)
274 /* Flushing the log */
275 TRACE_EVENT(gfs2_log_flush,
277 TP_PROTO(const struct gfs2_sbd *sdp, int start),
279 TP_ARGS(sdp, start),
281 TP_STRUCT__entry(
282 __field( dev_t, dev )
283 __field( int, start )
284 __field( u64, log_seq )
287 TP_fast_assign(
288 __entry->dev = sdp->sd_vfs->s_dev;
289 __entry->start = start;
290 __entry->log_seq = sdp->sd_log_sequence;
293 TP_printk("%u,%u log flush %s %llu",
294 MAJOR(__entry->dev), MINOR(__entry->dev),
295 __entry->start ? "start" : "end",
296 (unsigned long long)__entry->log_seq)
299 /* Reserving/releasing blocks in the log */
300 TRACE_EVENT(gfs2_log_blocks,
302 TP_PROTO(const struct gfs2_sbd *sdp, int blocks),
304 TP_ARGS(sdp, blocks),
306 TP_STRUCT__entry(
307 __field( dev_t, dev )
308 __field( int, blocks )
311 TP_fast_assign(
312 __entry->dev = sdp->sd_vfs->s_dev;
313 __entry->blocks = blocks;
316 TP_printk("%u,%u log reserve %d", MAJOR(__entry->dev),
317 MINOR(__entry->dev), __entry->blocks)
320 /* Section 3 - bmap
322 * Objectives:
323 * Latency: Bmap request time
324 * Performance: Block allocator tracing
325 * Correctness: Test of disard generation vs. blocks allocated
328 /* Map an extent of blocks, possibly a new allocation */
329 TRACE_EVENT(gfs2_bmap,
331 TP_PROTO(const struct gfs2_inode *ip, const struct buffer_head *bh,
332 sector_t lblock, int create, int errno),
334 TP_ARGS(ip, bh, lblock, create, errno),
336 TP_STRUCT__entry(
337 __field( dev_t, dev )
338 __field( sector_t, lblock )
339 __field( sector_t, pblock )
340 __field( u64, inum )
341 __field( unsigned long, state )
342 __field( u32, len )
343 __field( int, create )
344 __field( int, errno )
347 TP_fast_assign(
348 __entry->dev = ip->i_gl->gl_sbd->sd_vfs->s_dev;
349 __entry->lblock = lblock;
350 __entry->pblock = buffer_mapped(bh) ? bh->b_blocknr : 0;
351 __entry->inum = ip->i_no_addr;
352 __entry->state = bh->b_state;
353 __entry->len = bh->b_size;
354 __entry->create = create;
355 __entry->errno = errno;
358 TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
359 MAJOR(__entry->dev), MINOR(__entry->dev),
360 (unsigned long long)__entry->inum,
361 (unsigned long long)__entry->lblock,
362 (unsigned long)__entry->len,
363 (unsigned long long)__entry->pblock,
364 __entry->state, __entry->create ? "create " : "nocreate",
365 __entry->errno)
368 /* Keep track of blocks as they are allocated/freed */
369 TRACE_EVENT(gfs2_block_alloc,
371 TP_PROTO(const struct gfs2_inode *ip, u64 block, unsigned len,
372 u8 block_state),
374 TP_ARGS(ip, block, len, block_state),
376 TP_STRUCT__entry(
377 __field( dev_t, dev )
378 __field( u64, start )
379 __field( u64, inum )
380 __field( u32, len )
381 __field( u8, block_state )
384 TP_fast_assign(
385 __entry->dev = ip->i_gl->gl_sbd->sd_vfs->s_dev;
386 __entry->start = block;
387 __entry->inum = ip->i_no_addr;
388 __entry->len = len;
389 __entry->block_state = block_state;
392 TP_printk("%u,%u bmap %llu alloc %llu/%lu %s",
393 MAJOR(__entry->dev), MINOR(__entry->dev),
394 (unsigned long long)__entry->inum,
395 (unsigned long long)__entry->start,
396 (unsigned long)__entry->len,
397 block_state_name(__entry->block_state))
400 #endif /* _TRACE_GFS2_H */
402 /* This part must be outside protection */
403 #undef TRACE_INCLUDE_PATH
404 #define TRACE_INCLUDE_PATH .
405 #define TRACE_INCLUDE_FILE trace_gfs2
406 #include <trace/define_trace.h>