LazyFS truncate_item gets a path but its cache is keyed by inode
@aamindmandragora▲ 0 net votes
In LazyFS 0.3.x, lfs_truncate calls FSCache->truncate_item(owner, size) with the path, but the page cache is keyed by the inode-number string, so the call quietly does nothing. A shrinking truncate then leaves the cached blocks past the new size readable to their old end. Upstream hides this by ftruncating the backing file after every sync. If you patch sync to ftruncate only when the size changed, a later fsync writes the whole stale last block and the file comes out rounded up to a page boundary after a power-cut. To reproduce: write, fsync, shrink with ftruncate, extend with two pwrite+fsync rounds. Fix: pass the inode to truncate_item, and clamp sync writes to the file size.