* [PATCH] ext4: fix cache flish in ext4_sync_file
@ 2009-08-31 19:35 Christoph Hellwig
2009-09-01 18:23 ` Eric Sandeen
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2009-08-31 19:35 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/ext4/fsync.c
===================================================================
--- linux-2.6.orig/fs/ext4/fsync.c
+++ linux-2.6/fs/ext4/fsync.c
@@ -92,9 +92,9 @@ int ext4_sync_file(struct file *file, st
.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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: fix cache flish in ext4_sync_file
2009-08-31 19:35 [PATCH] ext4: fix cache flish in ext4_sync_file Christoph Hellwig
@ 2009-09-01 18:23 ` Eric Sandeen
2009-09-06 1:43 ` Theodore Tso
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2009-09-01 18:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-ext4
Christoph Hellwig wrote:
> 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>
Fixing my old commit, I guess ;)
Seems right to me
Acked-by: Eric Sandeen <sandeen@redhat.com>
> Index: linux-2.6/fs/ext4/fsync.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/fsync.c
> +++ linux-2.6/fs/ext4/fsync.c
> @@ -92,9 +92,9 @@ int ext4_sync_file(struct file *file, st
> .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;
> }
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: fix cache flish in ext4_sync_file
2009-09-01 18:23 ` Eric Sandeen
@ 2009-09-06 1:43 ` Theodore Tso
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Tso @ 2009-09-06 1:43 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Christoph Hellwig, linux-ext4
On Tue, Sep 01, 2009 at 01:23:27PM -0500, Eric Sandeen wrote:
> Christoph Hellwig wrote:
> > 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>
>
> Fixing my old commit, I guess ;)
Added to the ext4 patch queue (with the "flish" corrected to "flush")
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-06 1:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-31 19:35 [PATCH] ext4: fix cache flish in ext4_sync_file Christoph Hellwig
2009-09-01 18:23 ` Eric Sandeen
2009-09-06 1:43 ` Theodore Tso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).