]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/sync.c
vfs: Implement proper O_SYNC semantics
[mirror_ubuntu-bionic-kernel.git] / fs / sync.c
index d104591b066bf474f62f665e87e04154c4da5da1..b75ca68dc08189300ba9617c58d038e43b709b1e 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -295,10 +295,11 @@ SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
  */
 int generic_write_sync(struct file *file, loff_t pos, loff_t count)
 {
-       if (!(file->f_flags & O_SYNC) && !IS_SYNC(file->f_mapping->host))
+       if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host))
                return 0;
        return vfs_fsync_range(file, file->f_path.dentry, pos,
-                              pos + count - 1, 1);
+                              pos + count - 1,
+                              (file->f_flags & __O_SYNC) ? 0 : 1);
 }
 EXPORT_SYMBOL(generic_write_sync);