]>
Commit | Line | Data |
---|---|---|
7f041dd7 GKH |
1 | From 889c3508467677a534209736351f028a5b925cc2 Mon Sep 17 00:00:00 2001 |
2 | From: Christoph Hellwig <hch@lst.de> | |
3 | Date: Sat, 5 Sep 2009 21:42:42 -0400 | |
4 | Subject: [PATCH 16/85] ext4: fix cache flush in ext4_sync_file | |
5 | ||
6 | (cherry picked from commit 5f3481e9a80c240f169b36ea886e2325b9aeb745) | |
7 | ||
8 | We need to flush the write cache unconditionally in ->fsync, otherwise | |
9 | writes into already allocated blocks can get lost. Writes into fully | |
10 | allocated files are very common when using disk images for | |
11 | virtualization, and without this fix can easily lose data after | |
12 | an fdatasync, which is the typical implementation for a cache flush on | |
13 | the virtual drive. | |
14 | ||
15 | Signed-off-by: Christoph Hellwig <hch@lst.de> | |
16 | Acked-by: Eric Sandeen <sandeen@redhat.com> | |
17 | Signed-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 | } |