]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - fs/gfs2/trace_gfs2.h
GFS2: Make writeback more responsive to system conditions
[mirror_ubuntu-artful-kernel.git] / fs / gfs2 / trace_gfs2.h
CommitLineData
d0b6e04a
LZ
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM gfs2
3
63997775
SW
4#if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_GFS2_H
6
7#include <linux/tracepoint.h>
8
63997775
SW
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"
15
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))
25
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" })
31
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" }, \
7b5e3d5f 42 {(1UL << GLF_FROZEN), "F" }, \
627c10b7
SW
43 {(1UL << GLF_QUEUED), "q" }, \
44 {(1UL << GLF_LRU), "L" }, \
45 {(1UL << GLF_OBJECT), "o" })
63997775
SW
46
47#ifndef NUMPTY
48#define NUMPTY
49static inline u8 glock_trace_state(unsigned int state)
50{
51 switch(state) {
52 case LM_ST_SHARED:
53 return DLM_LOCK_PR;
54 case LM_ST_DEFERRED:
55 return DLM_LOCK_CW;
56 case LM_ST_EXCLUSIVE:
57 return DLM_LOCK_EX;
58 }
59 return DLM_LOCK_NL;
60}
61#endif
62
63/* Section 1 - Locking
64 *
65 * Objectives:
66 * Latency: Remote demote request to state change
67 * Latency: Local lock request to state change
68 * Latency: State change to lock grant
69 * Correctness: Ordering of local lock state vs. I/O requests
70 * Correctness: Responses to remote demote requests
71 */
72
73/* General glock state change (DLM lock request completes) */
74TRACE_EVENT(gfs2_glock_state_change,
75
76 TP_PROTO(const struct gfs2_glock *gl, unsigned int new_state),
77
78 TP_ARGS(gl, new_state),
79
80 TP_STRUCT__entry(
81 __field( dev_t, dev )
82 __field( u64, glnum )
83 __field( u32, gltype )
84 __field( u8, cur_state )
85 __field( u8, new_state )
86 __field( u8, dmt_state )
87 __field( u8, tgt_state )
88 __field( unsigned long, flags )
89 ),
90
91 TP_fast_assign(
92 __entry->dev = gl->gl_sbd->sd_vfs->s_dev;
93 __entry->glnum = gl->gl_name.ln_number;
94 __entry->gltype = gl->gl_name.ln_type;
95 __entry->cur_state = glock_trace_state(gl->gl_state);
96 __entry->new_state = glock_trace_state(new_state);
97 __entry->tgt_state = glock_trace_state(gl->gl_target);
98 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
627c10b7 99 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
63997775
SW
100 ),
101
102 TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
103 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
104 (unsigned long long)__entry->glnum,
105 glock_trace_name(__entry->cur_state),
106 glock_trace_name(__entry->new_state),
107 glock_trace_name(__entry->tgt_state),
108 glock_trace_name(__entry->dmt_state),
109 show_glock_flags(__entry->flags))
110);
111
112/* State change -> unlocked, glock is being deallocated */
113TRACE_EVENT(gfs2_glock_put,
114
115 TP_PROTO(const struct gfs2_glock *gl),
116
117 TP_ARGS(gl),
118
119 TP_STRUCT__entry(
120 __field( dev_t, dev )
121 __field( u64, glnum )
122 __field( u32, gltype )
123 __field( u8, cur_state )
124 __field( unsigned long, flags )
125 ),
126
127 TP_fast_assign(
128 __entry->dev = gl->gl_sbd->sd_vfs->s_dev;
129 __entry->gltype = gl->gl_name.ln_type;
130 __entry->glnum = gl->gl_name.ln_number;
131 __entry->cur_state = glock_trace_state(gl->gl_state);
627c10b7 132 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
63997775
SW
133 ),
134
135 TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
136 MAJOR(__entry->dev), MINOR(__entry->dev),
137 __entry->gltype, (unsigned long long)__entry->glnum,
138 glock_trace_name(__entry->cur_state),
139 glock_trace_name(DLM_LOCK_IV),
140 show_glock_flags(__entry->flags))
141
142);
143
144/* Callback (local or remote) requesting lock demotion */
145TRACE_EVENT(gfs2_demote_rq,
146
147 TP_PROTO(const struct gfs2_glock *gl),
148
149 TP_ARGS(gl),
150
151 TP_STRUCT__entry(
152 __field( dev_t, dev )
153 __field( u64, glnum )
154 __field( u32, gltype )
155 __field( u8, cur_state )
156 __field( u8, dmt_state )
157 __field( unsigned long, flags )
158 ),
159
160 TP_fast_assign(
161 __entry->dev = gl->gl_sbd->sd_vfs->s_dev;
162 __entry->gltype = gl->gl_name.ln_type;
163 __entry->glnum = gl->gl_name.ln_number;
164 __entry->cur_state = glock_trace_state(gl->gl_state);
165 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
627c10b7 166 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
63997775
SW
167 ),
168
169 TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s",
170 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
171 (unsigned long long)__entry->glnum,
172 glock_trace_name(__entry->cur_state),
173 glock_trace_name(__entry->dmt_state),
174 show_glock_flags(__entry->flags))
175
176);
177
178/* Promotion/grant of a glock */
179TRACE_EVENT(gfs2_promote,
180
181 TP_PROTO(const struct gfs2_holder *gh, int first),
182
183 TP_ARGS(gh, first),
184
185 TP_STRUCT__entry(
186 __field( dev_t, dev )
187 __field( u64, glnum )
188 __field( u32, gltype )
189 __field( int, first )
190 __field( u8, state )
191 ),
192
193 TP_fast_assign(
194 __entry->dev = gh->gh_gl->gl_sbd->sd_vfs->s_dev;
195 __entry->glnum = gh->gh_gl->gl_name.ln_number;
196 __entry->gltype = gh->gh_gl->gl_name.ln_type;
197 __entry->first = first;
198 __entry->state = glock_trace_state(gh->gh_state);
199 ),
200
201 TP_printk("%u,%u glock %u:%llu promote %s %s",
202 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
203 (unsigned long long)__entry->glnum,
204 __entry->first ? "first": "other",
205 glock_trace_name(__entry->state))
206);
207
208/* Queue/dequeue a lock request */
209TRACE_EVENT(gfs2_glock_queue,
210
211 TP_PROTO(const struct gfs2_holder *gh, int queue),
212
213 TP_ARGS(gh, queue),
214
215 TP_STRUCT__entry(
216 __field( dev_t, dev )
217 __field( u64, glnum )
218 __field( u32, gltype )
219 __field( int, queue )
220 __field( u8, state )
221 ),
222
223 TP_fast_assign(
224 __entry->dev = gh->gh_gl->gl_sbd->sd_vfs->s_dev;
225 __entry->glnum = gh->gh_gl->gl_name.ln_number;
226 __entry->gltype = gh->gh_gl->gl_name.ln_type;
227 __entry->queue = queue;
228 __entry->state = glock_trace_state(gh->gh_state);
229 ),
230
231 TP_printk("%u,%u glock %u:%llu %squeue %s",
232 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
233 (unsigned long long)__entry->glnum,
234 __entry->queue ? "" : "de",
235 glock_trace_name(__entry->state))
236);
237
238/* Section 2 - Log/journal
239 *
240 * Objectives:
241 * Latency: Log flush time
242 * Correctness: pin/unpin vs. disk I/O ordering
243 * Performance: Log usage stats
244 */
245
246/* Pin/unpin a block in the log */
247TRACE_EVENT(gfs2_pin,
248
249 TP_PROTO(const struct gfs2_bufdata *bd, int pin),
250
251 TP_ARGS(bd, pin),
252
253 TP_STRUCT__entry(
254 __field( dev_t, dev )
255 __field( int, pin )
256 __field( u32, len )
257 __field( sector_t, block )
258 __field( u64, ino )
259 ),
260
261 TP_fast_assign(
262 __entry->dev = bd->bd_gl->gl_sbd->sd_vfs->s_dev;
263 __entry->pin = pin;
264 __entry->len = bd->bd_bh->b_size;
265 __entry->block = bd->bd_bh->b_blocknr;
266 __entry->ino = bd->bd_gl->gl_name.ln_number;
267 ),
268
269 TP_printk("%u,%u log %s %llu/%lu inode %llu",
270 MAJOR(__entry->dev), MINOR(__entry->dev),
271 __entry->pin ? "pin" : "unpin",
272 (unsigned long long)__entry->block,
273 (unsigned long)__entry->len,
274 (unsigned long long)__entry->ino)
275);
276
277/* Flushing the log */
278TRACE_EVENT(gfs2_log_flush,
279
280 TP_PROTO(const struct gfs2_sbd *sdp, int start),
281
282 TP_ARGS(sdp, start),
283
284 TP_STRUCT__entry(
285 __field( dev_t, dev )
286 __field( int, start )
287 __field( u64, log_seq )
288 ),
289
290 TP_fast_assign(
291 __entry->dev = sdp->sd_vfs->s_dev;
292 __entry->start = start;
293 __entry->log_seq = sdp->sd_log_sequence;
294 ),
295
296 TP_printk("%u,%u log flush %s %llu",
297 MAJOR(__entry->dev), MINOR(__entry->dev),
298 __entry->start ? "start" : "end",
299 (unsigned long long)__entry->log_seq)
300);
301
302/* Reserving/releasing blocks in the log */
303TRACE_EVENT(gfs2_log_blocks,
304
305 TP_PROTO(const struct gfs2_sbd *sdp, int blocks),
306
307 TP_ARGS(sdp, blocks),
308
309 TP_STRUCT__entry(
310 __field( dev_t, dev )
311 __field( int, blocks )
312 ),
313
314 TP_fast_assign(
315 __entry->dev = sdp->sd_vfs->s_dev;
316 __entry->blocks = blocks;
317 ),
318
319 TP_printk("%u,%u log reserve %d", MAJOR(__entry->dev),
320 MINOR(__entry->dev), __entry->blocks)
321);
322
323/* Section 3 - bmap
324 *
325 * Objectives:
326 * Latency: Bmap request time
327 * Performance: Block allocator tracing
328 * Correctness: Test of disard generation vs. blocks allocated
329 */
330
331/* Map an extent of blocks, possibly a new allocation */
332TRACE_EVENT(gfs2_bmap,
333
334 TP_PROTO(const struct gfs2_inode *ip, const struct buffer_head *bh,
335 sector_t lblock, int create, int errno),
336
337 TP_ARGS(ip, bh, lblock, create, errno),
338
339 TP_STRUCT__entry(
340 __field( dev_t, dev )
341 __field( sector_t, lblock )
342 __field( sector_t, pblock )
343 __field( u64, inum )
344 __field( unsigned long, state )
345 __field( u32, len )
346 __field( int, create )
347 __field( int, errno )
348 ),
349
350 TP_fast_assign(
351 __entry->dev = ip->i_gl->gl_sbd->sd_vfs->s_dev;
352 __entry->lblock = lblock;
353 __entry->pblock = buffer_mapped(bh) ? bh->b_blocknr : 0;
354 __entry->inum = ip->i_no_addr;
355 __entry->state = bh->b_state;
356 __entry->len = bh->b_size;
357 __entry->create = create;
358 __entry->errno = errno;
359 ),
360
361 TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
362 MAJOR(__entry->dev), MINOR(__entry->dev),
363 (unsigned long long)__entry->inum,
364 (unsigned long long)__entry->lblock,
365 (unsigned long)__entry->len,
366 (unsigned long long)__entry->pblock,
367 __entry->state, __entry->create ? "create " : "nocreate",
368 __entry->errno)
369);
370
371/* Keep track of blocks as they are allocated/freed */
372TRACE_EVENT(gfs2_block_alloc,
373
374 TP_PROTO(const struct gfs2_inode *ip, u64 block, unsigned len,
375 u8 block_state),
376
377 TP_ARGS(ip, block, len, block_state),
378
379 TP_STRUCT__entry(
380 __field( dev_t, dev )
381 __field( u64, start )
382 __field( u64, inum )
383 __field( u32, len )
384 __field( u8, block_state )
385 ),
386
387 TP_fast_assign(
388 __entry->dev = ip->i_gl->gl_sbd->sd_vfs->s_dev;
389 __entry->start = block;
390 __entry->inum = ip->i_no_addr;
391 __entry->len = len;
392 __entry->block_state = block_state;
393 ),
394
395 TP_printk("%u,%u bmap %llu alloc %llu/%lu %s",
396 MAJOR(__entry->dev), MINOR(__entry->dev),
397 (unsigned long long)__entry->inum,
398 (unsigned long long)__entry->start,
399 (unsigned long)__entry->len,
400 block_state_name(__entry->block_state))
401);
402
403#endif /* _TRACE_GFS2_H */
404
405/* This part must be outside protection */
406#undef TRACE_INCLUDE_PATH
407#define TRACE_INCLUDE_PATH .
d0b6e04a 408#define TRACE_INCLUDE_FILE trace_gfs2
63997775
SW
409#include <trace/define_trace.h>
410