xref: /linux/fs/gfs2/trace_gfs2.h (revision 8e2e00473598dd5379d8408cb974dade000acafc)
1d0b6e04aSLi Zefan #undef TRACE_SYSTEM
2d0b6e04aSLi Zefan #define TRACE_SYSTEM gfs2
3d0b6e04aSLi Zefan 
463997775SSteven Whitehouse #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
563997775SSteven Whitehouse #define _TRACE_GFS2_H
663997775SSteven Whitehouse 
763997775SSteven Whitehouse #include <linux/tracepoint.h>
863997775SSteven Whitehouse 
963997775SSteven Whitehouse #include <linux/fs.h>
1063997775SSteven Whitehouse #include <linux/buffer_head.h>
1163997775SSteven Whitehouse #include <linux/dlmconstants.h>
1263997775SSteven Whitehouse #include <linux/gfs2_ondisk.h>
13c83ae9caSSteven Whitehouse #include <linux/writeback.h>
14a245769fSSteven Whitehouse #include <linux/ktime.h>
1563997775SSteven Whitehouse #include "incore.h"
1663997775SSteven Whitehouse #include "glock.h"
17*8e2e0047SBob Peterson #include "rgrp.h"
1863997775SSteven Whitehouse 
1963997775SSteven Whitehouse #define dlm_state_name(nn) { DLM_LOCK_##nn, #nn }
2063997775SSteven Whitehouse #define glock_trace_name(x) __print_symbolic(x,		\
2163997775SSteven Whitehouse 			    dlm_state_name(IV),		\
2263997775SSteven Whitehouse 			    dlm_state_name(NL),		\
2363997775SSteven Whitehouse 			    dlm_state_name(CR),		\
2463997775SSteven Whitehouse 			    dlm_state_name(CW),		\
2563997775SSteven Whitehouse 			    dlm_state_name(PR),		\
2663997775SSteven Whitehouse 			    dlm_state_name(PW),		\
2763997775SSteven Whitehouse 			    dlm_state_name(EX))
2863997775SSteven Whitehouse 
2963997775SSteven Whitehouse #define block_state_name(x) __print_symbolic(x,			\
3063997775SSteven Whitehouse 			    { GFS2_BLKST_FREE, "free" },	\
3163997775SSteven Whitehouse 			    { GFS2_BLKST_USED, "used" },	\
3263997775SSteven Whitehouse 			    { GFS2_BLKST_DINODE, "dinode" },	\
3363997775SSteven Whitehouse 			    { GFS2_BLKST_UNLINKED, "unlinked" })
3463997775SSteven Whitehouse 
35*8e2e0047SBob Peterson #define TRACE_RS_DELETE  0
36*8e2e0047SBob Peterson #define TRACE_RS_TREEDEL 1
37*8e2e0047SBob Peterson #define TRACE_RS_INSERT  2
38*8e2e0047SBob Peterson #define TRACE_RS_CLAIM   3
39*8e2e0047SBob Peterson 
40*8e2e0047SBob Peterson #define rs_func_name(x) __print_symbolic(x,	\
41*8e2e0047SBob Peterson 					 { 0, "del " },	\
42*8e2e0047SBob Peterson 					 { 1, "tdel" },	\
43*8e2e0047SBob Peterson 					 { 2, "ins " },	\
44*8e2e0047SBob Peterson 					 { 3, "clm " })
45*8e2e0047SBob Peterson 
4663997775SSteven Whitehouse #define show_glock_flags(flags) __print_flags(flags, "",	\
4763997775SSteven Whitehouse 	{(1UL << GLF_LOCK),			"l" },		\
4863997775SSteven Whitehouse 	{(1UL << GLF_DEMOTE),			"D" },		\
4963997775SSteven Whitehouse 	{(1UL << GLF_PENDING_DEMOTE),		"d" },		\
5063997775SSteven Whitehouse 	{(1UL << GLF_DEMOTE_IN_PROGRESS),	"p" },		\
5163997775SSteven Whitehouse 	{(1UL << GLF_DIRTY),			"y" },		\
5263997775SSteven Whitehouse 	{(1UL << GLF_LFLUSH),			"f" },		\
5363997775SSteven Whitehouse 	{(1UL << GLF_INVALIDATE_IN_PROGRESS),	"i" },		\
5463997775SSteven Whitehouse 	{(1UL << GLF_REPLY_PENDING),		"r" },		\
5563997775SSteven Whitehouse 	{(1UL << GLF_INITIAL),			"I" },		\
567b5e3d5fSSteven Whitehouse 	{(1UL << GLF_FROZEN),			"F" },		\
57627c10b7SSteven Whitehouse 	{(1UL << GLF_QUEUED),			"q" },		\
58627c10b7SSteven Whitehouse 	{(1UL << GLF_LRU),			"L" },		\
59a245769fSSteven Whitehouse 	{(1UL << GLF_OBJECT),			"o" },		\
60a245769fSSteven Whitehouse 	{(1UL << GLF_BLOCKING),			"b" })
6163997775SSteven Whitehouse 
6263997775SSteven Whitehouse #ifndef NUMPTY
6363997775SSteven Whitehouse #define NUMPTY
6463997775SSteven Whitehouse static inline u8 glock_trace_state(unsigned int state)
6563997775SSteven Whitehouse {
6663997775SSteven Whitehouse 	switch(state) {
6763997775SSteven Whitehouse 	case LM_ST_SHARED:
6863997775SSteven Whitehouse 		return DLM_LOCK_PR;
6963997775SSteven Whitehouse 	case LM_ST_DEFERRED:
7063997775SSteven Whitehouse 		return DLM_LOCK_CW;
7163997775SSteven Whitehouse 	case LM_ST_EXCLUSIVE:
7263997775SSteven Whitehouse 		return DLM_LOCK_EX;
7363997775SSteven Whitehouse 	}
7463997775SSteven Whitehouse 	return DLM_LOCK_NL;
7563997775SSteven Whitehouse }
7663997775SSteven Whitehouse #endif
7763997775SSteven Whitehouse 
7863997775SSteven Whitehouse /* Section 1 - Locking
7963997775SSteven Whitehouse  *
8063997775SSteven Whitehouse  * Objectives:
8163997775SSteven Whitehouse  * Latency: Remote demote request to state change
8263997775SSteven Whitehouse  * Latency: Local lock request to state change
8363997775SSteven Whitehouse  * Latency: State change to lock grant
8463997775SSteven Whitehouse  * Correctness: Ordering of local lock state vs. I/O requests
8563997775SSteven Whitehouse  * Correctness: Responses to remote demote requests
8663997775SSteven Whitehouse  */
8763997775SSteven Whitehouse 
8863997775SSteven Whitehouse /* General glock state change (DLM lock request completes) */
8963997775SSteven Whitehouse TRACE_EVENT(gfs2_glock_state_change,
9063997775SSteven Whitehouse 
9163997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_glock *gl, unsigned int new_state),
9263997775SSteven Whitehouse 
9363997775SSteven Whitehouse 	TP_ARGS(gl, new_state),
9463997775SSteven Whitehouse 
9563997775SSteven Whitehouse 	TP_STRUCT__entry(
9663997775SSteven Whitehouse 		__field(	dev_t,	dev			)
9763997775SSteven Whitehouse 		__field(	u64,	glnum			)
9863997775SSteven Whitehouse 		__field(	u32,	gltype			)
9963997775SSteven Whitehouse 		__field(	u8,	cur_state		)
10063997775SSteven Whitehouse 		__field(	u8,	new_state		)
10163997775SSteven Whitehouse 		__field(	u8,	dmt_state		)
10263997775SSteven Whitehouse 		__field(	u8,	tgt_state		)
10363997775SSteven Whitehouse 		__field(	unsigned long,	flags		)
10463997775SSteven Whitehouse 	),
10563997775SSteven Whitehouse 
10663997775SSteven Whitehouse 	TP_fast_assign(
10763997775SSteven Whitehouse 		__entry->dev		= gl->gl_sbd->sd_vfs->s_dev;
10863997775SSteven Whitehouse 		__entry->glnum		= gl->gl_name.ln_number;
10963997775SSteven Whitehouse 		__entry->gltype		= gl->gl_name.ln_type;
11063997775SSteven Whitehouse 		__entry->cur_state	= glock_trace_state(gl->gl_state);
11163997775SSteven Whitehouse 		__entry->new_state	= glock_trace_state(new_state);
11263997775SSteven Whitehouse 		__entry->tgt_state	= glock_trace_state(gl->gl_target);
11363997775SSteven Whitehouse 		__entry->dmt_state	= glock_trace_state(gl->gl_demote_state);
114627c10b7SSteven Whitehouse 		__entry->flags		= gl->gl_flags | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
11563997775SSteven Whitehouse 	),
11663997775SSteven Whitehouse 
11763997775SSteven Whitehouse 	TP_printk("%u,%u glock %d:%lld state %s to %s tgt:%s dmt:%s flags:%s",
11863997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
11963997775SSteven Whitehouse 		 (unsigned long long)__entry->glnum,
12063997775SSteven Whitehouse 		  glock_trace_name(__entry->cur_state),
12163997775SSteven Whitehouse 		  glock_trace_name(__entry->new_state),
12263997775SSteven Whitehouse 		  glock_trace_name(__entry->tgt_state),
12363997775SSteven Whitehouse 		  glock_trace_name(__entry->dmt_state),
12463997775SSteven Whitehouse 		  show_glock_flags(__entry->flags))
12563997775SSteven Whitehouse );
12663997775SSteven Whitehouse 
12763997775SSteven Whitehouse /* State change -> unlocked, glock is being deallocated */
12863997775SSteven Whitehouse TRACE_EVENT(gfs2_glock_put,
12963997775SSteven Whitehouse 
13063997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_glock *gl),
13163997775SSteven Whitehouse 
13263997775SSteven Whitehouse 	TP_ARGS(gl),
13363997775SSteven Whitehouse 
13463997775SSteven Whitehouse 	TP_STRUCT__entry(
13563997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
13663997775SSteven Whitehouse 		__field(	u64,	glnum			)
13763997775SSteven Whitehouse 		__field(	u32,	gltype			)
13863997775SSteven Whitehouse 		__field(	u8,	cur_state		)
13963997775SSteven Whitehouse 		__field(	unsigned long,	flags		)
14063997775SSteven Whitehouse 	),
14163997775SSteven Whitehouse 
14263997775SSteven Whitehouse 	TP_fast_assign(
14363997775SSteven Whitehouse 		__entry->dev		= gl->gl_sbd->sd_vfs->s_dev;
14463997775SSteven Whitehouse 		__entry->gltype		= gl->gl_name.ln_type;
14563997775SSteven Whitehouse 		__entry->glnum		= gl->gl_name.ln_number;
14663997775SSteven Whitehouse 		__entry->cur_state	= glock_trace_state(gl->gl_state);
147627c10b7SSteven Whitehouse 		__entry->flags		= gl->gl_flags  | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
14863997775SSteven Whitehouse 	),
14963997775SSteven Whitehouse 
15063997775SSteven Whitehouse 	TP_printk("%u,%u glock %d:%lld state %s => %s flags:%s",
15163997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev),
15263997775SSteven Whitehouse                   __entry->gltype, (unsigned long long)__entry->glnum,
15363997775SSteven Whitehouse                   glock_trace_name(__entry->cur_state),
15463997775SSteven Whitehouse 		  glock_trace_name(DLM_LOCK_IV),
15563997775SSteven Whitehouse 		  show_glock_flags(__entry->flags))
15663997775SSteven Whitehouse 
15763997775SSteven Whitehouse );
15863997775SSteven Whitehouse 
15963997775SSteven Whitehouse /* Callback (local or remote) requesting lock demotion */
16063997775SSteven Whitehouse TRACE_EVENT(gfs2_demote_rq,
16163997775SSteven Whitehouse 
16263997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_glock *gl),
16363997775SSteven Whitehouse 
16463997775SSteven Whitehouse 	TP_ARGS(gl),
16563997775SSteven Whitehouse 
16663997775SSteven Whitehouse 	TP_STRUCT__entry(
16763997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
16863997775SSteven Whitehouse 		__field(	u64,	glnum			)
16963997775SSteven Whitehouse 		__field(	u32,	gltype			)
17063997775SSteven Whitehouse 		__field(	u8,	cur_state		)
17163997775SSteven Whitehouse 		__field(	u8,	dmt_state		)
17263997775SSteven Whitehouse 		__field(	unsigned long,	flags		)
17363997775SSteven Whitehouse 	),
17463997775SSteven Whitehouse 
17563997775SSteven Whitehouse 	TP_fast_assign(
17663997775SSteven Whitehouse 		__entry->dev		= gl->gl_sbd->sd_vfs->s_dev;
17763997775SSteven Whitehouse 		__entry->gltype		= gl->gl_name.ln_type;
17863997775SSteven Whitehouse 		__entry->glnum		= gl->gl_name.ln_number;
17963997775SSteven Whitehouse 		__entry->cur_state	= glock_trace_state(gl->gl_state);
18063997775SSteven Whitehouse 		__entry->dmt_state	= glock_trace_state(gl->gl_demote_state);
181627c10b7SSteven Whitehouse 		__entry->flags		= gl->gl_flags  | (gl->gl_object ? (1UL<<GLF_OBJECT) : 0);
18263997775SSteven Whitehouse 	),
18363997775SSteven Whitehouse 
18463997775SSteven Whitehouse 	TP_printk("%u,%u glock %d:%lld demote %s to %s flags:%s",
18563997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
18663997775SSteven Whitehouse 		  (unsigned long long)__entry->glnum,
18763997775SSteven Whitehouse                   glock_trace_name(__entry->cur_state),
18863997775SSteven Whitehouse                   glock_trace_name(__entry->dmt_state),
18963997775SSteven Whitehouse 		  show_glock_flags(__entry->flags))
19063997775SSteven Whitehouse 
19163997775SSteven Whitehouse );
19263997775SSteven Whitehouse 
19363997775SSteven Whitehouse /* Promotion/grant of a glock */
19463997775SSteven Whitehouse TRACE_EVENT(gfs2_promote,
19563997775SSteven Whitehouse 
19663997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_holder *gh, int first),
19763997775SSteven Whitehouse 
19863997775SSteven Whitehouse 	TP_ARGS(gh, first),
19963997775SSteven Whitehouse 
20063997775SSteven Whitehouse 	TP_STRUCT__entry(
20163997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
20263997775SSteven Whitehouse 		__field(	u64,	glnum			)
20363997775SSteven Whitehouse 		__field(	u32,	gltype			)
20463997775SSteven Whitehouse 		__field(	int,	first			)
20563997775SSteven Whitehouse 		__field(	u8,	state			)
20663997775SSteven Whitehouse 	),
20763997775SSteven Whitehouse 
20863997775SSteven Whitehouse 	TP_fast_assign(
20963997775SSteven Whitehouse 		__entry->dev	= gh->gh_gl->gl_sbd->sd_vfs->s_dev;
21063997775SSteven Whitehouse 		__entry->glnum	= gh->gh_gl->gl_name.ln_number;
21163997775SSteven Whitehouse 		__entry->gltype	= gh->gh_gl->gl_name.ln_type;
21263997775SSteven Whitehouse 		__entry->first	= first;
21363997775SSteven Whitehouse 		__entry->state	= glock_trace_state(gh->gh_state);
21463997775SSteven Whitehouse 	),
21563997775SSteven Whitehouse 
21663997775SSteven Whitehouse 	TP_printk("%u,%u glock %u:%llu promote %s %s",
21763997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
21863997775SSteven Whitehouse 		  (unsigned long long)__entry->glnum,
21963997775SSteven Whitehouse 		  __entry->first ? "first": "other",
22063997775SSteven Whitehouse 		  glock_trace_name(__entry->state))
22163997775SSteven Whitehouse );
22263997775SSteven Whitehouse 
22363997775SSteven Whitehouse /* Queue/dequeue a lock request */
22463997775SSteven Whitehouse TRACE_EVENT(gfs2_glock_queue,
22563997775SSteven Whitehouse 
22663997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_holder *gh, int queue),
22763997775SSteven Whitehouse 
22863997775SSteven Whitehouse 	TP_ARGS(gh, queue),
22963997775SSteven Whitehouse 
23063997775SSteven Whitehouse 	TP_STRUCT__entry(
23163997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
23263997775SSteven Whitehouse 		__field(	u64,	glnum			)
23363997775SSteven Whitehouse 		__field(	u32,	gltype			)
23463997775SSteven Whitehouse 		__field(	int,	queue			)
23563997775SSteven Whitehouse 		__field(	u8,	state			)
23663997775SSteven Whitehouse 	),
23763997775SSteven Whitehouse 
23863997775SSteven Whitehouse 	TP_fast_assign(
23963997775SSteven Whitehouse 		__entry->dev	= gh->gh_gl->gl_sbd->sd_vfs->s_dev;
24063997775SSteven Whitehouse 		__entry->glnum	= gh->gh_gl->gl_name.ln_number;
24163997775SSteven Whitehouse 		__entry->gltype	= gh->gh_gl->gl_name.ln_type;
24263997775SSteven Whitehouse 		__entry->queue	= queue;
24363997775SSteven Whitehouse 		__entry->state	= glock_trace_state(gh->gh_state);
24463997775SSteven Whitehouse 	),
24563997775SSteven Whitehouse 
24663997775SSteven Whitehouse 	TP_printk("%u,%u glock %u:%llu %squeue %s",
24763997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
24863997775SSteven Whitehouse 		  (unsigned long long)__entry->glnum,
24963997775SSteven Whitehouse 		  __entry->queue ? "" : "de",
25063997775SSteven Whitehouse 		  glock_trace_name(__entry->state))
25163997775SSteven Whitehouse );
25263997775SSteven Whitehouse 
253a245769fSSteven Whitehouse /* DLM sends a reply to GFS2 */
254a245769fSSteven Whitehouse TRACE_EVENT(gfs2_glock_lock_time,
255a245769fSSteven Whitehouse 
256a245769fSSteven Whitehouse 	TP_PROTO(const struct gfs2_glock *gl, s64 tdiff),
257a245769fSSteven Whitehouse 
258a245769fSSteven Whitehouse 	TP_ARGS(gl, tdiff),
259a245769fSSteven Whitehouse 
260a245769fSSteven Whitehouse 	TP_STRUCT__entry(
261a245769fSSteven Whitehouse 		__field(	dev_t,	dev		)
262a245769fSSteven Whitehouse 		__field(	u64,	glnum		)
263a245769fSSteven Whitehouse 		__field(	u32,	gltype		)
264a245769fSSteven Whitehouse 		__field(	int,	status		)
265a245769fSSteven Whitehouse 		__field(	char,	flags		)
266a245769fSSteven Whitehouse 		__field(	s64,	tdiff		)
267a245769fSSteven Whitehouse 		__field(	s64,	srtt		)
268a245769fSSteven Whitehouse 		__field(	s64,	srttvar		)
269a245769fSSteven Whitehouse 		__field(	s64,	srttb		)
270a245769fSSteven Whitehouse 		__field(	s64,	srttvarb	)
271a245769fSSteven Whitehouse 		__field(	s64,	sirt		)
272a245769fSSteven Whitehouse 		__field(	s64,	sirtvar		)
273a245769fSSteven Whitehouse 		__field(	s64,	dcount		)
274a245769fSSteven Whitehouse 		__field(	s64,	qcount		)
275a245769fSSteven Whitehouse 	),
276a245769fSSteven Whitehouse 
277a245769fSSteven Whitehouse 	TP_fast_assign(
278a245769fSSteven Whitehouse 		__entry->dev            = gl->gl_sbd->sd_vfs->s_dev;
279a245769fSSteven Whitehouse 		__entry->glnum          = gl->gl_name.ln_number;
280a245769fSSteven Whitehouse 		__entry->gltype         = gl->gl_name.ln_type;
281a245769fSSteven Whitehouse 		__entry->status		= gl->gl_lksb.sb_status;
282a245769fSSteven Whitehouse 		__entry->flags		= gl->gl_lksb.sb_flags;
283a245769fSSteven Whitehouse 		__entry->tdiff		= tdiff;
284a245769fSSteven Whitehouse 		__entry->srtt		= gl->gl_stats.stats[GFS2_LKS_SRTT];
285a245769fSSteven Whitehouse 		__entry->srttvar	= gl->gl_stats.stats[GFS2_LKS_SRTTVAR];
286a245769fSSteven Whitehouse 		__entry->srttb		= gl->gl_stats.stats[GFS2_LKS_SRTTB];
287a245769fSSteven Whitehouse 		__entry->srttvarb	= gl->gl_stats.stats[GFS2_LKS_SRTTVARB];
288a245769fSSteven Whitehouse 		__entry->sirt		= gl->gl_stats.stats[GFS2_LKS_SIRT];
289a245769fSSteven Whitehouse 		__entry->sirtvar	= gl->gl_stats.stats[GFS2_LKS_SIRTVAR];
290a245769fSSteven Whitehouse 		__entry->dcount		= gl->gl_stats.stats[GFS2_LKS_DCOUNT];
291a245769fSSteven Whitehouse 		__entry->qcount		= gl->gl_stats.stats[GFS2_LKS_QCOUNT];
292a245769fSSteven Whitehouse 	),
293a245769fSSteven Whitehouse 
294a245769fSSteven Whitehouse 	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",
295a245769fSSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
296a245769fSSteven Whitehouse 		  (unsigned long long)__entry->glnum,
297a245769fSSteven Whitehouse 		  __entry->status, __entry->flags,
298a245769fSSteven Whitehouse 		  (long long)__entry->tdiff,
299a245769fSSteven Whitehouse 		  (long long)__entry->srtt,
300a245769fSSteven Whitehouse 		  (long long)__entry->srttvar,
301a245769fSSteven Whitehouse 		  (long long)__entry->srttb,
302a245769fSSteven Whitehouse 		  (long long)__entry->srttvarb,
303a245769fSSteven Whitehouse 		  (long long)__entry->sirt,
304a245769fSSteven Whitehouse 		  (long long)__entry->sirtvar,
305a245769fSSteven Whitehouse 		  (long long)__entry->dcount,
306a245769fSSteven Whitehouse 		  (long long)__entry->qcount)
307a245769fSSteven Whitehouse );
308a245769fSSteven Whitehouse 
30963997775SSteven Whitehouse /* Section 2 - Log/journal
31063997775SSteven Whitehouse  *
31163997775SSteven Whitehouse  * Objectives:
31263997775SSteven Whitehouse  * Latency: Log flush time
31363997775SSteven Whitehouse  * Correctness: pin/unpin vs. disk I/O ordering
31463997775SSteven Whitehouse  * Performance: Log usage stats
31563997775SSteven Whitehouse  */
31663997775SSteven Whitehouse 
31763997775SSteven Whitehouse /* Pin/unpin a block in the log */
31863997775SSteven Whitehouse TRACE_EVENT(gfs2_pin,
31963997775SSteven Whitehouse 
32063997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_bufdata *bd, int pin),
32163997775SSteven Whitehouse 
32263997775SSteven Whitehouse 	TP_ARGS(bd, pin),
32363997775SSteven Whitehouse 
32463997775SSteven Whitehouse 	TP_STRUCT__entry(
32563997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
32663997775SSteven Whitehouse 		__field(	int,	pin			)
32763997775SSteven Whitehouse 		__field(	u32,	len			)
32863997775SSteven Whitehouse 		__field(	sector_t,	block		)
32963997775SSteven Whitehouse 		__field(	u64,	ino			)
33063997775SSteven Whitehouse 	),
33163997775SSteven Whitehouse 
33263997775SSteven Whitehouse 	TP_fast_assign(
33363997775SSteven Whitehouse 		__entry->dev		= bd->bd_gl->gl_sbd->sd_vfs->s_dev;
33463997775SSteven Whitehouse 		__entry->pin		= pin;
33563997775SSteven Whitehouse 		__entry->len		= bd->bd_bh->b_size;
33663997775SSteven Whitehouse 		__entry->block		= bd->bd_bh->b_blocknr;
33763997775SSteven Whitehouse 		__entry->ino		= bd->bd_gl->gl_name.ln_number;
33863997775SSteven Whitehouse 	),
33963997775SSteven Whitehouse 
34063997775SSteven Whitehouse 	TP_printk("%u,%u log %s %llu/%lu inode %llu",
34163997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev),
34263997775SSteven Whitehouse 		  __entry->pin ? "pin" : "unpin",
34363997775SSteven Whitehouse 		  (unsigned long long)__entry->block,
34463997775SSteven Whitehouse 		  (unsigned long)__entry->len,
34563997775SSteven Whitehouse 		  (unsigned long long)__entry->ino)
34663997775SSteven Whitehouse );
34763997775SSteven Whitehouse 
34863997775SSteven Whitehouse /* Flushing the log */
34963997775SSteven Whitehouse TRACE_EVENT(gfs2_log_flush,
35063997775SSteven Whitehouse 
35163997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_sbd *sdp, int start),
35263997775SSteven Whitehouse 
35363997775SSteven Whitehouse 	TP_ARGS(sdp, start),
35463997775SSteven Whitehouse 
35563997775SSteven Whitehouse 	TP_STRUCT__entry(
35663997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
35763997775SSteven Whitehouse 		__field(	int,	start			)
35863997775SSteven Whitehouse 		__field(	u64,	log_seq			)
35963997775SSteven Whitehouse 	),
36063997775SSteven Whitehouse 
36163997775SSteven Whitehouse 	TP_fast_assign(
36263997775SSteven Whitehouse 		__entry->dev            = sdp->sd_vfs->s_dev;
36363997775SSteven Whitehouse 		__entry->start		= start;
36463997775SSteven Whitehouse 		__entry->log_seq	= sdp->sd_log_sequence;
36563997775SSteven Whitehouse 	),
36663997775SSteven Whitehouse 
36763997775SSteven Whitehouse 	TP_printk("%u,%u log flush %s %llu",
36863997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev),
36963997775SSteven Whitehouse 		  __entry->start ? "start" : "end",
37063997775SSteven Whitehouse 		  (unsigned long long)__entry->log_seq)
37163997775SSteven Whitehouse );
37263997775SSteven Whitehouse 
37363997775SSteven Whitehouse /* Reserving/releasing blocks in the log */
37463997775SSteven Whitehouse TRACE_EVENT(gfs2_log_blocks,
37563997775SSteven Whitehouse 
37663997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_sbd *sdp, int blocks),
37763997775SSteven Whitehouse 
37863997775SSteven Whitehouse 	TP_ARGS(sdp, blocks),
37963997775SSteven Whitehouse 
38063997775SSteven Whitehouse 	TP_STRUCT__entry(
38163997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
38263997775SSteven Whitehouse 		__field(	int,	blocks			)
38363997775SSteven Whitehouse 	),
38463997775SSteven Whitehouse 
38563997775SSteven Whitehouse 	TP_fast_assign(
38663997775SSteven Whitehouse 		__entry->dev		= sdp->sd_vfs->s_dev;
38763997775SSteven Whitehouse 		__entry->blocks		= blocks;
38863997775SSteven Whitehouse 	),
38963997775SSteven Whitehouse 
39063997775SSteven Whitehouse 	TP_printk("%u,%u log reserve %d", MAJOR(__entry->dev),
39163997775SSteven Whitehouse 		  MINOR(__entry->dev), __entry->blocks)
39263997775SSteven Whitehouse );
39363997775SSteven Whitehouse 
394c83ae9caSSteven Whitehouse /* Writing back the AIL */
395c83ae9caSSteven Whitehouse TRACE_EVENT(gfs2_ail_flush,
396c83ae9caSSteven Whitehouse 
397c83ae9caSSteven Whitehouse 	TP_PROTO(const struct gfs2_sbd *sdp, const struct writeback_control *wbc, int start),
398c83ae9caSSteven Whitehouse 
399c83ae9caSSteven Whitehouse 	TP_ARGS(sdp, wbc, start),
400c83ae9caSSteven Whitehouse 
401c83ae9caSSteven Whitehouse 	TP_STRUCT__entry(
402c83ae9caSSteven Whitehouse 		__field(	dev_t,	dev			)
403c83ae9caSSteven Whitehouse 		__field(	int, start			)
404c83ae9caSSteven Whitehouse 		__field(	int, sync_mode			)
405c83ae9caSSteven Whitehouse 		__field(	long, nr_to_write		)
406c83ae9caSSteven Whitehouse 	),
407c83ae9caSSteven Whitehouse 
408c83ae9caSSteven Whitehouse 	TP_fast_assign(
409c83ae9caSSteven Whitehouse 		__entry->dev		= sdp->sd_vfs->s_dev;
410c83ae9caSSteven Whitehouse 		__entry->start		= start;
411c83ae9caSSteven Whitehouse 		__entry->sync_mode	= wbc->sync_mode;
412c83ae9caSSteven Whitehouse 		__entry->nr_to_write	= wbc->nr_to_write;
413c83ae9caSSteven Whitehouse 	),
414c83ae9caSSteven Whitehouse 
415c83ae9caSSteven Whitehouse 	TP_printk("%u,%u ail flush %s %s %ld", MAJOR(__entry->dev),
416c83ae9caSSteven Whitehouse 		  MINOR(__entry->dev), __entry->start ? "start" : "end",
417c83ae9caSSteven Whitehouse 		  __entry->sync_mode == WB_SYNC_ALL ? "all" : "none",
418c83ae9caSSteven Whitehouse 		  __entry->nr_to_write)
419c83ae9caSSteven Whitehouse );
420c83ae9caSSteven Whitehouse 
42163997775SSteven Whitehouse /* Section 3 - bmap
42263997775SSteven Whitehouse  *
42363997775SSteven Whitehouse  * Objectives:
42463997775SSteven Whitehouse  * Latency: Bmap request time
42563997775SSteven Whitehouse  * Performance: Block allocator tracing
42663997775SSteven Whitehouse  * Correctness: Test of disard generation vs. blocks allocated
42763997775SSteven Whitehouse  */
42863997775SSteven Whitehouse 
42963997775SSteven Whitehouse /* Map an extent of blocks, possibly a new allocation */
43063997775SSteven Whitehouse TRACE_EVENT(gfs2_bmap,
43163997775SSteven Whitehouse 
43263997775SSteven Whitehouse 	TP_PROTO(const struct gfs2_inode *ip, const struct buffer_head *bh,
43363997775SSteven Whitehouse 		sector_t lblock, int create, int errno),
43463997775SSteven Whitehouse 
43563997775SSteven Whitehouse 	TP_ARGS(ip, bh, lblock, create, errno),
43663997775SSteven Whitehouse 
43763997775SSteven Whitehouse 	TP_STRUCT__entry(
43863997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
43963997775SSteven Whitehouse 		__field(	sector_t, lblock		)
44063997775SSteven Whitehouse 		__field(	sector_t, pblock		)
44163997775SSteven Whitehouse 		__field(	u64,	inum			)
44263997775SSteven Whitehouse 		__field(	unsigned long, state		)
44363997775SSteven Whitehouse 		__field(	u32,	len			)
44463997775SSteven Whitehouse 		__field(	int,	create			)
44563997775SSteven Whitehouse 		__field(	int,	errno			)
44663997775SSteven Whitehouse 	),
44763997775SSteven Whitehouse 
44863997775SSteven Whitehouse 	TP_fast_assign(
44963997775SSteven Whitehouse 		__entry->dev            = ip->i_gl->gl_sbd->sd_vfs->s_dev;
45063997775SSteven Whitehouse 		__entry->lblock		= lblock;
45163997775SSteven Whitehouse 		__entry->pblock		= buffer_mapped(bh) ?  bh->b_blocknr : 0;
45263997775SSteven Whitehouse 		__entry->inum		= ip->i_no_addr;
45363997775SSteven Whitehouse 		__entry->state		= bh->b_state;
45463997775SSteven Whitehouse 		__entry->len		= bh->b_size;
45563997775SSteven Whitehouse 		__entry->create		= create;
45663997775SSteven Whitehouse 		__entry->errno		= errno;
45763997775SSteven Whitehouse 	),
45863997775SSteven Whitehouse 
45963997775SSteven Whitehouse 	TP_printk("%u,%u bmap %llu map %llu/%lu to %llu flags:%08lx %s %d",
46063997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev),
46163997775SSteven Whitehouse 		  (unsigned long long)__entry->inum,
46263997775SSteven Whitehouse 		  (unsigned long long)__entry->lblock,
46363997775SSteven Whitehouse 		  (unsigned long)__entry->len,
46463997775SSteven Whitehouse 		  (unsigned long long)__entry->pblock,
46563997775SSteven Whitehouse 		  __entry->state, __entry->create ? "create " : "nocreate",
46663997775SSteven Whitehouse 		  __entry->errno)
46763997775SSteven Whitehouse );
46863997775SSteven Whitehouse 
46963997775SSteven Whitehouse /* Keep track of blocks as they are allocated/freed */
47063997775SSteven Whitehouse TRACE_EVENT(gfs2_block_alloc,
47163997775SSteven Whitehouse 
47241db1ab9SBob Peterson 	TP_PROTO(const struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
47341db1ab9SBob Peterson 		 u64 block, unsigned len, u8 block_state),
47463997775SSteven Whitehouse 
47541db1ab9SBob Peterson 	TP_ARGS(ip, rgd, block, len, block_state),
47663997775SSteven Whitehouse 
47763997775SSteven Whitehouse 	TP_STRUCT__entry(
47863997775SSteven Whitehouse 		__field(        dev_t,  dev                     )
47963997775SSteven Whitehouse 		__field(	u64,	start			)
48063997775SSteven Whitehouse 		__field(	u64,	inum			)
48163997775SSteven Whitehouse 		__field(	u32,	len			)
48263997775SSteven Whitehouse 		__field(	u8,	block_state		)
48341db1ab9SBob Peterson 		__field(        u64,	rd_addr			)
48441db1ab9SBob Peterson 		__field(        u32,	rd_free_clone		)
485*8e2e0047SBob Peterson 		__field(	u32,	rd_reserved		)
48663997775SSteven Whitehouse 	),
48763997775SSteven Whitehouse 
48863997775SSteven Whitehouse 	TP_fast_assign(
48963997775SSteven Whitehouse 		__entry->dev		= ip->i_gl->gl_sbd->sd_vfs->s_dev;
49063997775SSteven Whitehouse 		__entry->start		= block;
49163997775SSteven Whitehouse 		__entry->inum		= ip->i_no_addr;
49263997775SSteven Whitehouse 		__entry->len		= len;
49363997775SSteven Whitehouse 		__entry->block_state	= block_state;
49441db1ab9SBob Peterson 		__entry->rd_addr	= rgd->rd_addr;
49541db1ab9SBob Peterson 		__entry->rd_free_clone	= rgd->rd_free_clone;
496*8e2e0047SBob Peterson 		__entry->rd_reserved	= rgd->rd_reserved;
49763997775SSteven Whitehouse 	),
49863997775SSteven Whitehouse 
499*8e2e0047SBob Peterson 	TP_printk("%u,%u bmap %llu alloc %llu/%lu %s rg:%llu rf:%u rr:%lu",
50063997775SSteven Whitehouse 		  MAJOR(__entry->dev), MINOR(__entry->dev),
50163997775SSteven Whitehouse 		  (unsigned long long)__entry->inum,
50263997775SSteven Whitehouse 		  (unsigned long long)__entry->start,
50363997775SSteven Whitehouse 		  (unsigned long)__entry->len,
50441db1ab9SBob Peterson 		  block_state_name(__entry->block_state),
50541db1ab9SBob Peterson 		  (unsigned long long)__entry->rd_addr,
506*8e2e0047SBob Peterson 		  __entry->rd_free_clone, (unsigned long)__entry->rd_reserved)
507*8e2e0047SBob Peterson );
508*8e2e0047SBob Peterson 
509*8e2e0047SBob Peterson /* Keep track of multi-block reservations as they are allocated/freed */
510*8e2e0047SBob Peterson TRACE_EVENT(gfs2_rs,
511*8e2e0047SBob Peterson 
512*8e2e0047SBob Peterson 	TP_PROTO(const struct gfs2_inode *ip, const struct gfs2_blkreserv *rs,
513*8e2e0047SBob Peterson 		 u8 func),
514*8e2e0047SBob Peterson 
515*8e2e0047SBob Peterson 	TP_ARGS(ip, rs, func),
516*8e2e0047SBob Peterson 
517*8e2e0047SBob Peterson 	TP_STRUCT__entry(
518*8e2e0047SBob Peterson 		__field(        dev_t,  dev                     )
519*8e2e0047SBob Peterson 		__field(	u64,	rd_addr			)
520*8e2e0047SBob Peterson 		__field(	u32,	rd_free_clone		)
521*8e2e0047SBob Peterson 		__field(	u32,	rd_reserved		)
522*8e2e0047SBob Peterson 		__field(	u64,	inum			)
523*8e2e0047SBob Peterson 		__field(	u64,	start			)
524*8e2e0047SBob Peterson 		__field(	u32,	free			)
525*8e2e0047SBob Peterson 		__field(	u8,	func			)
526*8e2e0047SBob Peterson 	),
527*8e2e0047SBob Peterson 
528*8e2e0047SBob Peterson 	TP_fast_assign(
529*8e2e0047SBob Peterson 		__entry->dev		= rs->rs_rgd ? rs->rs_rgd->rd_sbd->sd_vfs->s_dev : 0;
530*8e2e0047SBob Peterson 		__entry->rd_addr	= rs->rs_rgd ? rs->rs_rgd->rd_addr : 0;
531*8e2e0047SBob Peterson 		__entry->rd_free_clone	= rs->rs_rgd ? rs->rs_rgd->rd_free_clone : 0;
532*8e2e0047SBob Peterson 		__entry->rd_reserved	= rs->rs_rgd ? rs->rs_rgd->rd_reserved : 0;
533*8e2e0047SBob Peterson 		__entry->inum		= ip ? ip->i_no_addr : 0;
534*8e2e0047SBob Peterson 		__entry->start		= gfs2_rs_startblk(rs);
535*8e2e0047SBob Peterson 		__entry->free		= rs->rs_free;
536*8e2e0047SBob Peterson 		__entry->func		= func;
537*8e2e0047SBob Peterson 	),
538*8e2e0047SBob Peterson 
539*8e2e0047SBob Peterson 	TP_printk("%u,%u bmap %llu resrv %llu rg:%llu rf:%lu rr:%lu %s "
540*8e2e0047SBob Peterson 		  "f:%lu",
541*8e2e0047SBob Peterson 		  MAJOR(__entry->dev), MINOR(__entry->dev),
542*8e2e0047SBob Peterson 		  (unsigned long long)__entry->inum,
543*8e2e0047SBob Peterson 		  (unsigned long long)__entry->start,
544*8e2e0047SBob Peterson 		  (unsigned long long)__entry->rd_addr,
545*8e2e0047SBob Peterson 		  (unsigned long)__entry->rd_free_clone,
546*8e2e0047SBob Peterson 		  (unsigned long)__entry->rd_reserved,
547*8e2e0047SBob Peterson 		  rs_func_name(__entry->func), (unsigned long)__entry->free)
54863997775SSteven Whitehouse );
54963997775SSteven Whitehouse 
55063997775SSteven Whitehouse #endif /* _TRACE_GFS2_H */
55163997775SSteven Whitehouse 
55263997775SSteven Whitehouse /* This part must be outside protection */
55363997775SSteven Whitehouse #undef TRACE_INCLUDE_PATH
55463997775SSteven Whitehouse #define TRACE_INCLUDE_PATH .
555d0b6e04aSLi Zefan #define TRACE_INCLUDE_FILE trace_gfs2
55663997775SSteven Whitehouse #include <trace/define_trace.h>
55763997775SSteven Whitehouse 
558