|
@ -38,9 +38,9 @@ type Option struct { |
|
|
DiskType types.DiskType |
|
|
DiskType types.DiskType |
|
|
ChunkSizeLimit int64 |
|
|
ChunkSizeLimit int64 |
|
|
ConcurrentWriters int |
|
|
ConcurrentWriters int |
|
|
CacheDir string |
|
|
|
|
|
CacheSizeMB int64 |
|
|
|
|
|
CacheDirWrite string |
|
|
|
|
|
|
|
|
CacheDirForRead string |
|
|
|
|
|
CacheSizeMBForRead int64 |
|
|
|
|
|
CacheDirForWrite string |
|
|
DataCenter string |
|
|
DataCenter string |
|
|
Umask os.FileMode |
|
|
Umask os.FileMode |
|
|
Quota int64 |
|
|
Quota int64 |
|
@ -57,8 +57,8 @@ type Option struct { |
|
|
Cipher bool // whether encrypt data on volume server
|
|
|
Cipher bool // whether encrypt data on volume server
|
|
|
UidGidMapper *meta_cache.UidGidMapper |
|
|
UidGidMapper *meta_cache.UidGidMapper |
|
|
|
|
|
|
|
|
uniqueCacheDir string |
|
|
|
|
|
uniqueCacheTempPageDir string |
|
|
|
|
|
|
|
|
uniqueCacheDirForRead string |
|
|
|
|
|
uniqueCacheDirForWrite string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type WFS struct { |
|
|
type WFS struct { |
|
@ -92,11 +92,11 @@ func NewSeaweedFileSystem(option *Option) *WFS { |
|
|
|
|
|
|
|
|
wfs.option.filerIndex = int32(rand.Intn(len(option.FilerAddresses))) |
|
|
wfs.option.filerIndex = int32(rand.Intn(len(option.FilerAddresses))) |
|
|
wfs.option.setupUniqueCacheDirectory() |
|
|
wfs.option.setupUniqueCacheDirectory() |
|
|
if option.CacheSizeMB > 0 { |
|
|
|
|
|
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, option.getUniqueCacheDir(), option.CacheSizeMB, 1024*1024) |
|
|
|
|
|
|
|
|
if option.CacheSizeMBForRead > 0 { |
|
|
|
|
|
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, option.getUniqueCacheDirForRead(), option.CacheSizeMBForRead, 1024*1024) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDir(), "meta"), option.UidGidMapper, |
|
|
|
|
|
|
|
|
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDirForRead(), "meta"), option.UidGidMapper, |
|
|
util.FullPath(option.FilerMountRootPath), |
|
|
util.FullPath(option.FilerMountRootPath), |
|
|
func(path util.FullPath) { |
|
|
func(path util.FullPath) { |
|
|
wfs.inodeToPath.MarkChildrenCached(path) |
|
|
wfs.inodeToPath.MarkChildrenCached(path) |
|
@ -106,8 +106,8 @@ func NewSeaweedFileSystem(option *Option) *WFS { |
|
|
}) |
|
|
}) |
|
|
grace.OnInterrupt(func() { |
|
|
grace.OnInterrupt(func() { |
|
|
wfs.metaCache.Shutdown() |
|
|
wfs.metaCache.Shutdown() |
|
|
os.RemoveAll(option.getUniqueCacheDir()) |
|
|
|
|
|
os.RemoveAll(option.getTempFilePageDir()) |
|
|
|
|
|
|
|
|
os.RemoveAll(option.getUniqueCacheDirForRead()) |
|
|
|
|
|
os.RemoveAll(option.getUniqueCacheDirForWrite()) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
if wfs.option.ConcurrentWriters > 0 { |
|
|
if wfs.option.ConcurrentWriters > 0 { |
|
@ -193,16 +193,16 @@ func (wfs *WFS) getCurrentFiler() pb.ServerAddress { |
|
|
|
|
|
|
|
|
func (option *Option) setupUniqueCacheDirectory() { |
|
|
func (option *Option) setupUniqueCacheDirectory() { |
|
|
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8] |
|
|
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8] |
|
|
option.uniqueCacheDir = path.Join(option.CacheDir, cacheUniqueId) |
|
|
|
|
|
os.MkdirAll(option.uniqueCacheDir, os.FileMode(0777)&^option.Umask) |
|
|
|
|
|
option.uniqueCacheTempPageDir = filepath.Join(path.Join(option.CacheDirWrite, cacheUniqueId), "swap") |
|
|
|
|
|
os.MkdirAll(option.uniqueCacheTempPageDir, os.FileMode(0777)&^option.Umask) |
|
|
|
|
|
|
|
|
option.uniqueCacheDirForRead = path.Join(option.CacheDirForRead, cacheUniqueId) |
|
|
|
|
|
os.MkdirAll(option.uniqueCacheDirForRead, os.FileMode(0777)&^option.Umask) |
|
|
|
|
|
option.uniqueCacheDirForWrite = filepath.Join(path.Join(option.CacheDirForWrite, cacheUniqueId), "swap") |
|
|
|
|
|
os.MkdirAll(option.uniqueCacheDirForWrite, os.FileMode(0777)&^option.Umask) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (option *Option) getTempFilePageDir() string { |
|
|
|
|
|
return option.uniqueCacheTempPageDir |
|
|
|
|
|
|
|
|
func (option *Option) getUniqueCacheDirForWrite() string { |
|
|
|
|
|
return option.uniqueCacheDirForWrite |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (option *Option) getUniqueCacheDir() string { |
|
|
|
|
|
return option.uniqueCacheDir |
|
|
|
|
|
|
|
|
func (option *Option) getUniqueCacheDirForRead() string { |
|
|
|
|
|
return option.uniqueCacheDirForRead |
|
|
} |
|
|
} |