Skip to content

Commit 25f51ea

Browse files
fatherMatrixtytso
authored andcommitted
ext4: disambiguate the return value of ext4_dio_write_end_io()
The commit 9156289 ("ext4: properly sync file size update after O_SYNC direct IO") causes confusion about the meaning of the return value of ext4_dio_write_end_io(). Specifically, when the ext4_handle_inode_extension() operation succeeds, ext4_dio_write_end_io() directly returns count instead of 0. This does not cause a bug in the current kernel, but the semantics of the return value of the ext4_dio_write_end_io() function are wrong, which is likely to introduce bugs in the future code evolution. Signed-off-by: Jinliang Zheng <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 813f853 commit 25f51ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/ext4/file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ static int ext4_dio_write_end_io(struct kiocb *iocb, ssize_t size,
392392
*/
393393
if (pos + size <= READ_ONCE(EXT4_I(inode)->i_disksize) &&
394394
pos + size <= i_size_read(inode))
395-
return size;
396-
return ext4_handle_inode_extension(inode, pos, size, size);
395+
return 0;
396+
error = ext4_handle_inode_extension(inode, pos, size, size);
397+
return error < 0 ? error : 0;
397398
}
398399

399400
static const struct iomap_dio_ops ext4_dio_write_ops = {

0 commit comments

Comments
 (0)