mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
mount: add back support for filer.path
This commit is contained in:
parent
ca0cd81a75
commit
fcf3714443
@ -21,13 +21,13 @@ type InodeEntry struct {
|
|||||||
isChildrenCached bool
|
isChildrenCached bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInodeToPath() *InodeToPath {
|
func NewInodeToPath(root util.FullPath) *InodeToPath {
|
||||||
t := &InodeToPath{
|
t := &InodeToPath{
|
||||||
inode2path: make(map[uint64]*InodeEntry),
|
inode2path: make(map[uint64]*InodeEntry),
|
||||||
path2inode: make(map[util.FullPath]uint64),
|
path2inode: make(map[util.FullPath]uint64),
|
||||||
}
|
}
|
||||||
t.inode2path[1] = &InodeEntry{"/", 1, true, false}
|
t.inode2path[1] = &InodeEntry{root, 1, true, false}
|
||||||
t.path2inode["/"] = 1
|
t.path2inode[root] = 1
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
// e.g. fill fileId field for chunks
|
// e.g. fill fileId field for chunks
|
||||||
|
|
||||||
type MetaCache struct {
|
type MetaCache struct {
|
||||||
|
root util.FullPath
|
||||||
localStore filer.VirtualFilerStore
|
localStore filer.VirtualFilerStore
|
||||||
// sync.RWMutex
|
// sync.RWMutex
|
||||||
uidGidMapper *UidGidMapper
|
uidGidMapper *UidGidMapper
|
||||||
@ -22,8 +23,10 @@ type MetaCache struct {
|
|||||||
invalidateFunc func(fullpath util.FullPath, entry *filer_pb.Entry)
|
invalidateFunc func(fullpath util.FullPath, entry *filer_pb.Entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(util.FullPath, *filer_pb.Entry)) *MetaCache {
|
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, root util.FullPath,
|
||||||
|
markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(util.FullPath, *filer_pb.Entry)) *MetaCache {
|
||||||
return &MetaCache{
|
return &MetaCache{
|
||||||
|
root: root,
|
||||||
localStore: openMetaStore(dbFolder),
|
localStore: openMetaStore(dbFolder),
|
||||||
markCachedFn: markCachedFn,
|
markCachedFn: markCachedFn,
|
||||||
isCachedFn: isCachedFn,
|
isCachedFn: isCachedFn,
|
||||||
|
@ -33,7 +33,7 @@ func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.Full
|
|||||||
}
|
}
|
||||||
|
|
||||||
// continue to parent directory
|
// continue to parent directory
|
||||||
if currentPath != "/" {
|
if currentPath != mc.root {
|
||||||
parent, _ := currentPath.DirAndName()
|
parent, _ := currentPath.DirAndName()
|
||||||
currentPath = util.FullPath(parent)
|
currentPath = util.FullPath(parent)
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,7 +73,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
|||||||
RawFileSystem: fuse.NewDefaultRawFileSystem(),
|
RawFileSystem: fuse.NewDefaultRawFileSystem(),
|
||||||
option: option,
|
option: option,
|
||||||
signature: util.RandomInt32(),
|
signature: util.RandomInt32(),
|
||||||
inodeToPath: NewInodeToPath(),
|
inodeToPath: NewInodeToPath(util.FullPath(option.FilerMountRootPath)),
|
||||||
fhmap: NewFileHandleToInode(),
|
fhmap: NewFileHandleToInode(),
|
||||||
dhmap: NewDirectoryHandleToInode(),
|
dhmap: NewDirectoryHandleToInode(),
|
||||||
}
|
}
|
||||||
@ -84,12 +84,14 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
|||||||
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, option.getUniqueCacheDir(), option.CacheSizeMB, 1024*1024)
|
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, option.getUniqueCacheDir(), option.CacheSizeMB, 1024*1024)
|
||||||
}
|
}
|
||||||
|
|
||||||
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDir(), "meta"), option.UidGidMapper, func(path util.FullPath) {
|
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDir(), "meta"), option.UidGidMapper,
|
||||||
wfs.inodeToPath.MarkChildrenCached(path)
|
util.FullPath(option.FilerMountRootPath),
|
||||||
}, func(path util.FullPath) bool {
|
func(path util.FullPath) {
|
||||||
return wfs.inodeToPath.IsChildrenCached(path)
|
wfs.inodeToPath.MarkChildrenCached(path)
|
||||||
}, func(filePath util.FullPath, entry *filer_pb.Entry) {
|
}, func(path util.FullPath) bool {
|
||||||
})
|
return wfs.inodeToPath.IsChildrenCached(path)
|
||||||
|
}, func(filePath util.FullPath, entry *filer_pb.Entry) {
|
||||||
|
})
|
||||||
grace.OnInterrupt(func() {
|
grace.OnInterrupt(func() {
|
||||||
wfs.metaCache.Shutdown()
|
wfs.metaCache.Shutdown()
|
||||||
os.RemoveAll(option.getUniqueCacheDir())
|
os.RemoveAll(option.getUniqueCacheDir())
|
||||||
|
Loading…
Reference in New Issue
Block a user