mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-11 22:38:53 +01:00
address gemini code review's suggested changes
This commit is contained in:
1 parent
bcfdd78e7e
commit
04fff7b002
6 files changed
+26
-25
No files matched your search
@@ -27,18 +27,18 @@ type MetaCache struct {
|
|||||||
localStore filer.VirtualFilerStore
|
localStore filer.VirtualFilerStore
|
||||||
leveldbStore *leveldb.LevelDBStore // direct reference for batch operations
|
leveldbStore *leveldb.LevelDBStore // direct reference for batch operations
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
uidGidMapper *UidGidMapper
|
uidGidMapper *UidGidMapper
|
||||||
markCachedFn func(fullpath util.FullPath)
|
markCachedFn func(fullpath util.FullPath)
|
||||||
isCachedFn func(fullpath util.FullPath) bool
|
isCachedFn func(fullpath util.FullPath) bool
|
||||||
invalidateFunc func(fullpath util.FullPath, entry *filer_pb.Entry)
|
invalidateFunc func(fullpath util.FullPath, entry *filer_pb.Entry)
|
||||||
onDirectoryUpdate func(dir util.FullPath)
|
onDirectoryUpdate func(dir util.FullPath)
|
||||||
visitGroup singleflight.Group // deduplicates concurrent EnsureVisited calls for the same path
|
visitGroup singleflight.Group // deduplicates concurrent EnsureVisited calls for the same path
|
||||||
applyCh chan metadataApplyRequest
|
applyCh chan metadataApplyRequest
|
||||||
applyDone chan struct{}
|
applyDone chan struct{}
|
||||||
applyStateMu sync.Mutex
|
applyStateMu sync.Mutex
|
||||||
applyClosed bool
|
applyClosed bool
|
||||||
buildingDirs map[util.FullPath]*directoryBuildState
|
buildingDirs map[util.FullPath]*directoryBuildState
|
||||||
dedupRing dedupRingBuffer
|
dedupRing dedupRingBuffer
|
||||||
includeSystemEntries bool
|
includeSystemEntries bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,17 +85,18 @@ type metadataApplyRequest struct {
|
|||||||
done chan error
|
done chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, root util.FullPath,
|
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, root util.FullPath, includeSystemEntries bool,
|
||||||
markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(util.FullPath, *filer_pb.Entry), onDirectoryUpdate func(dir util.FullPath)) *MetaCache {
|
markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(util.FullPath, *filer_pb.Entry), onDirectoryUpdate func(dir util.FullPath)) *MetaCache {
|
||||||
leveldbStore, virtualStore := openMetaStore(dbFolder)
|
leveldbStore, virtualStore := openMetaStore(dbFolder)
|
||||||
mc := &MetaCache{
|
mc := &MetaCache{
|
||||||
root: root,
|
root: root,
|
||||||
localStore: virtualStore,
|
localStore: virtualStore,
|
||||||
leveldbStore: leveldbStore,
|
leveldbStore: leveldbStore,
|
||||||
markCachedFn: markCachedFn,
|
markCachedFn: markCachedFn,
|
||||||
isCachedFn: isCachedFn,
|
isCachedFn: isCachedFn,
|
||||||
uidGidMapper: uidGidMapper,
|
uidGidMapper: uidGidMapper,
|
||||||
onDirectoryUpdate: onDirectoryUpdate,
|
onDirectoryUpdate: onDirectoryUpdate,
|
||||||
|
includeSystemEntries: includeSystemEntries,
|
||||||
invalidateFunc: func(fullpath util.FullPath, entry *filer_pb.Entry) {
|
invalidateFunc: func(fullpath util.FullPath, entry *filer_pb.Entry) {
|
||||||
invalidateFunc(fullpath, entry)
|
invalidateFunc(fullpath, entry)
|
||||||
},
|
},
|
||||||
@@ -108,10 +109,6 @@ func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, root util.FullPat
|
|||||||
return mc
|
return mc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MetaCache) SetIncludeSystemEntries(include bool) {
|
|
||||||
mc.includeSystemEntries = include
|
|
||||||
}
|
|
||||||
|
|
||||||
func openMetaStore(dbFolder string) (*leveldb.LevelDBStore, filer.VirtualFilerStore) {
|
func openMetaStore(dbFolder string) (*leveldb.LevelDBStore, filer.VirtualFilerStore) {
|
||||||
|
|
||||||
os.RemoveAll(dbFolder)
|
os.RemoveAll(dbFolder)
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ func newTestMetaCache(t *testing.T, cached map[util.FullPath]bool) (*MetaCache,
|
|||||||
filepath.Join(t.TempDir(), "meta"),
|
filepath.Join(t.TempDir(), "meta"),
|
||||||
mapper,
|
mapper,
|
||||||
util.FullPath("/"),
|
util.FullPath("/"),
|
||||||
|
false,
|
||||||
func(path util.FullPath) {
|
func(path util.FullPath) {
|
||||||
cachedMu.Lock()
|
cachedMu.Lock()
|
||||||
defer cachedMu.Unlock()
|
defer cachedMu.Unlock()
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
|||||||
|
|
||||||
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDirForRead(), "meta"), option.UidGidMapper,
|
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDirForRead(), "meta"), option.UidGidMapper,
|
||||||
util.FullPath(option.FilerMountRootPath),
|
util.FullPath(option.FilerMountRootPath),
|
||||||
|
option.ShowSystemEntries,
|
||||||
func(path util.FullPath) {
|
func(path util.FullPath) {
|
||||||
wfs.inodeToPath.MarkChildrenCached(path)
|
wfs.inodeToPath.MarkChildrenCached(path)
|
||||||
}, func(path util.FullPath) bool {
|
}, func(path util.FullPath) bool {
|
||||||
@@ -234,7 +235,6 @@ func NewSeaweedFileSystem(option *Option) *WFS {
|
|||||||
wfs.markDirectoryReadThrough(dirPath)
|
wfs.markDirectoryReadThrough(dirPath)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
wfs.metaCache.SetIncludeSystemEntries(option.ShowSystemEntries)
|
|
||||||
grace.OnInterrupt(func() {
|
grace.OnInterrupt(func() {
|
||||||
// grace calls os.Exit(0) after all hooks, so WaitForAsyncFlush
|
// grace calls os.Exit(0) after all hooks, so WaitForAsyncFlush
|
||||||
// after server.Serve() would never execute. Drain here first.
|
// after server.Serve() would never execute. Drain here first.
|
||||||
|
|||||||
@@ -338,6 +338,7 @@ func newCopyRangeTestWFSWithMetaCache(t *testing.T) *WFS {
|
|||||||
filepath.Join(t.TempDir(), "meta"),
|
filepath.Join(t.TempDir(), "meta"),
|
||||||
uidGidMapper,
|
uidGidMapper,
|
||||||
root,
|
root,
|
||||||
|
false,
|
||||||
func(path util.FullPath) {
|
func(path util.FullPath) {
|
||||||
wfs.inodeToPath.MarkChildrenCached(path)
|
wfs.inodeToPath.MarkChildrenCached(path)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ func newCreateTestWFS(t *testing.T) (*WFS, *createEntryTestServer) {
|
|||||||
filepath.Join(t.TempDir(), "meta"),
|
filepath.Join(t.TempDir(), "meta"),
|
||||||
uidGidMapper,
|
uidGidMapper,
|
||||||
root,
|
root,
|
||||||
|
false,
|
||||||
func(path util.FullPath) {
|
func(path util.FullPath) {
|
||||||
wfs.inodeToPath.MarkChildrenCached(path)
|
wfs.inodeToPath.MarkChildrenCached(path)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ func TestHandleRenameResponseLeavesUncachedTargetOutOfCache(t *testing.T) {
|
|||||||
filepath.Join(t.TempDir(), "meta"),
|
filepath.Join(t.TempDir(), "meta"),
|
||||||
uidGidMapper,
|
uidGidMapper,
|
||||||
root,
|
root,
|
||||||
|
false,
|
||||||
func(path util.FullPath) {
|
func(path util.FullPath) {
|
||||||
inodeToPath.MarkChildrenCached(path)
|
inodeToPath.MarkChildrenCached(path)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user