From: Darrick J. Wong <djwong@xxxxxxxxxx> Make it so that fuse servers can ask the kernel fuse driver to use iomap to support direct IO. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- include/fuse_common.h | 2 ++ include/fuse_kernel.h | 7 +++++-- lib/fuse_lowlevel.c | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/fuse_common.h b/include/fuse_common.h index 9181ec6cb5e5e9..6e8b2958373258 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -1228,6 +1228,8 @@ static inline bool fuse_iomap_need_write_allocate(unsigned int opflags, /* enable fsdax */ #define FUSE_IFLAG_DAX (1U << 0) +/* use iomap for this inode */ +#define FUSE_IFLAG_IOMAP (1U << 1) /* ----------------------------------------------------------- * * Compatibility stuff * diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h index 849238c17baf5e..86c81871ca2b37 100644 --- a/include/fuse_kernel.h +++ b/include/fuse_kernel.h @@ -238,7 +238,8 @@ * * 7.99 * - add FUSE_IOMAP and iomap_{begin,end,ioend} handlers for FIEMAP and - * SEEK_{DATA,HOLE} + * SEEK_{DATA,HOLE}, and direct I/O + * - add FUSE_ATTR_IOMAP to enable iomap for specific inodes */ #ifndef _LINUX_FUSE_H @@ -448,7 +449,7 @@ struct fuse_file_lock { * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests. * init_out.request_timeout contains the timeout (in secs) * FUSE_IOMAP: Client supports iomap for FIEMAP and SEEK_{DATA,HOLE} file - * operations. + * operations and direct I/O. */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -580,9 +581,11 @@ struct fuse_file_lock { * * FUSE_ATTR_SUBMOUNT: Object is a submount root * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode + * FUSE_ATTR_IOMAP: Use iomap for this inode */ #define FUSE_ATTR_SUBMOUNT (1 << 0) #define FUSE_ATTR_DAX (1 << 1) +#define FUSE_ATTR_IOMAP (1 << 2) /** * Open flags diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 04bc858f54d01f..6a96c0f62d5884 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -124,6 +124,8 @@ static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr, attr->flags = 0; if (iflags & FUSE_IFLAG_DAX) attr->flags |= FUSE_ATTR_DAX; + if (iflags & FUSE_IFLAG_IOMAP) + attr->flags |= FUSE_ATTR_IOMAP; } static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)