diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 1e6e6def45..6f17385279 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -373,10 +373,8 @@ func initShardOptions(c *cfg) { engineconfig.IterateShards(c.appCfg, require, func(sc *shardconfig.Config) { var writeCacheOpts []writecache.Option - useWriteCache := sc.UseWriteCache() - if useWriteCache { - writeCacheCfg := sc.WriteCache() - + writeCacheCfg := sc.WriteCache() + if writeCacheCfg.Enabled() { writeCacheOpts = []writecache.Option{ writecache.WithPath(writeCacheCfg.Path()), writecache.WithLogger(c.log), @@ -421,7 +419,7 @@ func initShardOptions(c *cfg) { Timeout: 100 * time.Millisecond, }), ), - shard.WithWriteCache(useWriteCache), + shard.WithWriteCache(writeCacheCfg.Enabled()), shard.WithWriteCacheOptions(writeCacheOpts...), shard.WithRemoverBatchSize(gcCfg.RemoverBatchSize()), shard.WithGCRemoverSleepInterval(gcCfg.RemoverSleepInterval()), diff --git a/cmd/neofs-node/config/engine/config_test.go b/cmd/neofs-node/config/engine/config_test.go index fd4df9afd0..3f95de485e 100644 --- a/cmd/neofs-node/config/engine/config_test.go +++ b/cmd/neofs-node/config/engine/config_test.go @@ -55,7 +55,7 @@ func TestEngineSection(t *testing.T) { switch num { case 0: - require.Equal(t, false, sc.UseWriteCache()) + require.Equal(t, false, wc.Enabled()) require.Equal(t, "tmp/0/cache", wc.Path()) require.EqualValues(t, 2147483648, wc.MemSize()) @@ -85,7 +85,7 @@ func TestEngineSection(t *testing.T) { require.Equal(t, false, sc.RefillMetabase()) require.Equal(t, shard.ModeReadOnly, sc.Mode()) case 1: - require.Equal(t, true, sc.UseWriteCache()) + require.Equal(t, true, wc.Enabled()) require.Equal(t, "tmp/1/cache", wc.Path()) require.EqualValues(t, 2147483648, wc.MemSize()) diff --git a/cmd/neofs-node/config/engine/shard/config.go b/cmd/neofs-node/config/engine/shard/config.go index a4ce95e506..147b1c3374 100644 --- a/cmd/neofs-node/config/engine/shard/config.go +++ b/cmd/neofs-node/config/engine/shard/config.go @@ -20,16 +20,6 @@ func From(c *config.Config) *Config { return (*Config)(c) } -// UseWriteCache returns value of "use_write_cache" config parameter. -// -// Panics if value is not a valid bool. -func (x *Config) UseWriteCache() bool { - return config.Bool( - (*config.Config)(x), - "use_write_cache", - ) -} - // BlobStor returns "blobstor" subsection as a blobstorconfig.Config. func (x *Config) BlobStor() *blobstorconfig.Config { return blobstorconfig.From( diff --git a/cmd/neofs-node/config/engine/shard/writecache/config.go b/cmd/neofs-node/config/engine/shard/writecache/config.go index 9a8f22b534..223f2d9bfd 100644 --- a/cmd/neofs-node/config/engine/shard/writecache/config.go +++ b/cmd/neofs-node/config/engine/shard/writecache/config.go @@ -31,6 +31,13 @@ func From(c *config.Config) *Config { return (*Config)(c) } +// Enabled returns true if write-cache is enabled and false otherwise. +// +// Panics if value is not a boolean. +func (x *Config) Enabled() bool { + return config.Bool((*config.Config)(x), "enabled") +} + // Path returns value of "path" config parameter. // // Panics if value is not a non-empty string. diff --git a/config/example/node.env b/config/example/node.env index f241817c45..110b4c8636 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -76,7 +76,7 @@ NEOFS_STORAGE_SHARD_0_RESYNC_METABASE=false ### Flag to set shard mode NEOFS_STORAGE_SHARD_0_MODE=read-only ### Write cache config -NEOFS_STORAGE_SHARD_0_USE_WRITE_CACHE=false +NEOFS_STORAGE_SHARD_0_WRITECACHE_ENABLED=false NEOFS_STORAGE_SHARD_0_WRITECACHE_PATH=tmp/0/cache NEOFS_STORAGE_SHARD_0_WRITECACHE_MEMCACHE_CAPACITY=2147483648 NEOFS_STORAGE_SHARD_0_WRITECACHE_SMALL_OBJECT_SIZE=16384 @@ -110,7 +110,7 @@ NEOFS_STORAGE_SHARD_1_RESYNC_METABASE=true ### Flag to set shard mode NEOFS_STORAGE_SHARD_1_MODE=read-write ### Write cache config -NEOFS_STORAGE_SHARD_1_USE_WRITE_CACHE=true +NEOFS_STORAGE_SHARD_1_WRITECACHE_ENABLED=true NEOFS_STORAGE_SHARD_1_WRITECACHE_PATH=tmp/1/cache NEOFS_STORAGE_SHARD_1_WRITECACHE_MEMCACHE_CAPACITY=2147483648 NEOFS_STORAGE_SHARD_1_WRITECACHE_SMALL_OBJECT_SIZE=16384 diff --git a/config/example/node.json b/config/example/node.json index 7c2887392a..10537c1ae1 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -119,8 +119,8 @@ "0": { "mode": "read-only", "resync_metabase": false, - "use_write_cache": false, "writecache": { + "enabled": false, "path": "tmp/0/cache", "memcache_capacity": 2147483648, "small_object_size": 16384, @@ -156,8 +156,8 @@ "1": { "mode": "read-write", "resync_metabase": true, - "use_write_cache": true, "writecache": { + "enabled": true, "path": "tmp/1/cache", "memcache_capacity": 2147483648, "small_object_size": 16384, diff --git a/config/example/node.yaml b/config/example/node.yaml index 217d81b0c3..7dda3d5c68 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -102,9 +102,8 @@ storage: default: # section with the default shard parameters resync_metabase: true # sync metabase with blobstor on start, expensive, leave false until complete understanding - use_write_cache: true # use write-cache - writecache: + enabled: true memcache_capacity: 2147483648 # approximate RAM usage limit for "small" objects, bytes small_object_size: 16384 # size threshold for "small" objects which are cached in key-value DB, not in FS, bytes max_object_size: 134217728 # size threshold for "big" objects which bypass write-cache and go to the storage directly, bytes @@ -134,9 +133,8 @@ storage: mode: "read-only" # mode of the shard, must be one of the: "read-write" (default), "read-only" resync_metabase: false # sync metabase with blobstor on start, expensive, leave false until complete understanding - use_write_cache: false # use write-cache - writecache: + enabled: false path: tmp/0/cache # write-cache root directory capacity: 3221225472 # approximate write-cache total size, bytes diff --git a/config/mainnet/config.yml b/config/mainnet/config.yml index b4f13dfca8..fac3a4298c 100644 --- a/config/mainnet/config.yml +++ b/config/mainnet/config.yml @@ -20,7 +20,6 @@ storage: shard_num: 1 shard: 0: - use_write_cache: false metabase: path: /metabase perm: 0600 @@ -31,6 +30,8 @@ storage: opened_cache_capacity: 32 depth: 1 width: 1 + writecache: + enabled: false gc: remover_batch_size: 100 remover_sleep_interval: 1m diff --git a/config/testnet/config.yml b/config/testnet/config.yml index 61d0158876..6616da3307 100644 --- a/config/testnet/config.yml +++ b/config/testnet/config.yml @@ -39,7 +39,6 @@ storage: shard_num: 1 shard: 0: - use_write_cache: false metabase: path: /storage/metabase perm: 0777 @@ -50,6 +49,8 @@ storage: opened_cache_capacity: 32 depth: 1 width: 1 + writecache: + enabled: false gc: remover_batch_size: 100 remover_sleep_interval: 1m