gvisor icon indicating copy to clipboard operation
gvisor copied to clipboard

Passthru more open flags to gofers

Open fvoznika opened this issue 4 years ago • 7 comments

Flags like O_NOATIME and O_DIRECT need to be passed to the gofer, otherwise they will have no effect to the underlying file (for the filesystems that support them). Apart from file mode, the only flag passed currently is O_TRUNC.

It will likely require a version bump in the gofer.

fvoznika avatar Aug 13 '20 23:08 fvoznika

Dropping from milestone since this is general FS improvement, not specific to VFS2.

fvoznika avatar Jan 19 '21 19:01 fvoznika

@fvoznika We should also be passing O_SYNC to the gofer right?

ayushr2 avatar Feb 28 '21 20:02 ayushr2

O_SYNC needs to be handled by goferfs to flush dirty cache pages. It could be added to save the extra syncRemoteFile() call, but it needs to account for gofers that are not file backed. So not worth until someone actually needs it.

fvoznika avatar Mar 02 '21 02:03 fvoznika

Supporting the passing of O_NOATIME and O_DIRECT would require more complex handle sharing in the gofer client. Currently all reads and writes for an FD go through the backing dentry's read and write handles. I think that has been done to avoid excessive Open RPCs on the same dentry. We would have to special case FDs that are opened with flags like O_NOATIME and O_DIRECT and have special handles for such FDs that were initially opened on remote FS with the right flags.

ayushr2 avatar Mar 05 '21 05:03 ayushr2

Note that another level of complexity is that O_DIRECT and O_NOATIME flags can change on an FD via fcntl(F_SETFL). See vfs.SetStatusFlags(). Those flags are only changed on the VFS level. We would have to implement a filesystem hook for file description status flag updates and re-open the handle appropriately if the flags in question have changed.

ayushr2 avatar Mar 06 '21 17:03 ayushr2

Yes it would require keeping extra files for the different options. When a file is being open, it would need to check open flags against other open files to try to find one that is compatible. If none are found, creates a new one an add to the list of open files to be matched.

fcntl(2) complicate things a bit :-( It could just ignore them, like we do today. Or reopen the backing file with the new options. This is transparent to the application.

fvoznika avatar Mar 10 '21 20:03 fvoznika

Any update on this issue? I'm looking to benchmark gVisor to other runtimes, but I keep running into O_DIRECT flag issue. Other studies seem to be able to pypass this issue, but I cannot figure how they did it.

WillemDendauw avatar May 05 '22 09:05 WillemDendauw