[PATCH 05/28] fuse_trace: adapt FUSE_DEV_IOC_BACKING_{OPEN,CLOSE} to add new iomap devices

Darrick J. Wong
2025-09-16T00:29:17Z

Enhance the existing backing file tracepoints to report the subsystem
that's actually using the backing file.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/fuse/fuse_trace.h | 42 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index ef94f07cbbf2d4..d39029b30e0198 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -175,6 +175,10 @@ TRACE_EVENT(fuse_request_end,
);

#ifdef CONFIG_FUSE_BACKING
+#define FUSE_BACKING_FLAG_STRINGS \
+ { FUSE_BACKING_TYPE_PASSTHROUGH, "pass" }, \
+ { FUSE_BACKING_TYPE_IOMAP, "iomap" }
+
TRACE_EVENT(fuse_backing_class,
TP_PROTO(const struct fuse_conn *fc, unsigned int idx,
const struct fuse_backing *fb),
@@ -184,7 +188,9 @@ TRACE_EVENT(fuse_backing_class,
TP_STRUCT__entry(
__field(dev_t, connection)
__field(unsigned int, idx)
+ __field(unsigned int, type)
__field(unsigned long, ino)
+ __field(dev_t, rdev)
),

TP_fast_assign(
@@ -193,12 +199,19 @@ TRACE_EVENT(fuse_backing_class,
__entry->connection = fc->dev;
__entry->idx = idx;
__entry->ino = inode->i_ino;
+ __entry->type = fb->ops->type;
+ if (fb->ops->type == FUSE_BACKING_TYPE_IOMAP)
+ __entry->rdev = inode->i_rdev;
+ else
+ __entry->rdev = 0;
),

- TP_printk("connection %u idx %u ino 0x%lx",
+ TP_printk("connection %u idx %u type %s ino 0x%lx rdev %u:%u",
__entry->connection,
__entry->idx,
- __entry->ino)
+ __print_symbolic(__entry->type, FUSE_BACKING_FLAG_STRINGS),
+ __entry->ino,
+ MAJOR(__entry->rdev), MINOR(__entry->rdev))
);
#define DEFINE_FUSE_BACKING_EVENT(name) \
DEFINE_EVENT(fuse_backing_class, name, \
@@ -210,7 +223,6 @@ DEFINE_FUSE_BACKING_EVENT(fuse_backing_close);
#endif /* CONFIG_FUSE_BACKING */

#if IS_ENABLED(CONFIG_FUSE_IOMAP)
-
/* tracepoint boilerplate so we don't have to keep doing this */
#define FUSE_IOMAP_OPFLAGS_FIELD \
__field(unsigned, opflags)
@@ -452,6 +464,30 @@ TRACE_EVENT(fuse_iomap_end_error,
__entry->written,
__entry->error)
);
+
+TRACE_EVENT(fuse_iomap_dev_add,
+ TP_PROTO(const struct fuse_conn *fc,
+ const struct fuse_backing_map *map),
+
+ TP_ARGS(fc, map),
+
+ TP_STRUCT__entry(
+ __field(dev_t, connection)
+ __field(int, fd)
+ __field(unsigned int, flags)
+ ),
+
+ TP_fast_assign(
+ __entry->connection = fc->dev;
+ __entry->fd = map->fd;
+ __entry->flags = map->flags;
+ ),
+
+ TP_printk("connection %u fd %d flags 0x%x",
+ __entry->connection,
+ __entry->fd,
+ __entry->flags)
+);
#endif /* CONFIG_FUSE_IOMAP */

#endif /* _TRACE_FUSE_H */