[#1296] writecache: Add count limit

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-08-06 15:09:12 +03:00 committed by Evgenii Stratonikov
parent 36efccd862
commit 08b1f18bca
10 changed files with 65 additions and 20 deletions

View file

@ -76,8 +76,7 @@ func (c *cache) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, erro
// putSmall persists small objects to the write-cache database and
// pushes the to the flush workers queue.
func (c *cache) putSmall(obj objectInfo) error {
cacheSize := c.estimateCacheSize()
if c.maxCacheSize < c.incSizeDB(cacheSize) {
if !c.hasEnoughSpaceDB() {
return ErrOutOfSpace
}
@ -107,8 +106,7 @@ func (c *cache) putSmall(obj objectInfo) error {
// putBig writes object to FSTree and pushes it to the flush workers queue.
func (c *cache) putBig(ctx context.Context, addr string, prm common.PutPrm) error {
cacheSz := c.estimateCacheSize()
if c.maxCacheSize < c.incSizeFS(cacheSz) {
if !c.hasEnoughSpaceFS() {
return ErrOutOfSpace
}