From 1608fd1c075acf41f6a5776bf0d9d10c1bfc7475 Mon Sep 17 00:00:00 2001
From: Pavel Karpy
Date: Tue, 20 Dec 2022 15:29:05 +0300
Subject: [PATCH] [#2167] write-cache: Add "write-cache" to its logs
Signed-off-by: Pavel Karpy
---
pkg/local_object_storage/writecache/delete.go | 12 ++++++++++--
pkg/local_object_storage/writecache/init.go | 12 ++++++++++--
pkg/local_object_storage/writecache/put.go | 13 +++++++++++--
pkg/local_object_storage/writecache/storage.go | 12 ++++++++++--
pkg/local_object_storage/writecache/writecache.go | 3 +++
5 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/pkg/local_object_storage/writecache/delete.go b/pkg/local_object_storage/writecache/delete.go
index b8988dbb3..e580317f8 100644
--- a/pkg/local_object_storage/writecache/delete.go
+++ b/pkg/local_object_storage/writecache/delete.go
@@ -36,14 +36,22 @@ func (c *cache) Delete(addr oid.Address) error {
if err != nil {
return err
}
- storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("db DELETE"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(saddr),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("db DELETE"),
+ )
c.objCounters.DecDB()
return nil
}
_, err := c.fsTree.Delete(common.DeletePrm{Address: addr})
if err == nil {
- storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("fstree DELETE"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(saddr),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("fstree DELETE"),
+ )
c.objCounters.DecFS()
}
diff --git a/pkg/local_object_storage/writecache/init.go b/pkg/local_object_storage/writecache/init.go
index 0ccdb6851..fbcc455c0 100644
--- a/pkg/local_object_storage/writecache/init.go
+++ b/pkg/local_object_storage/writecache/init.go
@@ -26,7 +26,11 @@ func (c *cache) initFlushMarks() {
_, err := c.fsTree.Delete(prm)
if err == nil {
- storagelog.Write(c.log, storagelog.AddressField(addr), storagelog.OpField("fstree DELETE"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(addr),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("fstree DELETE"),
+ )
}
}
}
@@ -83,7 +87,11 @@ func (c *cache) initFlushMarks() {
})
if err == nil {
for _, j := range indices {
- storagelog.Write(c.log, zap.String("address", m[j]), storagelog.OpField("db DELETE"))
+ storagelog.Write(c.log,
+ zap.String("address", m[j]),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("db DELETE"),
+ )
}
}
lastKey = append([]byte(m[len(m)-1]), 0)
diff --git a/pkg/local_object_storage/writecache/put.go b/pkg/local_object_storage/writecache/put.go
index 4a78c0b7e..9396f3a68 100644
--- a/pkg/local_object_storage/writecache/put.go
+++ b/pkg/local_object_storage/writecache/put.go
@@ -53,7 +53,11 @@ func (c *cache) putSmall(obj objectInfo) error {
return b.Put([]byte(obj.addr), obj.data)
})
if err == nil {
- storagelog.Write(c.log, storagelog.AddressField(obj.addr), storagelog.OpField("db PUT"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(obj.addr),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("db PUT"),
+ )
c.objCounters.IncDB()
}
return nil
@@ -77,6 +81,11 @@ func (c *cache) putBig(addr string, prm common.PutPrm) error {
c.mtx.Unlock()
}
c.objCounters.IncFS()
- storagelog.Write(c.log, storagelog.AddressField(addr), storagelog.OpField("fstree PUT"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(addr),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("fstree PUT"),
+ )
+
return nil
}
diff --git a/pkg/local_object_storage/writecache/storage.go b/pkg/local_object_storage/writecache/storage.go
index af25a01ec..bb65a612a 100644
--- a/pkg/local_object_storage/writecache/storage.go
+++ b/pkg/local_object_storage/writecache/storage.go
@@ -109,7 +109,11 @@ func (c *cache) deleteFromDB(keys []string) []string {
})
for i := 0; i < errorIndex; i++ {
c.objCounters.DecDB()
- storagelog.Write(c.log, storagelog.AddressField(keys[i]), storagelog.OpField("db DELETE"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(keys[i]),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("db DELETE"),
+ )
}
if err != nil {
c.log.Error("can't remove objects from the database", zap.Error(err))
@@ -142,7 +146,11 @@ func (c *cache) deleteFromDisk(keys []string) []string {
copyIndex++
continue
} else if err == nil {
- storagelog.Write(c.log, storagelog.AddressField(keys[i]), storagelog.OpField("fstree DELETE"))
+ storagelog.Write(c.log,
+ storagelog.AddressField(keys[i]),
+ storagelog.StorageTypeField(wcStorageType),
+ storagelog.OpField("fstree DELETE"),
+ )
c.objCounters.DecFS()
}
}
diff --git a/pkg/local_object_storage/writecache/writecache.go b/pkg/local_object_storage/writecache/writecache.go
index 4d5110d65..fa52c08a0 100644
--- a/pkg/local_object_storage/writecache/writecache.go
+++ b/pkg/local_object_storage/writecache/writecache.go
@@ -67,6 +67,9 @@ type cache struct {
fsTree *fstree.FSTree
}
+// wcStorageType is used for write-cache operations logging.
+const wcStorageType = "write-cache"
+
type objectInfo struct {
addr string
data []byte