mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add separate cache directory for write buffers
This commit is contained in:
parent
b05ab1e092
commit
6c7fa567d4
|
@ -153,6 +153,8 @@ func runFuse(cmd *Command, args []string) bool {
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Errorf("cacheCapacityMB: %s", err))
|
panic(fmt.Errorf("cacheCapacityMB: %s", err))
|
||||||
}
|
}
|
||||||
|
case "cacheDirWrite":
|
||||||
|
mountOptions.cacheDirWrite = ¶meter.value
|
||||||
case "dataCenter":
|
case "dataCenter":
|
||||||
mountOptions.dataCenter = ¶meter.value
|
mountOptions.dataCenter = ¶meter.value
|
||||||
case "allowOthers":
|
case "allowOthers":
|
||||||
|
|
|
@ -18,6 +18,7 @@ type MountOptions struct {
|
||||||
chunkSizeLimitMB *int
|
chunkSizeLimitMB *int
|
||||||
concurrentWriters *int
|
concurrentWriters *int
|
||||||
cacheDir *string
|
cacheDir *string
|
||||||
|
cacheDirWrite *string
|
||||||
cacheSizeMB *int64
|
cacheSizeMB *int64
|
||||||
dataCenter *string
|
dataCenter *string
|
||||||
allowOthers *bool
|
allowOthers *bool
|
||||||
|
@ -56,6 +57,7 @@ func init() {
|
||||||
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.cacheDir = 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.cacheSizeMB = 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.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")
|
||||||
|
|
|
@ -227,6 +227,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||||
ConcurrentWriters: *option.concurrentWriters,
|
ConcurrentWriters: *option.concurrentWriters,
|
||||||
CacheDir: *option.cacheDir,
|
CacheDir: *option.cacheDir,
|
||||||
CacheSizeMB: *option.cacheSizeMB,
|
CacheSizeMB: *option.cacheSizeMB,
|
||||||
|
CacheDirWrite: *option.cacheDirWrite,
|
||||||
DataCenter: *option.dataCenter,
|
DataCenter: *option.dataCenter,
|
||||||
Quota: int64(*option.collectionQuota) * 1024 * 1024,
|
Quota: int64(*option.collectionQuota) * 1024 * 1024,
|
||||||
MountUid: uid,
|
MountUid: uid,
|
||||||
|
|
|
@ -40,6 +40,7 @@ type Option struct {
|
||||||
ConcurrentWriters int
|
ConcurrentWriters int
|
||||||
CacheDir string
|
CacheDir string
|
||||||
CacheSizeMB int64
|
CacheSizeMB int64
|
||||||
|
CacheDirWrite string
|
||||||
DataCenter string
|
DataCenter string
|
||||||
Umask os.FileMode
|
Umask os.FileMode
|
||||||
Quota int64
|
Quota int64
|
||||||
|
@ -106,6 +107,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
||||||
grace.OnInterrupt(func() {
|
grace.OnInterrupt(func() {
|
||||||
wfs.metaCache.Shutdown()
|
wfs.metaCache.Shutdown()
|
||||||
os.RemoveAll(option.getUniqueCacheDir())
|
os.RemoveAll(option.getUniqueCacheDir())
|
||||||
|
os.RemoveAll(option.getTempFilePageDir())
|
||||||
})
|
})
|
||||||
|
|
||||||
if wfs.option.ConcurrentWriters > 0 {
|
if wfs.option.ConcurrentWriters > 0 {
|
||||||
|
@ -192,7 +194,8 @@ 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.uniqueCacheDir = path.Join(option.CacheDir, cacheUniqueId)
|
||||||
option.uniqueCacheTempPageDir = filepath.Join(option.uniqueCacheDir, "swap")
|
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)
|
os.MkdirAll(option.uniqueCacheTempPageDir, os.FileMode(0777)&^option.Umask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue