mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: fix bound tree with filer.path
fix https://github.com/chrislusf/seaweedfs/issues/1528
This commit is contained in:
parent
f022aff289
commit
b18f21cce1
|
@ -16,7 +16,7 @@ debug_shell:
|
|||
|
||||
debug_mount:
|
||||
go build -gcflags="all=-N -l"
|
||||
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- mount -dir=~/tmp/mm
|
||||
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- mount -dir=~/tmp/mm -cacheCapacityMB=0 -filer.path=/buckets
|
||||
|
||||
debug_server:
|
||||
go build -gcflags="all=-N -l"
|
||||
|
|
|
@ -22,10 +22,10 @@ type MetaCache struct {
|
|||
uidGidMapper *UidGidMapper
|
||||
}
|
||||
|
||||
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper) *MetaCache {
|
||||
func NewMetaCache(dbFolder string, baseDir util.FullPath, uidGidMapper *UidGidMapper) *MetaCache {
|
||||
return &MetaCache{
|
||||
localStore: openMetaStore(dbFolder),
|
||||
visitedBoundary: bounded_tree.NewBoundedTree(),
|
||||
visitedBoundary: bounded_tree.NewBoundedTree(baseDir),
|
||||
uidGidMapper: uidGidMapper,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
|||
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, cacheDir, option.CacheSizeMB, 1024*1024)
|
||||
}
|
||||
|
||||
wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"), option.UidGidMapper)
|
||||
wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"), util.FullPath(option.FilerMountRootPath), option.UidGidMapper)
|
||||
startTime := time.Now()
|
||||
go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano())
|
||||
grace.OnInterrupt(func() {
|
||||
|
|
|
@ -16,13 +16,15 @@ type Node struct {
|
|||
type BoundedTree struct {
|
||||
root *Node
|
||||
sync.RWMutex
|
||||
baseDir util.FullPath
|
||||
}
|
||||
|
||||
func NewBoundedTree() *BoundedTree {
|
||||
func NewBoundedTree(baseDir util.FullPath) *BoundedTree {
|
||||
return &BoundedTree{
|
||||
root: &Node{
|
||||
Name: "/",
|
||||
},
|
||||
baseDir: baseDir,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,9 +41,12 @@ func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) {
|
|||
if t.root == nil {
|
||||
return
|
||||
}
|
||||
if t.baseDir != "/" {
|
||||
p = p[len(t.baseDir):]
|
||||
}
|
||||
components := p.Split()
|
||||
// fmt.Printf("components %v %d\n", components, len(components))
|
||||
if canDelete := t.ensureVisited(t.root, util.FullPath("/"), components, 0, visitFn); canDelete {
|
||||
if canDelete := t.ensureVisited(t.root, t.baseDir, components, 0, visitFn); canDelete {
|
||||
t.root = nil
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +65,12 @@ func (t *BoundedTree) ensureVisited(n *Node, currentPath util.FullPath, componen
|
|||
} else {
|
||||
// fmt.Printf("ensure %v\n", currentPath)
|
||||
|
||||
children, err := visitFn(currentPath)
|
||||
filerPath := currentPath
|
||||
if t.baseDir != "/" {
|
||||
filerPath = t.baseDir + filerPath
|
||||
}
|
||||
|
||||
children, err := visitFn(filerPath)
|
||||
if err != nil {
|
||||
glog.V(0).Infof("failed to visit %s: %v", currentPath, err)
|
||||
return
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestBoundedTree(t *testing.T) {
|
|||
// g
|
||||
// h
|
||||
|
||||
tree := NewBoundedTree()
|
||||
tree := NewBoundedTree(util.FullPath("/"))
|
||||
|
||||
tree.EnsureVisited(util.FullPath("/a/b/c"), visitFn)
|
||||
|
||||
|
@ -100,7 +100,7 @@ func TestEmptyBoundedTree(t *testing.T) {
|
|||
// g
|
||||
// h
|
||||
|
||||
tree := NewBoundedTree()
|
||||
tree := NewBoundedTree(util.FullPath("/"))
|
||||
|
||||
visitFn := func(path util.FullPath) (childDirectories []string, err error) {
|
||||
fmt.Printf(" visit %v ...\n", path)
|
||||
|
|
Loading…
Reference in a new issue