[PATCH 4/5] fuse_trace: move the passthrough-specific code back to passthrough.c

Darrick J. Wong
2025-09-16T00:27:43Z

Add tracepoints for the previous patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/fuse/fuse_trace.h | 35 +++++++++++++++++++++++++++++++++++
fs/fuse/backing.c | 5 +++++
2 files changed, 40 insertions(+)

diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index bbe9ddd8c71696..286a0845dc0898 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -124,6 +124,41 @@ TRACE_EVENT(fuse_request_end,
__entry->unique, __entry->len, __entry->error)
);

+#ifdef CONFIG_FUSE_BACKING
+TRACE_EVENT(fuse_backing_class,
+ TP_PROTO(const struct fuse_conn *fc, unsigned int idx,
+ const struct fuse_backing *fb),
+
+ TP_ARGS(fc, idx, fb),
+
+ TP_STRUCT__entry(
+ __field(dev_t, connection)
+ __field(unsigned int, idx)
+ __field(unsigned long, ino)
+ ),
+
+ TP_fast_assign(
+ struct inode *inode = file_inode(fb->file);
+
+ __entry->connection = fc->dev;
+ __entry->idx = idx;
+ __entry->ino = inode->i_ino;
+ ),
+
+ TP_printk("connection %u idx %u ino 0x%lx",
+ __entry->connection,
+ __entry->idx,
+ __entry->ino)
+);
+#define DEFINE_FUSE_BACKING_EVENT(name) \
+DEFINE_EVENT(fuse_backing_class, name, \
+ TP_PROTO(const struct fuse_conn *fc, unsigned int idx, \
+ const struct fuse_backing *fb), \
+ TP_ARGS(fc, idx, fb))
+DEFINE_FUSE_BACKING_EVENT(fuse_backing_open);
+DEFINE_FUSE_BACKING_EVENT(fuse_backing_close);
+#endif /* CONFIG_FUSE_BACKING */
+
#endif /* _TRACE_FUSE_H */

#undef TRACE_INCLUDE_PATH
diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c
index da0dff288396ed..229c101ab46b0e 100644
--- a/fs/fuse/backing.c
+++ b/fs/fuse/backing.c
@@ -71,6 +71,7 @@ static int fuse_backing_id_free(int id, void *p, void *data)

WARN_ON_ONCE(refcount_read(&fb->count) != 1);

+ trace_fuse_backing_close((struct fuse_conn *)data, id, fb);
fuse_backing_free(fb);
return 0;
}
@@ -144,6 +145,8 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)
fb = NULL;
goto out;
}
+
+ trace_fuse_backing_open(fc, res, fb);
out:
pr_debug("%s: fb=0x%p, ret=%i\n", __func__, fb, res);

@@ -193,6 +196,8 @@ int fuse_backing_close(struct fuse_conn *fc, int backing_id)
if (err)
goto out_fb;

+ trace_fuse_backing_close(fc, backing_id, fb);
+
err = -ENOENT;
test_fb = fuse_backing_id_remove(fc, backing_id);
if (!test_fb)