Skip to content

Commit

Permalink
update: adapt to rollback process of txn in metanode
Browse files Browse the repository at this point in the history
clean some log

Signed-off-by: leonrayang <[email protected]>
  • Loading branch information
leonrayang committed May 18, 2023
1 parent 7bccbc4 commit 103dc8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 0 additions & 5 deletions metanode/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,8 @@ func (uMgr *UidManager) setUidAcl(info []*proto.UidSpaceInfo) {
defer uMgr.acLock.Unlock()

uMgr.uidAcl = new(sync.Map)
log.LogDebugf("setUidAcl.vol %v info size %v", uMgr.volName, len(info))
for _, uidInfo := range info {
if uidInfo.VolName != uMgr.volName {
log.LogErrorf("setUidAcl.vol %v:%v not equal uid %v be set enable %v", uMgr.volName, uidInfo.VolName, uidInfo.Uid, uidInfo.Limited)
continue
}
log.LogDebugf("setUidAcl.vol %v uid %v be set enable %v", uMgr.volName, uidInfo.Uid, uidInfo.Limited)
Expand All @@ -364,17 +362,14 @@ func (uMgr *UidManager) getAllUidSpace() (rsp []*proto.UidReportSpaceInfo) {
uMgr.accumDelta.Range(func(key, value interface{}) bool {
var size int64
size += value.(int64)
log.LogDebugf("getAllUidSpace. mp[%v] accumBase key %v size %v", uMgr.mpID, key.(uint32), size)
if baseInfo, ok := uMgr.accumBase.Load(key.(uint32)); ok {
size += baseInfo.(int64)
if size < 0 {
log.LogErrorf("getAllUidSpace. mp[%v] uid %v size small than 0 %v, old %v, new %v", uMgr.mpID, key.(uint32), size, value.(int64), baseInfo.(int64))
return false
}
log.LogDebugf("getAllUidSpace. mp[%v] accumBase key %v size %v", uMgr.mpID, key.(uint32), size)
}
uMgr.accumBase.Store(key.(uint32), size)
log.LogDebugf("getAllUidSpace. mp[%v] accumBase key %v plus size %v", uMgr.mpID, key.(uint32), size)
return true
})

Expand Down
7 changes: 1 addition & 6 deletions metanode/partition_fsmop_inode.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ func (mp *metaPartition) fsmTxCreateInode(txIno *TxInode) (status uint8) {
return
}
//3.insert inode in inode tree
if _, ok := mp.inodeTree.ReplaceOrInsert(txIno.Inode, false); !ok {
status = proto.OpExistErr
return
}

return
return mp.fsmCreateInode(txIno.Inode)
}

// Create and inode and attach it to the inode tree.
Expand Down
9 changes: 8 additions & 1 deletion metanode/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,11 +896,18 @@ func (tr *TransactionResource) rollbackInode(txID string, inode uint64) (status
switch rbInode.rbType {
case TxAdd:
tr.txProcessor.mp.freeList.Remove(rbInode.inode.Inode)
tr.txProcessor.mp.inodeTree.ReplaceOrInsert(rbInode.inode, true)
_, ok = tr.txProcessor.mp.inodeTree.ReplaceOrInsert(rbInode.inode, false)
if ok && tr.txProcessor.mp.uidManager != nil {
tr.txProcessor.mp.uidManager.addUidSpace(rbInode.inode.Uid, rbInode.inode.Inode, rbInode.inode.Extents.eks)
}

//_ = tr.txProcessor.mp.fsmCreateInode(rbInode.inode)
case TxDelete:
//todo_tx: fsmUnlinkInode or internalDelete?
//_ = tr.txProcessor.mp.fsmUnlinkInode(rbInode.inode)
if rsp := tr.txProcessor.mp.getInode(rbInode.inode); tr.txProcessor.mp.uidManager != nil && rsp.Status == proto.OpOk {
tr.txProcessor.mp.uidManager.doMinusUidSpace(rbInode.inode.Uid, rbInode.inode.Inode, rbInode.inode.Size)
}
tr.txProcessor.mp.internalDeleteInode(rbInode.inode)
case TxUpdate:
if _, ok = tr.txProcessor.mp.inodeTree.ReplaceOrInsert(rbInode.inode, true); !ok {
Expand Down

0 comments on commit 103dc8f

Please sign in to comment.