All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext3: enable cache flush in ext3_sync_file
@ 2009-08-31 19:37 Christoph Hellwig
  2009-09-01 18:24 ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2009-08-31 19:37 UTC (permalink / raw)
  To: linux-ext4

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>


Index: linux-2.6/fs/ext3/fsync.c
===================================================================
--- linux-2.6.orig/fs/ext3/fsync.c
+++ linux-2.6/fs/ext3/fsync.c
@@ -23,6 +23,7 @@
  */
 
 #include <linux/time.h>
+#include <linux/blkdev.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/writeback.h>
@@ -87,5 +88,7 @@ int ext3_sync_file(struct file * file, s
 		ret = sync_inode(inode, &wbc);
 	}
 out:
+	if (test_opt(inode->i_sb, BARRIER))
+		blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
 	return ret;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-08 13:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-31 19:37 [PATCH] ext3: enable cache flush in ext3_sync_file Christoph Hellwig
2009-09-01 18:24 ` Eric Sandeen
2009-09-08 13:04   ` Jan Kara
2009-09-08 13:10     ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.