aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/wfs.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-03-25 22:19:19 -0700
committerChris Lu <chris.lu@gmail.com>2020-03-25 22:19:19 -0700
commit2e4fadd10aa8835e7bcbbe25b46169a6335154f6 (patch)
treefb47187d2ccd70c004ed7906b9c0842bc590c968 /weed/filesys/wfs.go
parent5c5ddc740dc224cfecb4107d6b728ed70fbcf4a3 (diff)
downloadseaweedfs-2e4fadd10aa8835e7bcbbe25b46169a6335154f6.tar.xz
seaweedfs-2e4fadd10aa8835e7bcbbe25b46169a6335154f6.zip
fix fscache move
Diffstat (limited to 'weed/filesys/wfs.go')
-rw-r--r--weed/filesys/wfs.go33
1 files changed, 5 insertions, 28 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index a7475da56..5d3dd984a 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -61,9 +61,10 @@ type WFS struct {
stats statsCache
// nodes, protected by nodesLock
- nodesLock sync.Mutex
- nodes map[uint64]fs.Node
- root fs.Node
+ nodesLock sync.Mutex
+ nodes map[uint64]fs.Node
+ root fs.Node
+ fsNodeCache *FsCache
}
type statsCache struct {
filer_pb.StatisticsResponse
@@ -84,9 +85,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
}
wfs.root = &Dir{Path: wfs.option.FilerMountRootPath, wfs: wfs}
- wfs.getNode(util.FullPath(wfs.option.FilerMountRootPath), func() fs.Node {
- return wfs.root
- })
+ wfs.fsNodeCache = newFsCache(wfs.root)
return wfs
}
@@ -235,28 +234,6 @@ func (wfs *WFS) cacheDelete(path util.FullPath) {
wfs.listDirectoryEntriesCache.Delete(string(path))
}
-func (wfs *WFS) getNode(fullpath util.FullPath, fn func() fs.Node) fs.Node {
- wfs.nodesLock.Lock()
- defer wfs.nodesLock.Unlock()
-
- node, found := wfs.nodes[fullpath.AsInode()]
- if found {
- return node
- }
- node = fn()
- if node != nil {
- wfs.nodes[fullpath.AsInode()] = node
- }
- return node
-}
-
-func (wfs *WFS) forgetNode(fullpath util.FullPath) {
- wfs.nodesLock.Lock()
- defer wfs.nodesLock.Unlock()
-
- delete(wfs.nodes, fullpath.AsInode())
-}
-
func (wfs *WFS) AdjustedUrl(hostAndPort string) string {
if !wfs.option.OutsideContainerClusterMode {
return hostAndPort