fusefrontend: print dirCache stats after unmount
This commit is contained in:
parent
043f81dd01
commit
f73aee72f8
@ -151,17 +151,24 @@ func (d *dirCache) expireThread() {
|
|||||||
for {
|
for {
|
||||||
time.Sleep(60 * time.Second)
|
time.Sleep(60 * time.Second)
|
||||||
d.Clear()
|
d.Clear()
|
||||||
if enableStats {
|
d.stats()
|
||||||
d.Lock()
|
}
|
||||||
lookups := d.lookups
|
}
|
||||||
hits := d.hits
|
|
||||||
d.lookups = 0
|
// stats prints hit rate statistics and resets the counters. No-op if
|
||||||
d.hits = 0
|
// enableStats == false.
|
||||||
d.Unlock()
|
func (d *dirCache) stats() {
|
||||||
if lookups > 0 {
|
if !enableStats {
|
||||||
fmt.Printf("dirCache: hits=%3d lookups=%3d, rate=%3d%%\n", hits, lookups, (hits*100)/lookups)
|
return
|
||||||
}
|
}
|
||||||
}
|
d.Lock()
|
||||||
|
lookups := d.lookups
|
||||||
|
hits := d.hits
|
||||||
|
d.lookups = 0
|
||||||
|
d.hits = 0
|
||||||
|
d.Unlock()
|
||||||
|
if lookups > 0 {
|
||||||
|
fmt.Printf("dirCache: hits=%3d lookups=%3d, rate=%3d%%\n", hits, lookups, (hits*100)/lookups)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,12 @@ func NewRootNode(args Args, c *contentenc.ContentEnc, n nametransform.NameTransf
|
|||||||
return rn
|
return rn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// main.doMount() calls this after unmount
|
||||||
|
func (rn *RootNode) AfterUnmount() {
|
||||||
|
// print stats before we exit
|
||||||
|
rn.dirCache.stats()
|
||||||
|
}
|
||||||
|
|
||||||
// mangleOpenFlags is used by Create() and Open() to convert the open flags the user
|
// mangleOpenFlags is used by Create() and Open() to convert the open flags the user
|
||||||
// wants to the flags we internally use to open the backing file.
|
// wants to the flags we internally use to open the backing file.
|
||||||
// The returned flags always contain O_NOFOLLOW.
|
// The returned flags always contain O_NOFOLLOW.
|
||||||
|
13
mount.go
13
mount.go
@ -37,6 +37,12 @@ import (
|
|||||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AfterUnmount is called after the filesystem has been unmounted.
|
||||||
|
// This can be used for cleanup and printing statistics.
|
||||||
|
type AfterUnmounter interface {
|
||||||
|
AfterUnmount()
|
||||||
|
}
|
||||||
|
|
||||||
// doMount mounts an encrypted directory.
|
// doMount mounts an encrypted directory.
|
||||||
// Called from main.
|
// Called from main.
|
||||||
func doMount(args *argContainer) {
|
func doMount(args *argContainer) {
|
||||||
@ -116,10 +122,13 @@ func doMount(args *argContainer) {
|
|||||||
tlog.Debug.Printf("cli args: %#v", args)
|
tlog.Debug.Printf("cli args: %#v", args)
|
||||||
// Initialize gocryptfs (read config file, ask for password, ...)
|
// Initialize gocryptfs (read config file, ask for password, ...)
|
||||||
fs, wipeKeys := initFuseFrontend(args)
|
fs, wipeKeys := initFuseFrontend(args)
|
||||||
// Initialize go-fuse FUSE server
|
|
||||||
srv := initGoFuse(fs, args)
|
|
||||||
// Try to wipe secret keys from memory after unmount
|
// Try to wipe secret keys from memory after unmount
|
||||||
defer wipeKeys()
|
defer wipeKeys()
|
||||||
|
// Initialize go-fuse FUSE server
|
||||||
|
srv := initGoFuse(fs, args)
|
||||||
|
if x, ok := fs.(AfterUnmounter); ok {
|
||||||
|
defer x.AfterUnmount()
|
||||||
|
}
|
||||||
|
|
||||||
tlog.Info.Println(tlog.ColorGreen + "Filesystem mounted and ready." + tlog.ColorReset)
|
tlog.Info.Println(tlog.ColorGreen + "Filesystem mounted and ready." + tlog.ColorReset)
|
||||||
// We have been forked into the background, as evidenced by the set
|
// We have been forked into the background, as evidenced by the set
|
||||||
|
Loading…
Reference in New Issue
Block a user