aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-17 21:26:56 +0200
committerJakob Unterwurzacher2020-05-17 21:26:56 +0200
commitf6088e5008606ba8ca8f7be2b95b5087b59e5cab (patch)
treedfdc61acb41745982337114888fef0757811b1e6
parentbf66da68806da745da6173bbdab1a185c673fa96 (diff)
dircache: improve debug messages
Before: Lookup "errno.html/1/2/3/4/5": miss Store: "errno.html/1/2/3/4/5" fd=26 iv=21be6e083d60dcabfe7368264d5082b7 Lookup "errno.html": hit 25 6d68a16d217978915036a3bd55428ae7 Lookup "errno.html/1": hit 25 932a464c299b3430c5e55c924f98ac4d Lookup "errno.html/1/2": hit 25 7d53348b1692d537f017bf86b3cf5feb Lookup "errno.html/1/2/3": hit 25 2aef1c9d1ab2b55b163215053fefe703 Lookup "errno.html/1/2/3/4": hit 25 cb802be53721c46a46247c5e4e0f4ce6 Lookup "errno.html/1/2/3/4": hit 25 cb802be53721c46a46247c5e4e0f4ce6 Lookup "errno.html": hit 25 6d68a16d217978915036a3bd55428ae7 After: Lookup "earlyoom/.git/refs" hit fd=10 dup=17 iv=6ae2cecd269a25e8d946aff6afe9b8b8 Lookup "earlyoom/.git/refs/remotes" hit fd=19 dup=17 iv=f04c2d2a5bcc33ebdeaca664859c980d Lookup "earlyoom/.git/refs/remotes/origin" miss Store "earlyoom/.git/refs/remotes/origin" fd=17 iv=834a64a1697c9f5705455ba6dbed22b5 Lookup "earlyoom" hit fd=7 dup=25 iv=2303a892d6e2357c483574a8070b7679 Lookup "earlyoom/.git" hit fd=11 dup=25 iv=d43ca4aff23720c57789c9f62f0aee00 Lookup "earlyoom/.git" hit fd=11 dup=25 iv=d43ca4aff23720c57789c9f62f0aee00 Lookup "earlyoom/.git/refs" hit fd=10 dup=25 iv=6ae2cecd269a25e8d946aff6afe9b8b8 Lookup "earlyoom/.git/refs/heads" hit fd=13 dup=25 iv=f9245e7c066b9adc768a1a666da9fbc8
-rw-r--r--internal/fusefrontend/dircache.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/fusefrontend/dircache.go b/internal/fusefrontend/dircache.go
index 68fd99c..718e5b2 100644
--- a/internal/fusefrontend/dircache.go
+++ b/internal/fusefrontend/dircache.go
@@ -21,6 +21,8 @@ const (
enableDebugMessages = false
// Enable hit rate statistics printing
enableStats = false
+
+ pathFmt = "%-40q"
)
type dirCacheEntryStruct struct {
@@ -64,6 +66,7 @@ type dirCacheStruct struct {
// Clear clears the cache contents.
func (d *dirCacheStruct) Clear() {
+ d.dbg("Clear\n")
d.Lock()
defer d.Unlock()
for i := range d.entries {
@@ -91,7 +94,7 @@ func (d *dirCacheStruct) Store(dirRelPath string, fd int, iv []byte) {
tlog.Warn.Printf("dirCache.Store: Dup failed: %v", err)
return
}
- d.dbg("Store: %q %d %x\n", dirRelPath, fd2, iv)
+ d.dbg("Store "+pathFmt+" fd=%d iv=%x\n", dirRelPath, fd2, iv)
e.fd = fd2
e.dirRelPath = dirRelPath
e.iv = iv
@@ -111,8 +114,9 @@ func (d *dirCacheStruct) Lookup(dirRelPath string) (fd int, iv []byte) {
if enableStats {
d.lookups++
}
+ var e *dirCacheEntryStruct
for i := range d.entries {
- e := &d.entries[i]
+ e = &d.entries[i]
if e.fd <= 0 {
// Cache slot is empty
continue
@@ -131,7 +135,7 @@ func (d *dirCacheStruct) Lookup(dirRelPath string) (fd int, iv []byte) {
break
}
if fd == 0 {
- d.dbg("Lookup %q: miss\n", dirRelPath)
+ d.dbg("Lookup "+pathFmt+" miss\n", dirRelPath)
return -1, nil
}
if enableStats {
@@ -140,7 +144,7 @@ func (d *dirCacheStruct) Lookup(dirRelPath string) (fd int, iv []byte) {
if fd <= 0 || len(iv) != nametransform.DirIVLen {
log.Panicf("Lookup sanity check failed: fd=%d len=%d", fd, len(iv))
}
- d.dbg("Lookup %q: hit %d %x\n", dirRelPath, fd, iv)
+ d.dbg("Lookup "+pathFmt+" hit fd=%d dup=%d iv=%x\n", dirRelPath, e.fd, fd, iv)
return fd, iv
}