diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 9886c56e..3e276da1 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -117,6 +117,7 @@ const ( cfgShardUseWriteCache = "use_write_cache" cfgBlobStorSection = "blobstor" + cfgWriteCacheSection = "writecache" cfgBlobStorCompress = "compress" cfgBlobStorShallowDepth = "shallow_depth" cfgBlobStorTreePath = "path" @@ -442,6 +443,15 @@ func initShardOptions(c *cfg) { configPath(prefix, cfgShardUseWriteCache), ) + writeCachePrefix := configPath(prefix, cfgWriteCacheSection) + + writeCachePath := c.viper.GetString( + configPath(writeCachePrefix, cfgBlobStorTreePath), + ) + if useCache && writeCachePath == "" { + break + } + blobPrefix := configPath(prefix, cfgBlobStorSection) blobPath := c.viper.GetString( @@ -517,10 +527,14 @@ func initShardOptions(c *cfg) { meta.WithPermissions(metaPerm), ), shard.WithWriteCache(useCache), + shard.WithWriteCacheOptions( + blobstor.WithTreeRootPath(writeCachePath), + ), }) c.log.Info("storage shard options", zap.Bool("with write cache", useCache), + zap.String("with write cache path", writeCachePath), zap.String("BLOB path", blobPath), zap.Stringer("BLOB permissions", blobPerm), zap.Bool("BLOB compress", compressObjects), diff --git a/pkg/local_object_storage/shard/info.go b/pkg/local_object_storage/shard/info.go index dba9787b..f195ee42 100644 --- a/pkg/local_object_storage/shard/info.go +++ b/pkg/local_object_storage/shard/info.go @@ -16,6 +16,9 @@ type Info struct { // Information about the BLOB storage. BlobStorInfo blobstor.Info + // Information about the Write Cache. + WriteCacheInfo blobstor.Info + // Weight parameters of the shard. WeightValues WeightValues } diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index 838fc072..d245d74a 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -32,6 +32,8 @@ type cfg struct { metaOpts []meta.Option + writeCacheOpts []blobstor.Option + log *logger.Logger } @@ -51,10 +53,11 @@ func New(opts ...Option) *Shard { if c.useWriteCache { writeCache = blobstor.New( - blobstor.WithBlobovniczaShallowDepth(0), - blobstor.WithBlobovniczaShallowWidth(1), - blobstor.WithLogger(c.log), - // ? what about path + append(c.blobOpts, append( + c.writeCacheOpts, + blobstor.WithBlobovniczaShallowDepth(0), + blobstor.WithBlobovniczaShallowWidth(1))..., + )..., ) } @@ -88,6 +91,13 @@ func WithMetaBaseOptions(opts ...meta.Option) Option { } } +// WithMetaBaseOptions returns option to set internal metabase options. +func WithWriteCacheOptions(opts ...blobstor.Option) Option { + return func(c *cfg) { + c.writeCacheOpts = opts + } +} + // WithLogger returns option to set Shard's logger. func WithLogger(l *logger.Logger) Option { return func(c *cfg) {