[PATCH 25/28] fuse_trace: implement inline data file IO via iomap

Darrick J. Wong
2025-09-16T00:34:30Z

Add tracepoints for the previous patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/fuse/fuse_trace.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
fs/fuse/file_iomap.c | 7 +++++++
2 files changed, 52 insertions(+)

diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index 1cff42bc5907bf..b1c45abe40b440 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -227,6 +227,7 @@ DEFINE_FUSE_BACKING_EVENT(fuse_backing_close);
#if IS_ENABLED(CONFIG_FUSE_IOMAP)
struct iomap_writepage_ctx;
struct iomap_ioend;
+struct iomap;

/* tracepoint boilerplate so we don't have to keep doing this */
#define FUSE_IOMAP_OPFLAGS_FIELD \
@@ -1042,6 +1043,50 @@ TRACE_EVENT(fuse_iomap_dev_inval,
__entry->offset,
__entry->length)
);
+
+DECLARE_EVENT_CLASS(fuse_iomap_inline_class,
+ TP_PROTO(const struct inode *inode, loff_t pos, uint64_t count,
+ const struct iomap *map),
+ TP_ARGS(inode, pos, count, map),
+
+ TP_STRUCT__entry(
+ FUSE_IO_RANGE_FIELDS()
+ FUSE_IOMAP_MAP_FIELDS(map)
+ __field(bool, has_buf)
+ __field(uint64_t, validity_cookie)
+ ),
+
+ TP_fast_assign(
+ FUSE_INODE_ASSIGN(inode, fi, fm);
+ __entry->offset = pos;
+ __entry->length = count;
+
+ __entry->mapdev = FUSE_IOMAP_DEV_NULL;
+ __entry->mapaddr = map->addr;
+ __entry->mapoffset = map->offset;
+ __entry->maplength = map->length;
+ __entry->maptype = map->type;
+ __entry->mapflags = map->flags;
+
+ __entry->has_buf = map->inline_data != NULL;
+ __entry->validity_cookie= map->validity_cookie;
+ ),
+
+ TP_printk(FUSE_IO_RANGE_FMT() FUSE_IOMAP_MAP_FMT() " has_buf? %d cookie 0x%llx",
+ FUSE_IO_RANGE_PRINTK_ARGS(),
+ FUSE_IOMAP_MAP_PRINTK_ARGS(map),
+ __entry->has_buf,
+ __entry->validity_cookie)
+);
+#define DEFINE_FUSE_IOMAP_INLINE_EVENT(name) \
+DEFINE_EVENT(fuse_iomap_inline_class, name, \
+ TP_PROTO(const struct inode *inode, loff_t pos, uint64_t count, \
+ const struct iomap *map), \
+ TP_ARGS(inode, pos, count, map))
+DEFINE_FUSE_IOMAP_INLINE_EVENT(fuse_iomap_inline_read);
+DEFINE_FUSE_IOMAP_INLINE_EVENT(fuse_iomap_inline_write);
+DEFINE_FUSE_IOMAP_INLINE_EVENT(fuse_iomap_set_inline_iomap);
+DEFINE_FUSE_IOMAP_INLINE_EVENT(fuse_iomap_set_inline_srcmap);
#endif /* CONFIG_FUSE_IOMAP */

#endif /* _TRACE_FUSE_H */
diff --git a/fs/fuse/file_iomap.c b/fs/fuse/file_iomap.c
index 8faf16f58df035..a71de4ea5eb32d 100644
--- a/fs/fuse/file_iomap.c
+++ b/fs/fuse/file_iomap.c
@@ -452,6 +452,8 @@ static int fuse_iomap_inline_read(struct inode *inode, loff_t pos,
if (BAD_DATA(!iomap_inline_data_valid(iomap)))
return -EFSCORRUPTED;

+ trace_fuse_iomap_inline_read(inode, pos, count, iomap);
+
args.opcode = FUSE_READ;
args.nodeid = fi->nodeid;
args.in_numargs = 1;
@@ -497,6 +499,8 @@ static int fuse_iomap_inline_write(struct inode *inode, loff_t pos,
if (BAD_DATA(!iomap_inline_data_valid(iomap)))
return -EFSCORRUPTED;

+ trace_fuse_iomap_inline_write(inode, pos, count, iomap);
+
args.opcode = FUSE_WRITE;
args.nodeid = fi->nodeid;
args.in_numargs = 2;
@@ -558,6 +562,9 @@ static int fuse_iomap_set_inline(struct inode *inode, unsigned opflags,
return err;
}

+ trace_fuse_iomap_set_inline_iomap(inode, pos, count, iomap);
+ trace_fuse_iomap_set_inline_srcmap(inode, pos, count, srcmap);
+
return 0;
}