forked from TrueCloudLab/frostfs-node
[#602] blobovnicza: Fix size counter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
2e49d7ea7e
commit
809e97626b
7 changed files with 99 additions and 52 deletions
|
@ -28,8 +28,9 @@ func bucketKeyFromBounds(upperBound uint64) []byte {
|
|||
return buf[:ln]
|
||||
}
|
||||
|
||||
func bucketForSize(sz uint64) []byte {
|
||||
return bucketKeyFromBounds(upperPowerOfTwo(sz))
|
||||
func bucketForSize(sz uint64) ([]byte, uint64) {
|
||||
upperBound := upperPowerOfTwo(sz)
|
||||
return bucketKeyFromBounds(upperBound), upperBound
|
||||
}
|
||||
|
||||
func upperPowerOfTwo(v uint64) uint64 {
|
||||
|
@ -40,15 +41,15 @@ func upperPowerOfTwo(v uint64) uint64 {
|
|||
}
|
||||
|
||||
func (b *Blobovnicza) incSize(sz uint64) {
|
||||
b.filled.Add(sz)
|
||||
b.dataSize.Add(sz)
|
||||
b.metrics.AddSize(sz)
|
||||
}
|
||||
|
||||
func (b *Blobovnicza) decSize(sz uint64) {
|
||||
b.filled.Add(^(sz - 1))
|
||||
b.dataSize.Add(^(sz - 1))
|
||||
b.metrics.SubSize(sz)
|
||||
}
|
||||
|
||||
func (b *Blobovnicza) full() bool {
|
||||
return b.filled.Load() >= b.fullSizeLimit
|
||||
return b.dataSize.Load() >= b.fullSizeLimit
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue