SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
mount: fix bound tree with filer.path
Chris Lub18f21cce178
diff --git a/weed/Makefile b/weed/Makefileindex f537fe0517..0e2d296239 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=/bucketsdebug_server:go build -gcflags="all=-N -l"diff --git a/weed/filesys/meta_cache/meta_cache.go b/weed/filesys/meta_cache/meta_cache.goindex bb81d6d276..247f0ce818 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.goindex 57b4c3da54..265fc95a8a 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.goindex 0e023c0d11..0182aeba10 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 *Nodesync.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)returndiff --git a/weed/util/bounded_tree/bounded_tree_test.go b/weed/util/bounded_tree/bounded_tree_test.goindex 0b9c3177af..465f1cc9cc 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)