[#1992] neofs-node: Allow to open fstree in NOSYNC mode

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-28 13:00:11 +03:00 committed by fyrchik
parent 3c1f788642
commit a386448ab9
7 changed files with 28 additions and 7 deletions

View file

@ -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

View file

@ -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
},

View file

@ -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())

View file

@ -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")
}

View file

@ -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"

View file

@ -214,6 +214,7 @@
{
"type": "fstree",
"path": "tmp/1/blob",
"no_sync": true,
"perm": "0644",
"depth": 5
}

View file

@ -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