mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
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:
parent
7af36c991a
commit
b701abdf6a
@ -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"}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user