From b0e94b6a6b9e89f8c59402279ba903259cd96f5f Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 8 Nov 2022 15:20:58 +0300 Subject: [PATCH] [#1906] writecache: Do not require `read-only` mode in `Flush` It was needed before we started to flush during transition to `degraded` mode. Now it is confusing. Signed-off-by: Evgenii Stratonikov --- CHANGELOG.md | 1 + pkg/local_object_storage/shard/writecache.go | 9 +-------- pkg/local_object_storage/writecache/flush.go | 4 ---- pkg/local_object_storage/writecache/flush_test.go | 1 - 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e719b41b6..aefd217c6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Changelog for NeoFS Node - Physical child object removal by GC (#1699) - Broadcasting helper objects (#1972) - `neofs-cli lock object`'s `lifetime` flag handling (#1972) +- Do not move write-cache in read-only mode for flushing (#1906) ### Removed ### Updated diff --git a/pkg/local_object_storage/shard/writecache.go b/pkg/local_object_storage/shard/writecache.go index c217ab913b..7282f121ca 100644 --- a/pkg/local_object_storage/shard/writecache.go +++ b/pkg/local_object_storage/shard/writecache.go @@ -2,8 +2,6 @@ package shard import ( "errors" - - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode" ) // FlushWriteCachePrm represents parameters of a `FlushWriteCache` operation. @@ -20,8 +18,7 @@ func (p *FlushWriteCachePrm) SetIgnoreErrors(ignore bool) { // but write-cache is disabled. var errWriteCacheDisabled = errors.New("write-cache is disabled") -// FlushWriteCache moves writecache in read-only mode and flushes all data from it. -// After the operation writecache will remain read-only mode. +// FlushWriteCache flushes all data from the write-cache. func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error { if !s.hasWriteCache() { return errWriteCacheDisabled @@ -38,9 +35,5 @@ func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error { return ErrDegradedMode } - if err := s.writeCache.SetMode(mode.ReadOnly); err != nil { - return err - } - return s.writeCache.Flush(p.ignoreErrors) } diff --git a/pkg/local_object_storage/writecache/flush.go b/pkg/local_object_storage/writecache/flush.go index 346f4613f0..3a6aed5b30 100644 --- a/pkg/local_object_storage/writecache/flush.go +++ b/pkg/local_object_storage/writecache/flush.go @@ -261,10 +261,6 @@ func (c *cache) Flush(ignoreErrors bool) error { c.modeMtx.RLock() defer c.modeMtx.RUnlock() - if !c.mode.ReadOnly() { - return errMustBeReadOnly - } - return c.flush(ignoreErrors) } diff --git a/pkg/local_object_storage/writecache/flush_test.go b/pkg/local_object_storage/writecache/flush_test.go index dea042e12c..15dbfa6b6d 100644 --- a/pkg/local_object_storage/writecache/flush_test.go +++ b/pkg/local_object_storage/writecache/flush_test.go @@ -113,7 +113,6 @@ func TestFlush(t *testing.T) { wc, bs, mb := newCache(t) objects := putObjects(t, wc) - require.NoError(t, wc.SetMode(mode.ReadOnly)) require.NoError(t, bs.SetMode(mode.ReadWrite)) require.NoError(t, mb.SetMode(mode.ReadWrite))