[PATCH 11/28] fuse_trace: implement basic iomap reporting such as FIEMAP and SEEK_{DATA,HOLE}

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

Add tracepoints for the previous patch.

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

diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index cdedaf2b2a0ad5..4fe51be0e65bdc 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -530,6 +530,52 @@ DEFINE_EVENT(fuse_inode_state_class, name, \
TP_ARGS(inode))
DEFINE_FUSE_INODE_STATE_EVENT(fuse_iomap_init_inode);
DEFINE_FUSE_INODE_STATE_EVENT(fuse_iomap_evict_inode);
+
+TRACE_EVENT(fuse_iomap_fiemap,
+ TP_PROTO(const struct inode *inode, u64 start, u64 count,
+ unsigned int flags),
+
+ TP_ARGS(inode, start, count, flags),
+
+ TP_STRUCT__entry(
+ FUSE_IO_RANGE_FIELDS()
+ __field(unsigned int, flags)
+ ),
+
+ TP_fast_assign(
+ FUSE_INODE_ASSIGN(inode, fi, fm);
+ __entry->offset = start;
+ __entry->length = count;
+ __entry->flags = flags;
+ ),
+
+ TP_printk(FUSE_IO_RANGE_FMT("fiemap") " flags 0x%x",
+ FUSE_IO_RANGE_PRINTK_ARGS(),
+ __entry->flags)
+);
+
+TRACE_EVENT(fuse_iomap_lseek,
+ TP_PROTO(const struct inode *inode, loff_t offset, int whence),
+
+ TP_ARGS(inode, offset, whence),
+
+ TP_STRUCT__entry(
+ FUSE_INODE_FIELDS
+ __field(loff_t, offset)
+ __field(int, whence)
+ ),
+
+ TP_fast_assign(
+ FUSE_INODE_ASSIGN(inode, fi, fm);
+ __entry->offset = offset;
+ __entry->whence = whence;
+ ),
+
+ TP_printk(FUSE_INODE_FMT " offset 0x%llx whence %d",
+ FUSE_INODE_PRINTK_ARGS,
+ __entry->offset,
+ __entry->whence)
+);
#endif /* CONFIG_FUSE_IOMAP */

#endif /* _TRACE_FUSE_H */
diff --git a/fs/fuse/file_iomap.c b/fs/fuse/file_iomap.c
index 29603eec939589..88d85d572faf97 100644
--- a/fs/fuse/file_iomap.c
+++ b/fs/fuse/file_iomap.c
@@ -693,6 +693,8 @@ int fuse_iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
if (!fuse_allow_current_process(fc))
return -EACCES;

+ trace_fuse_iomap_fiemap(inode, start, count, fieinfo->fi_flags);
+
inode_lock_shared(inode);
error = iomap_fiemap(inode, fieinfo, start, count, &fuse_iomap_ops);
inode_unlock_shared(inode);
@@ -720,6 +722,8 @@ loff_t fuse_iomap_lseek(struct file *file, loff_t offset, int whence)
if (!fuse_allow_current_process(fc))
return -EACCES;

+ trace_fuse_iomap_lseek(inode, offset, whence);
+
switch (whence) {
case SEEK_HOLE:
offset = iomap_seek_hole(inode, offset, &fuse_iomap_ops);