From: Darrick J. Wong <djwong@xxxxxxxxxx> Add the single flag that we need to turn on atomic write support in fuse. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- include/fuse_common.h | 4 ++++ include/fuse_kernel.h | 3 +++ lib/fuse_lowlevel.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/include/fuse_common.h b/include/fuse_common.h index 8e585cc7483643..19770262c4b518 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -548,6 +548,8 @@ struct fuse_loop_config_v1 { * FUSE_IOMAP_SUPPORT_FILEIO: basic file I/O functionality through iomap */ #define FUSE_IOMAP_SUPPORT_FILEIO (1ULL << 0) +/* untorn writes through iomap */ +#define FUSE_IOMAP_SUPPORT_ATOMIC (1ULL << 1) /** * Connection information, passed to the ->init() method @@ -1237,6 +1239,8 @@ static inline bool fuse_iomap_need_write_allocate(unsigned int opflags, #define FUSE_IFLAG_DAX (1U << 0) /* use iomap for this inode */ #define FUSE_IFLAG_IOMAP (1U << 1) +/* enable untorn writes */ +#define FUSE_IFLAG_ATOMIC (1U << 2) /* Which fields are set in fuse_iomap_config_out? */ #define FUSE_IOMAP_CONFIG_SID (1 << 0ULL) diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h index 1470b59d742165..fcf02c9371ba3a 100644 --- a/include/fuse_kernel.h +++ b/include/fuse_kernel.h @@ -242,6 +242,7 @@ * - add FUSE_ATTR_IOMAP to enable iomap for specific inodes * - add FUSE_IOMAP_CONFIG so the fuse server can configure more fs geometry * - add FUSE_NOTIFY_IOMAP_DEV_INVAL to invalidate iomap bdev ranges + * - add FUSE_ATTR_ATOMIC for single-fsblock atomic write support */ #ifndef _LINUX_FUSE_H @@ -584,10 +585,12 @@ 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 + * FUSE_ATTR_ATOMIC: Enable untorn writes */ #define FUSE_ATTR_SUBMOUNT (1 << 0) #define FUSE_ATTR_DAX (1 << 1) #define FUSE_ATTR_IOMAP (1 << 2) +#define FUSE_ATTR_ATOMIC (1 << 3) /** * Open flags diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index f730a7fd4ead09..ee73de4a8950be 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -126,6 +126,8 @@ static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr, attr->flags |= FUSE_ATTR_DAX; if (iflags & FUSE_IFLAG_IOMAP) attr->flags |= FUSE_ATTR_IOMAP; + if (iflags & FUSE_IFLAG_ATOMIC) + attr->flags |= FUSE_ATTR_ATOMIC; } static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)