diff --git a/pkg/local_object_storage/engine/delete.go b/pkg/local_object_storage/engine/delete.go index 47207c3bd..6992bfc61 100644 --- a/pkg/local_object_storage/engine/delete.go +++ b/pkg/local_object_storage/engine/delete.go @@ -30,9 +30,6 @@ func (p *DeletePrm) WithAddress(addr *objectSDK.Address) *DeletePrm { // Returns any error encountered that did not allow to completely // mark the object to delete. func (e *StorageEngine) Delete(prm *DeletePrm) (*DeleteRes, error) { - e.mtx.RLock() - defer e.mtx.RUnlock() - shPrm := new(shard.DeletePrm) e.iterateOverSortedShards(prm.addr, func(sh *shard.Shard) (stop bool) { diff --git a/pkg/local_object_storage/engine/get.go b/pkg/local_object_storage/engine/get.go index b3e5d41d6..56aa2cf9f 100644 --- a/pkg/local_object_storage/engine/get.go +++ b/pkg/local_object_storage/engine/get.go @@ -61,9 +61,6 @@ func (r *GetRes) Object() *object.Object { // // Returns ErrObjectNotFound if requested object is missing in local storage. func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { - e.mtx.RLock() - defer e.mtx.RUnlock() - var obj *object.Object shPrm := new(shard.GetPrm). diff --git a/pkg/local_object_storage/engine/head.go b/pkg/local_object_storage/engine/head.go index e366cb50d..153afe491 100644 --- a/pkg/local_object_storage/engine/head.go +++ b/pkg/local_object_storage/engine/head.go @@ -43,9 +43,6 @@ func (r *HeadRes) Header() *object.Object { // // Returns ErrObjectNotFound if requested object is missing in local storage. func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) { - e.mtx.RLock() - defer e.mtx.RUnlock() - var head *object.Object shPrm := new(shard.GetPrm). diff --git a/pkg/local_object_storage/engine/put.go b/pkg/local_object_storage/engine/put.go index 1de882a59..ff085a958 100644 --- a/pkg/local_object_storage/engine/put.go +++ b/pkg/local_object_storage/engine/put.go @@ -34,9 +34,6 @@ func (p *PutPrm) WithObject(obj *object.Object) *PutPrm { // Returns any error encountered that // did not allow to completely save the object. func (e *StorageEngine) Put(prm *PutPrm) (*PutRes, error) { - e.mtx.Lock() - defer e.mtx.Unlock() - // choose shards through sorting by weight sortedShards := e.sortShardsByWeight(prm.obj.Address()) diff --git a/pkg/local_object_storage/engine/select.go b/pkg/local_object_storage/engine/select.go index 289de84f9..5ca1b84fd 100644 --- a/pkg/local_object_storage/engine/select.go +++ b/pkg/local_object_storage/engine/select.go @@ -35,9 +35,6 @@ func (r *SelectRes) AddressList() []*objectSDK.Address { // // Returns any error encountered that did not allow to completely select the objects. func (e *StorageEngine) Select(prm *SelectPrm) (*SelectRes, error) { - e.mtx.RLock() - defer e.mtx.RUnlock() - addrList := make([]*object.Address, 0) shPrm := new(shard.SelectPrm). diff --git a/pkg/local_object_storage/engine/shards.go b/pkg/local_object_storage/engine/shards.go index 3435b2c0c..ee41e2d69 100644 --- a/pkg/local_object_storage/engine/shards.go +++ b/pkg/local_object_storage/engine/shards.go @@ -49,6 +49,9 @@ func (e *StorageEngine) shardWeight(sh *shard.Shard) float64 { } func (e *StorageEngine) sortShardsByWeight(objAddr fmt.Stringer) []*shard.Shard { + e.mtx.RLock() + defer e.mtx.RUnlock() + shards := make([]*shard.Shard, 0, len(e.shards)) weights := make([]float64, 0, len(e.shards))