From b6930f221986fb48b336fecd1fedf8fe655b35b0 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 28 Oct 2022 13:00:11 +0300 Subject: [PATCH] [#1992] neofs-node: Allow to open fstree in NOSYNC mode Signed-off-by: Evgenii Stratonikov --- CHANGELOG.md | 2 ++ cmd/neofs-node/config.go | 13 ++++++++----- cmd/neofs-node/config/engine/config_test.go | 10 ++++++++-- .../config/engine/shard/blobstor/fstree/config.go | 7 +++++++ config/example/node.env | 1 + config/example/node.json | 1 + config/example/node.yaml | 1 + 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 846d2545..4da70062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Changelog for NeoFS Node ### Added ### Changed ### Fixed +- Open FSTree in sync mode by default (#1992) + ### Removed ### Updated ### Updating from v0.34.0 diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 7ecdad33..c36028c0 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -155,10 +155,11 @@ func (c *shardCfg) id() string { type subStorageCfg struct { // common for all storages - typ string - path string - perm fs.FileMode - depth uint64 + typ string + path string + perm fs.FileMode + depth uint64 + noSync bool // blobovnicza-specific size uint64 @@ -258,6 +259,7 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error { case fstree.Type: sub := fstreeconfig.From((*config.Config)(storagesCfg[i])) sCfg.depth = sub.Depth() + sCfg.noSync = sub.NoSync() default: return fmt.Errorf("invalid storage type: %s", storagesCfg[i].Type()) } @@ -681,7 +683,8 @@ func (c *cfg) shardOpts() []shardOptsWithID { Storage: fstree.New( fstree.WithPath(sRead.path), fstree.WithPerm(sRead.perm), - fstree.WithDepth(sRead.depth)), + fstree.WithDepth(sRead.depth), + fstree.WithNoSync(sRead.noSync)), Policy: func(_ *objectSDK.Object, data []byte) bool { return true }, diff --git a/cmd/neofs-node/config/engine/config_test.go b/cmd/neofs-node/config/engine/config_test.go index fa0f656d..22444727 100644 --- a/cmd/neofs-node/config/engine/config_test.go +++ b/cmd/neofs-node/config/engine/config_test.go @@ -95,7 +95,10 @@ func TestEngineSection(t *testing.T) { require.Equal(t, "tmp/0/blob", ss[1].Path()) require.EqualValues(t, 0644, ss[1].Perm()) - require.EqualValues(t, 5, fstreeconfig.From((*config.Config)(ss[1])).Depth()) + + fst := fstreeconfig.From((*config.Config)(ss[1])) + require.EqualValues(t, 5, fst.Depth()) + require.Equal(t, false, fst.NoSync()) require.EqualValues(t, 150, gc.RemoverBatchSize()) require.Equal(t, 2*time.Minute, gc.RemoverSleepInterval()) @@ -137,7 +140,10 @@ func TestEngineSection(t *testing.T) { require.Equal(t, "tmp/1/blob", ss[1].Path()) require.EqualValues(t, 0644, ss[1].Perm()) - require.EqualValues(t, 5, fstreeconfig.From((*config.Config)(ss[1])).Depth()) + + fst := fstreeconfig.From((*config.Config)(ss[1])) + require.EqualValues(t, 5, fst.Depth()) + require.Equal(t, true, fst.NoSync()) require.EqualValues(t, 200, gc.RemoverBatchSize()) require.Equal(t, 5*time.Minute, gc.RemoverSleepInterval()) diff --git a/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go b/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go index 8be8876c..cf9df902 100644 --- a/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go +++ b/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go @@ -38,3 +38,10 @@ func (x *Config) Depth() uint64 { return DepthDefault } + +// NoSync returns the value of "no_sync" config parameter. +// +// Returns false if the value is not a boolean or is missing. +func (x *Config) NoSync() bool { + return config.BoolSafe((*config.Config)(x), "no_sync") +} diff --git a/config/example/node.env b/config/example/node.env index e7c9cfab..e07b467e 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -160,6 +160,7 @@ NEOFS_STORAGE_SHARD_1_BLOBSTOR_0_OPENED_CACHE_CAPACITY=50 NEOFS_STORAGE_SHARD_1_BLOBSTOR_1_TYPE=fstree NEOFS_STORAGE_SHARD_1_BLOBSTOR_1_PATH=tmp/1/blob NEOFS_STORAGE_SHARD_1_BLOBSTOR_1_PERM=0644 +NEOFS_STORAGE_SHARD_1_BLOBSTOR_1_NO_SYNC=true NEOFS_STORAGE_SHARD_1_BLOBSTOR_1_DEPTH=5 ### Pilorama config NEOFS_STORAGE_SHARD_1_PILORAMA_PATH="tmp/1/blob/pilorama.db" diff --git a/config/example/node.json b/config/example/node.json index fa35fa27..b7d12758 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -214,6 +214,7 @@ { "type": "fstree", "path": "tmp/1/blob", + "no_sync": true, "perm": "0644", "depth": 5 } diff --git a/config/example/node.yaml b/config/example/node.yaml index 6a316e83..e1a7fbf0 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -198,6 +198,7 @@ storage: path: tmp/1/blob/blobovnicza - type: fstree path: tmp/1/blob # blobstor path + no_sync: true pilorama: path: tmp/1/blob/pilorama.db