libfuse: add atomic write support Add the single flag that we need to turn on atomic write support in fuse. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
diff --git a/include/fuse_common.h b/include/fuse_common.h index 8e585cc..1977026 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h
@@ -548,6 +548,8 @@ * 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 @@ #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 1470b59..fcf02c9 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 @@ * 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 f730a7f..ee73de4 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c
@@ -126,6 +126,8 @@ 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)