diff --git a/client/fs/super.go b/client/fs/super.go index e3e537198..6e3571471 100644 --- a/client/fs/super.go +++ b/client/fs/super.go @@ -34,6 +34,7 @@ import ( "github.com/cubefs/cubefs/proto" "github.com/cubefs/cubefs/sdk/data/blobstore" "github.com/cubefs/cubefs/sdk/data/stream" + "github.com/cubefs/cubefs/sdk/master" "github.com/cubefs/cubefs/sdk/meta" "github.com/cubefs/cubefs/util" "github.com/cubefs/cubefs/util/auditlog" @@ -131,6 +132,8 @@ func NewSuper(opt *proto.MountOptions) (s *Super, err error) { return nil, errors.Trace(err, "NewMetaWrapper failed!"+err.Error()) } + master.BcacheOnlyForNotSSD = opt.EnableBcache && opt.BcacheOnlyForNotSSD + s.SetTransaction(opt.EnableTransaction, opt.TxTimeout, opt.TxConflictRetryNum, opt.TxConflictRetryInterval) s.mw.EnableQuota = opt.EnableQuota diff --git a/master/api_service.go b/master/api_service.go index a955ad980..2b9c59d3a 100644 --- a/master/api_service.go +++ b/master/api_service.go @@ -5635,14 +5635,16 @@ func (m *Server) getVolStatInfo(w http.ResponseWriter, r *http.Request) { clientVer := r.FormValue(proto.ClientVerKey) hostName := r.FormValue(proto.HostKey) role := r.FormValue(proto.RoleKey) - log.LogInfof("getVolStatInfo: get client ver info %s, ip %s, host %s, vol %s, role %s", clientVer, remoteIp, hostName, name, role) + enableBcache := r.FormValue(proto.BcacheOnlyForNotSSDKey) + log.LogInfof("getVolStatInfo: get client ver info %s, ip %s, host %s, vol %s, role %s, enableBcache %s", + clientVer, remoteIp, hostName, name, role, enableBcache) if vol, err = m.cluster.getVol(name); err != nil { sendErrReply(w, r, newErrHTTPReply(proto.ErrVolNotExists)) return } - m.cliMgr.PutItem(remoteIp, hostName, name, clientVer, role) + m.cliMgr.PutItem(remoteIp, hostName, name, clientVer, role, enableBcache) if proto.IsCold(vol.VolType) && ver != proto.LFClient { sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: "ec-vol is supported by LF client only"}) diff --git a/master/client_info.go b/master/client_info.go index d5dfb5d25..7b148c8f6 100644 --- a/master/client_info.go +++ b/master/client_info.go @@ -30,7 +30,7 @@ func newClientMgr() *ClientMgr { return mgr } -func (cm *ClientMgr) PutItem(ip, host, vol, version, role string) { +func (cm *ClientMgr) PutItem(ip, host, vol, version, role, enableBcache string) { cm.Lock() defer cm.Unlock() @@ -46,7 +46,13 @@ func (cm *ClientMgr) PutItem(ip, host, vol, version, role string) { role = defaultRole } - key := fmt.Sprintf("_%s_%s_%s_%s_%s", vol, version, role, ip, host) + if enableBcache == "1" { + enableBcache = "true" + } else { + enableBcache = "false" + } + + key := fmt.Sprintf("_%s_%s_%s_%s_%s_enableBcache-%s", vol, version, role, ip, host, enableBcache) if len(cm.clients) > maxClientCnt { log.LogWarnf("PutItem: too many record in cluster, ignore, key %s", key) diff --git a/proto/admin_proto.go b/proto/admin_proto.go index 6eaaebd92..9bfa0b929 100644 --- a/proto/admin_proto.go +++ b/proto/admin_proto.go @@ -390,6 +390,7 @@ const ( HostKey = "host" ClientVerKey = "clientVer" RoleKey = "role" + BcacheOnlyForNotSSDKey = "enableBcacheNotSSD" ) // const TimeFormat = "2006-01-02 15:04:05" diff --git a/sdk/master/api_client.go b/sdk/master/api_client.go index dc7d49995..4815ed731 100644 --- a/sdk/master/api_client.go +++ b/sdk/master/api_client.go @@ -23,6 +23,8 @@ import ( "github.com/cubefs/cubefs/util/iputil" ) +var BcacheOnlyForNotSSD bool + type Decoder func([]byte) ([]byte, error) func (d Decoder) Decode(raw []byte) ([]byte, error) { @@ -90,6 +92,7 @@ func (api *ClientAPI) GetVolumeStat(volName string) (info *proto.VolStatInfo, er anyParam{proto.ClientVerKey, proto.Version}, anyParam{proto.HostKey, iputil.HostName}, anyParam{proto.RoleKey, proto.Role}, + anyParam{proto.BcacheOnlyForNotSSDKey, BcacheOnlyForNotSSD}, )) return }