diff options
| author | hasagi <30975629+LIBA-S@users.noreply.github.com> | 2020-09-22 21:38:38 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-22 21:38:38 +0800 |
| commit | d7bf2390e2bf4ac55132878faa68119b3558e8e4 (patch) | |
| tree | 48ede45893c2130d3e039f7fe4af8440835eb02d /weed/filesys/wfs.go | |
| parent | 37e964d4bd60a9dd792a9cc24f05eaa05d3766f2 (diff) | |
| parent | ec5b9f1e91a8609d0e70bf9d26dc0840774153c4 (diff) | |
| download | seaweedfs-d7bf2390e2bf4ac55132878faa68119b3558e8e4.tar.xz seaweedfs-d7bf2390e2bf4ac55132878faa68119b3558e8e4.zip | |
Merge pull request #1 from chrislusf/master
catch up
Diffstat (limited to 'weed/filesys/wfs.go')
| -rw-r--r-- | weed/filesys/wfs.go | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index e41693048..8d46e0862 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -34,7 +34,6 @@ type Option struct { CacheDir string CacheSizeMB int64 DataCenter string - DirListCacheLimit int64 EntryCacheTtl time.Duration Umask os.FileMode @@ -46,7 +45,7 @@ type Option struct { OutsideContainerClusterMode bool // whether the mount runs outside SeaweedFS containers Cipher bool // whether encrypt data on volume server - + UidGidMapper *meta_cache.UidGidMapper } var _ = fs.FS(&WFS{}) @@ -64,9 +63,11 @@ type WFS struct { stats statsCache root fs.Node + fsNodeCache *FsCache - chunkCache *chunk_cache.ChunkCache + chunkCache *chunk_cache.TieredChunkCache metaCache *meta_cache.MetaCache + signature int32 } type statsCache struct { filer_pb.StatisticsResponse @@ -82,25 +83,24 @@ func NewSeaweedFileSystem(option *Option) *WFS { return make([]byte, option.ChunkSizeLimit) }, }, + signature: util.RandomInt32(), } - cacheUniqueId := util.Md5([]byte(option.FilerGrpcAddress + option.FilerMountRootPath + util.Version()))[0:4] + cacheUniqueId := util.Md5String([]byte(option.FilerGrpcAddress + option.FilerMountRootPath + util.Version()))[0:4] cacheDir := path.Join(option.CacheDir, cacheUniqueId) if option.CacheSizeMB > 0 { os.MkdirAll(cacheDir, 0755) - wfs.chunkCache = chunk_cache.NewChunkCache(256, cacheDir, option.CacheSizeMB) - grace.OnInterrupt(func() { - wfs.chunkCache.Shutdown() - }) + wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, cacheDir, option.CacheSizeMB) } - wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta")) + wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"), option.UidGidMapper) startTime := time.Now() - go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) + go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) grace.OnInterrupt(func() { wfs.metaCache.Shutdown() }) wfs.root = &Dir{name: wfs.option.FilerMountRootPath, wfs: wfs} + wfs.fsNodeCache = newFsCache(wfs.root) return wfs } @@ -112,7 +112,7 @@ func (wfs *WFS) Root() (fs.Node, error) { func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHandle) { fullpath := file.fullpath() - glog.V(4).Infof("%s AcquireHandle uid=%d gid=%d", fullpath, uid, gid) + glog.V(4).Infof("AcquireHandle %s uid=%d gid=%d", fullpath, uid, gid) wfs.handlesLock.Lock() defer wfs.handlesLock.Unlock() @@ -120,13 +120,16 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHand inodeId := file.fullpath().AsInode() existingHandle, found := wfs.handles[inodeId] if found && existingHandle != nil { + file.isOpen++ return existingHandle } fileHandle = newFileHandle(file, uid, gid) + file.maybeLoadEntry(context.Background()) + file.isOpen++ + wfs.handles[inodeId] = fileHandle fileHandle.handle = inodeId - glog.V(4).Infof("%s new fh %d", fullpath, fileHandle.handle) return } @@ -203,3 +206,10 @@ func (wfs *WFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse. return nil } + +func (wfs *WFS) mapPbIdFromFilerToLocal(entry *filer_pb.Entry) { + entry.Attributes.Uid, entry.Attributes.Gid = wfs.option.UidGidMapper.FilerToLocal(entry.Attributes.Uid, entry.Attributes.Gid) +} +func (wfs *WFS) mapPbIdFromLocalToFiler(entry *filer_pb.Entry) { + entry.Attributes.Uid, entry.Attributes.Gid = wfs.option.UidGidMapper.LocalToFiler(entry.Attributes.Uid, entry.Attributes.Gid) +} |
