[#2057] blobstor: Block operations on a mode change

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
remotes/fyrchik/remove-useless-logs
Pavel Karpy 2022-11-15 15:33:48 +03:00 committed by fyrchik
parent 1779664644
commit fa231b8c56
7 changed files with 21 additions and 0 deletions

View File

@ -8,6 +8,9 @@ import (
)
func (b *BlobStor) Delete(prm common.DeletePrm) (common.DeleteRes, error) {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
if prm.StorageID == nil {
for i := range b.storage {
res, err := b.storage[i].Storage.Delete(prm)

View File

@ -10,6 +10,9 @@ import (
// Returns any error encountered that did not allow
// to completely check object existence.
func (b *BlobStor) Exists(prm common.ExistsPrm) (common.ExistsRes, error) {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
// If there was an error during existence check below,
// it will be returned unless object was found in blobovnicza.
// Otherwise, it is logged and the latest error is returned.

View File

@ -12,6 +12,9 @@ import (
// If the descriptor is present, only one sub-storage is tried,
// Otherwise, each sub-storage is tried in order.
func (b *BlobStor) Get(prm common.GetPrm) (common.GetRes, error) {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
if prm.StorageID == nil {
for i := range b.storage {
res, err := b.storage[i].Storage.Get(prm)

View File

@ -12,6 +12,9 @@ import (
// If the descriptor is present, only one sub-storage is tried,
// Otherwise, each sub-storage is tried in order.
func (b *BlobStor) GetRange(prm common.GetRangePrm) (common.GetRangeRes, error) {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
if prm.StorageID == nil {
for i := range b.storage {
res, err := b.storage[i].Storage.GetRange(prm)

View File

@ -2,6 +2,9 @@ package blobstor
// DumpInfo returns information about blob stor.
func (b *BlobStor) DumpInfo() Info {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
sub := make([]SubStorageInfo, len(b.storage))
for i := range b.storage {
sub[i].Path = b.storage[i].Storage.Path()

View File

@ -16,6 +16,9 @@ import (
//
// If handler returns an error, method wraps and returns it immediately.
func (b *BlobStor) Iterate(prm common.IteratePrm) (common.IterateRes, error) {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
for i := range b.storage {
_, err := b.storage[i].Storage.Iterate(prm)
if err != nil && !prm.IgnoreErrors {

View File

@ -22,6 +22,9 @@ var ErrNoPlaceFound = logicerr.New("couldn't find a place to store an object")
// Returns any error encountered that
// did not allow to completely save the object.
func (b *BlobStor) Put(prm common.PutPrm) (common.PutRes, error) {
b.modeMtx.RLock()
defer b.modeMtx.RUnlock()
if prm.Object != nil {
prm.Address = object.AddressOf(prm.Object)
}