Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many fixes and features #453

Merged
merged 2 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/fs/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {

inodes := make([]uint64, 0, len(children))
dirents := make([]fuse.Dirent, 0, len(children))
dcache := NewDentryCache()

var dcache *DentryCache
if !d.super.disableDcache {
dcache = NewDentryCache()
}

for _, child := range children {
dentry := fuse.Dirent{
Expand Down
3 changes: 3 additions & 0 deletions client/fs/super.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Super struct {

nodeCache map[uint64]fs.Node
fslock sync.Mutex

disableDcache bool
}

// Functions that Super needs to implement
Expand Down Expand Up @@ -110,6 +112,7 @@ func NewSuper(opt *proto.MountOptions) (s *Super, err error) {
s.ic = NewInodeCache(inodeExpiration, MaxInodeCache)
s.orphan = NewOrphanInodeList()
s.nodeCache = make(map[uint64]fs.Node)
s.disableDcache = opt.DisableDcache
log.LogInfof("NewSuper: cluster(%v) volname(%v) icacheExpiration(%v) LookupValidDuration(%v) AttrValidDuration(%v)", s.cluster, s.volname, inodeExpiration, LookupValidDuration, AttrValidDuration)
return s, nil
}
Expand Down
1 change: 1 addition & 0 deletions client/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func parseMountOption(cfg *config.Config) (*proto.MountOptions, error) {
opt.TokenKey = GlobalMountOptions[proto.TokenKey].GetString()
opt.AccessKey = GlobalMountOptions[proto.AccessKey].GetString()
opt.SecretKey = GlobalMountOptions[proto.SecretKey].GetString()
opt.DisableDcache = GlobalMountOptions[proto.DisableDcache].GetBool()

if opt.MountPoint == "" || opt.Volname == "" || opt.Owner == "" || opt.Master == "" {
return nil, errors.New(fmt.Sprintf("invalid config file: lack of mandatory fields, mountPoint(%v), volName(%v), owner(%v), masterAddr(%v)", opt.MountPoint, opt.Volname, opt.Owner, opt.Master))
Expand Down
4 changes: 4 additions & 0 deletions proto/mount_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
TokenKey
AccessKey
SecretKey
DisableDcache

MaxMountOption
)
Expand Down Expand Up @@ -97,6 +98,8 @@ func InitMountOptions(opts []MountOption) {
opts[AccessKey] = MountOption{"accessKey", "Access Key", "", ""}
opts[SecretKey] = MountOption{"secretKey", "Secret Key", "", ""}

opts[DisableDcache] = MountOption{"disableDcache", "Disable Dentry Cache", "", false}

for i := 0; i < MaxMountOption; i++ {
flag.StringVar(&opts[i].cmdlineValue, opts[i].keyword, "", opts[i].description)
}
Expand Down Expand Up @@ -207,4 +210,5 @@ type MountOptions struct {
TokenKey string
AccessKey string
SecretKey string
DisableDcache bool
}
9 changes: 5 additions & 4 deletions sdk/data/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func NewDataPartitionWrapper(volName string, masters []string) (w *Wrapper, err
err = errors.Trace(err, "NewDataPartitionWrapper:")
return
}
if err = w.updateDataPartition(); err != nil {
if err = w.updateDataPartition(true); err != nil {
err = errors.Trace(err, "NewDataPartitionWrapper:")
return
}
Expand Down Expand Up @@ -119,14 +119,14 @@ func (w *Wrapper) update() {
for {
select {
case <-ticker.C:
w.updateDataPartition()
w.updateDataPartition(false)
case <-w.stopC:
return
}
}
}

func (w *Wrapper) updateDataPartition() (err error) {
func (w *Wrapper) updateDataPartition(isInit bool) (err error) {

var dpv *proto.DataPartitionsView
if dpv, err = w.mc.ClientAPI().GetDataPartitions(w.volName); err != nil {
Expand All @@ -153,7 +153,8 @@ func (w *Wrapper) updateDataPartition() (err error) {
}
}

if len(rwPartitionGroups) >= MinWriteAbleDataPartitionCnt {
// isInit used to identify whether this call is caused by mount action
if isInit || (len(rwPartitionGroups) >= MinWriteAbleDataPartitionCnt) {
w.rwPartition = rwPartitionGroups
w.localLeaderPartitions = localLeaderPartitionGroups
} else {
Expand Down