]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.31.8/0016-ext4-fix-cache-flush-in-ext4_sync_file.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.31.8 / 0016-ext4-fix-cache-flush-in-ext4_sync_file.patch
CommitLineData
7f041dd7
GKH
1From 889c3508467677a534209736351f028a5b925cc2 Mon Sep 17 00:00:00 2001
2From: Christoph Hellwig <hch@lst.de>
3Date: Sat, 5 Sep 2009 21:42:42 -0400
4Subject: [PATCH 16/85] ext4: fix cache flush in ext4_sync_file
5
6(cherry picked from commit 5f3481e9a80c240f169b36ea886e2325b9aeb745)
7
8We need to flush the write cache unconditionally in ->fsync, otherwise
9writes into already allocated blocks can get lost. Writes into fully
10allocated files are very common when using disk images for
11virtualization, and without this fix can easily lose data after
12an fdatasync, which is the typical implementation for a cache flush on
13the virtual drive.
14
15Signed-off-by: Christoph Hellwig <hch@lst.de>
16Acked-by: Eric Sandeen <sandeen@redhat.com>
17Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
18---
19 fs/ext4/fsync.c | 4 ++--
20 1 file changed, 2 insertions(+), 2 deletions(-)
21
22--- a/fs/ext4/fsync.c
23+++ b/fs/ext4/fsync.c
24@@ -92,9 +92,9 @@ int ext4_sync_file(struct file *file, st
25 .nr_to_write = 0, /* sys_fsync did this */
26 };
27 ret = sync_inode(inode, &wbc);
28- if (journal && (journal->j_flags & JBD2_BARRIER))
29- blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
30 }
31 out:
32+ if (journal && (journal->j_flags & JBD2_BARRIER))
33+ blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
34 return ret;
35 }