aboutsummaryrefslogtreecommitdiff
path: root/weed
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-12 21:58:37 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-12 21:58:37 -0700
commitb18f21cce178b60531086f164d24e832a7b6eb86 (patch)
tree328a7050a256977bef47edd9e45bff7fb5cb1eb6 /weed
parentf022aff289d509e93a93a0e8386693876d1be240 (diff)
downloadseaweedfs-b18f21cce178b60531086f164d24e832a7b6eb86.tar.xz
seaweedfs-b18f21cce178b60531086f164d24e832a7b6eb86.zip
mount: fix bound tree with filer.path
fix https://github.com/chrislusf/seaweedfs/issues/1528
Diffstat (limited to 'weed')
-rw-r--r--weed/Makefile2
-rw-r--r--weed/filesys/meta_cache/meta_cache.go4
-rw-r--r--weed/filesys/wfs.go2
-rw-r--r--weed/util/bounded_tree/bounded_tree.go16
-rw-r--r--weed/util/bounded_tree/bounded_tree_test.go4
5 files changed, 19 insertions, 9 deletions
diff --git a/weed/Makefile b/weed/Makefile
index f537fe051..0e2d29623 100644
--- a/weed/Makefile
+++ b/weed/Makefile
@@ -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"
diff --git a/weed/filesys/meta_cache/meta_cache.go b/weed/filesys/meta_cache/meta_cache.go
index bb81d6d27..247f0ce81 100644
--- a/weed/filesys/meta_cache/meta_cache.go
+++ b/weed/filesys/meta_cache/meta_cache.go
@@ -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,
}
}
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index 57b4c3da5..265fc95a8 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -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() {
diff --git a/weed/util/bounded_tree/bounded_tree.go b/weed/util/bounded_tree/bounded_tree.go
index 0e023c0d1..0182aeba1 100644
--- a/weed/util/bounded_tree/bounded_tree.go
+++ b/weed/util/bounded_tree/bounded_tree.go
@@ -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
diff --git a/weed/util/bounded_tree/bounded_tree_test.go b/weed/util/bounded_tree/bounded_tree_test.go
index 0b9c3177a..465f1cc9c 100644
--- a/weed/util/bounded_tree/bounded_tree_test.go
+++ b/weed/util/bounded_tree/bounded_tree_test.go
@@ -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)