Commit 0b0f4ddb authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Log the number of FUSE operations in an expvar.

parent ce1a82ae
......@@ -5,8 +5,10 @@ import (
"github.com/hanwen/go-fuse/examplelib"
"fmt"
"os"
"expvar"
"flag"
"runtime"
"strings"
)
func main() {
......@@ -36,4 +38,10 @@ func main() {
fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v, cpus=%v)\n", orig, mountPoint, *threaded, *debug, cpus)
state.Loop(*threaded)
fmt.Println("Finished", state.Stats())
for v := range(expvar.Iter()) {
if strings.HasPrefix(v.Key, "mount") {
fmt.Printf("%v: %v\n", v.Key, v.Value)
}
}
}
......@@ -3,6 +3,7 @@ package fuse
import (
"bytes"
"encoding/binary"
"expvar"
"fmt"
"log"
"os"
......@@ -11,7 +12,6 @@ import (
"syscall"
)
// TODO make generic option setting.
const (
// bufSize should be a power of two to minimize lossage in
......@@ -56,6 +56,8 @@ type MountState struct {
// For efficient reads.
buffers *BufferPool
operationCounts *expvar.Map
}
func (self *MountState) RegisterFile(file RawFuseFile) uint64 {
......@@ -115,6 +117,8 @@ func (self *MountState) Mount(mountPoint string) os.Error {
}
self.mountPoint = mp
self.mountFile = file
self.operationCounts = expvar.NewMap(fmt.Sprintf("mount(%v)", mountPoint))
return nil
}
......@@ -184,6 +188,7 @@ func NewMountState(fs RawFileSystem) *MountState {
self.fileSystem = fs
self.buffers = NewBufferPool()
return self
}
// TODO - more of them.
......@@ -269,6 +274,9 @@ func (self *MountState) handle(in_data []byte) {
func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]byte) {
// TODO - would be nice to remove this logging from the critical path.
state.operationCounts.Add(operationName(h.Opcode), 1)
input := newInput(h.Opcode)
if input != nil && !parseLittleEndian(arg, input) {
return serialize(h, EIO, nil, nil, false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment