diff options
author | Eric Sandeen <sandeen@redhat.com> | 2008-07-11 19:27:31 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-07-11 19:27:31 -0400 |
commit | d755fb384250d6bd7fd18a0930e71965acc8e72e (patch) | |
tree | 7913bce90918cd26c8a5fe05f6c8943828e333bb /fs/ext4/fsync.c | |
parent | 654b4908bc17a6318d18f3036fecc5155de92f55 (diff) |
ext4: call blkdev_issue_flush on fsync
To ensure that bits are truly on-disk after an fsync,
we should call blkdev_issue_flush if barriers are supported.
Inspired by an old thread on barriers, by reiserfs & xfs
which do the same, and by a patch SuSE ships with their kernel
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/fsync.c')
-rw-r--r-- | fs/ext4/fsync.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 1c8ba48d4f8d..a45c3737ad31 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
28 | #include <linux/writeback.h> | 28 | #include <linux/writeback.h> |
29 | #include <linux/jbd2.h> | 29 | #include <linux/jbd2.h> |
30 | #include <linux/blkdev.h> | ||
30 | #include "ext4.h" | 31 | #include "ext4.h" |
31 | #include "ext4_jbd2.h" | 32 | #include "ext4_jbd2.h" |
32 | 33 | ||
@@ -45,6 +46,7 @@ | |||
45 | int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync) | 46 | int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync) |
46 | { | 47 | { |
47 | struct inode *inode = dentry->d_inode; | 48 | struct inode *inode = dentry->d_inode; |
49 | journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; | ||
48 | int ret = 0; | 50 | int ret = 0; |
49 | 51 | ||
50 | J_ASSERT(ext4_journal_current_handle() == NULL); | 52 | J_ASSERT(ext4_journal_current_handle() == NULL); |
@@ -85,6 +87,8 @@ int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync) | |||
85 | .nr_to_write = 0, /* sys_fsync did this */ | 87 | .nr_to_write = 0, /* sys_fsync did this */ |
86 | }; | 88 | }; |
87 | ret = sync_inode(inode, &wbc); | 89 | ret = sync_inode(inode, &wbc); |
90 | if (journal && (journal->j_flags & JBD2_BARRIER)) | ||
91 | blkdev_issue_flush(inode->i_sb->s_bdev, NULL); | ||
88 | } | 92 | } |
89 | out: | 93 | out: |
90 | return ret; | 94 | return ret; |