fix(meta): if inode is dir, not allowed to set migrate extents in UpdateExtentKeyAfterMigration

close:#22076233
Signed-off-by: true1064 <tangjingyu@oppo.com>
This commit is contained in:
true1064 2024-04-15 17:47:12 +08:00 committed by AmazingChi
parent 7af36c991a
commit b701abdf6a
4 changed files with 21 additions and 4 deletions

View File

@ -1140,6 +1140,15 @@ func (m *MetaNode) updateExtentKeyAfterMigrationHandler(w http.ResponseWriter, r
return
}
if leaderAddr, ok := mp.IsLeader(); !ok {
resp.Code = http.StatusSeeOther
err = fmt.Errorf("not mp leader, leader is %v", leaderAddr)
log.LogErrorf("[updateExtentKeyAfterMigrationHandler] mpId(%v) ino(%v), get mp err: %v",
req.PartitionID, req.Inode, err.Error())
resp.Msg = err.Error()
return
}
p := &Packet{}
p.Opcode = proto.OpMetaUpdateExtentKeyAfterMigration
req.FullPaths = []string{"N/A"}

View File

@ -2491,4 +2491,5 @@ func (i *Inode) UpdateHybridCloudParams(paramIno *Inode) {
i.HybridCouldExtentsMigration.storageClass = paramIno.HybridCouldExtentsMigration.storageClass
i.HybridCouldExtentsMigration.sortedEks = paramIno.HybridCouldExtentsMigration.sortedEks
i.HybridCouldExtentsMigration.expiredTime = paramIno.HybridCouldExtentsMigration.expiredTime
i.Type = paramIno.Type
}

View File

@ -1134,6 +1134,13 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
}()
}
if proto.IsDir(ino.Type) && req.NewObjExtentKeys != nil {
err = fmt.Errorf("mp(%v) inode(%v) is dir, but request NewObjExtentKeys is not nil", mp.config.PartitionId, ino.Inode)
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err)
p.PacketErrorWithBody(proto.OpArgMismatchErr, []byte(err.Error()))
return
}
defer func() {
//delete migration extent key if encounter an error
if err != nil {
@ -1154,7 +1161,7 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
err = fmt.Errorf("inode(%v) storageClass(%v) is already the same with request storageClass",
ino.Inode, ino.StorageClass)
log.LogWarnf("[UpdateExtentKeyAfterMigration] %v", err.Error())
p.PacketErrorWithBody(proto.OpErr, []byte(err.Error()))
p.PacketErrorWithBody(proto.OpArgMismatchErr, []byte(err.Error()))
return
}

View File

@ -83,7 +83,7 @@ func (cache *ExtentCache) RefreshForce(inode uint64, force bool, getExtents GetE
// log.LogDebugf("Local ExtentCache before update: ino(%v) gen(%v) size(%v) extents(%v)", inode, cache.gen, cache.size, cache.List())
cache.update(gen, size, force, extents)
if log.EnableDebug() {
log.LogDebugf("Local ExtentCache after update: ino(%v) gen(%v) size(%v) extents(%v) openForWrite(%v) isMigration(%v)",
log.LogDebugf("[RefreshForce] Local ExtentCache after update: ino(%v) gen(%v) size(%v) extents(%v) openForWrite(%v) isMigration(%v)",
inode, cache.gen, cache.size, cache.List(), openForWrite, isMigration)
}
return nil
@ -99,10 +99,10 @@ func (cache *ExtentCache) Refresh(inode uint64, getExtents GetExtentsFunc, isCac
if err != nil {
return err
}
// log.LogDebugf("Local ExtentCache before update: ino(%v) gen(%v) size(%v) extents(%v)", inode, cache.gen, cache.size, cache.List())
cache.update(gen, size, false, extents)
if log.EnableDebug() {
log.LogDebugf("Local ExtentCache after update: ino(%v) gen(%v) size(%v) extents(%v) openForWrite(%v) isMigration(%v)",
log.LogDebugf("[Refresh] Local ExtentCache after update: ino(%v) gen(%v) size(%v) extents(%v) openForWrite(%v) isMigration(%v)",
inode, cache.gen, cache.size, cache.List(), openForWrite, isMigration)
}
return nil