1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2009-2021 Christoph Hellwig
5 * NOTE: none of these tracepoints shall be considered a stable kernel ABI
6 * as they can change at any time.
8 * Current conventions for printing numbers measuring specific units:
10 * offset: byte offset into a subcomponent of a file operation
11 * pos: file offset, in bytes
12 * length: length of a file operation, in bytes
15 * Numbers describing space allocations should be formatted in hexadecimal.
18 #define TRACE_SYSTEM iomap
20 #if !defined(_IOMAP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
21 #define _IOMAP_TRACE_H
23 #include <linux/tracepoint.h>
27 DECLARE_EVENT_CLASS(iomap_readpage_class,
28 TP_PROTO(struct inode *inode, int nr_pages),
29 TP_ARGS(inode, nr_pages),
33 __field(int, nr_pages)
36 __entry->dev = inode->i_sb->s_dev;
37 __entry->ino = inode->i_ino;
38 __entry->nr_pages = nr_pages;
40 TP_printk("dev %d:%d ino 0x%llx nr_pages %d",
41 MAJOR(__entry->dev), MINOR(__entry->dev),
46 #define DEFINE_READPAGE_EVENT(name) \
47 DEFINE_EVENT(iomap_readpage_class, name, \
48 TP_PROTO(struct inode *inode, int nr_pages), \
49 TP_ARGS(inode, nr_pages))
50 DEFINE_READPAGE_EVENT(iomap_readpage);
51 DEFINE_READPAGE_EVENT(iomap_readahead);
53 DECLARE_EVENT_CLASS(iomap_range_class,
54 TP_PROTO(struct inode *inode, loff_t off, u64 len),
55 TP_ARGS(inode, off, len),
60 __field(loff_t, offset)
64 __entry->dev = inode->i_sb->s_dev;
65 __entry->ino = inode->i_ino;
66 __entry->size = i_size_read(inode);
67 __entry->offset = off;
68 __entry->length = len;
70 TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx length 0x%llx",
71 MAJOR(__entry->dev), MINOR(__entry->dev),
78 #define DEFINE_RANGE_EVENT(name) \
79 DEFINE_EVENT(iomap_range_class, name, \
80 TP_PROTO(struct inode *inode, loff_t off, u64 len),\
81 TP_ARGS(inode, off, len))
82 DEFINE_RANGE_EVENT(iomap_writepage);
83 DEFINE_RANGE_EVENT(iomap_release_folio);
84 DEFINE_RANGE_EVENT(iomap_invalidate_folio);
85 DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
86 DEFINE_RANGE_EVENT(iomap_dio_rw_queued);
88 #define IOMAP_TYPE_STRINGS \
89 { IOMAP_HOLE, "HOLE" }, \
90 { IOMAP_DELALLOC, "DELALLOC" }, \
91 { IOMAP_MAPPED, "MAPPED" }, \
92 { IOMAP_UNWRITTEN, "UNWRITTEN" }, \
93 { IOMAP_INLINE, "INLINE" }
95 #define IOMAP_FLAGS_STRINGS \
96 { IOMAP_WRITE, "WRITE" }, \
97 { IOMAP_ZERO, "ZERO" }, \
98 { IOMAP_REPORT, "REPORT" }, \
99 { IOMAP_FAULT, "FAULT" }, \
100 { IOMAP_DIRECT, "DIRECT" }, \
101 { IOMAP_NOWAIT, "NOWAIT" }
103 #define IOMAP_F_FLAGS_STRINGS \
104 { IOMAP_F_NEW, "NEW" }, \
105 { IOMAP_F_DIRTY, "DIRTY" }, \
106 { IOMAP_F_SHARED, "SHARED" }, \
107 { IOMAP_F_MERGED, "MERGED" }, \
108 { IOMAP_F_BUFFER_HEAD, "BH" }, \
109 { IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" }
111 #define IOMAP_DIO_STRINGS \
112 {IOMAP_DIO_FORCE_WAIT, "DIO_FORCE_WAIT" }, \
113 {IOMAP_DIO_OVERWRITE_ONLY, "DIO_OVERWRITE_ONLY" }, \
114 {IOMAP_DIO_PARTIAL, "DIO_PARTIAL" }
116 DECLARE_EVENT_CLASS(iomap_class,
117 TP_PROTO(struct inode *inode, struct iomap *iomap),
118 TP_ARGS(inode, iomap),
123 __field(loff_t, offset)
130 __entry->dev = inode->i_sb->s_dev;
131 __entry->ino = inode->i_ino;
132 __entry->addr = iomap->addr;
133 __entry->offset = iomap->offset;
134 __entry->length = iomap->length;
135 __entry->type = iomap->type;
136 __entry->flags = iomap->flags;
137 __entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0;
139 TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr 0x%llx offset 0x%llx "
140 "length 0x%llx type %s flags %s",
141 MAJOR(__entry->dev), MINOR(__entry->dev),
143 MAJOR(__entry->bdev), MINOR(__entry->bdev),
147 __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS),
148 __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS))
151 #define DEFINE_IOMAP_EVENT(name) \
152 DEFINE_EVENT(iomap_class, name, \
153 TP_PROTO(struct inode *inode, struct iomap *iomap), \
154 TP_ARGS(inode, iomap))
155 DEFINE_IOMAP_EVENT(iomap_iter_dstmap);
156 DEFINE_IOMAP_EVENT(iomap_iter_srcmap);
157 DEFINE_IOMAP_EVENT(iomap_writepage_map);
159 TRACE_EVENT(iomap_iter,
160 TP_PROTO(struct iomap_iter *iter, const void *ops,
161 unsigned long caller),
162 TP_ARGS(iter, ops, caller),
168 __field(unsigned int, flags)
169 __field(const void *, ops)
170 __field(unsigned long, caller)
173 __entry->dev = iter->inode->i_sb->s_dev;
174 __entry->ino = iter->inode->i_ino;
175 __entry->pos = iter->pos;
176 __entry->length = iomap_length(iter);
177 __entry->flags = iter->flags;
179 __entry->caller = caller;
181 TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%llx flags %s (0x%x) ops %ps caller %pS",
182 MAJOR(__entry->dev), MINOR(__entry->dev),
186 __print_flags(__entry->flags, "|", IOMAP_FLAGS_STRINGS),
189 (void *)__entry->caller)
192 TRACE_EVENT(iomap_dio_rw_begin,
193 TP_PROTO(struct kiocb *iocb, struct iov_iter *iter,
194 unsigned int dio_flags, size_t done_before),
195 TP_ARGS(iocb, iter, dio_flags, done_before),
199 __field(loff_t, isize)
201 __field(size_t, count)
202 __field(size_t, done_before)
203 __field(int, ki_flags)
204 __field(unsigned int, dio_flags)
208 __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
209 __entry->ino = file_inode(iocb->ki_filp)->i_ino;
210 __entry->isize = file_inode(iocb->ki_filp)->i_size;
211 __entry->pos = iocb->ki_pos;
212 __entry->count = iov_iter_count(iter);
213 __entry->done_before = done_before;
214 __entry->ki_flags = iocb->ki_flags;
215 __entry->dio_flags = dio_flags;
216 __entry->aio = !is_sync_kiocb(iocb);
218 TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx length 0x%zx done_before 0x%zx flags %s dio_flags %s aio %d",
219 MAJOR(__entry->dev), MINOR(__entry->dev),
224 __entry->done_before,
225 __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
226 __print_flags(__entry->dio_flags, "|", IOMAP_DIO_STRINGS),
230 TRACE_EVENT(iomap_dio_complete,
231 TP_PROTO(struct kiocb *iocb, int error, ssize_t ret),
232 TP_ARGS(iocb, error, ret),
236 __field(loff_t, isize)
238 __field(int, ki_flags)
241 __field(ssize_t, ret)
244 __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
245 __entry->ino = file_inode(iocb->ki_filp)->i_ino;
246 __entry->isize = file_inode(iocb->ki_filp)->i_size;
247 __entry->pos = iocb->ki_pos;
248 __entry->ki_flags = iocb->ki_flags;
249 __entry->aio = !is_sync_kiocb(iocb);
250 __entry->error = error;
253 TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx flags %s aio %d error %d ret %zd",
254 MAJOR(__entry->dev), MINOR(__entry->dev),
258 __print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
264 #endif /* _IOMAP_TRACE_H */
266 #undef TRACE_INCLUDE_PATH
267 #define TRACE_INCLUDE_PATH .
268 #define TRACE_INCLUDE_FILE trace
269 #include <trace/define_trace.h>