All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, Jan Kara <jack@suse.cz>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
	kyle@mcmartin.ca, sct@redhat.com
Subject: Re: [PATCH] implement posix O_SYNC and O_DSYNC semantics
Date: Thu, 17 Sep 2009 19:16:17 +0200	[thread overview]
Message-ID: <20090917171617.GB858@lst.de> (raw)
In-Reply-To: <4AAFA9BC.1000409@redhat.com>

Btw, a little update on O_RSYNC:  I have a patch that should work,
but surprisingly enough it doesn't.  Seem like the O_ flags grew too
large and somewhere in the middle they get truncated off.  Here's what I
have so far:

Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c	2009-09-15 00:06:09.737003454 -0300
+++ linux-2.6/fs/splice.c	2009-09-15 00:08:23.669254032 -0300
@@ -501,6 +501,10 @@ ssize_t generic_file_splice_read(struct 
 	if (unlikely(left < len))
 		len = left;
 
+	ret = generic_read_sync(in, *ppos, len);
+	if (ret)
+		return ret;
+
 	ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
 	if (ret > 0) {
 		*ppos += ret;
Index: linux-2.6/fs/sync.c
===================================================================
--- linux-2.6.orig/fs/sync.c	2009-09-15 00:08:23.180271144 -0300
+++ linux-2.6/fs/sync.c	2009-09-15 00:28:41.359031442 -0300
@@ -295,6 +295,33 @@ int generic_write_sync(struct file *file
 }
 EXPORT_SYMBOL(generic_write_sync);
 
+/**
+ * generic_read_sync - perform syncing befor
+ * @file:	file to which the read happens
+ * @pos:	offset where the read starts
+ * @count:	length of the read
+ *
+ * This implements the O_RSYNC semantics:
+ *   O_RSYNC on its own just means the data is successfully transferred to
+ *   the calling process (always the case).
+ *
+ *   O_RSYNC|O_DSYNC means that if a read request hits data that is currently
+ *   in a cache and not yet on the medium, then the write to medium is
+ *   successful before the read succeeds.
+ *
+ *   O_RSYNC|O_SYNC means the same plus the integrity of file meta information
+ *   (access time etc).
+ */
+int generic_read_sync(struct file *file, loff_t pos, loff_t count)
+{
+	if (((file->f_flags & (O_RSYNC|O_DSYNC)) != (O_RSYNC|O_DSYNC)))
+		return 0;
+	return vfs_fsync_range(file, file->f_path.dentry, pos,
+			       pos + count - 1,
+			       (file->f_flags & __O_SYNC) ? 0 : 1);
+}
+EXPORT_SYMBOL(generic_read_sync);
+
 /*
  * sys_sync_file_range() permits finely controlled syncing over a segment of
  * a file in the range offset .. (offset+nbytes-1) inclusive.  If nbytes is
Index: linux-2.6/include/asm-generic/fcntl.h
===================================================================
--- linux-2.6.orig/include/asm-generic/fcntl.h	2009-09-15 00:08:23.162254189 -0300
+++ linux-2.6/include/asm-generic/fcntl.h	2009-09-15 00:08:23.672254134 -0300
@@ -68,6 +68,10 @@
 #define O_SYNC		(__O_SYNC|O_DSYNC)
 #endif
 
+#ifndef O_RSYNC
+#define O_RSYNC		010000000
+#endif
+
 #ifndef O_NDELAY
 #define O_NDELAY	O_NONBLOCK
 #endif
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h	2009-09-15 00:06:09.758004312 -0300
+++ linux-2.6/include/linux/fs.h	2009-09-15 00:08:23.673254191 -0300
@@ -2097,6 +2097,7 @@ extern int vfs_fsync_range(struct file *
 			   loff_t start, loff_t end, int datasync);
 extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync);
 extern int generic_write_sync(struct file *file, loff_t pos, loff_t count);
+extern int generic_read_sync(struct file *file, loff_t pos, loff_t count);
 extern void sync_supers(void);
 extern void emergency_sync(void);
 extern void emergency_remount(void);
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c	2009-09-15 00:06:09.764004377 -0300
+++ linux-2.6/mm/filemap.c	2009-09-15 00:08:23.676300248 -0300
@@ -1285,6 +1285,10 @@ generic_file_aio_read(struct kiocb *iocb
 	if (retval)
 		return retval;
 
+	retval = generic_read_sync(filp, pos, count);
+	if (retval)
+		return retval;
+
 	/* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
 	if (filp->f_flags & O_DIRECT) {
 		loff_t size;
Index: linux-2.6/arch/alpha/include/asm/fcntl.h
===================================================================
--- linux-2.6.orig/arch/alpha/include/asm/fcntl.h	2009-09-15 00:08:23.169254241 -0300
+++ linux-2.6/arch/alpha/include/asm/fcntl.h	2009-09-15 00:08:23.678253988 -0300
@@ -30,6 +30,7 @@
  */
 #define __O_SYNC	020000000
 #define O_SYNC		(__O_SYNC|O_DSYNC)
+#define O_RSYNC		040000000
 
 #define F_GETLK		7
 #define F_SETLK		8
Index: linux-2.6/arch/mips/include/asm/fcntl.h
===================================================================
--- linux-2.6.orig/arch/mips/include/asm/fcntl.h	2009-09-15 00:08:23.172253854 -0300
+++ linux-2.6/arch/mips/include/asm/fcntl.h	2009-09-15 00:08:23.678253988 -0300
@@ -34,6 +34,7 @@
 #define __O_SYNC	0x4000
 #define O_SYNC		(__O_SYNC|O_DSYNC)
 #define O_DIRECT	0x8000	/* direct disk access hint */
+#define O_DSYNC		0x10000
 
 #define F_GETLK		14
 #define F_SETLK		6
Index: linux-2.6/arch/parisc/include/asm/fcntl.h
===================================================================
--- linux-2.6.orig/arch/parisc/include/asm/fcntl.h	2009-09-15 00:08:23.178298896 -0300
+++ linux-2.6/arch/parisc/include/asm/fcntl.h	2009-09-15 00:08:23.680301735 -0300
@@ -14,6 +14,7 @@
 #define O_RSYNC		002000000 /* HPUX only */
 #define O_NOATIME	004000000
 #define O_CLOEXEC	010000000 /* set close_on_exec */
+#define O_RSYNC		020000000
 
 #define O_DIRECTORY	000010000 /* must be a directory */
 #define O_NOFOLLOW	000000200 /* don't follow links */
Index: linux-2.6/arch/sparc/include/asm/fcntl.h
===================================================================
--- linux-2.6.orig/arch/sparc/include/asm/fcntl.h	2009-09-15 00:08:23.179254674 -0300
+++ linux-2.6/arch/sparc/include/asm/fcntl.h	2009-09-15 00:08:23.681254370 -0300
@@ -33,6 +33,7 @@
  */
 #define __O_SYNC	0x800000
 #define O_SYNC		(__O_SYNC|O_DSYNC)
+#define O_RSYNC		0x1000000
 
 #define F_GETOWN	5	/*  for sockets. */
 #define F_SETOWN	6	/*  for sockets. */

  reply	other threads:[~2009-09-17 17:16 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02 13:59 [PATCH 0/16] Make O_SYNC handling use standard syncing path (version 4) Jan Kara
2009-09-02 13:59 ` [PATCH 01/16] vfs: Introduce filemap_fdatawait_range Jan Kara
2009-09-02 13:59 ` [PATCH 02/16] vfs: Export __generic_file_aio_write() and add some comments Jan Kara
2009-09-02 13:59   ` [Ocfs2-devel] " Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59 ` [PATCH 03/16] vfs: Remove syncing from generic_file_direct_write() and generic_file_buffered_write() Jan Kara
2009-09-02 13:59   ` [Ocfs2-devel] " Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59 ` [PATCH 04/16] pohmelfs: Use __generic_file_aio_write instead of generic_file_aio_write_nolock Jan Kara
2009-09-02 13:59 ` [PATCH 05/16] ocfs2: " Jan Kara
2009-09-02 13:59   ` [Ocfs2-devel] " Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59 ` [PATCH 06/16] vfs: Rename generic_file_aio_write_nolock Jan Kara
2009-09-02 21:47   ` Christoph Hellwig
2009-09-03 10:24     ` Jan Kara
2009-09-03 15:37       ` Christoph Hellwig
2009-09-02 13:59 ` [PATCH 07/16] vfs: Introduce new helpers for syncing after writing to O_SYNC file or IS_SYNC inode Jan Kara
2009-09-02 13:59   ` [Ocfs2-devel] " Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59 ` [PATCH 08/16] ext2: Update comment about generic_osync_inode Jan Kara
2009-09-02 13:59 ` [PATCH 09/16] ext3: Remove syncing logic from ext3_file_write Jan Kara
2009-09-02 13:59 ` [PATCH 10/16] ext4: Remove syncing logic from ext4_file_write Jan Kara
2009-09-02 13:59 ` [PATCH 11/16] ntfs: Use new syncing helpers and update comments Jan Kara
2009-09-02 13:59 ` [PATCH 12/16] ocfs2: Update syncing after splicing to match generic version Jan Kara
2009-09-02 13:59   ` [Ocfs2-devel] " Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59 ` [PATCH 13/16] xfs: Convert sync_page_range() to simple filemap_write_and_wait_range() Jan Kara
2009-09-02 13:59   ` Jan Kara
2009-09-02 13:59 ` [PATCH 14/16] pohmelfs: Use new syncing helper Jan Kara
2009-09-02 13:59 ` [PATCH 15/16] fat: Opencode sync_page_range_nolock() Jan Kara
2009-09-02 13:59 ` [PATCH 16/16] vfs: Remove generic_osync_inode() and sync_page_range{_nolock}() Jan Kara
2009-09-02 14:16 ` [PATCH 0/16] Make O_SYNC handling use standard syncing path (version 4) Christoph Hellwig
2009-09-02 22:18 ` [PATCH] fsync: wait for data writeout completion before calling ->fsync Christoph Hellwig
2009-09-02 22:37   ` Joel Becker
2009-09-03 10:47   ` Jan Kara
2009-09-03 15:39     ` Christoph Hellwig
2009-09-10 20:25 ` [PATCH 18/16] implement posix O_SYNC and O_DSYNC semantics Christoph Hellwig
2009-09-10 20:38   ` Trond Myklebust
2009-09-10 20:40     ` Christoph Hellwig
2009-09-10 20:43       ` Trond Myklebust
2009-09-10 20:44         ` Christoph Hellwig
2009-09-10 23:07   ` Andreas Dilger
2009-09-10 23:18     ` Christoph Hellwig
2009-09-11 19:16   ` [PATCHv2 " Christoph Hellwig
2009-09-14 16:54     ` Jan Kara
2009-09-14 17:02       ` Christoph Hellwig
2009-09-15 13:12       ` [PATCH] " Christoph Hellwig
2009-09-15 14:10         ` Jan Kara
2009-09-15 14:50         ` Ulrich Drepper
2009-09-17 17:16           ` Christoph Hellwig [this message]
2009-09-17 21:03         ` Kyle McMartin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090917171617.GB858@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=drepper@redhat.com \
    --cc=jack@suse.cz \
    --cc=kyle@mcmartin.ca \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sct@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.