diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2023-09-13 18:28:15 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2023-09-13 18:29:50 +0200 |
commit | f6038a23064020ab60ddb6cb19affb59d39036f7 (patch) | |
tree | ab38a5bb731130e35af32ebd11e0d1dddf1359fe | |
parent | f1622b4f67fd8e962e21d09e7f8cf50f3972eb75 (diff) | |
download | linux-f6038a23064020ab60ddb6cb19affb59d39036f7.tar.gz |
direct_write_fallback(): on error revert the ->ki_pos update from buffered write
If we fail filemap_write_and_wait_range() on the range the buffered write went
into, we only report the "number of bytes which we direct-written", to quote
the comment in there. Which is fine, but buffered write has already advanced
iocb->ki_pos, so we need to roll that back. Otherwise we end up with e.g.
write(2) advancing position by more than the amount it reports having written.
Fixes: 182c25e9c157 "filemap: update ki_pos in generic_perform_write"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Message-Id: <20230827214518.GU3390869@ZenIV>
Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r-- | fs/libfs.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index a4eb1275788627..37f2d34ee090bd 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1903,6 +1903,7 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter, * We don't know how much we wrote, so just return the number of * bytes which were direct-written */ + iocb->ki_pos -= buffered_written; if (direct_written) return direct_written; return err; |