mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-08 15:41:15 +02:00
mount: size the listing cache through NewMetaCache rather than a second constructor
A NewXWithY alongside NewX is two names for one thing, and the one that takes the argument is the only one that ever needed to exist. Callers pass the default explicitly.
This commit is contained in:
@@ -111,6 +111,7 @@ func TestReadUncachedRemoteEntryDoesNotDeadlock(t *testing.T) {
|
||||
wfs.fhLockTable.ReleaseLock(fh.fh, lock)
|
||||
},
|
||||
nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
wfs.inodeToPath.MarkChildrenCached(root)
|
||||
wfs.inodeToPath.Lookup(util.FullPath("/dir"), time.Now().Unix(), true, false, 0, false)
|
||||
|
||||
@@ -19,7 +19,7 @@ func newListingTestCache(t *testing.T, maxEntries int) *MetaCache {
|
||||
t.Fatalf("uid/gid mapper: %v", err)
|
||||
}
|
||||
cached := map[util.FullPath]bool{}
|
||||
mc := NewMetaCacheWithListingCache(t.TempDir(), uidGidMapper, util.FullPath("/"), false,
|
||||
mc := NewMetaCache(t.TempDir(), uidGidMapper, util.FullPath("/"), false,
|
||||
func(p util.FullPath) { cached[p] = true },
|
||||
func(p util.FullPath) bool { return cached[p] },
|
||||
func(EntryInvalidation) {}, nil, maxEntries)
|
||||
|
||||
@@ -107,13 +107,8 @@ type metadataApplyRequest struct {
|
||||
done chan error
|
||||
}
|
||||
|
||||
// listingCacheEntries sizes the directory listing cache; zero disables it.
|
||||
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, root util.FullPath, includeSystemEntries bool,
|
||||
markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(EntryInvalidation), onDirectoryUpdate func(dir util.FullPath)) *MetaCache {
|
||||
return NewMetaCacheWithListingCache(dbFolder, uidGidMapper, root, includeSystemEntries, markCachedFn, isCachedFn, invalidateFunc, onDirectoryUpdate, DefaultListingCacheEntries)
|
||||
}
|
||||
|
||||
// NewMetaCacheWithListingCache sizes the directory listing cache; zero disables it.
|
||||
func NewMetaCacheWithListingCache(dbFolder string, uidGidMapper *UidGidMapper, root util.FullPath, includeSystemEntries bool,
|
||||
markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(EntryInvalidation), onDirectoryUpdate func(dir util.FullPath),
|
||||
listingCacheEntries int) *MetaCache {
|
||||
leveldbStore, virtualStore := openMetaStore(dbFolder)
|
||||
|
||||
@@ -506,6 +506,7 @@ func newTestMetaCache(t *testing.T, cached map[util.FullPath]bool) (*MetaCache,
|
||||
func(dir util.FullPath) {
|
||||
notifications.record(dir)
|
||||
},
|
||||
DefaultListingCacheEntries,
|
||||
)
|
||||
|
||||
return mc, cached, notifications, invalidations
|
||||
|
||||
@@ -66,6 +66,7 @@ func TestApplyLoopInvalidateDoesNotDeadlockWithLockHoldingEnqueuer(t *testing.T)
|
||||
fhLockTable.ReleaseLock(fhKey, lock)
|
||||
},
|
||||
func(dir util.FullPath) {},
|
||||
DefaultListingCacheEntries,
|
||||
)
|
||||
defer func() {
|
||||
// Only safe to shut down once the apply loop is unwedged.
|
||||
|
||||
@@ -304,7 +304,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
||||
wfs.writeBufferAccountant.SetEvictor(wfs.evictOneWritableChunk)
|
||||
}
|
||||
|
||||
wfs.metaCache = meta_cache.NewMetaCacheWithListingCache(path.Join(option.getUniqueCacheDirForRead(), "meta"), option.UidGidMapper,
|
||||
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDirForRead(), "meta"), option.UidGidMapper,
|
||||
util.FullPath(option.FilerMountRootPath),
|
||||
option.IncludeSystemEntries,
|
||||
func(path util.FullPath) {
|
||||
|
||||
@@ -110,6 +110,7 @@ func newBenchWFS(tb testing.TB, dir util.FullPath, n int) *WFS {
|
||||
func(path util.FullPath) bool { return wfs.inodeToPath.IsChildrenCached(path) },
|
||||
func(meta_cache.EntryInvalidation) {},
|
||||
nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
tb.Cleanup(wfs.metaCache.Shutdown)
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ func newPagingWFS(tb testing.TB, dir util.FullPath, names []string, ttlSec int32
|
||||
func(p util.FullPath) { wfs.inodeToPath.MarkChildrenCached(p) },
|
||||
func(p util.FullPath) bool { return wfs.inodeToPath.IsChildrenCached(p) },
|
||||
func(meta_cache.EntryInvalidation) {}, nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
tb.Cleanup(wfs.metaCache.Shutdown)
|
||||
|
||||
|
||||
@@ -348,6 +348,7 @@ func newCopyRangeTestWFSWithMetaCache(t *testing.T) *WFS {
|
||||
},
|
||||
func(meta_cache.EntryInvalidation) {},
|
||||
nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
t.Cleanup(func() {
|
||||
wfs.metaCache.Shutdown()
|
||||
|
||||
@@ -130,6 +130,7 @@ func newCreateTestWFS(t *testing.T) (*WFS, *createEntryTestServer) {
|
||||
},
|
||||
func(meta_cache.EntryInvalidation) {},
|
||||
nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
wfs.inodeToPath.MarkChildrenCached(root)
|
||||
t.Cleanup(func() {
|
||||
|
||||
@@ -62,6 +62,7 @@ func newInvalidateTestWFS(t *testing.T) *WFS {
|
||||
func(path util.FullPath) bool { return wfs.inodeToPath.IsChildrenCached(path) },
|
||||
wfs.invalidateOpenFileHandle,
|
||||
nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
t.Cleanup(wfs.metaCache.Shutdown)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ func TestHandleRenameResponseLeavesUncachedTargetOutOfCache(t *testing.T) {
|
||||
},
|
||||
func(meta_cache.EntryInvalidation) {},
|
||||
nil,
|
||||
meta_cache.DefaultListingCacheEntries,
|
||||
)
|
||||
defer mc.Shutdown()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user