diff --git a/master/api_service.go b/master/api_service.go index 8ed334f4b..917768a47 100644 --- a/master/api_service.go +++ b/master/api_service.go @@ -5748,15 +5748,16 @@ func (m *Server) getVolStatInfo(w http.ResponseWriter, r *http.Request) { hostName := r.FormValue(proto.HostKey) role := r.FormValue(proto.RoleKey) 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) + enableRCache := r.FormValue(proto.EnableRemoteCache) + log.LogInfof("getVolStatInfo: get client ver info %s, ip %s, host %s, vol %s, role %s, enableBcache %s, enableRCache %s", + clientVer, remoteIp, hostName, name, role, enableBcache, enableRCache) if vol, err = m.cluster.getVol(name); err != nil { sendErrReply(w, r, newErrHTTPReply(proto.ErrVolNotExists)) return } - m.cliMgr.PutItem(remoteIp, hostName, name, clientVer, role, enableBcache) + m.cliMgr.PutItem(remoteIp, hostName, name, clientVer, role, enableBcache, enableRCache) 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 29e4784d5..1bdbddc56 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, enableBcache string) { +func (cm *ClientMgr) PutItem(ip, host, vol, version, role, enableBcache, enableRCache string) { cm.Lock() defer cm.Unlock() @@ -50,7 +50,7 @@ func (cm *ClientMgr) PutItem(ip, host, vol, version, role, enableBcache string) enableBcache = "false" } - key := fmt.Sprintf("_%s_%s_%s_%s_%s_enableBcache-%s", vol, version, role, ip, host, enableBcache) + key := fmt.Sprintf("_%s_%s_%s_%s_%s_enableBcache-%s_enableRCache-%s", vol, version, role, ip, host, enableBcache, enableRCache) 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 7e2559cbb..0c17455d7 100644 --- a/proto/admin_proto.go +++ b/proto/admin_proto.go @@ -416,6 +416,7 @@ const ( ClientVerKey = "clientVer" RoleKey = "role" BcacheOnlyForNotSSDKey = "enableBcacheNotSSD" + EnableRemoteCache = "enableRemoteCache" ) // const TimeFormat = "2006-01-02 15:04:05" diff --git a/sdk/data/stream/extent_client.go b/sdk/data/stream/extent_client.go index 099927027..1c7ba4024 100644 --- a/sdk/data/stream/extent_client.go +++ b/sdk/data/stream/extent_client.go @@ -30,6 +30,7 @@ import ( "github.com/cubefs/cubefs/proto" "github.com/cubefs/cubefs/sdk/data/manager" "github.com/cubefs/cubefs/sdk/data/wrapper" + "github.com/cubefs/cubefs/sdk/master" "github.com/cubefs/cubefs/sdk/meta" "github.com/cubefs/cubefs/util" "github.com/cubefs/cubefs/util/bloom" @@ -427,7 +428,9 @@ func (client *ExtentClient) SetClientID(id uint64) (err error) { } func (client *ExtentClient) IsRemoteCacheEnabled() bool { - return client.RemoteCache.ClusterEnabled && client.RemoteCache.VolumeEnabled + rcEnable := client.RemoteCache.ClusterEnabled && client.RemoteCache.VolumeEnabled + master.ClientRCacheEnable = rcEnable + return rcEnable } func (client *ExtentClient) enableRemoteCacheCluster(enabled bool) { diff --git a/sdk/master/api_client.go b/sdk/master/api_client.go index 4815ed731..8ba3448f6 100644 --- a/sdk/master/api_client.go +++ b/sdk/master/api_client.go @@ -23,7 +23,7 @@ import ( "github.com/cubefs/cubefs/util/iputil" ) -var BcacheOnlyForNotSSD bool +var BcacheOnlyForNotSSD, ClientRCacheEnable bool type Decoder func([]byte) ([]byte, error) @@ -93,6 +93,7 @@ func (api *ClientAPI) GetVolumeStat(volName string) (info *proto.VolStatInfo, er anyParam{proto.HostKey, iputil.HostName}, anyParam{proto.RoleKey, proto.Role}, anyParam{proto.BcacheOnlyForNotSSDKey, BcacheOnlyForNotSSD}, + anyParam{proto.EnableRemoteCache, ClientRCacheEnable}, )) return }