Patchwork [RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate()

login
register
mail settings
Submitter Zheng Liu
Date Jan. 16, 2012, 8:47 a.m.
Message ID <1326703663-4801-1-git-send-email-wenqing.lz@taobao.com>
Download mbox | patch
Permalink /patch/136258/
State New
Headers show

Comments

Zheng Liu - Jan. 16, 2012, 8:47 a.m.
Ext4 must make sure the transaction to be commited to the disk when user opens
a file with O_(D)SYNC flag and do a fallocate(2) call.

This problem had been reported by Christoph Hellwig in this thread:
http://www.spinics.net/lists/linux-btrfs/msg13621.html

CC: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
 fs/ext4/extents.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Zheng Liu - May 23, 2012, 1:19 a.m.
On Mon, Jan 16, 2012 at 04:47:43PM +0800, Zheng Liu wrote:
> Ext4 must make sure the transaction to be commited to the disk when user opens
> a file with O_(D)SYNC flag and do a fallocate(2) call.
> 
> This problem had been reported by Christoph Hellwig in this thread:
> http://www.spinics.net/lists/linux-btrfs/msg13621.html

Hi Ted,

Could you please review this patch?  Thank you.

Regards,
Zheng  
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 74f23c2..00e32d9 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4356,6 +4356,8 @@  retry:
 			ret = PTR_ERR(handle);
 			break;
 		}
+		if (file->f_flags & O_SYNC)
+			ext4_handle_sync(handle);
 		ret = ext4_map_blocks(handle, inode, &map, flags);
 		if (ret <= 0) {
 #ifdef EXT4FS_DEBUG