Skip to content

Commit

Permalink
Merge pull request cubefs#847 from shuoranliu/fix-batch-inode-get-out…
Browse files Browse the repository at this point in the history
…-of-service

fix: batch inode get mechanism is out of service
  • Loading branch information
awzhgw authored Aug 31, 2020
2 parents 820b4b5 + c94a30e commit 3e67841
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
1 change: 0 additions & 1 deletion client/fs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ func (f *File) fileSize(ino uint64) (size int, gen uint64) {
log.LogDebugf("fileSize: ino(%v) fileSize(%v) gen(%v) valid(%v)", ino, size, gen, valid)

if !valid {
f.super.ic.Delete(ino)
if info, err := f.super.InodeGet(ino); err == nil {
size = int(info.Size)
gen = info.Generation
Expand Down
33 changes: 17 additions & 16 deletions client/fs/super.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,6 @@ func NewSuper(opt *proto.MountOptions) (s *Super, err error) {
return nil, errors.Trace(err, "NewMetaWrapper failed!")
}

var extentConfig = &stream.ExtentConfig{
Volume: opt.Volname,
Masters: masters,
FollowerRead: opt.FollowerRead,
NearRead: opt.NearRead,
ReadRate: opt.ReadRate,
WriteRate: opt.WriteRate,
OnAppendExtentKey: s.mw.AppendExtentKey,
OnGetExtents: s.mw.GetExtents,
OnTruncate: s.mw.Truncate,
}
s.ec, err = stream.NewExtentClient(extentConfig)
if err != nil {
return nil, errors.Trace(err, "NewExtentClient failed!")
}

s.volname = opt.Volname
s.owner = opt.Owner
s.cluster = s.mw.Cluster()
Expand All @@ -119,6 +103,23 @@ func NewSuper(opt *proto.MountOptions) (s *Super, err error) {
s.fsyncOnClose = opt.FsyncOnClose
s.enableXattr = opt.EnableXattr

var extentConfig = &stream.ExtentConfig{
Volume: opt.Volname,
Masters: masters,
FollowerRead: opt.FollowerRead,
NearRead: opt.NearRead,
ReadRate: opt.ReadRate,
WriteRate: opt.WriteRate,
OnAppendExtentKey: s.mw.AppendExtentKey,
OnGetExtents: s.mw.GetExtents,
OnTruncate: s.mw.Truncate,
OnEvictIcache: s.ic.Delete,
}
s.ec, err = stream.NewExtentClient(extentConfig)
if err != nil {
return nil, errors.Trace(err, "NewExtentClient failed!")
}

if s.rootIno, err = s.mw.GetRootIno(opt.SubDir); err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/data/stream/extent_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
type AppendExtentKeyFunc func(inode uint64, key proto.ExtentKey) error
type GetExtentsFunc func(inode uint64) (uint64, uint64, []proto.ExtentKey, error)
type TruncateFunc func(inode, size uint64) error
type EvictIcacheFunc func(inode uint64)

const (
MaxMountRetryLimit = 5
Expand Down Expand Up @@ -85,6 +86,7 @@ type ExtentConfig struct {
OnAppendExtentKey AppendExtentKeyFunc
OnGetExtents GetExtentsFunc
OnTruncate TruncateFunc
OnEvictIcache EvictIcacheFunc
}

// ExtentClient defines the struct of the extent client.
Expand All @@ -99,6 +101,7 @@ type ExtentClient struct {
appendExtentKey AppendExtentKeyFunc
getExtents GetExtentsFunc
truncate TruncateFunc
evictIcache EvictIcacheFunc //May be null, must check before using
}

// NewExtentClient returns a new extent client.
Expand All @@ -122,6 +125,7 @@ retry:
client.appendExtentKey = config.OnAppendExtentKey
client.getExtents = config.OnGetExtents
client.truncate = config.OnTruncate
client.evictIcache = config.OnEvictIcache
client.dataWrapper.InitFollowerRead(config.FollowerRead)
client.dataWrapper.SetNearRead(config.NearRead)

Expand Down
3 changes: 3 additions & 0 deletions sdk/data/stream/stream_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func (s *Streamer) server() {
s.client.streamerLock.Lock()
if s.idle >= streamWriterIdleTimeoutPeriod && len(s.request) == 0 {
delete(s.client.streamers, s.inode)
if s.client.evictIcache != nil {
s.client.evictIcache(s.inode)
}
s.client.streamerLock.Unlock()

// fail the remaining requests in such case
Expand Down

0 comments on commit 3e67841

Please sign in to comment.