Skip to content

Commit 8fdd60f

Browse files
committed
Revert "ext4: use ext4_write_inode() when fsyncing w/o a journal"
This reverts commit ad211f3. As Jan Kara pointed out, this change was unsafe since it means we lose the call to sync_mapping_buffers() in the nojournal case. The original point of the commit was avoid taking the inode mutex (since it causes a lockdep warning in generic/113); but we need the mutex in order to call sync_mapping_buffers(). The real fix to this problem was discussed here: https://lore.kernel.org/lkml/20181025150540.259281-4-bvanassche@acm.org The proposed patch was to fix a syzbot complaint, but the problem can also demonstrated via "kvm-xfstests -c nojournal generic/113". Multiple solutions were discused in the e-mail thread, but none have landed in the kernel as of this writing. Anyway, commit ad211f3 is absolutely the wrong way to suppress the lockdep, so revert it. Fixes: ad211f3 ("ext4: use ext4_write_inode() when fsyncing w/o a journal") Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reported: Jan Kara <jack@suse.cz>
1 parent 49a5785 commit 8fdd60f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fs/ext4/fsync.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,18 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
116116
goto out;
117117
}
118118

119-
ret = file_write_and_wait_range(file, start, end);
120-
if (ret)
121-
return ret;
122-
123119
if (!journal) {
124-
struct writeback_control wbc = {
125-
.sync_mode = WB_SYNC_ALL
126-
};
127-
128-
ret = ext4_write_inode(inode, &wbc);
120+
ret = __generic_file_fsync(file, start, end, datasync);
129121
if (!ret)
130122
ret = ext4_sync_parent(inode);
131123
if (test_opt(inode->i_sb, BARRIER))
132124
goto issue_flush;
133125
goto out;
134126
}
135127

128+
ret = file_write_and_wait_range(file, start, end);
129+
if (ret)
130+
return ret;
136131
/*
137132
* data=writeback,ordered:
138133
* The caller's filemap_fdatawrite()/wait will sync the data.

0 commit comments

Comments
 (0)