mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(metanode): support empty file migration
Signed-off-by: chihe <chihe@oppo.com>
This commit is contained in:
parent
08665970fd
commit
52f2317304
@ -49,6 +49,10 @@ type TransitionMgr struct {
|
||||
}
|
||||
|
||||
func (t *TransitionMgr) migrate(e *proto.ScanDentry) (err error) {
|
||||
if e.Size == 0 {
|
||||
log.LogInfof("skip migration, size=0, inode(%v)", e.Inode)
|
||||
return
|
||||
}
|
||||
if err = t.ec.OpenStream(e.Inode, false, false); err != nil {
|
||||
log.LogErrorf("migrate: ec OpenStream fail, inode(%v) err: %v", e.Inode, err)
|
||||
return
|
||||
@ -204,6 +208,10 @@ func (t *TransitionMgr) readFromExtentClient(e *proto.ScanDentry, writer io.Writ
|
||||
}
|
||||
|
||||
func (t *TransitionMgr) migrateToEbs(e *proto.ScanDentry) (oek []proto.ObjExtentKey, err error) {
|
||||
if e.Size == 0 {
|
||||
log.LogInfof("skip migration, size=0, inode(%v)", e.Inode)
|
||||
return
|
||||
}
|
||||
if err = t.ec.OpenStream(e.Inode, false, false); err != nil {
|
||||
log.LogErrorf("migrateToEbs: OpenStream fail, inode(%v) err: %v", e.Inode, err)
|
||||
return
|
||||
|
||||
@ -717,6 +717,10 @@ func (mp *metaPartition) checkAndInsertFreeList(ino *Inode) {
|
||||
} else if ino.ShouldDeleteMigrationExtentKey(true) {
|
||||
mp.freeList.Push(ino.Inode)
|
||||
}
|
||||
if atomic.LoadUint32(&ino.ForbiddenMigration) == ForbiddenToMigration {
|
||||
mp.fmList.Put(ino.Inode)
|
||||
log.LogDebugf("action[checkAndInsertFreeList] put ino %v to forbidden migration check list", ino.Inode)
|
||||
}
|
||||
}
|
||||
|
||||
func (mp *metaPartition) fsmSetAttr(req *SetattrRequest) (err error) {
|
||||
@ -1081,7 +1085,7 @@ func (mp *metaPartition) fsmUpdateExtentKeyAfterMigration(inoParam *Inode) (resp
|
||||
|
||||
func logCurrentExtentKeys(storageClass uint32, sortedEks interface{}, inode uint64) {
|
||||
if sortedEks == nil {
|
||||
log.LogErrorf("action[fsmUpdateExtentKeyAfterMigration] inode %v current ek empty", inode)
|
||||
log.LogInfof("action[fsmUpdateExtentKeyAfterMigration] inode %v current ek empty", inode)
|
||||
} else {
|
||||
if proto.IsStorageClassReplica(storageClass) {
|
||||
log.LogInfof("action[fsmUpdateExtentKeyAfterMigration] inode %v current ek %v",
|
||||
|
||||
@ -83,10 +83,10 @@ func replyInfo(info *proto.InodeInfo, ino *Inode, quotaInfos map[uint32]*proto.M
|
||||
info.ForbiddenLc = true
|
||||
}
|
||||
info.MigrationStorageClass = ino.HybridCouldExtentsMigration.storageClass
|
||||
if ino.HybridCouldExtentsMigration.storageClass != proto.StorageClass_Unspecified {
|
||||
if ino.HybridCouldExtentsMigration.sortedEks != nil {
|
||||
info.HasMigrationEk = true
|
||||
}
|
||||
info.MigrationExtentKeyExpiredTime = time.Unix(ino.HybridCouldExtentsMigration.expiredTime, 0).Format("2006-01-02 15:04:05")
|
||||
info.MigrationExtentKeyExpiredTime = time.Unix(ino.HybridCouldExtentsMigration.expiredTime, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -1164,15 +1164,23 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
|
||||
ino.HybridCouldExtentsMigration.storageClass = req.StorageClass
|
||||
ino.HybridCouldExtentsMigration.expiredTime = time.Now().Add(time.Duration(req.DelayDeleteMinute) * time.Minute).Unix()
|
||||
if req.StorageClass == proto.StorageClass_BlobStore {
|
||||
//may be
|
||||
ino.HybridCouldExtentsMigration.sortedEks = NewSortedObjExtentsFromObjEks(req.NewObjExtentKeys)
|
||||
} else if req.StorageClass == proto.MediaType_HDD {
|
||||
if item.(*Inode).HybridCouldExtentsMigration.storageClass != proto.MediaType_HDD {
|
||||
err = fmt.Errorf("mp %v inode %v migration class now is %v",
|
||||
mp.config.PartitionId, ino.Inode, item.(*Inode).HybridCouldExtentsMigration.storageClass)
|
||||
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err)
|
||||
p.PacketErrorWithBody(proto.OpErr, []byte(err.Error()))
|
||||
} else if req.StorageClass == proto.StorageClass_Replica_HDD {
|
||||
if item.(*Inode).HybridCouldExtentsMigration.sortedEks == nil &&
|
||||
item.(*Inode).HybridCouldExtentsMigration.storageClass == proto.StorageClass_Unspecified {
|
||||
log.LogDebugf("action[UpdateExtentKeyAfterMigration] ino %v has no migration data", ino.Inode)
|
||||
ino.HybridCouldExtentsMigration.sortedEks = NewSortedExtents()
|
||||
} else {
|
||||
if item.(*Inode).HybridCouldExtentsMigration.storageClass != proto.StorageClass_Replica_HDD {
|
||||
err = fmt.Errorf("mp %v inode %v migration class now is %v",
|
||||
mp.config.PartitionId, ino.Inode, item.(*Inode).HybridCouldExtentsMigration.storageClass)
|
||||
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err)
|
||||
p.PacketErrorWithBody(proto.OpErr, []byte(err.Error()))
|
||||
return
|
||||
}
|
||||
ino.HybridCouldExtentsMigration.sortedEks = item.(*Inode).HybridCouldExtentsMigration.sortedEks
|
||||
}
|
||||
ino.HybridCouldExtentsMigration.sortedEks = item.(*Inode).HybridCouldExtentsMigration.sortedEks
|
||||
} else {
|
||||
err = fmt.Errorf("mp %v inode %v unsupport new migration storage class %v",
|
||||
mp.config.PartitionId, ino.Inode, req.StorageClass)
|
||||
|
||||
@ -28,6 +28,12 @@ func NewSortedExtentsFromEks(eks []proto.ExtentKey) *SortedExtents {
|
||||
}
|
||||
}
|
||||
|
||||
func (se *SortedExtents) IsEmpty() bool {
|
||||
se.RLock()
|
||||
defer se.RUnlock()
|
||||
return len(se.eks) == 0
|
||||
}
|
||||
|
||||
func (se *SortedExtents) String() string {
|
||||
se.RLock()
|
||||
data, err := json.Marshal(se.eks)
|
||||
|
||||
@ -36,6 +36,12 @@ func (se *SortedObjExtents) String() string {
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func (se *SortedObjExtents) IsEmpty() bool {
|
||||
se.RLock()
|
||||
defer se.RUnlock()
|
||||
return len(se.eks) == 0
|
||||
}
|
||||
|
||||
func (se *SortedObjExtents) MarshalBinary() ([]byte, error) {
|
||||
var data []byte
|
||||
|
||||
|
||||
@ -96,12 +96,12 @@ type InodeInfo struct {
|
||||
expiration int64
|
||||
PersistAccessTime time.Time `json:"pat"`
|
||||
|
||||
StorageClass uint32 `json:"storageClass"`
|
||||
WriteGen uint64 `json:"writeGen"`
|
||||
ForbiddenLc bool `json:"forbiddenLc"`
|
||||
MigrationStorageClass uint32 `json:"migrationStorageClass"`
|
||||
HasMigrationEk bool `json:"hasMigrationEk"`
|
||||
MigrationExtentKeyExpiredTime string `json:"mekExpiredTime"`
|
||||
StorageClass uint32 `json:"storageClass"`
|
||||
WriteGen uint64 `json:"writeGen"`
|
||||
ForbiddenLc bool `json:"forbiddenLc"`
|
||||
MigrationStorageClass uint32 `json:"migrationStorageClass"`
|
||||
HasMigrationEk bool `json:"hasMigrationEk"`
|
||||
MigrationExtentKeyExpiredTime time.Time `json:"mekExpiredTime"`
|
||||
}
|
||||
|
||||
type SimpleExtInfo struct {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user