fix(metanode): fix tx bug in concurrent use case.

Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
Victor1319 2024-08-08 16:42:36 +08:00 committed by AmazingChi
parent 79ce6ff6cf
commit d3fa6c9244
3 changed files with 24 additions and 0 deletions

View File

@ -94,6 +94,11 @@ func (mp *metaPartition) Apply(command []byte, index uint64) (resp interface{},
if inoOnce, err = InodeOnceUnmarshal(msg.V); err != nil {
return
}
status := mp.inodeInTx(inoOnce.Inode)
if status != proto.OpOk {
resp = &InodeResponse{Status: status}
return
}
ino := NewInode(inoOnce.Inode, 0)
ino.setVer(inoOnce.VerSeq)
resp = mp.fsmUnlinkInode(ino, inoOnce.UniqID)
@ -125,6 +130,11 @@ func (mp *metaPartition) Apply(command []byte, index uint64) (resp interface{},
if inoOnce, err = InodeOnceUnmarshal(msg.V); err != nil {
return
}
status := mp.inodeInTx(inoOnce.Inode)
if status != proto.OpOk {
resp = &InodeResponse{Status: status}
return
}
ino := NewInode(inoOnce.Inode, 0)
resp = mp.fsmCreateLinkInode(ino, inoOnce.UniqID)
case opFSMEvictInode:

View File

@ -64,6 +64,13 @@ func (mp *metaPartition) fsmTxCreateDentry(txDentry *TxDentry) (status uint8) {
}
}()
item := mp.dentryTree.Get(txDentry.Dentry)
if item != nil {
log.LogWarnf("fsmTxCreateDentry: got wrong dentry, want %v, got %v", txDentry.Dentry, item)
status = proto.OpExistErr
return
}
return mp.fsmCreateDentry(txDentry.Dentry, false)
}

View File

@ -263,6 +263,13 @@ func (mp *metaPartition) fsmTxUnlinkInode(txIno *TxInode) (resp *InodeResponse)
}
}()
item := mp.inodeTree.Get(txIno.Inode)
if item == nil || item.(*Inode).IsTempFile() {
resp.Status = proto.OpNotExistErr
log.LogWarnf("fsmTxUnlinkInode: inode may be already not exist or link 0, txInode %v, item %v", txIno, item)
return
}
resp = mp.fsmUnlinkInode(txIno.Inode, 0)
if resp.Status != proto.OpOk {
return