Skip to content

Commit c2bff94

Browse files
ayushr2gvisor-bot
authored andcommitted
gofer: Flush lisafs FDs on inode destruction in shared interop mode.
When the gofer filesystem is in `InteropModeShared`, immediately flush the `Close` RPC for inode FDs upon inode destruction. This prevents caching of file descriptors on the server, which could block external processes from unmounting or releasing disk space. The existing behavior of flushing for deleted regular files is preserved. PiperOrigin-RevId: 819357479
1 parent b2b828e commit c2bff94

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/sentry/fsimpl/gofer/lisafs_inode.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,15 @@ func (i *lisafsInode) destroy(ctx context.Context, d *dentry) {
333333
i.writeFDLisa.Close(ctx, false /* flush */)
334334
}
335335
if i.controlFD.Ok() {
336-
// Close the control FD. Propagate the Close RPCs immediately to the server
337-
// if the dentry being destroyed is a deleted regular file. This is to
338-
// release the disk space on remote immediately. This will flush the above
339-
// read/write lisa FDs as well.
340-
flushClose := d.isDeleted() && i.isRegularFile()
336+
// Close the control FD.
337+
// Propagate the Close RPCs immediately to the server if:
338+
// - The dentry being destroyed is a deleted regular file. This is to
339+
// release the disk space on remote immediately.
340+
// - The filesystem is shared with external writers, who may try to delete
341+
// files and attempt to unmount the filesystem. gVisor should not be
342+
// caching FDs here as it would prevent external cleanup.
343+
// This will flush the Close RPCs for read/write lisa FDs above as well.
344+
flushClose := i.fs.opts.interop == InteropModeShared || (d.isDeleted() && i.isRegularFile())
341345
i.controlFD.Close(ctx, flushClose)
342346
}
343347
}

0 commit comments

Comments
 (0)