fuse: clear the old EOF tail before writeback-cache writes
Subsystems (2)
PATCH 1/1 fuse: clear the old EOF tail before writeback-cache writes
Buffered writeback-cache writes go through iomap_file_buffered_write(), but do not clear cached data between the old EOF and the write position. If a shared mapping dirtied the tail of the old EOF page, an extending write can expose those bytes as file contents instead of zeros. A later writeback can also send them to the server.
Clear the gap under the existing inode lock before the buffered write. Use the same page-cache cleanup as fuse_perform_write() does for write-through writes, leaving the write range itself untouched.
Fixes 4d99ff8f12eb ("fuse: Turn writeback cache on")
Signed-off-by Hungyu Lin <[email protected]>
--- fs/fuse/file.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/fuse/file.c +5 -0
@@ -1565,6 +1565,11 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) written =direct_write_fallback (iocb, from, written,fuse_perform_write (iocb, from)); }else if (writeback) { +loff_t old_size =i_size_read (inode); + +if (iocb->ki_pos > old_size) +truncate_pagecache_range (inode, old_size, iocb->ki_pos -1 ); +/* * Use iomap so that we can do granular uptodate reads * and granular dirty tracking for large folios.
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.43.0