Skip to content

Commit ad211f3

Browse files
committed
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
1 parent e868078 commit ad211f3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/ext4/fsync.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,23 @@ 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+
119123
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);
121129
if (!ret)
122130
ret = ext4_sync_parent(inode);
123131
if (test_opt(inode->i_sb, BARRIER))
124132
goto issue_flush;
125133
goto out;
126134
}
127135

128-
ret = file_write_and_wait_range(file, start, end);
129-
if (ret)
130-
return ret;
131136
/*
132137
* data=writeback,ordered:
133138
* The caller's filemap_fdatawrite()/wait will sync the data.

0 commit comments

Comments
 (0)