Skip to content

Commit 6334b91

Browse files
committed
iomap: trace iomap_appply results
Add some tracepoints so that we can more easily debug what the filesystem is returning from ->iomap_begin. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent e9f930a commit 6334b91

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

fs/iomap/apply.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/compiler.h>
88
#include <linux/fs.h>
99
#include <linux/iomap.h>
10+
#include "trace.h"
1011

1112
/*
1213
* Execute a iomap write on a segment of the mapping that spans a
@@ -28,6 +29,8 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags,
2829
loff_t written = 0, ret;
2930
u64 end;
3031

32+
trace_iomap_apply(inode, pos, length, flags, ops, actor, _RET_IP_);
33+
3134
/*
3235
* Need to map a range from start position for length bytes. This can
3336
* span multiple pages - it is only guaranteed to return a range of a
@@ -48,6 +51,10 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags,
4851
if (WARN_ON(iomap.length == 0))
4952
return -EIO;
5053

54+
trace_iomap_apply_dstmap(inode, &iomap);
55+
if (srcmap.type != IOMAP_HOLE)
56+
trace_iomap_apply_srcmap(inode, &srcmap);
57+
5158
/*
5259
* Cut down the length to the one actually provided by the filesystem,
5360
* as it might not be able to give us the whole size that we requested.

fs/iomap/trace.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,109 @@ DEFINE_PAGE_EVENT(iomap_writepage);
8080
DEFINE_PAGE_EVENT(iomap_releasepage);
8181
DEFINE_PAGE_EVENT(iomap_invalidatepage);
8282

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+
83186
#endif /* _IOMAP_TRACE_H */
84187

85188
#undef TRACE_INCLUDE_PATH

0 commit comments

Comments
 (0)