mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
refactor(lcnode): rename variable name writeGen to leaseExpire. #22855673
Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
parent
306132d83d
commit
edcad2d620
@ -402,7 +402,7 @@ func (s *LcScanner) handleFile(dentry *proto.ScanDentry) {
|
||||
dentry.Op = op
|
||||
dentry.Size = info.Size
|
||||
dentry.StorageClass = info.StorageClass
|
||||
dentry.WriteGen = info.LeaseExpireTime
|
||||
dentry.LeaseExpire = info.LeaseExpireTime
|
||||
dentry.HasMek = info.HasMigrationEk
|
||||
if op == "" {
|
||||
log.LogInfof("handleFile: %+v, ctime(%v), atime(%v), is not expired", dentry, info.CreateTime, info.AccessTime)
|
||||
@ -413,7 +413,7 @@ func (s *LcScanner) handleFile(dentry *proto.ScanDentry) {
|
||||
log.LogInfof("handleFile: %+v, ctime(%v), atime(%v), is expired", dentry, info.CreateTime, info.AccessTime)
|
||||
|
||||
defer func() {
|
||||
auditlog.LogLcNodeOp(op, s.Volume, dentry.Name, dentry.Path, dentry.ParentId, dentry.Inode, dentry.Size, dentry.WriteGen,
|
||||
auditlog.LogLcNodeOp(op, s.Volume, dentry.Name, dentry.Path, dentry.ParentId, dentry.Inode, dentry.Size, dentry.LeaseExpire,
|
||||
dentry.HasMek, dentry.StorageClass, proto.OpTypeToStorageType(op), time.Since(start).Milliseconds(), err)
|
||||
}()
|
||||
|
||||
@ -450,7 +450,7 @@ func (s *LcScanner) handleFile(dentry *proto.ScanDentry) {
|
||||
log.LogErrorf("migrate err: %v, dentry: %+v", err, dentry)
|
||||
return
|
||||
}
|
||||
err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(op), nil, dentry.WriteGen, delayDelMinute, dentry.Path)
|
||||
err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(op), nil, dentry.LeaseExpire, delayDelMinute, dentry.Path)
|
||||
if err != nil {
|
||||
if isSkipErr(err) {
|
||||
err = fmt.Errorf("skip (%v)", err)
|
||||
@ -486,7 +486,7 @@ func (s *LcScanner) handleFile(dentry *proto.ScanDentry) {
|
||||
log.LogErrorf("migrate blobstore err: %v, dentry: %+v", err, dentry)
|
||||
return
|
||||
}
|
||||
err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(op), oek, dentry.WriteGen, delayDelMinute, dentry.Path)
|
||||
err = s.mw.UpdateExtentKeyAfterMigration(dentry.Inode, proto.OpTypeToStorageType(op), oek, dentry.LeaseExpire, delayDelMinute, dentry.Path)
|
||||
if err != nil {
|
||||
if isSkipErr(err) {
|
||||
err = fmt.Errorf("skip (%v)", err)
|
||||
@ -528,7 +528,7 @@ func (s *LcScanner) inodeExpired(inode *proto.InodeInfo, condE *proto.Expiration
|
||||
}
|
||||
|
||||
if inode.ForbiddenLc {
|
||||
log.LogWarnf("ForbiddenLc, lease is occupied, inode: %+v, WriteGen(%v)", inode, inode.LeaseExpireTime)
|
||||
log.LogWarnf("ForbiddenLc, lease is occupied, inode: %+v, LeaseExpireTime(%v)", inode, inode.LeaseExpireTime)
|
||||
return
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ func (s *LcScanner) inodeExpired(inode *proto.InodeInfo, condE *proto.Expiration
|
||||
func expired(inode *proto.InodeInfo, now int64, days *int, date *time.Time) bool {
|
||||
if days != nil && *days > 0 {
|
||||
if inode.AccessTime.Before(inode.CreateTime) {
|
||||
log.LogWarnf("AccessTime before CreateTime, skip, inode: %+v, WriteGen(%v), AccessTime(%v), CreateTime(%v)", inode, inode.LeaseExpireTime, inode.AccessTime, inode.CreateTime)
|
||||
log.LogWarnf("AccessTime before CreateTime, skip, inode: %+v, LeaseExpireTime(%v), AccessTime(%v), CreateTime(%v)", inode, inode.LeaseExpireTime, inode.AccessTime, inode.CreateTime)
|
||||
return false
|
||||
}
|
||||
inodeTime := inode.AccessTime.Unix()
|
||||
|
||||
@ -23,7 +23,7 @@ type MetaWrapper interface {
|
||||
InodeGet_ll(inode uint64) (*proto.InodeInfo, error)
|
||||
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, delayDelMinute uint64, fullPath string) error
|
||||
UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, extentKeys []proto.ObjExtentKey, leaseExpireTime 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
|
||||
|
||||
@ -1179,7 +1179,7 @@ func (i *Inode) UnmarshalInodeValue(buff *bytes.Buffer) (err error) {
|
||||
return
|
||||
}
|
||||
if err = binary.Read(buff, binary.BigEndian, &i.LeaseExpireTime); err != nil {
|
||||
err = UnmarshalInodeFiledError("WriteGeneration(v4)", err)
|
||||
err = UnmarshalInodeFiledError("LeaseExpireTime(v4)", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -1172,10 +1172,10 @@ func (mp *metaPartition) UpdateExtentKeyAfterMigration(req *proto.UpdateExtentKe
|
||||
p.PacketErrorWithBody(proto.OpLeaseOccupiedByOthers, []byte(err.Error()))
|
||||
return
|
||||
}
|
||||
writeGen := inoParm.LeaseExpireTime
|
||||
if writeGen != req.WriteGen {
|
||||
leaseExpire := inoParm.LeaseExpireTime
|
||||
if leaseExpire != req.LeaseExpire {
|
||||
err = fmt.Errorf("mp(%v) inode(%v) write generation not match, curent(%v) request(%v)",
|
||||
mp.config.PartitionId, inoParm.Inode, writeGen, req.WriteGen)
|
||||
mp.config.PartitionId, inoParm.Inode, leaseExpire, req.LeaseExpire)
|
||||
log.LogErrorf("action[UpdateExtentKeyAfterMigration] %v", err)
|
||||
p.PacketErrorWithBody(proto.OpLeaseGenerationNotMatch, []byte(err.Error()))
|
||||
return
|
||||
|
||||
@ -1095,7 +1095,7 @@ type UpdateExtentKeyAfterMigrationRequest struct {
|
||||
Inode uint64 `json:"ino"`
|
||||
StorageClass uint32 `json:"storageClass"`
|
||||
NewObjExtentKeys []ObjExtentKey `json:"newObjExtentKeys"`
|
||||
WriteGen uint64 `json:"writeGen"`
|
||||
LeaseExpire uint64 `json:"leaseExpireTime"`
|
||||
DelayDeleteMinute uint64 `json:"delayDeleteMinute"`
|
||||
RequestExtend
|
||||
}
|
||||
|
||||
@ -405,14 +405,14 @@ type LcNodeRuleTaskStatistics struct {
|
||||
// lcnode <-> meta
|
||||
|
||||
type ScanDentry struct {
|
||||
ParentId uint64 `json:"pid"` // FileID value of the parent inode.
|
||||
Inode uint64 `json:"inode"` // FileID value of the current inode.
|
||||
Name string `json:"name"` // Name of the current dentry.
|
||||
Path string `json:"path"` // Path of the current dentry.
|
||||
Type uint32 `json:"type"` // Type of the current dentry.
|
||||
Op string `json:"op"` // to delete or migrate
|
||||
Size uint64 `json:"size"` // for migrate: size of the current dentry
|
||||
StorageClass uint32 `json:"sc"` // for migrate: storage class of the current dentry
|
||||
WriteGen uint64 `json:"gen"` // for migrate: used to determine whether a file is modified
|
||||
HasMek bool `json:"mek"` // for migrate: if HasMek, call DeleteMigrationExtentKey instead of migrating
|
||||
ParentId uint64 `json:"pid"` // FileID value of the parent inode.
|
||||
Inode uint64 `json:"inode"` // FileID value of the current inode.
|
||||
Name string `json:"name"` // Name of the current dentry.
|
||||
Path string `json:"path"` // Path of the current dentry.
|
||||
Type uint32 `json:"type"` // Type of the current dentry.
|
||||
Op string `json:"op"` // to delete or migrate
|
||||
Size uint64 `json:"size"` // for migrate: size of the current dentry
|
||||
StorageClass uint32 `json:"sc"` // for migrate: storage class of the current dentry
|
||||
LeaseExpire uint64 `json:"leaseExpire"` // for migrate: used to determine whether a file is modified
|
||||
HasMek bool `json:"mek"` // for migrate: if HasMek, call DeleteMigrationExtentKey instead of migrating
|
||||
}
|
||||
|
||||
@ -3099,25 +3099,28 @@ func (mw *MetaWrapper) RenewalForbiddenMigration(inode uint64) error {
|
||||
}
|
||||
|
||||
func (mw *MetaWrapper) UpdateExtentKeyAfterMigration(inode uint64, storageType uint32, objExtentKeys []proto.ObjExtentKey,
|
||||
writeGen uint64, delayDelMinute uint64, fullPath string,
|
||||
leaseExpire uint64, delayDelMinute uint64, fullPath string,
|
||||
) error {
|
||||
mp := mw.getPartitionByInode(inode)
|
||||
if mp == nil {
|
||||
err := fmt.Errorf("not found mp by inode(%v)", inode)
|
||||
log.LogErrorf("UpdateExtentKeyAfterMigration: inode(%v) storageType(%v) extentKeys(%v) writeGen(%v) err: %v",
|
||||
inode, storageType, objExtentKeys, writeGen, err.Error())
|
||||
log.LogErrorf("UpdateExtentKeyAfterMigration: inode(%v) storageType(%v) extentKeys(%v) leaseExpire(%v) err: %v",
|
||||
inode, storageType, objExtentKeys, leaseExpire, err.Error())
|
||||
return err
|
||||
}
|
||||
status, err := mw.updateExtentKeyAfterMigration(mp, inode, storageType, objExtentKeys, writeGen, delayDelMinute, fullPath)
|
||||
status, err := mw.updateExtentKeyAfterMigration(mp, inode, storageType, objExtentKeys, leaseExpire, delayDelMinute, fullPath)
|
||||
if err != nil || status != statusOK {
|
||||
log.LogErrorf("UpdateExtentKeyAfterMigration: inode(%v) storageType(%v) extentKeys(%v) writeGen(%v) status(%v) err: %v",
|
||||
inode, storageType, objExtentKeys, writeGen, status, err)
|
||||
msg := fmt.Sprintf("UpdateExtentKeyAfterMigration: inode(%v) storageType(%v) extentKeys(%v) leaseExpire(%v) status(%v) err: %v",
|
||||
inode, storageType, objExtentKeys, leaseExpire, status, err)
|
||||
if status == statusLeaseOccupiedByOthers {
|
||||
log.LogWarn(msg)
|
||||
return fmt.Errorf("statusLeaseOccupiedByOthers: %v", err)
|
||||
}
|
||||
if status == statusLeaseGenerationNotMatch {
|
||||
log.LogWarn(msg)
|
||||
return fmt.Errorf("statusLeaseGenerationNotMatch: %v", err)
|
||||
}
|
||||
log.LogError(msg)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@ -3040,7 +3040,7 @@ func (mw *MetaWrapper) renewalForbiddenMigration(mp *MetaPartition, inode uint64
|
||||
}
|
||||
|
||||
func (mw *MetaWrapper) updateExtentKeyAfterMigration(mp *MetaPartition, inode uint64, storageType uint32,
|
||||
extentKeys []proto.ObjExtentKey, writeGen uint64, delayDelMinute uint64, fullPath string,
|
||||
extentKeys []proto.ObjExtentKey, leaseExpire uint64, delayDelMinute uint64, fullPath string,
|
||||
) (status int, err error) {
|
||||
bgTime := stat.BeginStat()
|
||||
defer func() {
|
||||
@ -3051,7 +3051,7 @@ func (mw *MetaWrapper) updateExtentKeyAfterMigration(mp *MetaPartition, inode ui
|
||||
Inode: inode,
|
||||
StorageClass: storageType,
|
||||
NewObjExtentKeys: extentKeys,
|
||||
WriteGen: writeGen,
|
||||
LeaseExpire: leaseExpire,
|
||||
}
|
||||
req.DelayDeleteMinute = delayDelMinute
|
||||
req.FullPaths = []string{fullPath}
|
||||
|
||||
@ -399,7 +399,7 @@ func (a *Audit) LogMigrationOp(clientAddr, volume, op, fullPath string, err erro
|
||||
a.AddLog(entry)
|
||||
}
|
||||
|
||||
func (a *Audit) LogLcNodeOp(op, vol, name, path string, pid, inode, size, writeGen uint64, hasMek bool, from, to uint32, latency int64, err error) {
|
||||
func (a *Audit) LogLcNodeOp(op, vol, name, path string, pid, inode, size, leaseExpire uint64, hasMek bool, from, to uint32, latency int64, err error) {
|
||||
var errStr string
|
||||
if err != nil {
|
||||
errStr = err.Error()
|
||||
@ -412,7 +412,7 @@ func (a *Audit) LogLcNodeOp(op, vol, name, path string, pid, inode, size, writeG
|
||||
latencyStr := strconv.FormatInt(latency, 10) + " ms"
|
||||
|
||||
entry := fmt.Sprintf("%s %s, op: %s, vol: %s, %s, %s, parentIno: %v, ino: %v, size: %v, %v, %v, from: %v, to: %v, err: %v, %v",
|
||||
curTimeStr, timeZone, op, vol, name, path, pid, inode, size, writeGen, hasMek, from, to, errStr, latencyStr)
|
||||
curTimeStr, timeZone, op, vol, name, path, pid, inode, size, leaseExpire, hasMek, from, to, errStr, latencyStr)
|
||||
if a.prefix != nil {
|
||||
entry = fmt.Sprintf("%s%s", a.prefix.String(), entry)
|
||||
}
|
||||
@ -533,13 +533,13 @@ func LogMigrationOp(clientAddr, volume, op, fullPath string, err error, latency
|
||||
gAdt.LogMigrationOp(clientAddr, volume, op, fullPath, err, latency, ino, from, to)
|
||||
}
|
||||
|
||||
func LogLcNodeOp(op, vol, name, path string, pid, inode, size, writeGen uint64, hasMek bool, from, to uint32, latency int64, err error) {
|
||||
func LogLcNodeOp(op, vol, name, path string, pid, inode, size, leaseExpire uint64, hasMek bool, from, to uint32, latency int64, err error) {
|
||||
gAdtMutex.RLock()
|
||||
defer gAdtMutex.RUnlock()
|
||||
if gAdt == nil {
|
||||
return
|
||||
}
|
||||
gAdt.LogLcNodeOp(op, vol, name, path, pid, inode, size, writeGen, hasMek, from, to, latency, err)
|
||||
gAdt.LogLcNodeOp(op, vol, name, path, pid, inode, size, leaseExpire, hasMek, from, to, latency, err)
|
||||
}
|
||||
|
||||
func ResetWriterBufferSize(size int) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user