mount: rename to dirListCacheLimit to configure cache for long format directory list

This commit is contained in:
Chris Lu 2019-12-13 10:22:24 -08:00
parent 3e0cd122d8
commit f59119cd1d
3 changed files with 7 additions and 7 deletions

View file

@ -10,7 +10,7 @@ type MountOptions struct {
filer *string filer *string
filerMountRootPath *string filerMountRootPath *string
dir *string dir *string
dirListingLimit *int64 dirListCacheLimit *int64
collection *string collection *string
replication *string replication *string
ttlSec *int ttlSec *int
@ -31,7 +31,7 @@ func init() {
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location") mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server") mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory") mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
mountOptions.dirListingLimit = cmdMount.Flag.Int64("dirListLimit", 1000000, "limit directory listing size") mountOptions.dirListCacheLimit = cmdMount.Flag.Int64("dirListCacheLimit", 1000000, "limit cache size to speed up directory long format listing")
mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files") mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.") mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds") mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")

View file

@ -43,13 +43,13 @@ func runMount(cmd *Command, args []string) bool {
*mountOptions.chunkSizeLimitMB, *mountOptions.chunkSizeLimitMB,
*mountOptions.allowOthers, *mountOptions.allowOthers,
*mountOptions.ttlSec, *mountOptions.ttlSec,
*mountOptions.dirListingLimit, *mountOptions.dirListCacheLimit,
os.FileMode(umask), os.FileMode(umask),
) )
} }
func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCenter string, chunkSizeLimitMB int, func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCenter string, chunkSizeLimitMB int,
allowOthers bool, ttlSec int, dirListingLimit int64, umask os.FileMode) bool { allowOthers bool, ttlSec int, dirListCacheLimit int64, umask os.FileMode) bool {
util.LoadConfiguration("security", false) util.LoadConfiguration("security", false)
@ -155,7 +155,7 @@ func RunMount(filer, filerMountRootPath, dir, collection, replication, dataCente
TtlSec: int32(ttlSec), TtlSec: int32(ttlSec),
ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024, ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
DataCenter: dataCenter, DataCenter: dataCenter,
DirListingLimit: dirListingLimit, DirListCacheLimit: dirListCacheLimit,
EntryCacheTtl: 3 * time.Second, EntryCacheTtl: 3 * time.Second,
MountUid: uid, MountUid: uid,
MountGid: gid, MountGid: gid,

View file

@ -27,7 +27,7 @@ type Option struct {
TtlSec int32 TtlSec int32
ChunkSizeLimit int64 ChunkSizeLimit int64
DataCenter string DataCenter string
DirListingLimit int64 DirListCacheLimit int64
EntryCacheTtl time.Duration EntryCacheTtl time.Duration
Umask os.FileMode Umask os.FileMode
@ -61,7 +61,7 @@ type statsCache struct {
func NewSeaweedFileSystem(option *Option) *WFS { func NewSeaweedFileSystem(option *Option) *WFS {
wfs := &WFS{ wfs := &WFS{
option: option, option: option,
listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(option.DirListingLimit * 3).ItemsToPrune(100)), listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(option.DirListCacheLimit * 3).ItemsToPrune(100)),
pathToHandleIndex: make(map[string]int), pathToHandleIndex: make(map[string]int),
bufPool: sync.Pool{ bufPool: sync.Pool{
New: func() interface{} { New: func() interface{} {