Skip to contentSkip to conversation

fuse: fix possible write position calculation error

PATCH New Peng Hao 1 participant 1 message Oct 26, 2021

Subsystems (2)
lore
Share & tools
lore

Peng Hao

author
#0 lore raw

PATCH 1/1 fuse: fix possible write position calculation error

The 'written' that generic_file_direct_write return through filemap_write_and_wait_range is not necessarily sequential, and its iocb->ki_pos has not been updated.

---
 fs/fuse/file.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/fuse/file.c +2 -4
index 26730e699d68..52aaa1fb484d 100644
@@ -1314,14 +1314,12 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
 		goto out;
 
 	if (iocb->ki_flags & IOCB_DIRECT) {
-		loff_t pos = iocb->ki_pos;
+		loff_t pos;
 		written = generic_file_direct_write(iocb, from);
 		if (written < 0 || !iov_iter_count(from))
 			goto out;
 
-		pos += written;
-
-		written_buffered = fuse_perform_write(iocb, mapping, from, pos);
+		written_buffered = fuse_perform_write(iocb, mapping, from, pos = iocb->ki_pos);
 		if (written_buffered < 0) {
 			err = written_buffered;
 			goto out;
Signature · 1 line
2.27.0