[PATCH 4/9] fuse_trace: allow local filesystems to set some VFS iflags

Darrick J. Wong
2025-09-16T00:37:06Z

Add tracepoints for the previous patch.

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

diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index 9c2eb497730b06..2aff78a30503ee 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -176,6 +176,35 @@ TRACE_EVENT(fuse_request_end,
__entry->unique, __entry->len, __entry->error)
);

+DECLARE_EVENT_CLASS(fuse_fileattr_class,
+ TP_PROTO(const struct inode *inode, unsigned int old_iflags),
+
+ TP_ARGS(inode, old_iflags),
+
+ TP_STRUCT__entry(
+ FUSE_INODE_FIELDS
+ __field(unsigned int, old_iflags)
+ __field(unsigned int, new_iflags)
+ ),
+
+ TP_fast_assign(
+ FUSE_INODE_ASSIGN(inode, fi, fm);
+ __entry->old_iflags = old_iflags;
+ __entry->new_iflags = inode->i_flags;
+ ),
+
+ TP_printk(FUSE_INODE_FMT " old_iflags 0x%x iflags 0x%x",
+ FUSE_INODE_PRINTK_ARGS,
+ __entry->old_iflags,
+ __entry->new_iflags)
+);
+#define DEFINE_FUSE_FILEATTR_EVENT(name) \
+DEFINE_EVENT(fuse_fileattr_class, name, \
+ TP_PROTO(const struct inode *inode, unsigned int old_iflags), \
+ TP_ARGS(inode, old_iflags))
+DEFINE_FUSE_FILEATTR_EVENT(fuse_fileattr_update_inode);
+DEFINE_FUSE_FILEATTR_EVENT(fuse_fileattr_init);
+
#ifdef CONFIG_FUSE_BACKING
#define FUSE_BACKING_FLAG_STRINGS \
{ FUSE_BACKING_TYPE_PASSTHROUGH, "pass" }, \
diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index fc0c9bac7a5939..2ac1911dc5cc83 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -4,6 +4,7 @@
*/

#include "fuse_i.h"
+#include "fuse_trace.h"

#include <linux/uio.h>
#include <linux/compat.h>
@@ -531,6 +532,8 @@ static void fuse_fileattr_update_inode(struct inode *inode,
update_iflag(inode, S_APPEND, fa->fsx_xflags & FS_XFLAG_APPEND);
}

+ trace_fuse_fileattr_update_inode(inode, old_iflags);
+
if (old_iflags != inode->i_flags)
fuse_invalidate_attr(inode);
}
@@ -538,6 +541,7 @@ static void fuse_fileattr_update_inode(struct inode *inode,
void fuse_fileattr_init(struct inode *inode, const struct fuse_attr *attr)
{
struct fuse_conn *fc = get_fuse_conn(inode);
+ unsigned int old_iflags = inode->i_flags;

if (!fc->local_fs)
return;
@@ -550,6 +554,8 @@ void fuse_fileattr_init(struct inode *inode, const struct fuse_attr *attr)

if (attr->flags & FUSE_ATTR_APPEND)
inode->i_flags |= S_APPEND;
+
+ trace_fuse_fileattr_init(inode, old_iflags);
}

int fuse_fileattr_get(struct dentry *dentry, struct file_kattr *fa)