add patch track-more-dependencies-on-transaction-commit
[ext4-patch-queue.git] / respect-nobarrier-mount-option-in-nojournal-mode
blob162bca539777a0cb76be5229e3936d9abda7248e
1 ext4: respect the nobarrier mount option in nojournal mode
3 Also, if we are going to issue the barrier, we should do this after we
4 write out the parent directories if necessary.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 Reviewed-by: Jan Kara <jack@suse.cz>
8 ---
9  fs/ext4/fsync.c | 5 ++++-
10  1 file changed, 4 insertions(+), 1 deletion(-)
12 diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
13 index 8850254..5c43725 100644
14 --- a/fs/ext4/fsync.c
15 +++ b/fs/ext4/fsync.c
16 @@ -106,9 +106,11 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
17         }
19         if (!journal) {
20 -               ret = generic_file_fsync(file, start, end, datasync);
21 +               ret = __generic_file_fsync(file, start, end, datasync);
22                 if (!ret && !hlist_empty(&inode->i_dentry))
23                         ret = ext4_sync_parent(inode);
24 +               if (test_opt(inode->i_sb, BARRIER))
25 +                       goto issue_flush;
26                 goto out;
27         }
29 @@ -140,6 +142,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
30                 needs_barrier = true;
31         ret = jbd2_complete_transaction(journal, commit_tid);
32         if (needs_barrier) {
33 +       issue_flush:
34                 err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
35                 if (!ret)
36                         ret = err;