Skip to content

Commit

Permalink
Add --refresh-filename and --flush-filename to allow to invalidate an…
Browse files Browse the repository at this point in the history
…d flush cache on Windows
  • Loading branch information
vitalif committed Jun 19, 2023
1 parent 7f03a30 commit 38bb898
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ type FlagStorage struct {
MtimeAttr string
SymlinkAttr string
RefreshAttr string
RefreshFilename string
FlushFilename string
CachePopularThreshold int64
CacheMaxHits int64
CacheAgeInterval int64
Expand Down
19 changes: 19 additions & 0 deletions internal/cfg/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cfg
import (
"io"
"os"
"runtime"
"strconv"
"strings"
"syscall"
Expand Down Expand Up @@ -518,6 +519,19 @@ MISC OPTIONS:
},
}

if runtime.GOOS == "windows" {
tuningFlags = append(tuningFlags, cli.StringFlag{
Name: "refresh-filename",
Value: ".invalidate",
Usage: "Trying to open a file with this name refreshes the cache of its directory.",
})
tuningFlags = append(tuningFlags, cli.StringFlag{
Name: "flush-filename",
Value: ".fsyncdir",
Usage: "Trying to open a file with this name flushes the cache of its directory to server.",
})
}

debugFlags := []cli.Flag{
/////////////////////////
// Debugging
Expand Down Expand Up @@ -771,6 +785,11 @@ func PopulateFlags(c *cli.Context) (ret *FlagStorage) {
ClusterGrpcReflection: c.Bool("grpc-reflection"),
}

if runtime.GOOS == "windows" {
flags.RefreshFilename = c.String("refresh-filename")
flags.FlushFilename = c.String("flush-filename")
}

flags.PartSizes = parsePartSizes(c.String("part-sizes"))

if flags.ClusterMode {
Expand Down
3 changes: 2 additions & 1 deletion internal/goofys.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,9 @@ func (fs *Goofys) completeInflightListing(id int) map[string]bool {
}

func (fs *Goofys) SyncFS(parent *Inode) (err error) {
if parent == nil {
if parent == nil || parent.Id == fuseops.RootInodeID {
log.Infof("Flushing all changes")
parent = nil
} else {
log.Infof("Flushing all changes under %v", parent.FullName())
}
Expand Down
2 changes: 2 additions & 0 deletions internal/goofys_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ func (s *GoofysTest) SetUpTest(t *C) {
IgnoreFsync: false,
SymlinkAttr: "--symlink-target",
RefreshAttr: ".invalidate",
RefreshFilename: ".invalidate",
FlushFilename: ".fsyncdir",
PartSizes: []cfg.PartSizeConfig{
{ PartSize: 5*1024*1024, PartCount: 1000 },
{ PartSize: 25*1024*1024, PartCount: 1000 },
Expand Down

0 comments on commit 38bb898

Please sign in to comment.