On 7/18/25 01:38, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > Add the library methods so that fuse servers can manage an in-kernel > iomap cache. This enables better performance on small IOs and is > required if the filesystem needs synchronization between pagecache > writes and writeback. Sorry, if this ready to be merged? I don't see in linux master? Or part of your other patches (will take some to go through these). > > Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> > --- > include/fuse_common.h | 9 +++++ > include/fuse_kernel.h | 34 +++++++++++++++++++ > include/fuse_lowlevel.h | 39 ++++++++++++++++++++++ > lib/fuse_lowlevel.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ > lib/fuse_versionscript | 2 + > 5 files changed, 166 insertions(+) > > > diff --git a/include/fuse_common.h b/include/fuse_common.h > index 98cb8f656efd13..1237cc2656b9c4 100644 > --- a/include/fuse_common.h > +++ b/include/fuse_common.h > @@ -1164,6 +1164,7 @@ int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn); > */ > #if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 18) > #define FUSE_IOMAP_TYPE_PURE_OVERWRITE (0xFFFF) /* use read mapping data */ > +#define FUSE_IOMAP_TYPE_NULL (0xFFFE) /* no mapping here */ > #define FUSE_IOMAP_TYPE_HOLE 0 /* no blocks allocated, need allocation */ > #define FUSE_IOMAP_TYPE_DELALLOC 1 /* delayed allocation blocks */ > #define FUSE_IOMAP_TYPE_MAPPED 2 /* blocks allocated at @addr */ > @@ -1208,6 +1209,11 @@ struct fuse_iomap { > uint32_t dev; /* device cookie */ > }; > > +struct fuse_iomap_inval { > + uint64_t offset; /* file offset to invalidate, bytes */ > + uint64_t length; /* length to invalidate, bytes */ > +}; > + > /* out of place write extent */ > #define FUSE_IOMAP_IOEND_SHARED (1U << 0) > /* unwritten extent */ > @@ -1258,6 +1264,9 @@ struct fuse_iomap_config{ > int64_t s_maxbytes; /* max file size */ > }; > > +/* invalidate to end of file */ > +#define FUSE_IOMAP_INVAL_TO_EOF (~0ULL) > + > #endif /* FUSE_USE_VERSION >= 318 */ > > /* ----------------------------------------------------------- * > diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h > index 3c704f03434693..f1a93dbd1ff443 100644 > --- a/include/fuse_kernel.h > +++ b/include/fuse_kernel.h > @@ -243,6 +243,8 @@ > * - add FUSE_IOMAP_DIRECTIO/FUSE_ATTR_IOMAP_DIRECTIO for direct I/O support > * - add FUSE_IOMAP_FILEIO/FUSE_ATTR_IOMAP_FILEIO for buffered I/O support > * - add FUSE_IOMAP_CONFIG so the fuse server can configure more fs geometry > + * - add FUSE_NOTIFY_IOMAP_UPSERT and FUSE_NOTIFY_IOMAP_INVAL so fuse servers > + * can cache iomappings in the kernel Personally I prefer a preparation patch, that just syncs the entire fuse_kernel.h from linux-<version>. Also this file might get renamed to fuse_kernel_linux.h, there seems to be interest from BSD and OSX to have their own headers. > */ > > #ifndef _LINUX_FUSE_H > @@ -699,6 +701,8 @@ enum fuse_notify_code { > FUSE_NOTIFY_DELETE = 6, > FUSE_NOTIFY_RESEND = 7, > FUSE_NOTIFY_INC_EPOCH = 8, > + FUSE_NOTIFY_IOMAP_UPSERT = 9, > + FUSE_NOTIFY_IOMAP_INVAL = 10, > FUSE_NOTIFY_CODE_MAX, > }; > > @@ -1406,4 +1410,34 @@ struct fuse_iomap_config_out { > int64_t s_maxbytes; /* max file size */ > }; > > +struct fuse_iomap_upsert_out { > + uint64_t nodeid; /* Inode ID */ > + uint64_t attr_ino; /* matches fuse_attr:ino */ > + > + uint64_t read_offset; /* file offset of mapping, bytes */ > + uint64_t read_length; /* length of mapping, bytes */ > + uint64_t read_addr; /* disk offset of mapping, bytes */ > + uint16_t read_type; /* FUSE_IOMAP_TYPE_* */ > + uint16_t read_flags; /* FUSE_IOMAP_F_* */ > + uint32_t read_dev; /* device cookie */ > + > + uint64_t write_offset; /* file offset of mapping, bytes */ > + uint64_t write_length; /* length of mapping, bytes */ > + uint64_t write_addr; /* disk offset of mapping, bytes */ > + uint16_t write_type; /* FUSE_IOMAP_TYPE_* */ > + uint16_t write_flags; /* FUSE_IOMAP_F_* */ > + uint32_t write_dev; /* device cookie * */ > +}; > + > +struct fuse_iomap_inval_out { > + uint64_t nodeid; /* Inode ID */ > + uint64_t attr_ino; /* matches fuse_attr:ino */ > + > + uint64_t read_offset; /* range to invalidate read iomaps, bytes */ > + uint64_t read_length; /* can be FUSE_IOMAP_INVAL_TO_EOF */ > + > + uint64_t write_offset; /* range to invalidate write iomaps, bytes */ > + uint64_t write_length; /* can be FUSE_IOMAP_INVAL_TO_EOF */ > +}; > + > #endif /* _LINUX_FUSE_H */ > diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h > index fd7df5c2c11e16..f690c62fcdd61c 100644 > --- a/include/fuse_lowlevel.h > +++ b/include/fuse_lowlevel.h > @@ -2101,6 +2101,45 @@ int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino, > * @return positive device id for success, zero for failure > */ > int fuse_iomap_add_device(struct fuse_session *se, int fd, unsigned int flags); > + > +/** > + * Upsert some file mapping information into the kernel. This is necessary > + * for filesystems that require coordination of mapping state changes between > + * buffered writes and writeback, and desirable for better performance > + * elsewhere. > + * > + * Added in FUSE protocol version 7.99. If the kernel does not support 7.99? Thanks, Bernd