Commit 7c991e45 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent 29d35b93
......@@ -115,7 +115,7 @@ func (me *BufferPool) AllocBuffer(size uint32) []byte {
if len(me.outstandingBuffers) > 200 {
panic("Leaking buffers")
}
return b
}
......
......@@ -31,7 +31,7 @@ type request struct {
arg []byte // flat data.
// Unstructured data, a pointer to the relevant XxxxOut struct.
outData unsafe.Pointer
outData unsafe.Pointer
status Status
flatData []byte
......@@ -99,7 +99,7 @@ func (me *MountState) Write(req *request) {
if me.RecordStatistics {
req.preWriteNs = time.Nanoseconds()
}
if req.outHeaderBytes == nil {
return
}
......@@ -169,9 +169,9 @@ func (me *MountState) discardRequest(req *request) {
opname := operationName(req.inHeader.Opcode)
me.LatencyMap.AddMany(
[]LatencyArg{
{opname, "", dt},
{opname + "-dispatch", "", req.dispatchNs - req.startNs},
{opname + "-write", "", endNs - req.preWriteNs}})
{opname, "", dt},
{opname + "-dispatch", "", req.dispatchNs - req.startNs},
{opname + "-write", "", endNs - req.preWriteNs}})
}
me.buffers.FreeBuffer(req.inputBuf)
......@@ -228,7 +228,7 @@ func (me *MountState) chopMessage(req *request) *operationHandler {
log.Printf("Short read for input header: %v", req.inputBuf)
return nil
}
req.inHeader = (*InHeader)(unsafe.Pointer(&req.inputBuf[0]))
req.arg = req.inputBuf[inHSize:]
......@@ -263,7 +263,7 @@ func (me *MountState) handle(req *request) {
if req.status == OK {
me.dispatch(req, handler)
}
// If we try to write OK, nil, we will get
// error: writer: Writev [[16 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0]]
// failed, err: writev: no such file or directory
......@@ -277,7 +277,7 @@ func (me *MountState) dispatch(req *request, handler *operationHandler) {
if me.RecordStatistics {
req.dispatchNs = time.Nanoseconds()
}
if me.Debug {
nm := ""
// TODO - reinstate filename printing.
......
......@@ -8,18 +8,18 @@ import (
type latencyMapEntry struct {
count int
ns int64
ns int64
}
type LatencyArg struct {
Name string
Arg string
DtNs int64
Arg string
DtNs int64
}
type LatencyMap struct {
sync.Mutex
stats map[string]*latencyMapEntry
stats map[string]*latencyMapEntry
secondaryStats map[string]map[string]int64
}
......@@ -50,7 +50,7 @@ func (me *LatencyMap) add(name string, arg string, dtNs int64) {
me.stats[name] = e
}
e.count ++
e.count++
e.ns += dtNs
if arg != "" {
m, ok := me.secondaryStats[name]
......
package fuse
import (
"fmt"
"testing"
......
......@@ -253,62 +253,62 @@ func init() {
for i, _ := range operationHandlers {
operationHandlers[i] = &operationHandler{Name: "UNKNOWN"}
}
for op, sz := range map[int]int{
FUSE_FORGET: unsafe.Sizeof(ForgetIn{}),
FUSE_GETATTR: unsafe.Sizeof(GetAttrIn{}),
FUSE_SETATTR: unsafe.Sizeof(SetAttrIn{}),
FUSE_MKNOD: unsafe.Sizeof(MknodIn{}),
FUSE_MKDIR: unsafe.Sizeof(MkdirIn{}),
FUSE_RENAME: unsafe.Sizeof(RenameIn{}),
FUSE_LINK: unsafe.Sizeof(LinkIn{}),
FUSE_OPEN: unsafe.Sizeof(OpenIn{}),
FUSE_READ: unsafe.Sizeof(ReadIn{}),
FUSE_WRITE: unsafe.Sizeof(WriteIn{}),
FUSE_RELEASE: unsafe.Sizeof(ReleaseIn{}),
FUSE_FSYNC: unsafe.Sizeof(FsyncIn{}),
FUSE_SETXATTR: unsafe.Sizeof(SetXAttrIn{}),
FUSE_GETXATTR: unsafe.Sizeof(GetXAttrIn{}),
FUSE_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}),
FUSE_FLUSH: unsafe.Sizeof(FlushIn{}),
FUSE_INIT: unsafe.Sizeof(InitIn{}),
FUSE_OPENDIR: unsafe.Sizeof(OpenIn{}),
FUSE_READDIR: unsafe.Sizeof(ReadIn{}),
FUSE_RELEASEDIR: unsafe.Sizeof(ReleaseIn{}),
FUSE_FSYNCDIR: unsafe.Sizeof(FsyncIn{}),
FUSE_ACCESS: unsafe.Sizeof(AccessIn{}),
FUSE_CREATE: unsafe.Sizeof(CreateIn{}),
FUSE_INTERRUPT: unsafe.Sizeof(InterruptIn{}),
FUSE_BMAP: unsafe.Sizeof(BmapIn{}),
FUSE_IOCTL: unsafe.Sizeof(IoctlIn{}),
FUSE_POLL: unsafe.Sizeof(PollIn{}),
} {
FUSE_FORGET: unsafe.Sizeof(ForgetIn{}),
FUSE_GETATTR: unsafe.Sizeof(GetAttrIn{}),
FUSE_SETATTR: unsafe.Sizeof(SetAttrIn{}),
FUSE_MKNOD: unsafe.Sizeof(MknodIn{}),
FUSE_MKDIR: unsafe.Sizeof(MkdirIn{}),
FUSE_RENAME: unsafe.Sizeof(RenameIn{}),
FUSE_LINK: unsafe.Sizeof(LinkIn{}),
FUSE_OPEN: unsafe.Sizeof(OpenIn{}),
FUSE_READ: unsafe.Sizeof(ReadIn{}),
FUSE_WRITE: unsafe.Sizeof(WriteIn{}),
FUSE_RELEASE: unsafe.Sizeof(ReleaseIn{}),
FUSE_FSYNC: unsafe.Sizeof(FsyncIn{}),
FUSE_SETXATTR: unsafe.Sizeof(SetXAttrIn{}),
FUSE_GETXATTR: unsafe.Sizeof(GetXAttrIn{}),
FUSE_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}),
FUSE_FLUSH: unsafe.Sizeof(FlushIn{}),
FUSE_INIT: unsafe.Sizeof(InitIn{}),
FUSE_OPENDIR: unsafe.Sizeof(OpenIn{}),
FUSE_READDIR: unsafe.Sizeof(ReadIn{}),
FUSE_RELEASEDIR: unsafe.Sizeof(ReleaseIn{}),
FUSE_FSYNCDIR: unsafe.Sizeof(FsyncIn{}),
FUSE_ACCESS: unsafe.Sizeof(AccessIn{}),
FUSE_CREATE: unsafe.Sizeof(CreateIn{}),
FUSE_INTERRUPT: unsafe.Sizeof(InterruptIn{}),
FUSE_BMAP: unsafe.Sizeof(BmapIn{}),
FUSE_IOCTL: unsafe.Sizeof(IoctlIn{}),
FUSE_POLL: unsafe.Sizeof(PollIn{}),
} {
operationHandlers[op].InputSize = sz
}
for op, sz := range map[int]int{
FUSE_LOOKUP: unsafe.Sizeof(EntryOut{}),
FUSE_GETATTR: unsafe.Sizeof(AttrOut{}),
FUSE_SETATTR: unsafe.Sizeof(AttrOut{}),
FUSE_SYMLINK: unsafe.Sizeof(EntryOut{}),
FUSE_MKNOD: unsafe.Sizeof(EntryOut{}),
FUSE_MKDIR: unsafe.Sizeof(EntryOut{}),
FUSE_LINK: unsafe.Sizeof(EntryOut{}),
FUSE_OPEN: unsafe.Sizeof(OpenOut{}),
FUSE_WRITE: unsafe.Sizeof(WriteOut{}),
FUSE_STATFS: unsafe.Sizeof(StatfsOut{}),
FUSE_GETXATTR: unsafe.Sizeof(GetXAttrOut{}),
FUSE_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}),
FUSE_INIT: unsafe.Sizeof(InitOut{}),
FUSE_OPENDIR: unsafe.Sizeof(OpenOut{}),
FUSE_LOOKUP: unsafe.Sizeof(EntryOut{}),
FUSE_GETATTR: unsafe.Sizeof(AttrOut{}),
FUSE_SETATTR: unsafe.Sizeof(AttrOut{}),
FUSE_SYMLINK: unsafe.Sizeof(EntryOut{}),
FUSE_MKNOD: unsafe.Sizeof(EntryOut{}),
FUSE_MKDIR: unsafe.Sizeof(EntryOut{}),
FUSE_LINK: unsafe.Sizeof(EntryOut{}),
FUSE_OPEN: unsafe.Sizeof(OpenOut{}),
FUSE_WRITE: unsafe.Sizeof(WriteOut{}),
FUSE_STATFS: unsafe.Sizeof(StatfsOut{}),
FUSE_GETXATTR: unsafe.Sizeof(GetXAttrOut{}),
FUSE_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}),
FUSE_INIT: unsafe.Sizeof(InitOut{}),
FUSE_OPENDIR: unsafe.Sizeof(OpenOut{}),
FUSE_CREATE: unsafe.Sizeof(CreateOut{}),
FUSE_BMAP: unsafe.Sizeof(BmapOut{}),
FUSE_IOCTL: unsafe.Sizeof(IoctlOut{}),
FUSE_POLL: unsafe.Sizeof(PollOut{}),
} {
} {
operationHandlers[op].OutputSize = sz
}
for op, v := range map[int]string{
FUSE_LOOKUP: "FUSE_LOOKUP",
FUSE_FORGET: "FUSE_FORGET",
......
......@@ -41,7 +41,7 @@ func (me *FileSystemDebug) Add(name string, callback getter) {
}
func (me *FileSystemDebug) Open(path string, flags uint32) (fuseFile File, status Status) {
content := me.getContent(path)
if content != nil {
return NewReadOnlyFile(content), OK
......@@ -72,11 +72,11 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *FileSystemDebug) GetAttr(path string) (*Attr, Status) {
if !strings.HasPrefix(path, DebugDir) {
return me.Original.GetAttr(path)
}
}
if path == DebugDir {
return &Attr{
Mode: S_IFDIR | 0755,
}, OK
},OK
}
c := me.getContent(path)
if c != nil {
......@@ -123,17 +123,16 @@ func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status St
if name == DebugDir {
me.RWMutex.RLock()
defer me.RWMutex.RUnlock()
stream = make(chan DirEntry, len(me.callbacks))
for k, _ := range me.callbacks {
stream <- DirEntry {
stream <- DirEntry{
Name: k,
Mode: S_IFREG,
}
}
close(stream)
return stream, OK
}
return me.Original.OpenDir(name)
}
......
......@@ -10,7 +10,7 @@ import (
func TestPathDebug(t *testing.T) {
debugFs := NewFileSystemDebug()
debugFs.Original = &DefaultFileSystem{}
debugFs.Add("test-entry", func()[]byte { return []byte("test-content"); })
debugFs.Add("test-entry", func() []byte { return []byte("test-content") })
connector := NewFileSystemConnector(debugFs)
mountPoint := MakeTempDir()
......@@ -30,7 +30,7 @@ func TestPathDebug(t *testing.T) {
CheckSuccess(err)
if len(names) != 1 || names[0].Name != "test-entry" {
t.Error("unexpected readdir out:", names)
t.Error("unexpected readdir out:", names)
}
c, err := ioutil.ReadFile(filepath.Join(dir, "test-entry"))
......
......@@ -135,7 +135,7 @@ func (me *inode) setParent(newParent *inode) {
panic(fmt.Sprintf("Already have an inode with same name: %v: %v", me.Name, ch))
}
}
me.Parent.Children[me.Name] = me
}
}
......@@ -171,14 +171,14 @@ type FileSystemConnector struct {
treeLock sync.RWMutex
// Invariants: see the verify() method.
inodeMap map[uint64]*inode
rootNode *inode
inodeMap map[uint64]*inode
rootNode *inode
// Open files/directories.
openFiles map[uint64]*interfaceBridge
openFiles map[uint64]*interfaceBridge
// Protects openFiles and OpenCount in all of the nodes.
fileLock sync.RWMutex
fileLock sync.RWMutex
}
type interfaceBridge struct {
......@@ -215,7 +215,7 @@ func (me *FileSystemConnector) registerFile(node *inode, f interface{}) uint64 {
defer me.fileLock.Unlock()
b := &interfaceBridge{
Iface: f,
Iface: f,
}
h := uint64(uintptr(unsafe.Pointer(b)))
_, ok := me.openFiles[h]
......@@ -279,7 +279,7 @@ func (me *FileSystemConnector) newInode(root bool, isDir bool) *inode {
if isDir {
data.Children = make(map[string]*inode, initDirSize)
}
return data
}
......@@ -449,12 +449,12 @@ func (me *FileSystemConnector) Unmount(path string) Status {
me.fileLock.Lock()
unmountError := OK
mount := node.mount
if mount == nil || mount.unmountPending {
unmountError = EINVAL
}
// don't use defer: we don't want to call out to
// mount.fs.Unmount() with lock held.
if unmountError == OK && (node.totalOpenCount() > 0 || node.totalMountCount() > 1) {
......@@ -472,7 +472,7 @@ func (me *FileSystemConnector) Unmount(path string) Status {
if me.Debug {
log.Println("Unmount: ", mount)
}
mount.fs.Unmount()
}
return unmountError
......@@ -484,7 +484,7 @@ func (me *FileSystemConnector) GetPath(nodeid uint64) (path string, mount *mount
// Need to lock because renames create invalid states.
me.treeLock.RLock()
defer me.treeLock.RUnlock()
p, m := n.GetPath()
return p, m, n
}
......@@ -7,7 +7,7 @@ import (
"path/filepath"
"time"
)
func NewFileSystemConnector(fs FileSystem) (out *FileSystemConnector) {
out = EmptyFileSystemConnector()
......@@ -66,7 +66,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
data.LookupCount += lookupCount
out = &EntryOut{
NodeId: data.NodeId,
NodeId: data.NodeId,
Generation: 1, // where to get the generation?
}
SplitNs(me.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec)
......@@ -92,7 +92,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
}
out = &AttrOut{
Attr: *attr,
Attr: *attr,
}
out.Attr.Ino = header.NodeId
SplitNs(me.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
......@@ -112,7 +112,7 @@ func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags u
}
de := &Dir{
stream: stream,
stream: stream,
}
h := me.registerFile(node, de)
......@@ -164,7 +164,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
mount.fs.Truncate(fullPath, input.Size)
}
if err == OK && (input.Valid&FATTR_ATIME != 0 || input.Valid&FATTR_MTIME != 0) {
err = mount.fs.Utimens(fullPath,
uint64(input.Atime*1e9)+uint64(input.Atimensec),
uint64(input.Mtime*1e9)+uint64(input.Mtimensec))
......@@ -393,4 +393,3 @@ func (me *FileSystemConnector) Read(input *ReadIn, bp *BufferPool) ([]byte, Stat
f := me.getFile(input.Fh)
return f.Read(input, bp)
}
......@@ -532,10 +532,10 @@ type RawFileSystem interface {
Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status)
/*
// unimplemented.
Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status)
Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status)
Poll(header *InHeader, input *PollIn) (out *PollOut, code Status)
// unimplemented.
Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status)
Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status)
Poll(header *InHeader, input *PollIn) (out *PollOut, code Status)
*/
// File handling.
......
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