mount: fence the inode when its last handle drops uncommitted content

A synchronous release whose final flush fails destroys the handle's dirty
pages, while under writeback the kernel EOF already counts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-11-13 23:28:08 -08:00
1 parent ffa519973d
commit 4a75f2caa8
2 files changed
+48

No files matched your search

+45
View File
@@ -123,6 +123,51 @@ func TestAbandonedWritebackFlushFencesInode(t *testing.T) {
}
}
func TestFailedFlockReleaseFencesInode(t *testing.T) {
originalSleep := metadataFlushSleep
t.Cleanup(func() {
metadataFlushSleep = originalSleep
})
metadataFlushSleep = func(ctx context.Context, d time.Duration) {}
const name = "flock-release.log"
wfs, _ := newCreateTestWFS(t)
wfs.posixLocks = NewPosixLockTable()
fake := &rejectingCreateFiler{rejections: 1 << 20, refuse: func(req *filer_pb.CreateEntryRequest) (*filer_pb.CreateEntryResponse, error) {
return nil, status.Error(codes.PermissionDenied, "denied")
}}
startFakeFiler(t, wfs, fake)
out := &fuse.CreateOut{}
if code := wfs.Create(make(chan struct{}), &fuse.CreateIn{
InHeader: fuse.InHeader{NodeId: 1},
Flags: syscall.O_WRONLY | syscall.O_CREAT,
Mode: 0o644,
}, name, out); code != fuse.OK {
t.Fatalf("Create status = %v, want OK", code)
}
fh := wfs.GetHandle(FileHandleId(out.Fh))
if fh == nil {
t.Fatal("Create did not register an open file handle")
}
wfs.option.WritebackCache = true
fenced := new(atomic.Bool)
fh.writebackContentError = fenced
fh.dirtyMetadata = true
wfs.Release(make(chan struct{}), &fuse.ReleaseIn{
InHeader: fuse.InHeader{NodeId: out.NodeId},
Fh: out.Fh,
ReleaseFlags: fuse.FUSE_RELEASE_FLOCK_UNLOCK,
})
if fake.calls.Load() == 0 {
t.Fatal("synchronous release did not attempt the flush")
}
if !fenced.Load() {
t.Fatal("release dropped uncommitted writeback content without fencing the inode")
}
}
func TestIsFilerUnreachable(t *testing.T) {
path := "/unavailable/transport.log"
cases := []struct {
+3
View File
@@ -183,6 +183,9 @@ func (wfs *WFS) ReleaseHandle(handleId FileHandleId) {
wfs.pendingAsyncFlushMu.Unlock()
if fhToRelease != nil {
if fhToRelease.dirtyMetadata && !fhToRelease.isDeleted {
(&contentPublication{failure: fhToRelease.writebackContentError}).abandon()
}
fhToRelease.ReleaseHandle()
}
}