[#1085] writecache: add read-only mode

In read-only mode modifying operations are immediately returned with
error and all background operations are suspended.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-18 15:47:16 +03:00 committed by LeL
parent 9f963e001b
commit ad01aaf8bf
7 changed files with 139 additions and 28 deletions

View file

@ -12,6 +12,12 @@ var ErrBigObject = errors.New("too big object")
// Put puts object to write-cache.
func (c *cache) Put(o *object.Object) error {
c.modeMtx.RLock()
defer c.modeMtx.RUnlock()
if c.mode == ModeReadOnly {
return ErrReadOnly
}
sz := uint64(o.ToV2().StableSize())
if sz > c.maxObjectSize {
return ErrBigObject