aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2018-12-31 00:10:48 -0500
committerTheodore Ts'o <tytso@mit.edu>2018-12-31 00:10:48 -0500
commitad211f3e94b314a910d4af03178a0b52a7d1ee0a (patch)
tree1085f5cc536507cb1ee937e35ee6fe4d732f3993
parente86807862e6880809f191c4cea7f88a489f0ed34 (diff)
ext4: use ext4_write_inode() when fsyncing w/o a journal
In no-journal mode, we previously used __generic_file_fsync() in no-journal mode. This triggers a lockdep warning, and in addition, it's not safe to depend on the inode writeback mechanism in the case ext4. We can solve both problems by calling ext4_write_inode() directly. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
-rw-r--r--fs/ext4/fsync.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 26a7fe5c4fd3..87a7ff00ef62 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -116,8 +116,16 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
116 goto out; 116 goto out;
117 } 117 }
118 118
119 ret = file_write_and_wait_range(file, start, end);
120 if (ret)
121 return ret;
122
119 if (!journal) { 123 if (!journal) {
120 ret = __generic_file_fsync(file, start, end, datasync); 124 struct writeback_control wbc = {
125 .sync_mode = WB_SYNC_ALL
126 };
127
128 ret = ext4_write_inode(inode, &wbc);
121 if (!ret) 129 if (!ret)
122 ret = ext4_sync_parent(inode); 130 ret = ext4_sync_parent(inode);
123 if (test_opt(inode->i_sb, BARRIER)) 131 if (test_opt(inode->i_sb, BARRIER))
@@ -125,9 +133,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
125 goto out; 133 goto out;
126 } 134 }
127 135
128 ret = file_write_and_wait_range(file, start, end);
129 if (ret)
130 return ret;
131 /* 136 /*
132 * data=writeback,ordered: 137 * data=writeback,ordered:
133 * The caller's filemap_fdatawrite()/wait will sync the data. 138 * The caller's filemap_fdatawrite()/wait will sync the data.