forked from TrueCloudLab/frostfs-node
[#1493] metabase: Split inhumeTx() into 2 functions
No functional changes. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
1e6f132b4e
commit
44df67492f
1 changed files with 73 additions and 65 deletions
|
@ -224,8 +224,18 @@ func (db *DB) inhumeTx(tx *bbolt.Tx, epoch uint64, prm InhumePrm, res *InhumeRes
|
||||||
|
|
||||||
buf := make([]byte, addressKeySize)
|
buf := make([]byte, addressKeySize)
|
||||||
for i := range prm.target {
|
for i := range prm.target {
|
||||||
id := prm.target[i].Object()
|
if err := db.inhumeTxSingle(bkt, value, graveyardBKT, garbageBKT, prm.target[i], buf, epoch, prm, res); err != nil {
|
||||||
cnr := prm.target[i].Container()
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return db.applyInhumeResToCounters(tx, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DB) inhumeTxSingle(bkt *bbolt.Bucket, value []byte, graveyardBKT, garbageBKT *bbolt.Bucket, addr oid.Address, buf []byte, epoch uint64, prm InhumePrm, res *InhumeRes) error {
|
||||||
|
id := addr.Object()
|
||||||
|
cnr := addr.Container()
|
||||||
|
tx := bkt.Tx()
|
||||||
|
|
||||||
// prevent locked objects to be inhumed
|
// prevent locked objects to be inhumed
|
||||||
if !prm.forceRemoval && objectLocked(tx, cnr, id) {
|
if !prm.forceRemoval && objectLocked(tx, cnr, id) {
|
||||||
|
@ -245,8 +255,8 @@ func (db *DB) inhumeTx(tx *bbolt.Tx, epoch uint64, prm InhumePrm, res *InhumeRes
|
||||||
lockWasChecked = true
|
lockWasChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
obj, err := db.get(tx, prm.target[i], buf, false, true, epoch)
|
obj, err := db.get(tx, addr, buf, false, true, epoch)
|
||||||
targetKey := addressKey(prm.target[i], buf)
|
targetKey := addressKey(addr, buf)
|
||||||
var ecErr *objectSDK.ECInfoError
|
var ecErr *objectSDK.ECInfoError
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = db.updateDeleteInfo(tx, garbageBKT, graveyardBKT, targetKey, cnr, obj, res)
|
err = db.updateDeleteInfo(tx, garbageBKT, graveyardBKT, targetKey, cnr, obj, res)
|
||||||
|
@ -268,7 +278,7 @@ func (db *DB) inhumeTx(tx *bbolt.Tx, epoch uint64, prm InhumePrm, res *InhumeRes
|
||||||
}
|
}
|
||||||
|
|
||||||
if isTomb {
|
if isTomb {
|
||||||
continue
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,16 +294,14 @@ func (db *DB) inhumeTx(tx *bbolt.Tx, epoch uint64, prm InhumePrm, res *InhumeRes
|
||||||
if lockWasChecked {
|
if lockWasChecked {
|
||||||
// inhumed object is not of
|
// inhumed object is not of
|
||||||
// the LOCK type
|
// the LOCK type
|
||||||
continue
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if isLockObject(tx, cnr, id) {
|
if isLockObject(tx, cnr, id) {
|
||||||
res.deletedLockObj = append(res.deletedLockObj, prm.target[i])
|
res.deletedLockObj = append(res.deletedLockObj, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return nil
|
||||||
|
|
||||||
return db.applyInhumeResToCounters(tx, res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) inhumeECInfo(tx *bbolt.Tx, epoch uint64, tomb *oid.Address, res *InhumeRes,
|
func (db *DB) inhumeECInfo(tx *bbolt.Tx, epoch uint64, tomb *oid.Address, res *InhumeRes,
|
||||||
|
|
Loading…
Reference in a new issue