blob: d24bdcdd42e5002f70cf24bd5583af8aa3ce5987 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Li Zefand0b6e042009-07-13 10:33:21 +08002#undef TRACE_SYSTEM
3#define TRACE_SYSTEM gfs2
4
Steven Whitehouse63997772009-06-12 08:49:20 +01005#if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_GFS2_H
7
8#include <linux/tracepoint.h>
9
Steven Whitehouse63997772009-06-12 08:49:20 +010010#include <linux/fs.h>
11#include <linux/buffer_head.h>
12#include <linux/dlmconstants.h>
13#include <linux/gfs2_ondisk.h>
Steven Whitehousec83ae9c2011-04-18 14:18:38 +010014#include <linux/writeback.h>
Steven Whitehousea2457692012-01-20 10:38:36 +000015#include <linux/ktime.h>
Bob Peterson39743202017-02-16 10:27:16 -050016#include <linux/iomap.h>
Steven Whitehouse63997772009-06-12 08:49:20 +010017#include "incore.h"
18#include "glock.h"
Bob Peterson8e2e0042012-07-19 08:12:40 -040019#include "rgrp.h"
Steven Whitehouse63997772009-06-12 08:49:20 +010020
21#define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
22#define glock_trace_name(x) __print_symbolic(x, \
23 dlm_state_name(IV), \
24 dlm_state_name(NL), \
25 dlm_state_name(CR), \
26 dlm_state_name(CW), \
27 dlm_state_name(PR), \
28 dlm_state_name(PW), \
29 dlm_state_name(EX))
30
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" })
36
Bob Peterson8e2e0042012-07-19 08:12:40 -040037#define TRACE_RS_DELETE 0
38#define TRACE_RS_TREEDEL 1
39#define TRACE_RS_INSERT 2
40#define TRACE_RS_CLAIM 3
41
42#define rs_func_name(x) __print_symbolic(x, \
43 { 0, "del " }, \
44 { 1, "tdel" }, \
45 { 2, "ins " }, \
46 { 3, "clm " })
47
Steven Whitehouse63997772009-06-12 08:49:20 +010048#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" }, \
Steven Whitehouse7b5e3d52010-09-03 09:39:20 +010058 {(1UL << GLF_FROZEN), "F" }, \
Steven Whitehouse627c10b2011-04-14 14:09:52 +010059 {(1UL << GLF_LRU), "L" }, \
Steven Whitehousea2457692012-01-20 10:38:36 +000060 {(1UL << GLF_OBJECT), "o" }, \
61 {(1UL << GLF_BLOCKING), "b" })
Steven Whitehouse63997772009-06-12 08:49:20 +010062
63#ifndef NUMPTY
64#define NUMPTY
65static inline u8 glock_trace_state(unsigned int state)
66{
67 switch(state) {
68 case LM_ST_SHARED:
69 return DLM_LOCK_PR;
70 case LM_ST_DEFERRED:
71 return DLM_LOCK_CW;
72 case LM_ST_EXCLUSIVE:
73 return DLM_LOCK_EX;
74 }
75 return DLM_LOCK_NL;
76}
77#endif
78
79/* Section 1 - Locking
80 *
81 * Objectives:
82 * Latency: Remote demote request to state change
83 * Latency: Local lock request to state change
84 * Latency: State change to lock grant
85 * Correctness: Ordering of local lock state vs. I/O requests
86 * Correctness: Responses to remote demote requests
87 */
88
89/* General glock state change (DLM lock request completes) */
90TRACE_EVENT(gfs2_glock_state_change,
91
92 TP_PROTO(const struct gfs2_glock *gl, unsigned int new_state),
93
94 TP_ARGS(gl, new_state),
95
96 TP_STRUCT__entry(
97 __field( dev_t, dev )
98 __field( u64, glnum )
99 __field( u32, gltype )
100 __field( u8, cur_state )
101 __field( u8, new_state )
102 __field( u8, dmt_state )
103 __field( u8, tgt_state )
104 __field( unsigned long, flags )
105 ),
106
107 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500108 __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100109 __entry->glnum = gl->gl_name.ln_number;
110 __entry->gltype = gl->gl_name.ln_type;
111 __entry->cur_state = glock_trace_state(gl->gl_state);
112 __entry->new_state = glock_trace_state(new_state);
113 __entry->tgt_state = glock_trace_state(gl->gl_target);
114 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
Steven Whitehouse627c10b2011-04-14 14:09:52 +0100115 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
Steven Whitehouse63997772009-06-12 08:49:20 +0100116 ),
117
118 TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
119 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
120 (unsigned long long)__entry->glnum,
121 glock_trace_name(__entry->cur_state),
122 glock_trace_name(__entry->new_state),
123 glock_trace_name(__entry->tgt_state),
124 glock_trace_name(__entry->dmt_state),
125 show_glock_flags(__entry->flags))
126);
127
128/* State change -> unlocked, glock is being deallocated */
129TRACE_EVENT(gfs2_glock_put,
130
131 TP_PROTO(const struct gfs2_glock *gl),
132
133 TP_ARGS(gl),
134
135 TP_STRUCT__entry(
136 __field( dev_t, dev )
137 __field( u64, glnum )
138 __field( u32, gltype )
139 __field( u8, cur_state )
140 __field( unsigned long, flags )
141 ),
142
143 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500144 __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100145 __entry->gltype = gl->gl_name.ln_type;
146 __entry->glnum = gl->gl_name.ln_number;
147 __entry->cur_state = glock_trace_state(gl->gl_state);
Steven Whitehouse627c10b2011-04-14 14:09:52 +0100148 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
Steven Whitehouse63997772009-06-12 08:49:20 +0100149 ),
150
151 TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
152 MAJOR(__entry->dev), MINOR(__entry->dev),
153 __entry->gltype, (unsigned long long)__entry->glnum,
154 glock_trace_name(__entry->cur_state),
155 glock_trace_name(DLM_LOCK_IV),
156 show_glock_flags(__entry->flags))
157
158);
159
160/* Callback (local or remote) requesting lock demotion */
161TRACE_EVENT(gfs2_demote_rq,
162
Steven Whitehouse7bd8b2e2013-04-10 10:32:05 +0100163 TP_PROTO(const struct gfs2_glock *gl, bool remote),
Steven Whitehouse63997772009-06-12 08:49:20 +0100164
Steven Whitehouse7bd8b2e2013-04-10 10:32:05 +0100165 TP_ARGS(gl, remote),
Steven Whitehouse63997772009-06-12 08:49:20 +0100166
167 TP_STRUCT__entry(
168 __field( dev_t, dev )
169 __field( u64, glnum )
170 __field( u32, gltype )
171 __field( u8, cur_state )
172 __field( u8, dmt_state )
173 __field( unsigned long, flags )
Steven Whitehouse7bd8b2e2013-04-10 10:32:05 +0100174 __field( bool, remote )
Steven Whitehouse63997772009-06-12 08:49:20 +0100175 ),
176
177 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500178 __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100179 __entry->gltype = gl->gl_name.ln_type;
180 __entry->glnum = gl->gl_name.ln_number;
181 __entry->cur_state = glock_trace_state(gl->gl_state);
182 __entry->dmt_state = glock_trace_state(gl->gl_demote_state);
Steven Whitehouse627c10b2011-04-14 14:09:52 +0100183 __entry->flags = gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
Steven Whitehouse7bd8b2e2013-04-10 10:32:05 +0100184 __entry->remote = remote;
Steven Whitehouse63997772009-06-12 08:49:20 +0100185 ),
186
Steven Whitehouse7bd8b2e2013-04-10 10:32:05 +0100187 TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s %s",
Steven Whitehouse63997772009-06-12 08:49:20 +0100188 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
189 (unsigned long long)__entry->glnum,
190 glock_trace_name(__entry->cur_state),
191 glock_trace_name(__entry->dmt_state),
Steven Whitehouse7bd8b2e2013-04-10 10:32:05 +0100192 show_glock_flags(__entry->flags),
193 __entry->remote ? "remote" : "local")
Steven Whitehouse63997772009-06-12 08:49:20 +0100194
195);
196
197/* Promotion/grant of a glock */
198TRACE_EVENT(gfs2_promote,
199
200 TP_PROTO(const struct gfs2_holder *gh, int first),
201
202 TP_ARGS(gh, first),
203
204 TP_STRUCT__entry(
205 __field( dev_t, dev )
206 __field( u64, glnum )
207 __field( u32, gltype )
208 __field( int, first )
209 __field( u8, state )
210 ),
211
212 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500213 __entry->dev = gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100214 __entry->glnum = gh->gh_gl->gl_name.ln_number;
215 __entry->gltype = gh->gh_gl->gl_name.ln_type;
216 __entry->first = first;
217 __entry->state = glock_trace_state(gh->gh_state);
218 ),
219
220 TP_printk("%u,%u glock %u:%llu promote %s %s",
221 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
222 (unsigned long long)__entry->glnum,
223 __entry->first ? "first": "other",
224 glock_trace_name(__entry->state))
225);
226
227/* Queue/dequeue a lock request */
228TRACE_EVENT(gfs2_glock_queue,
229
230 TP_PROTO(const struct gfs2_holder *gh, int queue),
231
232 TP_ARGS(gh, queue),
233
234 TP_STRUCT__entry(
235 __field( dev_t, dev )
236 __field( u64, glnum )
237 __field( u32, gltype )
238 __field( int, queue )
239 __field( u8, state )
240 ),
241
242 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500243 __entry->dev = gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100244 __entry->glnum = gh->gh_gl->gl_name.ln_number;
245 __entry->gltype = gh->gh_gl->gl_name.ln_type;
246 __entry->queue = queue;
247 __entry->state = glock_trace_state(gh->gh_state);
248 ),
249
250 TP_printk("%u,%u glock %u:%llu %squeue %s",
251 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
252 (unsigned long long)__entry->glnum,
253 __entry->queue ? "" : "de",
254 glock_trace_name(__entry->state))
255);
256
Steven Whitehousea2457692012-01-20 10:38:36 +0000257/* DLM sends a reply to GFS2 */
258TRACE_EVENT(gfs2_glock_lock_time,
259
260 TP_PROTO(const struct gfs2_glock *gl, s64 tdiff),
261
262 TP_ARGS(gl, tdiff),
263
264 TP_STRUCT__entry(
265 __field( dev_t, dev )
266 __field( u64, glnum )
267 __field( u32, gltype )
268 __field( int, status )
269 __field( char, flags )
270 __field( s64, tdiff )
Ben Hutchings4d207132015-08-27 12:51:45 -0500271 __field( u64, srtt )
272 __field( u64, srttvar )
273 __field( u64, srttb )
274 __field( u64, srttvarb )
275 __field( u64, sirt )
276 __field( u64, sirtvar )
277 __field( u64, dcount )
278 __field( u64, qcount )
Steven Whitehousea2457692012-01-20 10:38:36 +0000279 ),
280
281 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500282 __entry->dev = gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehousea2457692012-01-20 10:38:36 +0000283 __entry->glnum = gl->gl_name.ln_number;
284 __entry->gltype = gl->gl_name.ln_type;
285 __entry->status = gl->gl_lksb.sb_status;
286 __entry->flags = gl->gl_lksb.sb_flags;
287 __entry->tdiff = tdiff;
288 __entry->srtt = gl->gl_stats.stats[GFS2_LKS_SRTT];
289 __entry->srttvar = gl->gl_stats.stats[GFS2_LKS_SRTTVAR];
290 __entry->srttb = gl->gl_stats.stats[GFS2_LKS_SRTTB];
291 __entry->srttvarb = gl->gl_stats.stats[GFS2_LKS_SRTTVARB];
292 __entry->sirt = gl->gl_stats.stats[GFS2_LKS_SIRT];
293 __entry->sirtvar = gl->gl_stats.stats[GFS2_LKS_SIRTVAR];
294 __entry->dcount = gl->gl_stats.stats[GFS2_LKS_DCOUNT];
295 __entry->qcount = gl->gl_stats.stats[GFS2_LKS_QCOUNT];
296 ),
297
298 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",
299 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
300 (unsigned long long)__entry->glnum,
301 __entry->status, __entry->flags,
302 (long long)__entry->tdiff,
303 (long long)__entry->srtt,
304 (long long)__entry->srttvar,
305 (long long)__entry->srttb,
306 (long long)__entry->srttvarb,
307 (long long)__entry->sirt,
308 (long long)__entry->sirtvar,
309 (long long)__entry->dcount,
310 (long long)__entry->qcount)
311);
312
Steven Whitehouse63997772009-06-12 08:49:20 +0100313/* Section 2 - Log/journal
314 *
315 * Objectives:
316 * Latency: Log flush time
317 * Correctness: pin/unpin vs. disk I/O ordering
318 * Performance: Log usage stats
319 */
320
321/* Pin/unpin a block in the log */
322TRACE_EVENT(gfs2_pin,
323
324 TP_PROTO(const struct gfs2_bufdata *bd, int pin),
325
326 TP_ARGS(bd, pin),
327
328 TP_STRUCT__entry(
329 __field( dev_t, dev )
330 __field( int, pin )
331 __field( u32, len )
332 __field( sector_t, block )
333 __field( u64, ino )
334 ),
335
336 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500337 __entry->dev = bd->bd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100338 __entry->pin = pin;
339 __entry->len = bd->bd_bh->b_size;
340 __entry->block = bd->bd_bh->b_blocknr;
341 __entry->ino = bd->bd_gl->gl_name.ln_number;
342 ),
343
344 TP_printk("%u,%u log %s %llu/%lu inode %llu",
345 MAJOR(__entry->dev), MINOR(__entry->dev),
346 __entry->pin ? "pin" : "unpin",
347 (unsigned long long)__entry->block,
348 (unsigned long)__entry->len,
349 (unsigned long long)__entry->ino)
350);
351
352/* Flushing the log */
353TRACE_EVENT(gfs2_log_flush,
354
Bob Peterson805c09072018-01-08 10:34:17 -0500355 TP_PROTO(const struct gfs2_sbd *sdp, int start, u32 flags),
Steven Whitehouse63997772009-06-12 08:49:20 +0100356
Bob Peterson805c09072018-01-08 10:34:17 -0500357 TP_ARGS(sdp, start, flags),
Steven Whitehouse63997772009-06-12 08:49:20 +0100358
359 TP_STRUCT__entry(
360 __field( dev_t, dev )
361 __field( int, start )
362 __field( u64, log_seq )
Bob Peterson805c09072018-01-08 10:34:17 -0500363 __field( u32, flags )
Steven Whitehouse63997772009-06-12 08:49:20 +0100364 ),
365
366 TP_fast_assign(
367 __entry->dev = sdp->sd_vfs->s_dev;
368 __entry->start = start;
369 __entry->log_seq = sdp->sd_log_sequence;
Bob Peterson805c09072018-01-08 10:34:17 -0500370 __entry->flags = flags;
Steven Whitehouse63997772009-06-12 08:49:20 +0100371 ),
372
Bob Peterson805c09072018-01-08 10:34:17 -0500373 TP_printk("%u,%u log flush %s %llu %llx",
Steven Whitehouse63997772009-06-12 08:49:20 +0100374 MAJOR(__entry->dev), MINOR(__entry->dev),
375 __entry->start ? "start" : "end",
Bob Peterson805c09072018-01-08 10:34:17 -0500376 (unsigned long long)__entry->log_seq,
377 (unsigned long long)__entry->flags)
Steven Whitehouse63997772009-06-12 08:49:20 +0100378);
379
380/* Reserving/releasing blocks in the log */
381TRACE_EVENT(gfs2_log_blocks,
382
383 TP_PROTO(const struct gfs2_sbd *sdp, int blocks),
384
385 TP_ARGS(sdp, blocks),
386
387 TP_STRUCT__entry(
388 __field( dev_t, dev )
389 __field( int, blocks )
Bob Peterson97c5e432020-08-20 08:59:28 -0500390 __field( int, blks_free )
Steven Whitehouse63997772009-06-12 08:49:20 +0100391 ),
392
393 TP_fast_assign(
394 __entry->dev = sdp->sd_vfs->s_dev;
395 __entry->blocks = blocks;
Bob Peterson97c5e432020-08-20 08:59:28 -0500396 __entry->blks_free = atomic_read(&sdp->sd_log_blks_free);
Steven Whitehouse63997772009-06-12 08:49:20 +0100397 ),
398
Bob Peterson97c5e432020-08-20 08:59:28 -0500399 TP_printk("%u,%u log reserve %d %d", MAJOR(__entry->dev),
400 MINOR(__entry->dev), __entry->blocks, __entry->blks_free)
Steven Whitehouse63997772009-06-12 08:49:20 +0100401);
402
Steven Whitehousec83ae9c2011-04-18 14:18:38 +0100403/* Writing back the AIL */
404TRACE_EVENT(gfs2_ail_flush,
405
406 TP_PROTO(const struct gfs2_sbd *sdp, const struct writeback_control *wbc, int start),
407
408 TP_ARGS(sdp, wbc, start),
409
410 TP_STRUCT__entry(
411 __field( dev_t, dev )
412 __field( int, start )
413 __field( int, sync_mode )
414 __field( long, nr_to_write )
415 ),
416
417 TP_fast_assign(
418 __entry->dev = sdp->sd_vfs->s_dev;
419 __entry->start = start;
420 __entry->sync_mode = wbc->sync_mode;
421 __entry->nr_to_write = wbc->nr_to_write;
422 ),
423
424 TP_printk("%u,%u ail flush %s %s %ld", MAJOR(__entry->dev),
425 MINOR(__entry->dev), __entry->start ? "start" : "end",
426 __entry->sync_mode == WB_SYNC_ALL ? "all" : "none",
427 __entry->nr_to_write)
428);
429
Steven Whitehouse63997772009-06-12 08:49:20 +0100430/* Section 3 - bmap
431 *
432 * Objectives:
433 * Latency: Bmap request time
434 * Performance: Block allocator tracing
435 * Correctness: Test of disard generation vs. blocks allocated
436 */
437
438/* Map an extent of blocks, possibly a new allocation */
439TRACE_EVENT(gfs2_bmap,
440
441 TP_PROTO(const struct gfs2_inode *ip, const struct buffer_head *bh,
442 sector_t lblock, int create, int errno),
443
444 TP_ARGS(ip, bh, lblock, create, errno),
445
446 TP_STRUCT__entry(
447 __field( dev_t, dev )
448 __field( sector_t, lblock )
449 __field( sector_t, pblock )
450 __field( u64, inum )
451 __field( unsigned long, state )
452 __field( u32, len )
453 __field( int, create )
454 __field( int, errno )
455 ),
456
457 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500458 __entry->dev = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100459 __entry->lblock = lblock;
460 __entry->pblock = buffer_mapped(bh) ? bh->b_blocknr : 0;
461 __entry->inum = ip->i_no_addr;
462 __entry->state = bh->b_state;
463 __entry->len = bh->b_size;
464 __entry->create = create;
465 __entry->errno = errno;
466 ),
467
468 TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
469 MAJOR(__entry->dev), MINOR(__entry->dev),
470 (unsigned long long)__entry->inum,
471 (unsigned long long)__entry->lblock,
472 (unsigned long)__entry->len,
473 (unsigned long long)__entry->pblock,
474 __entry->state, __entry->create ? "create " : "nocreate",
475 __entry->errno)
476);
477
Bob Peterson39743202017-02-16 10:27:16 -0500478TRACE_EVENT(gfs2_iomap_start,
479
480 TP_PROTO(const struct gfs2_inode *ip, loff_t pos, ssize_t length,
481 u16 flags),
482
483 TP_ARGS(ip, pos, length, flags),
484
485 TP_STRUCT__entry(
486 __field( dev_t, dev )
487 __field( u64, inum )
488 __field( loff_t, pos )
489 __field( ssize_t, length )
490 __field( u16, flags )
491 ),
492
493 TP_fast_assign(
494 __entry->dev = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
495 __entry->inum = ip->i_no_addr;
496 __entry->pos = pos;
497 __entry->length = length;
498 __entry->flags = flags;
499 ),
500
501 TP_printk("%u,%u bmap %llu iomap start %llu/%lu flags:%08x",
502 MAJOR(__entry->dev), MINOR(__entry->dev),
503 (unsigned long long)__entry->inum,
504 (unsigned long long)__entry->pos,
505 (unsigned long)__entry->length, (u16)__entry->flags)
506);
507
508TRACE_EVENT(gfs2_iomap_end,
509
510 TP_PROTO(const struct gfs2_inode *ip, struct iomap *iomap, int ret),
511
512 TP_ARGS(ip, iomap, ret),
513
514 TP_STRUCT__entry(
515 __field( dev_t, dev )
516 __field( u64, inum )
517 __field( loff_t, offset )
518 __field( ssize_t, length )
Andreas Gruenbacheree6ed852018-03-15 07:17:17 -0700519 __field( sector_t, pblock )
Bob Peterson39743202017-02-16 10:27:16 -0500520 __field( u16, flags )
521 __field( u16, type )
522 __field( int, ret )
523 ),
524
525 TP_fast_assign(
526 __entry->dev = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
527 __entry->inum = ip->i_no_addr;
528 __entry->offset = iomap->offset;
529 __entry->length = iomap->length;
Andreas Gruenbacheree6ed852018-03-15 07:17:17 -0700530 __entry->pblock = iomap->addr == IOMAP_NULL_ADDR ? 0 :
531 (iomap->addr >> ip->i_inode.i_blkbits);
Bob Peterson39743202017-02-16 10:27:16 -0500532 __entry->flags = iomap->flags;
533 __entry->type = iomap->type;
534 __entry->ret = ret;
535 ),
536
Andreas Gruenbacheree6ed852018-03-15 07:17:17 -0700537 TP_printk("%u,%u bmap %llu iomap end %llu/%lu to %llu ty:%d flags:%08x rc:%d",
Bob Peterson39743202017-02-16 10:27:16 -0500538 MAJOR(__entry->dev), MINOR(__entry->dev),
539 (unsigned long long)__entry->inum,
540 (unsigned long long)__entry->offset,
Andreas Gruenbacheree6ed852018-03-15 07:17:17 -0700541 (unsigned long)__entry->length,
542 (long long)__entry->pblock,
543 (u16)__entry->type,
Bob Peterson39743202017-02-16 10:27:16 -0500544 (u16)__entry->flags, __entry->ret)
545);
546
Steven Whitehouse63997772009-06-12 08:49:20 +0100547/* Keep track of blocks as they are allocated/freed */
548TRACE_EVENT(gfs2_block_alloc,
549
Bob Peterson41db1ab2012-05-09 12:11:35 -0400550 TP_PROTO(const struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
551 u64 block, unsigned len, u8 block_state),
Steven Whitehouse63997772009-06-12 08:49:20 +0100552
Bob Peterson41db1ab2012-05-09 12:11:35 -0400553 TP_ARGS(ip, rgd, block, len, block_state),
Steven Whitehouse63997772009-06-12 08:49:20 +0100554
555 TP_STRUCT__entry(
556 __field( dev_t, dev )
557 __field( u64, start )
558 __field( u64, inum )
559 __field( u32, len )
560 __field( u8, block_state )
Bob Peterson41db1ab2012-05-09 12:11:35 -0400561 __field( u64, rd_addr )
562 __field( u32, rd_free_clone )
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200563 __field( u32, rd_requested )
Steven Whitehouse63997772009-06-12 08:49:20 +0100564 ),
565
566 TP_fast_assign(
Bob Peterson15562c42015-03-16 11:52:05 -0500567 __entry->dev = rgd->rd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
Steven Whitehouse63997772009-06-12 08:49:20 +0100568 __entry->start = block;
569 __entry->inum = ip->i_no_addr;
570 __entry->len = len;
571 __entry->block_state = block_state;
Bob Peterson41db1ab2012-05-09 12:11:35 -0400572 __entry->rd_addr = rgd->rd_addr;
573 __entry->rd_free_clone = rgd->rd_free_clone;
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200574 __entry->rd_requested = rgd->rd_requested;
Steven Whitehouse63997772009-06-12 08:49:20 +0100575 ),
576
Bob Peterson8e2e0042012-07-19 08:12:40 -0400577 TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
Steven Whitehouse63997772009-06-12 08:49:20 +0100578 MAJOR(__entry->dev), MINOR(__entry->dev),
579 (unsigned long long)__entry->inum,
580 (unsigned long long)__entry->start,
581 (unsigned long)__entry->len,
Bob Peterson41db1ab2012-05-09 12:11:35 -0400582 block_state_name(__entry->block_state),
583 (unsigned long long)__entry->rd_addr,
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200584 __entry->rd_free_clone, (unsigned long)__entry->rd_requested)
Bob Peterson8e2e0042012-07-19 08:12:40 -0400585);
586
587/* Keep track of multi-block reservations as they are allocated/freed */
588TRACE_EVENT(gfs2_rs,
589
Steven Whitehouse9e733d32012-08-23 15:37:59 +0100590 TP_PROTO(const struct gfs2_blkreserv *rs, u8 func),
Bob Peterson8e2e0042012-07-19 08:12:40 -0400591
Steven Whitehouse9e733d32012-08-23 15:37:59 +0100592 TP_ARGS(rs, func),
Bob Peterson8e2e0042012-07-19 08:12:40 -0400593
594 TP_STRUCT__entry(
595 __field( dev_t, dev )
596 __field( u64, rd_addr )
597 __field( u32, rd_free_clone )
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200598 __field( u32, rd_requested )
Bob Peterson8e2e0042012-07-19 08:12:40 -0400599 __field( u64, inum )
600 __field( u64, start )
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200601 __field( u32, requested )
Bob Peterson8e2e0042012-07-19 08:12:40 -0400602 __field( u8, func )
603 ),
604
605 TP_fast_assign(
Andreas Gruenbacherc65b76b2018-10-11 18:56:40 +0200606 __entry->dev = rs->rs_rgd->rd_sbd->sd_vfs->s_dev;
607 __entry->rd_addr = rs->rs_rgd->rd_addr;
608 __entry->rd_free_clone = rs->rs_rgd->rd_free_clone;
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200609 __entry->rd_requested = rs->rs_rgd->rd_requested;
Bob Petersonf85c10e2018-06-13 08:52:47 -0500610 __entry->inum = container_of(rs, struct gfs2_inode,
611 i_res)->i_no_addr;
Andreas Gruenbacherc65b76b2018-10-11 18:56:40 +0200612 __entry->start = rs->rs_start;
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200613 __entry->requested = rs->rs_requested;
Bob Peterson8e2e0042012-07-19 08:12:40 -0400614 __entry->func = func;
615 ),
616
Steven Whitehouse9e733d32012-08-23 15:37:59 +0100617 TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s f:%lu",
Bob Peterson8e2e0042012-07-19 08:12:40 -0400618 MAJOR(__entry->dev), MINOR(__entry->dev),
619 (unsigned long long)__entry->inum,
620 (unsigned long long)__entry->start,
621 (unsigned long long)__entry->rd_addr,
622 (unsigned long)__entry->rd_free_clone,
Andreas Gruenbacher07974d22020-10-22 20:34:29 +0200623 (unsigned long)__entry->rd_requested,
624 rs_func_name(__entry->func), (unsigned long)__entry->requested)
Steven Whitehouse63997772009-06-12 08:49:20 +0100625);
626
627#endif /* _TRACE_GFS2_H */
628
629/* This part must be outside protection */
630#undef TRACE_INCLUDE_PATH
631#define TRACE_INCLUDE_PATH .
Li Zefand0b6e042009-07-13 10:33:21 +0800632#define TRACE_INCLUDE_FILE trace_gfs2
Steven Whitehouse63997772009-06-12 08:49:20 +0100633#include <trace/define_trace.h>
634