diff options
author | Jinliang Zheng <alexjlzheng@tencent.com> | 2024-09-19 10:25:39 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2024-11-13 05:54:14 +0100 |
commit | 25f51ea8ac8144af2fefb743c3439547610368ff (patch) | |
tree | 572ff8922f99044e71639799628bb1b54fb292ac /fs/ext4 | |
parent | ext4: pass write-hint for buffered IO (diff) | |
download | linux-25f51ea8ac8144af2fefb743c3439547610368ff.tar.xz linux-25f51ea8ac8144af2fefb743c3439547610368ff.zip |
ext4: disambiguate the return value of ext4_dio_write_end_io()
The commit 91562895f803 ("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 <alexjlzheng@tencent.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20240919082539.381626-1-alexjlzheng@tencent.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/file.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 23005f1345a8..8e9dfed1c34c 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -392,8 +392,9 @@ static int ext4_dio_write_end_io(struct kiocb *iocb, ssize_t size, */ if (pos + size <= READ_ONCE(EXT4_I(inode)->i_disksize) && pos + size <= i_size_read(inode)) - return size; - return ext4_handle_inode_extension(inode, pos, size, size); + return 0; + error = ext4_handle_inode_extension(inode, pos, size, size); + return error < 0 ? error : 0; } static const struct iomap_dio_ops ext4_dio_write_ops = { |