Rebase to 2.6.26-rc8
[ext4-patch-queue.git] / ext4-call-blkdev_issue_flush-on-fsync.patch
blob61a66e69886c3d2cfc7429e7c628a958f1e4938f
1 ext4: call blkdev_issue_flush on fsync
3 From: Eric Sandeen <sandeen@redhat.com>
5 To ensure that bits are truly on-disk after an fsync,
6 we should call blkdev_issue_flush if barriers are supported.
8 Inspired by an old thread on barriers, by reiserfs & xfs
9 which do the same, and by a patch SuSE ships with their kernel
11 Signed-off-by: Eric Sandeen <sandeen@redhat.com>
12 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
13 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
14 ---
15 fs/ext4/fsync.c | 4 ++++
16 1 file changed, 4 insertions(+)
18 Index: linux-2.6.26-rc6/fs/ext4/fsync.c
19 ===================================================================
20 --- linux-2.6.26-rc6.orig/fs/ext4/fsync.c 2008-06-17 10:43:18.000000000 -0700
21 +++ linux-2.6.26-rc6/fs/ext4/fsync.c 2008-06-17 10:43:32.000000000 -0700
22 @@ -27,6 +27,7 @@
23 #include <linux/sched.h>
24 #include <linux/writeback.h>
25 #include <linux/jbd2.h>
26 +#include <linux/blkdev.h>
27 #include "ext4.h"
28 #include "ext4_jbd2.h"
30 @@ -45,6 +46,7 @@
31 int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync)
33 struct inode *inode = dentry->d_inode;
34 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
35 int ret = 0;
37 J_ASSERT(ext4_journal_current_handle() == NULL);
38 @@ -85,6 +87,8 @@ int ext4_sync_file(struct file * file, s
39 .nr_to_write = 0, /* sys_fsync did this */
41 ret = sync_inode(inode, &wbc);
42 + if (journal && (journal->j_flags & JBD2_BARRIER))
43 + blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
45 out:
46 return ret;