feat(metanode): disable the process related to snapshots if snapshots are switched off

close:#22404072

Signed-off-by: leonrayang <chl696@sina.com>
This commit is contained in:
leonrayang 2024-12-02 23:27:59 +08:00 committed by AmazingChi
parent b99f674824
commit 498f7ecbbc
3 changed files with 32 additions and 5 deletions

View File

@ -162,6 +162,9 @@ func (i *Inode) setVer(seq uint64) {
}
func (i *Inode) insertEkRefMap(mpId uint64, ek *proto.ExtentKey) {
if !clusterEnableSnapshot {
return
}
if i.multiSnap == nil {
i.multiSnap = NewMultiSnap(i.getVer())
}
@ -1893,6 +1896,9 @@ func (i *Inode) CreateUnlinkVer(mpVer uint64, nVer uint64) {
}
func (i *Inode) CreateVer(ver uint64) {
if !clusterEnableSnapshot {
return
}
// inode copy not include multi ver array
ino := i.CopyDirectly().(*Inode)
ino.Extents = NewSortedExtents()
@ -1913,6 +1919,9 @@ func (i *Inode) CreateVer(ver uint64) {
}
func (i *Inode) buildMultiSnap() {
if !clusterEnableSnapshot {
return
}
if i.multiSnap == nil {
i.multiSnap = &InodeMultiSnap{}
}
@ -1969,6 +1978,9 @@ func (i *Inode) SplitExtentWithCheck(param *AppendExtParam) (delExtents []proto.
// try to create version between curVer and seq of multiSnap.multiVersions[0] in verList
func (i *Inode) CreateLowerVersion(curVer uint64, verlist *proto.VolVersionInfoList) (err error) {
if !clusterEnableSnapshot {
return
}
verlist.RWLock.RLock()
defer verlist.RWLock.RUnlock()
@ -2056,7 +2068,7 @@ func (i *Inode) AppendExtentWithCheck(param *AppendExtParam) (delExtents []proto
}
// TODO:support hybridcloud
// multi version take effect
if i.getVer() > 0 && len(delExtents) > 0 {
if clusterEnableSnapshot && i.getVer() > 0 && len(delExtents) > 0 {
var err error
if err = i.CreateLowerVersion(i.getVer(), param.multiVersionList); err != nil {
return
@ -2120,6 +2132,9 @@ func (i *Inode) DecNLinkByVer(verSeq uint64) {
}
func (i *Inode) DecSplitExts(mpId uint64, delExtents interface{}) {
if !clusterEnableSnapshot {
return
}
log.LogDebugf("[DecSplitExts] mpId [%v] inode[%v]", mpId, i.Inode)
cnt := len(delExtents.([]proto.ExtentKey))
for id := 0; id < cnt; id++ {

View File

@ -577,13 +577,17 @@ func (mp *metaPartition) fsmAppendExtentsWithCheck(ino *Inode, isSplit bool) (st
// conflict need delete eks[0], to clear garbage data
if status == proto.OpConflictExtentsErr {
log.LogInfof("action[fsmAppendExtentsWithCheck] mp[%v] OpConflictExtentsErr [%v]", mp.config.PartitionId, eks[:1])
if !storage.IsTinyExtent(eks[0].ExtentId) && eks[0].ExtentOffset >= util.ExtentSize {
if !storage.IsTinyExtent(eks[0].ExtentId) && eks[0].ExtentOffset >= util.ExtentSize && clusterEnableSnapshot {
eks[0].SetSplit(true)
}
mp.extDelCh <- eks[:1]
}
} else {
// TODO: support hybrid-cloud
if !clusterEnableSnapshot {
status = proto.OpArgMismatchErr
log.LogErrorf("action[fsmAppendExtentsWithCheck] mp[%v] snapshot not enabled", mp.config.PartitionId)
return
}
// only the ek itself will be moved to level before
// ino verseq be set with mp ver before submit in case other mp be updated while on flight, which will lead to
// inconsistent between raft pairs

View File

@ -148,6 +148,9 @@ func (se *SortedExtents) Append(ek proto.ExtentKey) (deleteExtents []proto.Exten
}
func storeEkSplit(mpId uint64, inodeID uint64, ekRef *sync.Map, ek *proto.ExtentKey) (id uint64) {
if !clusterEnableSnapshot {
return
}
if ekRef == nil {
log.LogErrorf("[storeEkSplit] mpId [%v] inodeID %v ekRef nil", mpId, inodeID)
return
@ -486,14 +489,19 @@ func (se *SortedExtents) Truncate(offset uint64, doOnLastKey func(*proto.ExtentK
if doOnLastKey != nil {
doOnLastKey(&proto.ExtentKey{Size: uint32(lastKey.FileOffset + uint64(lastKey.Size) - offset)})
}
originSize := lastKey.Size
lastKey.Size = uint32(offset - lastKey.FileOffset)
if !clusterEnableSnapshot {
return
}
rsKey := &proto.ExtentKey{}
*rsKey = *lastKey
lastKey.Size = uint32(offset - lastKey.FileOffset)
if insertRefMap != nil {
insertRefMap(lastKey)
}
rsKey.Size -= lastKey.Size
rsKey.Size = originSize - lastKey.Size
rsKey.FileOffset += uint64(lastKey.Size)
rsKey.ExtentOffset += uint64(lastKey.Size)
if insertRefMap != nil {