mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Decouple file_handle_sharing and cache settings in the gofer client.
Earlier, both these settings were controlled by the cache= option. Only cache_none was able to disable file handle sharing. But there can be cases where we want the FS cache but disable file handle sharing. Instead of adding yet another cache enum, decouple these settings so they can be set independently. As a result, we don't need cache_none anymore, get rid of it. PiperOrigin-RevId: 518780704
This commit is contained in:
@@ -1736,11 +1736,10 @@ func (fs *filesystem) MountOptions() string {
|
||||
case InteropModeWritethrough:
|
||||
optsKV = append(optsKV, mopt{moptCache, cacheFSCacheWritethrough})
|
||||
case InteropModeShared:
|
||||
if fs.opts.regularFilesUseSpecialFileFD {
|
||||
optsKV = append(optsKV, mopt{moptCache, cacheNone})
|
||||
} else {
|
||||
optsKV = append(optsKV, mopt{moptCache, cacheRemoteRevalidating})
|
||||
}
|
||||
optsKV = append(optsKV, mopt{moptCache, cacheRemoteRevalidating})
|
||||
}
|
||||
if fs.opts.regularFilesUseSpecialFileFD {
|
||||
optsKV = append(optsKV, mopt{moptDisableFileHandleSharing, nil})
|
||||
}
|
||||
if fs.opts.forcePageCache {
|
||||
optsKV = append(optsKV, mopt{moptForcePageCache, nil})
|
||||
|
||||
@@ -73,16 +73,17 @@ const Name = "9p"
|
||||
|
||||
// Mount option names for goferfs.
|
||||
const (
|
||||
moptTransport = "trans"
|
||||
moptReadFD = "rfdno"
|
||||
moptWriteFD = "wfdno"
|
||||
moptAname = "aname"
|
||||
moptDfltUID = "dfltuid"
|
||||
moptDfltGID = "dfltgid"
|
||||
moptCache = "cache"
|
||||
moptForcePageCache = "force_page_cache"
|
||||
moptLimitHostFDTranslation = "limit_host_fd_translation"
|
||||
moptOverlayfsStaleRead = "overlayfs_stale_read"
|
||||
moptTransport = "trans"
|
||||
moptReadFD = "rfdno"
|
||||
moptWriteFD = "wfdno"
|
||||
moptAname = "aname"
|
||||
moptDfltUID = "dfltuid"
|
||||
moptDfltGID = "dfltgid"
|
||||
moptCache = "cache"
|
||||
moptForcePageCache = "force_page_cache"
|
||||
moptLimitHostFDTranslation = "limit_host_fd_translation"
|
||||
moptOverlayfsStaleRead = "overlayfs_stale_read"
|
||||
moptDisableFileHandleSharing = "disable_file_handle_sharing"
|
||||
|
||||
// Directfs options.
|
||||
moptDirectfs = "directfs"
|
||||
@@ -90,7 +91,6 @@ const (
|
||||
|
||||
// Valid values for the "cache" mount option.
|
||||
const (
|
||||
cacheNone = "none"
|
||||
cacheFSCache = "fscache"
|
||||
cacheFSCacheWritethrough = "fscache_writethrough"
|
||||
cacheRemoteRevalidating = "remote_revalidating"
|
||||
@@ -422,9 +422,6 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt
|
||||
fsopts.interop = InteropModeExclusive
|
||||
case cacheFSCacheWritethrough:
|
||||
fsopts.interop = InteropModeWritethrough
|
||||
case cacheNone:
|
||||
fsopts.regularFilesUseSpecialFileFD = true
|
||||
fallthrough
|
||||
case cacheRemoteRevalidating:
|
||||
fsopts.interop = InteropModeShared
|
||||
default:
|
||||
@@ -459,6 +456,10 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt
|
||||
}
|
||||
|
||||
// Handle simple flags.
|
||||
if _, ok := mopts[moptDisableFileHandleSharing]; ok {
|
||||
delete(mopts, moptDisableFileHandleSharing)
|
||||
fsopts.regularFilesUseSpecialFileFD = true
|
||||
}
|
||||
if _, ok := mopts[moptForcePageCache]; ok {
|
||||
delete(mopts, moptForcePageCache)
|
||||
fsopts.forcePageCache = true
|
||||
|
||||
Reference in New Issue
Block a user