fs: add RWF_APPEND
authorJürg Billeter <j@bitron.ch>
Fri, 29 Sep 2017 12:07:17 +0000 (14:07 +0200)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 26 Jan 2018 00:32:55 +0000 (19:32 -0500)
This is the per-I/O equivalent of O_APPEND to support atomic append
operations on any open file.

If a file is opened with O_APPEND, pwrite() ignores the offset and
always appends data to the end of the file. RWF_APPEND enables atomic
append and pwrite() with offset on a single file descriptor.

Signed-off-by: Jürg Billeter <j@bitron.ch>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
include/linux/fs.h
include/uapi/linux/fs.h

index 6276f83..85c8ddc 100644 (file)
@@ -3224,6 +3224,8 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
                ki->ki_flags |= IOCB_DSYNC;
        if (flags & RWF_SYNC)
                ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
+       if (flags & RWF_APPEND)
+               ki->ki_flags |= IOCB_APPEND;
        return 0;
 }
 
index 4199f8a..d2a8313 100644 (file)
@@ -377,7 +377,11 @@ typedef int __bitwise __kernel_rwf_t;
 /* per-IO, return -EAGAIN if operation would block */
 #define RWF_NOWAIT     ((__force __kernel_rwf_t)0x00000008)
 
+/* per-IO O_APPEND */
+#define RWF_APPEND     ((__force __kernel_rwf_t)0x00000010)
+
 /* mask of flags supported by the kernel */
-#define RWF_SUPPORTED  (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT)
+#define RWF_SUPPORTED  (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
+                        RWF_APPEND)
 
 #endif /* _UAPI_LINUX_FS_H */