mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(metanode): recover panic when marshal inode failed. #22720099
Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
parent
97af707e01
commit
c6f2c51277
@ -731,12 +731,15 @@ func (i *Inode) MarshalInodeValue(buff *bytes.Buffer) {
|
||||
log.LogDebugf("MarshalInodeValue ino(%v) storageClass(%v) Reserved(%v)", i.Inode, i.StorageClass, i.Reserved)
|
||||
// reset reserved, V4EBSExtentsFlag maybe changed after migration .eg
|
||||
i.Reserved = 0
|
||||
//defer func() {
|
||||
// if err := recover(); err != nil {
|
||||
// log.LogErrorf("MarshalInodeValue ino(%v) storageClass(%v) Recovered from panic:%v",
|
||||
// i.Inode, i.StorageClass, err)
|
||||
// }
|
||||
//}()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.LogErrorf("MarshalInodeValue ino(%v) storageClass(%v) reserved(%d) Recovered from panic:%v",
|
||||
i.String(), i.StorageClass, i.Reserved, err)
|
||||
log.LogFlush()
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
if err = binary.Write(buff, binary.BigEndian, &i.Type); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -796,7 +799,7 @@ func (i *Inode) MarshalInodeValue(buff *bytes.Buffer) {
|
||||
if ObjExtents != nil && len(ObjExtents.eks) > 0 {
|
||||
// i.Reserved |= V4EBSExtentsFlag
|
||||
i.Reserved |= V2EnableEbsFlag
|
||||
log.LogDebugf("MarshalInodeValue ino(%v) storageClass(%v) V4EBSExtentsFlag", i.Inode, i.StorageClass)
|
||||
log.LogDebugf("MarshalInodeValue ino(%v) storageClass(%v) ?", i.Inode, i.StorageClass)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -837,10 +840,10 @@ func (i *Inode) MarshalInodeValue(buff *bytes.Buffer) {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
log.LogDebugf("MarshalInodeValue ino(%v) storageClass(%v) marshall HybridCouldExtents V4ReplicaExtentsFlag Reserved(%v)",
|
||||
log.LogDebugf("MarshalInodeValue ino(%v) storageClass(%v) marshall HybridCouldExtents V4ReplicaExtentsFlag or empyt obj exts Reserved(%v)",
|
||||
i.Inode, i.StorageClass, i.Reserved)
|
||||
replicaExtents := NewSortedExtents()
|
||||
if !i.HybridCouldExtents.Empty() {
|
||||
if i.HybridCouldExtents.HasReplicaExts() {
|
||||
replicaExtents = i.HybridCouldExtents.sortedEks.(*SortedExtents)
|
||||
}
|
||||
extData, err := replicaExtents.MarshalBinary(enableSnapshot)
|
||||
|
||||
@ -19,6 +19,15 @@ func (se *SortedHybridCloudExtents) Empty() bool {
|
||||
return se.sortedEks == nil
|
||||
}
|
||||
|
||||
func (se *SortedHybridCloudExtents) HasReplicaExts() bool {
|
||||
if se.sortedEks == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
_, ok := se.sortedEks.(*SortedExtents)
|
||||
return ok
|
||||
}
|
||||
|
||||
func NewSortedHybridCloudExtents() *SortedHybridCloudExtents {
|
||||
return &SortedHybridCloudExtents{}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user