xref: /linux/fs/iomap/trace.h (revision 8a79db5e83a5d52c74e6f3c40d6f312cf899213e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2009-2019 Christoph Hellwig
4  *
5  * NOTE: none of these tracepoints shall be consider a stable kernel ABI
6  * as they can change at any time.
7  */
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM iomap
10 
11 #if !defined(_IOMAP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _IOMAP_TRACE_H
13 
14 #include <linux/tracepoint.h>
15 
16 struct inode;
17 
18 DECLARE_EVENT_CLASS(iomap_readpage_class,
19 	TP_PROTO(struct inode *inode, int nr_pages),
20 	TP_ARGS(inode, nr_pages),
21 	TP_STRUCT__entry(
22 		__field(dev_t, dev)
23 		__field(u64, ino)
24 		__field(int, nr_pages)
25 	),
26 	TP_fast_assign(
27 		__entry->dev = inode->i_sb->s_dev;
28 		__entry->ino = inode->i_ino;
29 		__entry->nr_pages = nr_pages;
30 	),
31 	TP_printk("dev %d:%d ino 0x%llx nr_pages %d",
32 		  MAJOR(__entry->dev), MINOR(__entry->dev),
33 		  __entry->ino,
34 		  __entry->nr_pages)
35 )
36 
37 #define DEFINE_READPAGE_EVENT(name)		\
38 DEFINE_EVENT(iomap_readpage_class, name,	\
39 	TP_PROTO(struct inode *inode, int nr_pages), \
40 	TP_ARGS(inode, nr_pages))
41 DEFINE_READPAGE_EVENT(iomap_readpage);
42 DEFINE_READPAGE_EVENT(iomap_readpages);
43 
44 DECLARE_EVENT_CLASS(iomap_page_class,
45 	TP_PROTO(struct inode *inode, struct page *page, unsigned long off,
46 		 unsigned int len),
47 	TP_ARGS(inode, page, off, len),
48 	TP_STRUCT__entry(
49 		__field(dev_t, dev)
50 		__field(u64, ino)
51 		__field(pgoff_t, pgoff)
52 		__field(loff_t, size)
53 		__field(unsigned long, offset)
54 		__field(unsigned int, length)
55 	),
56 	TP_fast_assign(
57 		__entry->dev = inode->i_sb->s_dev;
58 		__entry->ino = inode->i_ino;
59 		__entry->pgoff = page_offset(page);
60 		__entry->size = i_size_read(inode);
61 		__entry->offset = off;
62 		__entry->length = len;
63 	),
64 	TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx "
65 		  "length %x",
66 		  MAJOR(__entry->dev), MINOR(__entry->dev),
67 		  __entry->ino,
68 		  __entry->pgoff,
69 		  __entry->size,
70 		  __entry->offset,
71 		  __entry->length)
72 )
73 
74 #define DEFINE_PAGE_EVENT(name)		\
75 DEFINE_EVENT(iomap_page_class, name,	\
76 	TP_PROTO(struct inode *inode, struct page *page, unsigned long off, \
77 		 unsigned int len),	\
78 	TP_ARGS(inode, page, off, len))
79 DEFINE_PAGE_EVENT(iomap_writepage);
80 DEFINE_PAGE_EVENT(iomap_releasepage);
81 DEFINE_PAGE_EVENT(iomap_invalidatepage);
82 
83 #define IOMAP_TYPE_STRINGS \
84 	{ IOMAP_HOLE,		"HOLE" }, \
85 	{ IOMAP_DELALLOC,	"DELALLOC" }, \
86 	{ IOMAP_MAPPED,		"MAPPED" }, \
87 	{ IOMAP_UNWRITTEN,	"UNWRITTEN" }, \
88 	{ IOMAP_INLINE,		"INLINE" }
89 
90 #define IOMAP_FLAGS_STRINGS \
91 	{ IOMAP_WRITE,		"WRITE" }, \
92 	{ IOMAP_ZERO,		"ZERO" }, \
93 	{ IOMAP_REPORT,		"REPORT" }, \
94 	{ IOMAP_FAULT,		"FAULT" }, \
95 	{ IOMAP_DIRECT,		"DIRECT" }, \
96 	{ IOMAP_NOWAIT,		"NOWAIT" }
97 
98 #define IOMAP_F_FLAGS_STRINGS \
99 	{ IOMAP_F_NEW,		"NEW" }, \
100 	{ IOMAP_F_DIRTY,	"DIRTY" }, \
101 	{ IOMAP_F_SHARED,	"SHARED" }, \
102 	{ IOMAP_F_MERGED,	"MERGED" }, \
103 	{ IOMAP_F_BUFFER_HEAD,	"BH" }, \
104 	{ IOMAP_F_SIZE_CHANGED,	"SIZE_CHANGED" }
105 
106 DECLARE_EVENT_CLASS(iomap_class,
107 	TP_PROTO(struct inode *inode, struct iomap *iomap),
108 	TP_ARGS(inode, iomap),
109 	TP_STRUCT__entry(
110 		__field(dev_t, dev)
111 		__field(u64, ino)
112 		__field(u64, addr)
113 		__field(loff_t, offset)
114 		__field(u64, length)
115 		__field(u16, type)
116 		__field(u16, flags)
117 		__field(dev_t, bdev)
118 	),
119 	TP_fast_assign(
120 		__entry->dev = inode->i_sb->s_dev;
121 		__entry->ino = inode->i_ino;
122 		__entry->addr = iomap->addr;
123 		__entry->offset = iomap->offset;
124 		__entry->length = iomap->length;
125 		__entry->type = iomap->type;
126 		__entry->flags = iomap->flags;
127 		__entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0;
128 	),
129 	TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr %lld offset %lld "
130 		  "length %llu type %s flags %s",
131 		  MAJOR(__entry->dev), MINOR(__entry->dev),
132 		  __entry->ino,
133 		  MAJOR(__entry->bdev), MINOR(__entry->bdev),
134 		  __entry->addr,
135 		  __entry->offset,
136 		  __entry->length,
137 		  __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS),
138 		  __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS))
139 )
140 
141 #define DEFINE_IOMAP_EVENT(name)		\
142 DEFINE_EVENT(iomap_class, name,	\
143 	TP_PROTO(struct inode *inode, struct iomap *iomap), \
144 	TP_ARGS(inode, iomap))
145 DEFINE_IOMAP_EVENT(iomap_apply_dstmap);
146 DEFINE_IOMAP_EVENT(iomap_apply_srcmap);
147 
148 TRACE_EVENT(iomap_apply,
149 	TP_PROTO(struct inode *inode, loff_t pos, loff_t length,
150 		unsigned int flags, const void *ops, void *actor,
151 		unsigned long caller),
152 	TP_ARGS(inode, pos, length, flags, ops, actor, caller),
153 	TP_STRUCT__entry(
154 		__field(dev_t, dev)
155 		__field(u64, ino)
156 		__field(loff_t, pos)
157 		__field(loff_t, length)
158 		__field(unsigned int, flags)
159 		__field(const void *, ops)
160 		__field(void *, actor)
161 		__field(unsigned long, caller)
162 	),
163 	TP_fast_assign(
164 		__entry->dev = inode->i_sb->s_dev;
165 		__entry->ino = inode->i_ino;
166 		__entry->pos = pos;
167 		__entry->length = length;
168 		__entry->flags = flags;
169 		__entry->ops = ops;
170 		__entry->actor = actor;
171 		__entry->caller = caller;
172 	),
173 	TP_printk("dev %d:%d ino 0x%llx pos %lld length %lld flags %s (0x%x) "
174 		  "ops %ps caller %pS actor %ps",
175 		  MAJOR(__entry->dev), MINOR(__entry->dev),
176 		   __entry->ino,
177 		   __entry->pos,
178 		   __entry->length,
179 		   __print_flags(__entry->flags, "|", IOMAP_FLAGS_STRINGS),
180 		   __entry->flags,
181 		   __entry->ops,
182 		   (void *)__entry->caller,
183 		   __entry->actor)
184 );
185 
186 #endif /* _IOMAP_TRACE_H */
187 
188 #undef TRACE_INCLUDE_PATH
189 #define TRACE_INCLUDE_PATH .
190 #define TRACE_INCLUDE_FILE trace
191 #include <trace/define_trace.h>
192