diff options
author | Christoph Hellwig <hch@lst.de> | 2009-09-05 21:42:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-14 08:06:20 -0800 |
commit | 2a8af5d4d0f69036fc02e91642f862e473350143 (patch) | |
tree | 0d2f423bd3acfa772036a0a0c056f09e48297b4f /fs | |
parent | 63762a2387882e4ff8ae77133b331abef8e6f555 (diff) |
ext4: fix cache flush in ext4_sync_file
(cherry picked from commit 5f3481e9a80c240f169b36ea886e2325b9aeb745)
We need to flush the write cache unconditionally in ->fsync, otherwise
writes into already allocated blocks can get lost. Writes into fully
allocated files are very common when using disk images for
virtualization, and without this fix can easily lose data after
an fdatasync, which is the typical implementation for a cache flush on
the virtual drive.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/fsync.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 83cf6415f59..ab418c0f502 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c @@ -92,9 +92,9 @@ int ext4_sync_file(struct file *file, struct dentry *dentry, int datasync) .nr_to_write = 0, /* sys_fsync did this */ }; ret = sync_inode(inode, &wbc); - if (journal && (journal->j_flags & JBD2_BARRIER)) - blkdev_issue_flush(inode->i_sb->s_bdev, NULL); } out: + if (journal && (journal->j_flags & JBD2_BARRIER)) + blkdev_issue_flush(inode->i_sb->s_bdev, NULL); return ret; } |