aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/wfs.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-06-11 01:50:00 -0700
committerChris Lu <chris.lu@gmail.com>2020-06-11 01:50:00 -0700
commit628b27ef3b4cf8c1c894430e0d40b0bc1de8ba96 (patch)
tree009480e6bddd1646fd1caa3caabdafd2a9a4eade /weed/filesys/wfs.go
parentb9365de47b04414e704cb62a3cfa9753e8c5ec0c (diff)
downloadseaweedfs-628b27ef3b4cf8c1c894430e0d40b0bc1de8ba96.tar.xz
seaweedfs-628b27ef3b4cf8c1c894430e0d40b0bc1de8ba96.zip
purge old cache implementation
Diffstat (limited to 'weed/filesys/wfs.go')
-rw-r--r--weed/filesys/wfs.go52
1 files changed, 14 insertions, 38 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index 2b0ef64c2..ee4dcc916 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -10,18 +10,19 @@ import (
"sync"
"time"
- "github.com/chrislusf/seaweedfs/weed/util/grace"
- "github.com/karlseguin/ccache"
"google.golang.org/grpc"
+ "github.com/chrislusf/seaweedfs/weed/util/grace"
+
+ "github.com/seaweedfs/fuse"
+ "github.com/seaweedfs/fuse/fs"
+
"github.com/chrislusf/seaweedfs/weed/filesys/meta_cache"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/util/chunk_cache"
- "github.com/seaweedfs/fuse"
- "github.com/seaweedfs/fuse/fs"
)
type Option struct {
@@ -47,7 +48,6 @@ type Option struct {
OutsideContainerClusterMode bool // whether the mount runs outside SeaweedFS containers
Cipher bool // whether encrypt data on volume server
- AsyncMetaDataCaching bool // whether asynchronously cache meta data
}
@@ -56,7 +56,6 @@ var _ = fs.FSStatfser(&WFS{})
type WFS struct {
option *Option
- listDirectoryEntriesCache *ccache.Cache
// contains all open handles, protected by handlesLock
handlesLock sync.Mutex
@@ -67,7 +66,6 @@ type WFS struct {
stats statsCache
root fs.Node
- fsNodeCache *FsCache
chunkCache *chunk_cache.ChunkCache
metaCache *meta_cache.MetaCache
@@ -80,7 +78,6 @@ type statsCache struct {
func NewSeaweedFileSystem(option *Option) *WFS {
wfs := &WFS{
option: option,
- listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(option.DirListCacheLimit * 3).ItemsToPrune(100)),
handles: make(map[uint64]*FileHandle),
bufPool: sync.Pool{
New: func() interface{} {
@@ -95,21 +92,18 @@ func NewSeaweedFileSystem(option *Option) *WFS {
wfs.chunkCache.Shutdown()
})
}
- if wfs.option.AsyncMetaDataCaching {
- wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.CacheDir, "meta"))
- startTime := time.Now()
- if err := meta_cache.InitMetaCache(wfs.metaCache, wfs, wfs.option.FilerMountRootPath); err != nil {
- glog.V(0).Infof("failed to init meta cache: %v", err)
- } else {
- go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano())
- grace.OnInterrupt(func() {
- wfs.metaCache.Shutdown()
- })
- }
+ wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.CacheDir, "meta"))
+ startTime := time.Now()
+ if err := meta_cache.InitMetaCache(wfs.metaCache, wfs, wfs.option.FilerMountRootPath); err != nil {
+ glog.V(0).Infof("failed to init meta cache: %v", err)
+ } else {
+ go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano())
+ grace.OnInterrupt(func() {
+ wfs.metaCache.Shutdown()
+ })
}
wfs.root = &Dir{name: wfs.option.FilerMountRootPath, wfs: wfs}
- wfs.fsNodeCache = newFsCache(wfs.root)
return wfs
}
@@ -229,24 +223,6 @@ func (wfs *WFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.
return nil
}
-func (wfs *WFS) cacheGet(path util.FullPath) *filer_pb.Entry {
- item := wfs.listDirectoryEntriesCache.Get(string(path))
- if item != nil && !item.Expired() {
- return item.Value().(*filer_pb.Entry)
- }
- return nil
-}
-func (wfs *WFS) cacheSet(path util.FullPath, entry *filer_pb.Entry, ttl time.Duration) {
- if entry == nil {
- wfs.listDirectoryEntriesCache.Delete(string(path))
- } else {
- wfs.listDirectoryEntriesCache.Set(string(path), entry, ttl)
- }
-}
-func (wfs *WFS) cacheDelete(path util.FullPath) {
- wfs.listDirectoryEntriesCache.Delete(string(path))
-}
-
func (wfs *WFS) AdjustedUrl(hostAndPort string) string {
if !wfs.option.OutsideContainerClusterMode {
return hostAndPort