diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-02-09 15:18:09 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-02-09 15:18:09 -0500 |
commit | d311d79de305f1ada47cadd672e6ed1b28a949eb (patch) | |
tree | ed5fe40264a27e1d8cc4410352585dfb34af50d8 /fs/ext4/file.c | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
fix O_SYNC|O_APPEND syncing the wrong range on write()
It actually goes back to 2004 ([PATCH] Concurrent O_SYNC write support)
when sync_page_range() had been introduced; generic_file_write{,v}() correctly
synced
pos_after_write - written .. pos_after_write - 1
but generic_file_aio_write() synced
pos_before_write .. pos_before_write + written - 1
instead. Which is not the same thing with O_APPEND, obviously.
A couple of years later correct variant had been killed off when
everything switched to use of generic_file_aio_write().
All users of generic_file_aio_write() are affected, and the same bug
has been copied into other instances of ->aio_write().
The fix is trivial; the only subtle point is that generic_write_sync()
ought to be inlined to avoid calculations useless for the majority of
calls.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r-- | fs/ext4/file.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 43e64f6022eb..1a5073959f32 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -152,7 +152,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, | |||
152 | if (ret > 0) { | 152 | if (ret > 0) { |
153 | ssize_t err; | 153 | ssize_t err; |
154 | 154 | ||
155 | err = generic_write_sync(file, pos, ret); | 155 | err = generic_write_sync(file, iocb->ki_pos - ret, ret); |
156 | if (err < 0 && ret > 0) | 156 | if (err < 0 && ret > 0) |
157 | ret = err; | 157 | ret = err; |
158 | } | 158 | } |