fs: add RWF_DSYNC aand RWF_SYNC
authorChristoph Hellwig <hch@lst.de>
Thu, 7 Apr 2016 15:52:03 +0000 (08:52 -0700)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 1 May 2016 23:58:39 +0000 (19:58 -0400)
This is the per-I/O equivalent of O_DSYNC and O_SYNC, and very useful for
all kinds of file servers and storage targets.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/read_write.c
include/uapi/linux/fs.h

index cf377cf9dfe3824ea58c90321940b938b1a5ab1b..3729d8d34797878e7c9e2321c11de896f9f17b7d 100644 (file)
@@ -698,12 +698,16 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
        struct kiocb kiocb;
        ssize_t ret;
 
-       if (flags & ~RWF_HIPRI)
+       if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC))
                return -EOPNOTSUPP;
 
        init_sync_kiocb(&kiocb, filp);
        if (flags & RWF_HIPRI)
                kiocb.ki_flags |= IOCB_HIPRI;
+       if (flags & RWF_DSYNC)
+               kiocb.ki_flags |= IOCB_DSYNC;
+       if (flags & RWF_SYNC)
+               kiocb.ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
        kiocb.ki_pos = *ppos;
 
        ret = fn(&kiocb, iter);
index a079d50376e15bd0a3db5ab7ce04fb24c0ef33ea..e21fe04acc12111cf0721d82ffc49441832dcfa4 100644 (file)
@@ -324,5 +324,7 @@ struct fscrypt_policy {
 
 /* flags for preadv2/pwritev2: */
 #define RWF_HIPRI                      0x00000001 /* high priority request, poll if possible */
+#define RWF_DSYNC                      0x00000002 /* per-IO O_DSYNC */
+#define RWF_SYNC                       0x00000004 /* per-IO O_SYNC */
 
 #endif /* _UAPI_LINUX_FS_H */