Commit 1d6f9351 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Han-Wen Nienhuys

fuse: request explicit control over data cache if filesystem asks for it

This complements commit "fuse: allow filesystems to disable
CAP_AUTO_INVAL_DATA" and teaches go-fuse to request explicit data cache
invalidation mode if fuse.MountOptions.ExplicitDataCacheControl is set.

See https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git/commit/?id=ad2ba64dd489
and https://lwn.net/ml/linux-fsdevel/20190315212556.9315-1-kirr%40nexedi.com/ for rationale and details.
parent 904ef0cc
...@@ -157,12 +157,6 @@ type MountOptions struct { ...@@ -157,12 +157,6 @@ type MountOptions struct {
// If set, ask kernel not to do automatic data cache invalidation. // If set, ask kernel not to do automatic data cache invalidation.
// The filesystem is fully responsible for invalidating data cache. // The filesystem is fully responsible for invalidating data cache.
//
// XXX for Linux ExplicitDataCacheControl currently disables data cache
// to be automatically invalidated only on file mtime change. If file size
// changes, Linux currently unconditionally discards whole cache of the
// file. See https://github.com/hanwen/go-fuse/pull/273 for kernel +
// go-fuse patches with corresponding fixes.
ExplicitDataCacheControl bool ExplicitDataCacheControl bool
} }
......
...@@ -98,14 +98,13 @@ func doInit(server *Server, req *request) { ...@@ -98,14 +98,13 @@ func doInit(server *Server, req *request) {
dataCacheMode := input.Flags & CAP_AUTO_INVAL_DATA dataCacheMode := input.Flags & CAP_AUTO_INVAL_DATA
if server.opts.ExplicitDataCacheControl { if server.opts.ExplicitDataCacheControl {
// XXX this only disables automatic invalidations on mtime // we don't want CAP_AUTO_INVAL_DATA even if we cannot go into fully explicit mode
// change, but not on size change.
//
// TODO explicitly disable invalidations on size change when
// kernel has proper support. Details:
//
// https://github.com/hanwen/go-fuse/pull/273
dataCacheMode = 0 dataCacheMode = 0
explicit := input.Flags & CAP_EXPLICIT_INVAL_DATA
if explicit != 0 {
dataCacheMode = explicit
}
} }
server.kernelSettings.Flags |= dataCacheMode server.kernelSettings.Flags |= dataCacheMode
......
...@@ -45,6 +45,7 @@ var ( ...@@ -45,6 +45,7 @@ var (
CAP_MAX_PAGES: "MAX_PAGES", CAP_MAX_PAGES: "MAX_PAGES",
CAP_CACHE_SYMLINKS: "CACHE_SYMLINKS", CAP_CACHE_SYMLINKS: "CACHE_SYMLINKS",
CAP_NO_OPENDIR_SUPPORT: "NO_OPENDIR_SUPPORT", CAP_NO_OPENDIR_SUPPORT: "NO_OPENDIR_SUPPORT",
CAP_EXPLICIT_INVAL_DATA: "EXPLICIT_INVAL_DATA",
} }
releaseFlagNames = map[int64]string{ releaseFlagNames = map[int64]string{
RELEASE_FLUSH: "FLUSH", RELEASE_FLUSH: "FLUSH",
......
...@@ -290,6 +290,7 @@ const ( ...@@ -290,6 +290,7 @@ const (
CAP_MAX_PAGES = (1 << 22) CAP_MAX_PAGES = (1 << 22)
CAP_CACHE_SYMLINKS = (1 << 23) CAP_CACHE_SYMLINKS = (1 << 23)
CAP_NO_OPENDIR_SUPPORT = (1 << 24) CAP_NO_OPENDIR_SUPPORT = (1 << 24)
CAP_EXPLICIT_INVAL_DATA = (1 << 25)
) )
type InitIn struct { type InitIn struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment