This commit is contained in:
chrislu 2023-08-16 23:47:43 -07:00
parent 6c7fa567d4
commit 3852307e94
5 changed files with 31 additions and 31 deletions

View file

@ -146,15 +146,15 @@ func runFuse(cmd *Command, args []string) bool {
panic(fmt.Errorf("concurrentWriters: %s", err)) panic(fmt.Errorf("concurrentWriters: %s", err))
} }
case "cacheDir": case "cacheDir":
mountOptions.cacheDir = &parameter.value mountOptions.cacheDirForRead = &parameter.value
case "cacheCapacityMB": case "cacheCapacityMB":
if parsed, err := strconv.ParseInt(parameter.value, 0, 64); err == nil { if parsed, err := strconv.ParseInt(parameter.value, 0, 64); err == nil {
mountOptions.cacheSizeMB = &parsed mountOptions.cacheSizeMBForRead = &parsed
} else { } else {
panic(fmt.Errorf("cacheCapacityMB: %s", err)) panic(fmt.Errorf("cacheCapacityMB: %s", err))
} }
case "cacheDirWrite": case "cacheDirWrite":
mountOptions.cacheDirWrite = &parameter.value mountOptions.cacheDirForWrite = &parameter.value
case "dataCenter": case "dataCenter":
mountOptions.dataCenter = &parameter.value mountOptions.dataCenter = &parameter.value
case "allowOthers": case "allowOthers":

View file

@ -17,9 +17,9 @@ type MountOptions struct {
ttlSec *int ttlSec *int
chunkSizeLimitMB *int chunkSizeLimitMB *int
concurrentWriters *int concurrentWriters *int
cacheDir *string cacheDirForRead *string
cacheDirWrite *string cacheDirForWrite *string
cacheSizeMB *int64 cacheSizeMBForRead *int64
dataCenter *string dataCenter *string
allowOthers *bool allowOthers *bool
umaskString *string umaskString *string
@ -55,9 +55,9 @@ func init() {
mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds") mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files") mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files")
mountOptions.concurrentWriters = cmdMount.Flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers") mountOptions.concurrentWriters = cmdMount.Flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers")
mountOptions.cacheDir = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data") mountOptions.cacheDirForRead = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
mountOptions.cacheSizeMB = cmdMount.Flag.Int64("cacheCapacityMB", 0, "file chunk read cache capacity in MB") mountOptions.cacheSizeMBForRead = cmdMount.Flag.Int64("cacheCapacityMB", 0, "file chunk read cache capacity in MB")
mountOptions.cacheDirWrite = cmdMount.Flag.String("cacheDirWrite", os.TempDir(), "buffer writes mostly for large files") mountOptions.cacheDirForWrite = cmdMount.Flag.String("cacheDirWrite", os.TempDir(), "buffer writes mostly for large files")
mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center") mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system") mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111") mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")

View file

@ -225,9 +225,9 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
DiskType: types.ToDiskType(*option.diskType), DiskType: types.ToDiskType(*option.diskType),
ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024, ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
ConcurrentWriters: *option.concurrentWriters, ConcurrentWriters: *option.concurrentWriters,
CacheDir: *option.cacheDir, CacheDirForRead: *option.cacheDirForRead,
CacheSizeMB: *option.cacheSizeMB, CacheSizeMBForRead: *option.cacheSizeMBForRead,
CacheDirWrite: *option.cacheDirWrite, CacheDirForWrite: *option.cacheDirForWrite,
DataCenter: *option.dataCenter, DataCenter: *option.dataCenter,
Quota: int64(*option.collectionQuota) * 1024 * 1024, Quota: int64(*option.collectionQuota) * 1024 * 1024,
MountUid: uid, MountUid: uid,

View file

@ -29,7 +29,7 @@ func newMemoryChunkPages(fh *FileHandle, chunkSize int64) *ChunkedDirtyPages {
fh: fh, fh: fh,
} }
swapFileDir := fh.wfs.option.getTempFilePageDir() swapFileDir := fh.wfs.option.getUniqueCacheDirForWrite()
dirtyPages.uploadPipeline = page_writer.NewUploadPipeline(fh.wfs.concurrentWriters, chunkSize, dirtyPages.uploadPipeline = page_writer.NewUploadPipeline(fh.wfs.concurrentWriters, chunkSize,
dirtyPages.saveChunkedFileIntervalToStorage, fh.wfs.option.ConcurrentWriters, swapFileDir) dirtyPages.saveChunkedFileIntervalToStorage, fh.wfs.option.ConcurrentWriters, swapFileDir)

View file

@ -38,9 +38,9 @@ type Option struct {
DiskType types.DiskType DiskType types.DiskType
ChunkSizeLimit int64 ChunkSizeLimit int64
ConcurrentWriters int ConcurrentWriters int
CacheDir string CacheDirForRead string
CacheSizeMB int64 CacheSizeMBForRead int64
CacheDirWrite string 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 uniqueCacheDirForRead string
uniqueCacheTempPageDir 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 { if option.CacheSizeMBForRead > 0 {
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, option.getUniqueCacheDir(), option.CacheSizeMB, 1024*1024) 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.getUniqueCacheDirForRead())
os.RemoveAll(option.getTempFilePageDir()) 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) option.uniqueCacheDirForRead = path.Join(option.CacheDirForRead, cacheUniqueId)
os.MkdirAll(option.uniqueCacheDir, os.FileMode(0777)&^option.Umask) os.MkdirAll(option.uniqueCacheDirForRead, os.FileMode(0777)&^option.Umask)
option.uniqueCacheTempPageDir = filepath.Join(path.Join(option.CacheDirWrite, cacheUniqueId), "swap") option.uniqueCacheDirForWrite = filepath.Join(path.Join(option.CacheDirForWrite, cacheUniqueId), "swap")
os.MkdirAll(option.uniqueCacheTempPageDir, os.FileMode(0777)&^option.Umask) os.MkdirAll(option.uniqueCacheDirForWrite, os.FileMode(0777)&^option.Umask)
} }
func (option *Option) getTempFilePageDir() string { func (option *Option) getUniqueCacheDirForWrite() string {
return option.uniqueCacheTempPageDir return option.uniqueCacheDirForWrite
} }
func (option *Option) getUniqueCacheDir() string { func (option *Option) getUniqueCacheDirForRead() string {
return option.uniqueCacheDir return option.uniqueCacheDirForRead
} }