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 ( ...@@ -5,8 +5,10 @@ import (
"github.com/hanwen/go-fuse/examplelib" "github.com/hanwen/go-fuse/examplelib"
"fmt" "fmt"
"os" "os"
"expvar"
"flag" "flag"
"runtime" "runtime"
"strings"
) )
func main() { func main() {
...@@ -36,4 +38,10 @@ 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) fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v, cpus=%v)\n", orig, mountPoint, *threaded, *debug, cpus)
state.Loop(*threaded) state.Loop(*threaded)
fmt.Println("Finished", state.Stats()) 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 ...@@ -3,6 +3,7 @@ package fuse
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"expvar"
"fmt" "fmt"
"log" "log"
"os" "os"
...@@ -11,7 +12,6 @@ import ( ...@@ -11,7 +12,6 @@ import (
"syscall" "syscall"
) )
// TODO make generic option setting. // TODO make generic option setting.
const ( const (
// bufSize should be a power of two to minimize lossage in // bufSize should be a power of two to minimize lossage in
...@@ -56,6 +56,8 @@ type MountState struct { ...@@ -56,6 +56,8 @@ type MountState struct {
// For efficient reads. // For efficient reads.
buffers *BufferPool buffers *BufferPool
operationCounts *expvar.Map
} }
func (self *MountState) RegisterFile(file RawFuseFile) uint64 { func (self *MountState) RegisterFile(file RawFuseFile) uint64 {
...@@ -115,6 +117,8 @@ func (self *MountState) Mount(mountPoint string) os.Error { ...@@ -115,6 +117,8 @@ func (self *MountState) Mount(mountPoint string) os.Error {
} }
self.mountPoint = mp self.mountPoint = mp
self.mountFile = file self.mountFile = file
self.operationCounts = expvar.NewMap(fmt.Sprintf("mount(%v)", mountPoint))
return nil return nil
} }
...@@ -184,6 +188,7 @@ func NewMountState(fs RawFileSystem) *MountState { ...@@ -184,6 +188,7 @@ func NewMountState(fs RawFileSystem) *MountState {
self.fileSystem = fs self.fileSystem = fs
self.buffers = NewBufferPool() self.buffers = NewBufferPool()
return self return self
} }
// TODO - more of them. // TODO - more of them.
...@@ -269,6 +274,9 @@ func (self *MountState) handle(in_data []byte) { ...@@ -269,6 +274,9 @@ func (self *MountState) handle(in_data []byte) {
func dispatch(state *MountState, h *InHeader, arg *bytes.Buffer) (outBytes [][]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) input := newInput(h.Opcode)
if input != nil && !parseLittleEndian(arg, input) { if input != nil && !parseLittleEndian(arg, input) {
return serialize(h, EIO, nil, nil, false) 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