diff options
-rw-r--r-- | fs/ext4/fsync.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 60fe5721fbe3..ce66d2fe826c 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c | |||
@@ -172,6 +172,7 @@ int ext4_sync_file(struct file *file, int datasync) | |||
172 | journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; | 172 | journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; |
173 | int ret; | 173 | int ret; |
174 | tid_t commit_tid; | 174 | tid_t commit_tid; |
175 | bool needs_barrier = false; | ||
175 | 176 | ||
176 | J_ASSERT(ext4_journal_current_handle() == NULL); | 177 | J_ASSERT(ext4_journal_current_handle() == NULL); |
177 | 178 | ||
@@ -211,22 +212,12 @@ int ext4_sync_file(struct file *file, int datasync) | |||
211 | } | 212 | } |
212 | 213 | ||
213 | commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid; | 214 | commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid; |
214 | if (jbd2_log_start_commit(journal, commit_tid)) { | 215 | if (journal->j_flags & JBD2_BARRIER && |
215 | /* | 216 | !jbd2_trans_will_send_data_barrier(journal, commit_tid)) |
216 | * When the journal is on a different device than the | 217 | needs_barrier = true; |
217 | * fs data disk, we need to issue the barrier in | 218 | jbd2_log_start_commit(journal, commit_tid); |
218 | * writeback mode. (In ordered mode, the jbd2 layer | 219 | ret = jbd2_log_wait_commit(journal, commit_tid); |
219 | * will take care of issuing the barrier. In | 220 | if (needs_barrier) |
220 | * data=journal, all of the data blocks are written to | ||
221 | * the journal device.) | ||
222 | */ | ||
223 | if (ext4_should_writeback_data(inode) && | ||
224 | (journal->j_fs_dev != journal->j_dev) && | ||
225 | (journal->j_flags & JBD2_BARRIER)) | ||
226 | blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, | ||
227 | NULL); | ||
228 | ret = jbd2_log_wait_commit(journal, commit_tid); | ||
229 | } else if (journal->j_flags & JBD2_BARRIER) | ||
230 | blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); | 221 | blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); |
231 | out: | 222 | out: |
232 | trace_ext4_sync_file_exit(inode, ret); | 223 | trace_ext4_sync_file_exit(inode, ret); |