Skip to content

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.

filer: support running multiple mount to different filers avoiding duplicated cache

Chris Lu54d6b3c30f27
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index 93f72ad65a..8dffa6555b 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -84,15 +84,17 @@ func NewSeaweedFileSystem(option *Option) *WFS {
},
},
}
+ cacheUniqueId := util.Md5([]byte(option.FilerGrpcAddress))[0:4]
+ cacheDir := path.Join(option.CacheDir, cacheUniqueId)
if option.CacheSizeMB > 0 {
- os.MkdirAll(option.CacheDir, 0755)
- wfs.chunkCache = chunk_cache.NewChunkCache(256, option.CacheDir, option.CacheSizeMB)
+ os.MkdirAll(cacheDir, 0755)
+ wfs.chunkCache = chunk_cache.NewChunkCache(256, cacheDir, option.CacheSizeMB)
grace.OnInterrupt(func() {
wfs.chunkCache.Shutdown()
})
}
- wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.CacheDir, "meta"))
+ wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"))
startTime := time.Now()
if err := meta_cache.InitMetaCache(wfs.metaCache, wfs, wfs.option.FilerMountRootPath); err != nil {
glog.V(0).Infof("failed to init meta cache: %v", err)