Skip to contentSkip to conversation

ocfs2: do not fallback to buffer I/O write if appending

PATCH New akpm at linux-foundation.org 1 participant 1 message Dec 15, 2014 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 13/15 ocfs2: do not fallback to buffer I/O write if appending

From: Weiwei Wang <[email protected]>
Subject: ocfs2: do not fallback to buffer I/O write if appending

Now we can do direct io and do not fallback to buffered IO any more in case of append O_DIRECT write.

---

 fs/ocfs2/file.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ocfs2/file.c renamed from fs/ocfs2/file.c~ocfs2-do-not-fallback-to-buffer-i-o-write-if-appending +4 -1
diff -puN fs/ocfs2/file.c~ocfs2-do-not-fallback-to-buffer-i-o-write-if-appending fs/ocfs2/file.c
@@ -2116,6 +2116,9 @@ static int ocfs2_prepare_inode_for_write
 	struct dentry *dentry = file->f_path.dentry;
 	struct inode *inode = dentry->d_inode;
 	loff_t saved_pos = 0, end;
+	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	int full_coherency = !(osb->s_mount_opt &
+		OCFS2_MOUNT_COHERENCY_BUFFERED);
 
 	/*
 	 * We start with a read level meta lock and only jump to an ex
@@ -2204,7 +2207,7 @@ static int ocfs2_prepare_inode_for_write
 		 * one node could wind up truncating another
 		 * nodes writes.
 		 */
-		if (end > i_size_read(inode)) {
+		if (end > i_size_read(inode) && !full_coherency) {
 			*direct_io = 0;
 			break;
 		}

_