diff --git a/lcnode/const.go b/lcnode/const.go index 0799892a6..c7b31f0ee 100644 --- a/lcnode/const.go +++ b/lcnode/const.go @@ -33,6 +33,7 @@ const ( configLcNodeTaskCountLimit = "lcNodeTaskCountLimit" configEnableDebugService = "enableDebugService" + configDelayDelMinute = "delayDelMinute" ) // Default of configuration value @@ -52,6 +53,7 @@ const ( defaultUnboundedChanInitCapacity = 10000 defaultLcNodeTaskCountLimit = 1 maxLcNodeTaskCountLimit = 20 + defaultDelayDelMinute = 1440 // default retention min(1 day) of old eks after migration MaxSizePutOnce = int64(1) << 23 ) @@ -70,4 +72,5 @@ var ( maxDirChanNum = 1000000 enableDebugService bool + delayDelMinute uint64 ) diff --git a/lcnode/lc_scanner.go b/lcnode/lc_scanner.go index 9db0a3caa..ae39d572d 100644 --- a/lcnode/lc_scanner.go +++ b/lcnode/lc_scanner.go @@ -396,7 +396,7 @@ func (s *LcScanner) handleFile(dentry *proto.ScanDentry) { log.LogErrorf("migrate err: %v, dentry: %+v, skip it", err, dentry) return } - err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(dentry.Op), nil, dentry.WriteGen, dentry.Path) + err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(dentry.Op), nil, dentry.WriteGen, delayDelMinute, dentry.Path) if err != nil { atomic.AddInt64(&s.currentStat.ErrorSkippedNum, 1) log.LogErrorf("update extent key err: %v, dentry: %+v, skip it", err, dentry) @@ -419,7 +419,7 @@ func (s *LcScanner) handleFile(dentry *proto.ScanDentry) { log.LogErrorf("migrateToEbs err: %v, dentry: %+v, skip it", err, dentry) return } - err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(dentry.Op), oeks, dentry.WriteGen, dentry.Path) + err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(dentry.Op), oeks, dentry.WriteGen, delayDelMinute, dentry.Path) if err != nil { atomic.AddInt64(&s.currentStat.ErrorSkippedNum, 1) log.LogErrorf("update extent key err: %v, dentry: %+v, skip it", err, dentry) diff --git a/lcnode/meta.go b/lcnode/meta.go index 011bc5319..c1c9d0b09 100644 --- a/lcnode/meta.go +++ b/lcnode/meta.go @@ -23,7 +23,7 @@ type MetaWrapper interface { BatchInodeGet(inodes []uint64) []*proto.InodeInfo DeleteWithCond_ll(parentID, cond uint64, name string, isDir bool, fullPath string) (inode *proto.InodeInfo, err error) Evict(inode uint64, fullPath string) error - UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, extentKeys []proto.ObjExtentKey, writeGen uint64, fullPath string) error + UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, extentKeys []proto.ObjExtentKey, writeGen uint64, delayDelMinute uint64, fullPath string) error DeleteMigrationExtentKey(inode uint64, fullPath string) error ReadDirLimit_ll(parentID uint64, from string, limit uint64) ([]proto.Dentry, error) Close() error diff --git a/lcnode/meta_test.go b/lcnode/meta_test.go index c6b946197..857712878 100644 --- a/lcnode/meta_test.go +++ b/lcnode/meta_test.go @@ -71,7 +71,7 @@ func (*MockMetaWrapper) Evict(inode uint64, fullPath string) error { return nil } -func (*MockMetaWrapper) UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, extentKeys []proto.ObjExtentKey, writeGen uint64, fullPath string) error { +func (*MockMetaWrapper) UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, extentKeys []proto.ObjExtentKey, writeGen uint64, delayDelMinute uint64, fullPath string) error { return nil } diff --git a/lcnode/server.go b/lcnode/server.go index a7480e60d..1a1b5123e 100644 --- a/lcnode/server.go +++ b/lcnode/server.go @@ -221,6 +221,21 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) { } log.LogInfof("loadConfig: setup config: %v(%v)", configLcNodeTaskCountLimit, lcNodeTaskCountLimit) + // parse delayDelMinute + var delay int64 + delayStr := cfg.GetString(configDelayDelMinute) + if delayStr != "" { + if delay, err = strconv.ParseInt(delayStr, 10, 64); err != nil { + return fmt.Errorf("%v,err:%v", proto.ErrInvalidCfg, err.Error()) + } + } + if delay <= 0 { + delayDelMinute = defaultDelayDelMinute + } else { + delayDelMinute = uint64(delay) + } + log.LogInfof("loadConfig: setup config: %v(%v)", configDelayDelMinute, delayDelMinute) + enableDebugService = cfg.GetBool(configEnableDebugService) log.LogInfof("loadConfig: setup config: %v(%v)", configEnableDebugService, enableDebugService) diff --git a/sdk/meta/api.go b/sdk/meta/api.go index 696028661..8cbb28024 100644 --- a/sdk/meta/api.go +++ b/sdk/meta/api.go @@ -2767,12 +2767,12 @@ func (mw *MetaWrapper) RenewalForbiddenMigration(inode uint64) error { } func (mw *MetaWrapper) UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, objExtentKeys []proto.ObjExtentKey, - writeGen uint64, fullPath string) error { + writeGen uint64, delayDelMinute uint64, fullPath string) error { mp := mw.getPartitionByInode(inode) if mp == nil { return syscall.ENOENT } - status, err := mw.updateExtentKeyAfterMigration(mp, inode, storageType, objExtentKeys, writeGen, fullPath) + status, err := mw.updateExtentKeyAfterMigration(mp, inode, storageType, objExtentKeys, writeGen, delayDelMinute, fullPath) if err != nil || status != statusOK { log.LogErrorf("UpdateExtentKeyAfterMigration: inode(%v) storageType(%v) extentKeys(%v) writeGen(%v) err(%v) status(%v)", inode, storageType, objExtentKeys, writeGen, err, status) diff --git a/sdk/meta/operation.go b/sdk/meta/operation.go index d09d951bf..718815971 100644 --- a/sdk/meta/operation.go +++ b/sdk/meta/operation.go @@ -3019,7 +3019,7 @@ func (mw *MetaWrapper) renewalForbiddenMigration(mp *MetaPartition, inode uint64 } func (mw *MetaWrapper) updateExtentKeyAfterMigration(mp *MetaPartition, inode uint64, storageType uint32, - extentKeys []proto.ObjExtentKey, writeGen uint64, fullPath string) (status int, err error) { + extentKeys []proto.ObjExtentKey, writeGen uint64, delayDelMinute uint64, fullPath string) (status int, err error) { bgTime := stat.BeginStat() defer func() { stat.EndStat("updateExtentKeyAfterMigration", err, bgTime, 1) @@ -3031,6 +3031,7 @@ func (mw *MetaWrapper) updateExtentKeyAfterMigration(mp *MetaPartition, inode ui NewObjExtentKeys: extentKeys, WriteGen: writeGen, } + req.DelayDeleteMinute = delayDelMinute req.FullPaths = []string{fullPath} packet := proto.NewPacketReqID() packet.Opcode = proto.OpMetaUpdateExtentKeyAfterMigration