From 62b895817742c9754221570b52506c8bcf2acc7d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 15 Apr 2021 17:58:15 +0300 Subject: [PATCH] [#472] blobstor: check for blobovnicza without mutex first Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/blobstor/blobovnicza.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/blobstor/blobovnicza.go b/pkg/local_object_storage/blobstor/blobovnicza.go index 3adf42e72..3a6bbffa9 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza.go +++ b/pkg/local_object_storage/blobstor/blobovnicza.go @@ -807,11 +807,19 @@ func (b *blobovniczas) close() error { // // If blobovnicza is already opened and cached, instance from cache is returned w/o changes. func (b *blobovniczas) openBlobovnicza(p string) (*blobovnicza.Blobovnicza, error) { + b.lruMtx.Lock() + v, ok := b.opened.Get(p) + b.lruMtx.Unlock() + if ok { + // blobovnicza should be opened in cache + return v.(*blobovnicza.Blobovnicza), nil + } + b.openMtx.Lock() defer b.openMtx.Unlock() b.lruMtx.Lock() - v, ok := b.opened.Get(p) + v, ok = b.opened.Get(p) b.lruMtx.Unlock() if ok { // blobovnicza should be opened in cache