From 851188164274de96cd581c3da1b5e847a42e2948 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 11 Nov 2026 21:22:00 +0100 Subject: fusefrontend: -sharedstorage: always check for file holes on write Write() skips writePadHole() when a write directly follows the previous one (isConsecutiveWrite), because such a write cannot create a hole. That decision is based on process-local state. With -sharedstorage, another mount may have shrunk the file in between, so the old partial last block was never padded and ended up as a short block in the middle of the file, making it unreadable (EIO). Disable the optimization with -sharedstorage. Add TestConsecutiveWriteAfterRemoteTruncate as a regression test. Co-Authored-By: Claude Opus 5.5 --- internal/fusefrontend/file.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'internal/fusefrontend') diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index fb97b9a..feb40b5 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -431,7 +431,9 @@ func (f *File) Write(ctx context.Context, data []byte, off int64) (uint32, sysca // If the write creates a file hole, we have to zero-pad the last block. // But if the write directly follows an earlier write, it cannot create a // hole, and we can save one Stat() call. - if !f.isConsecutiveWrite(off) { + // With -sharedstorage, another mount may have truncated the file since our + // last write, so we have to check every time. + if f.rootNode.args.SharedStorage || !f.isConsecutiveWrite(off) { errno := f.writePadHole(off) if errno != 0 { return 0, errno -- cgit v1.2.3