blob: 65e39785c284a2e93a187cfb4246c58a83361a0a [file] [log] [blame]
Christoph Hellwig9e91c572019-10-17 13:12:13 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/*
Christoph Hellwigf4b896c2021-08-10 18:33:07 -07003 * Copyright (c) 2009-2021 Christoph Hellwig
Christoph Hellwig9e91c572019-10-17 13:12:13 -07004 *
Christoph Hellwigd9d381f32021-08-10 18:33:03 -07005 * NOTE: none of these tracepoints shall be considered a stable kernel ABI
Christoph Hellwig9e91c572019-10-17 13:12:13 -07006 * as they can change at any time.
Darrick J. Wong03b8df82021-08-21 19:24:53 -07007 *
8 * Current conventions for printing numbers measuring specific units:
9 *
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
13 * ino: inode number
14 *
15 * Numbers describing space allocations should be formatted in hexadecimal.
Christoph Hellwig9e91c572019-10-17 13:12:13 -070016 */
17#undef TRACE_SYSTEM
18#define TRACE_SYSTEM iomap
19
20#if !defined(_IOMAP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
21#define _IOMAP_TRACE_H
22
23#include <linux/tracepoint.h>
24
25struct inode;
26
27DECLARE_EVENT_CLASS(iomap_readpage_class,
28 TP_PROTO(struct inode *inode, int nr_pages),
29 TP_ARGS(inode, nr_pages),
30 TP_STRUCT__entry(
31 __field(dev_t, dev)
32 __field(u64, ino)
33 __field(int, nr_pages)
34 ),
35 TP_fast_assign(
36 __entry->dev = inode->i_sb->s_dev;
37 __entry->ino = inode->i_ino;
38 __entry->nr_pages = nr_pages;
39 ),
40 TP_printk("dev %d:%d ino 0x%llx nr_pages %d",
41 MAJOR(__entry->dev), MINOR(__entry->dev),
42 __entry->ino,
43 __entry->nr_pages)
44)
45
46#define DEFINE_READPAGE_EVENT(name) \
47DEFINE_EVENT(iomap_readpage_class, name, \
48 TP_PROTO(struct inode *inode, int nr_pages), \
49 TP_ARGS(inode, nr_pages))
50DEFINE_READPAGE_EVENT(iomap_readpage);
Matthew Wilcox (Oracle)9d24a132020-06-01 21:47:34 -070051DEFINE_READPAGE_EVENT(iomap_readahead);
Christoph Hellwig9e91c572019-10-17 13:12:13 -070052
Matthew Wilcox (Oracle)1ac99452020-03-05 07:21:43 -080053DECLARE_EVENT_CLASS(iomap_range_class,
Darrick J. Wong03b8df82021-08-21 19:24:53 -070054 TP_PROTO(struct inode *inode, loff_t off, u64 len),
Matthew Wilcox (Oracle)1ac99452020-03-05 07:21:43 -080055 TP_ARGS(inode, off, len),
Christoph Hellwig9e91c572019-10-17 13:12:13 -070056 TP_STRUCT__entry(
57 __field(dev_t, dev)
58 __field(u64, ino)
Christoph Hellwig9e91c572019-10-17 13:12:13 -070059 __field(loff_t, size)
Darrick J. Wong03b8df82021-08-21 19:24:53 -070060 __field(loff_t, offset)
61 __field(u64, length)
Christoph Hellwig9e91c572019-10-17 13:12:13 -070062 ),
63 TP_fast_assign(
64 __entry->dev = inode->i_sb->s_dev;
65 __entry->ino = inode->i_ino;
Christoph Hellwig9e91c572019-10-17 13:12:13 -070066 __entry->size = i_size_read(inode);
67 __entry->offset = off;
68 __entry->length = len;
69 ),
Darrick J. Wong03b8df82021-08-21 19:24:53 -070070 TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx length 0x%llx",
Christoph Hellwig9e91c572019-10-17 13:12:13 -070071 MAJOR(__entry->dev), MINOR(__entry->dev),
72 __entry->ino,
Christoph Hellwig9e91c572019-10-17 13:12:13 -070073 __entry->size,
74 __entry->offset,
75 __entry->length)
76)
77
Matthew Wilcox (Oracle)1ac99452020-03-05 07:21:43 -080078#define DEFINE_RANGE_EVENT(name) \
79DEFINE_EVENT(iomap_range_class, name, \
Darrick J. Wong03b8df82021-08-21 19:24:53 -070080 TP_PROTO(struct inode *inode, loff_t off, u64 len),\
Matthew Wilcox (Oracle)1ac99452020-03-05 07:21:43 -080081 TP_ARGS(inode, off, len))
82DEFINE_RANGE_EVENT(iomap_writepage);
83DEFINE_RANGE_EVENT(iomap_releasepage);
84DEFINE_RANGE_EVENT(iomap_invalidatepage);
Christoph Hellwig60263d52020-07-23 22:45:59 -070085DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
Christoph Hellwig9e91c572019-10-17 13:12:13 -070086
Darrick J. Wong6334b912019-11-21 16:14:49 -080087#define IOMAP_TYPE_STRINGS \
88 { IOMAP_HOLE, "HOLE" }, \
89 { IOMAP_DELALLOC, "DELALLOC" }, \
90 { IOMAP_MAPPED, "MAPPED" }, \
91 { IOMAP_UNWRITTEN, "UNWRITTEN" }, \
92 { IOMAP_INLINE, "INLINE" }
93
94#define IOMAP_FLAGS_STRINGS \
95 { IOMAP_WRITE, "WRITE" }, \
96 { IOMAP_ZERO, "ZERO" }, \
97 { IOMAP_REPORT, "REPORT" }, \
98 { IOMAP_FAULT, "FAULT" }, \
99 { IOMAP_DIRECT, "DIRECT" }, \
100 { IOMAP_NOWAIT, "NOWAIT" }
101
102#define IOMAP_F_FLAGS_STRINGS \
103 { IOMAP_F_NEW, "NEW" }, \
104 { IOMAP_F_DIRTY, "DIRTY" }, \
105 { IOMAP_F_SHARED, "SHARED" }, \
106 { IOMAP_F_MERGED, "MERGED" }, \
107 { IOMAP_F_BUFFER_HEAD, "BH" }, \
108 { IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" }
109
110DECLARE_EVENT_CLASS(iomap_class,
111 TP_PROTO(struct inode *inode, struct iomap *iomap),
112 TP_ARGS(inode, iomap),
113 TP_STRUCT__entry(
114 __field(dev_t, dev)
115 __field(u64, ino)
116 __field(u64, addr)
117 __field(loff_t, offset)
118 __field(u64, length)
119 __field(u16, type)
120 __field(u16, flags)
121 __field(dev_t, bdev)
122 ),
123 TP_fast_assign(
124 __entry->dev = inode->i_sb->s_dev;
125 __entry->ino = inode->i_ino;
126 __entry->addr = iomap->addr;
127 __entry->offset = iomap->offset;
128 __entry->length = iomap->length;
129 __entry->type = iomap->type;
130 __entry->flags = iomap->flags;
131 __entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0;
132 ),
Darrick J. Wong03b8df82021-08-21 19:24:53 -0700133 TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr 0x%llx offset 0x%llx "
134 "length 0x%llx type %s flags %s",
Darrick J. Wong6334b912019-11-21 16:14:49 -0800135 MAJOR(__entry->dev), MINOR(__entry->dev),
136 __entry->ino,
137 MAJOR(__entry->bdev), MINOR(__entry->bdev),
138 __entry->addr,
139 __entry->offset,
140 __entry->length,
141 __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS),
142 __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS))
143)
144
145#define DEFINE_IOMAP_EVENT(name) \
146DEFINE_EVENT(iomap_class, name, \
147 TP_PROTO(struct inode *inode, struct iomap *iomap), \
148 TP_ARGS(inode, iomap))
Christoph Hellwigf4b896c2021-08-10 18:33:07 -0700149DEFINE_IOMAP_EVENT(iomap_iter_dstmap);
150DEFINE_IOMAP_EVENT(iomap_iter_srcmap);
Darrick J. Wong6334b912019-11-21 16:14:49 -0800151
Christoph Hellwigf4b896c2021-08-10 18:33:07 -0700152TRACE_EVENT(iomap_iter,
153 TP_PROTO(struct iomap_iter *iter, const void *ops,
154 unsigned long caller),
155 TP_ARGS(iter, ops, caller),
156 TP_STRUCT__entry(
157 __field(dev_t, dev)
158 __field(u64, ino)
159 __field(loff_t, pos)
Darrick J. Wong03b8df82021-08-21 19:24:53 -0700160 __field(u64, length)
Christoph Hellwigf4b896c2021-08-10 18:33:07 -0700161 __field(unsigned int, flags)
162 __field(const void *, ops)
163 __field(unsigned long, caller)
164 ),
165 TP_fast_assign(
166 __entry->dev = iter->inode->i_sb->s_dev;
167 __entry->ino = iter->inode->i_ino;
168 __entry->pos = iter->pos;
169 __entry->length = iomap_length(iter);
170 __entry->flags = iter->flags;
171 __entry->ops = ops;
172 __entry->caller = caller;
173 ),
Darrick J. Wong03b8df82021-08-21 19:24:53 -0700174 TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%llx flags %s (0x%x) ops %ps caller %pS",
Christoph Hellwigf4b896c2021-08-10 18:33:07 -0700175 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);
184
Christoph Hellwig9e91c572019-10-17 13:12:13 -0700185#endif /* _IOMAP_TRACE_H */
186
187#undef TRACE_INCLUDE_PATH
188#define TRACE_INCLUDE_PATH .
189#define TRACE_INCLUDE_FILE trace
190#include <trace/define_trace.h>