Commit 2003d2b2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent aaa7e243
...@@ -207,10 +207,9 @@ func TestingBOnePass(b *testing.B, threads int, sleepTime float64, files []strin ...@@ -207,10 +207,9 @@ func TestingBOnePass(b *testing.B, threads int, sleepTime float64, files []strin
return results return results
} }
func BenchmarkCFuseThreadedStat(b *testing.B) { func BenchmarkCFuseThreadedStat(b *testing.B) {
log.Println("benchmarking CFuse") log.Println("benchmarking CFuse")
lines := GetTestLines() lines := GetTestLines()
unique := map[string]int{} unique := map[string]int{}
for _, l := range lines { for _, l := range lines {
...@@ -220,7 +219,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) { ...@@ -220,7 +219,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
unique[dir] = 1 unique[dir] = 1
dir = filepath.Clean(dir) dir = filepath.Clean(dir)
dir, _ = filepath.Split(dir) dir, _ = filepath.Split(dir)
} }
} }
out := []string{} out := []string{}
...@@ -235,11 +234,11 @@ func BenchmarkCFuseThreadedStat(b *testing.B) { ...@@ -235,11 +234,11 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
f.Write([]byte(fmt.Sprintf("/%s\n", k))) f.Write([]byte(fmt.Sprintf("/%s\n", k)))
} }
f.Close() f.Close()
log.Println("Written:", f.Name()) log.Println("Written:", f.Name())
mountPoint := fuse.MakeTempDir() mountPoint := fuse.MakeTempDir()
wd, _ := os.Getwd() wd, _ := os.Getwd()
cmd := exec.Command(wd + "/cstatfs", mountPoint) cmd := exec.Command(wd+"/cstatfs", mountPoint)
cmd.Env = append(os.Environ(), fmt.Sprintf("STATFS_INPUT=%s", f.Name())) cmd.Env = append(os.Environ(), fmt.Sprintf("STATFS_INPUT=%s", f.Name()))
cmd.Start() cmd.Start()
...@@ -248,7 +247,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) { ...@@ -248,7 +247,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
stop := exec.Command(bin, "-u", mountPoint) stop := exec.Command(bin, "-u", mountPoint)
CheckSuccess(err) CheckSuccess(err)
defer stop.Run() defer stop.Run()
for i, l := range lines { for i, l := range lines {
lines[i] = filepath.Join(mountPoint, l) lines[i] = filepath.Join(mountPoint, l)
} }
...@@ -259,6 +258,5 @@ func BenchmarkCFuseThreadedStat(b *testing.B) { ...@@ -259,6 +258,5 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
log.Println("N = ", b.N) log.Println("N = ", b.N)
threads := runtime.GOMAXPROCS(0) threads := runtime.GOMAXPROCS(0)
results := TestingBOnePass(b, threads, ttl*1.2, lines) results := TestingBOnePass(b, threads, ttl*1.2, lines)
AnalyzeBenchmarkRuns(results) AnalyzeBenchmarkRuns(results)
} }
...@@ -27,7 +27,7 @@ type FsNode interface { ...@@ -27,7 +27,7 @@ type FsNode interface {
// The following are called by the FileSystemConnector // The following are called by the FileSystemConnector
Inode() *Inode Inode() *Inode
SetInode(node *Inode) SetInode(node *Inode)
// RmChild and AddChild run inside the critical section for // RmChild and AddChild run inside the critical section for
// the mutex behind Inode().LockTree(). // the mutex behind Inode().LockTree().
RmChild(name string, child FsNode) RmChild(name string, child FsNode)
...@@ -35,7 +35,7 @@ type FsNode interface { ...@@ -35,7 +35,7 @@ type FsNode interface {
Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status) Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status)
OnForget() OnForget()
// Misc. // Misc.
Access(mode uint32, context *Context) (code Status) Access(mode uint32, context *Context) (code Status)
Readlink(c *Context) ([]byte, Status) Readlink(c *Context) ([]byte, Status)
...@@ -160,7 +160,7 @@ type WithFlags struct { ...@@ -160,7 +160,7 @@ type WithFlags struct {
// For debugging. // For debugging.
Description string Description string
// Put FOPEN_* flags here. // Put FOPEN_* flags here.
FuseFlags uint32 FuseFlags uint32
......
...@@ -20,7 +20,7 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F ...@@ -20,7 +20,7 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F
return f, c return f, c
} }
return &WithFlags{ return &WithFlags{
File: f, File: f,
FuseFlags: FOPEN_KEEP_CACHE, FuseFlags: FOPEN_KEEP_CACHE,
}, c }, c
...@@ -108,7 +108,7 @@ func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile ...@@ -108,7 +108,7 @@ func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile
data := bytes.Repeat([]byte{42}, me.Length) data := bytes.Repeat([]byte{42}, me.Length)
f := NewReadOnlyFile(data) f := NewReadOnlyFile(data)
return &WithFlags{ return &WithFlags{
File: f, File: f,
FuseFlags: FOPEN_NONSEEKABLE, FuseFlags: FOPEN_NONSEEKABLE,
}, OK }, OK
} }
......
...@@ -83,7 +83,7 @@ func (me *FileSystemConnector) createChild(parent *Inode, name string, fi *os.Fi ...@@ -83,7 +83,7 @@ func (me *FileSystemConnector) createChild(parent *Inode, name string, fi *os.Fi
child = fsi.Inode() child = fsi.Inode()
child.addLookupCount(1) child.addLookupCount(1)
} }
out = parent.mount.fileInfoToEntry(fi) out = parent.mount.fileInfoToEntry(fi)
out.Ino = child.nodeId out.Ino = child.nodeId
out.NodeId = child.nodeId out.NodeId = child.nodeId
...@@ -337,4 +337,3 @@ func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) ...@@ -337,4 +337,3 @@ func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64)
func (me *FileSystemConnector) EntryNotify(dir *Inode, name string) Status { func (me *FileSystemConnector) EntryNotify(dir *Inode, name string) Status {
return me.fsInit.EntryNotify(dir.nodeId, name) return me.fsInit.EntryNotify(dir.nodeId, name)
} }
...@@ -15,7 +15,7 @@ type openedFile struct { ...@@ -15,7 +15,7 @@ type openedFile struct {
WithFlags WithFlags
dir rawDir dir rawDir
} }
type fileSystemMount struct { type fileSystemMount struct {
...@@ -50,8 +50,6 @@ func (me *fileSystemMount) mountName() string { ...@@ -50,8 +50,6 @@ func (me *fileSystemMount) mountName() string {
return "" return ""
} }
func (me *fileSystemMount) setOwner(attr *Attr) { func (me *fileSystemMount) setOwner(attr *Attr) {
if me.options.Owner != nil { if me.options.Owner != nil {
attr.Owner = *me.options.Owner attr.Owner = *me.options.Owner
...@@ -109,9 +107,9 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f ...@@ -109,9 +107,9 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
node.openFilesMutex.Lock() node.openFilesMutex.Lock()
defer node.openFilesMutex.Unlock() defer node.openFilesMutex.Unlock()
b := &openedFile{ b := &openedFile{
dir: dir, dir: dir,
WithFlags: WithFlags{ WithFlags: WithFlags{
File: f, File: f,
OpenFlags: flags, OpenFlags: flags,
}, },
} }
...@@ -139,4 +137,3 @@ func (me *fileSystemMount) negativeEntry() *EntryOut { ...@@ -139,4 +137,3 @@ func (me *fileSystemMount) negativeEntry() *EntryOut {
SplitNs(me.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec) SplitNs(me.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec)
return out return out
} }
...@@ -46,7 +46,7 @@ func (me *FileSystemConnector) internalLookup(parent *Inode, name string, contex ...@@ -46,7 +46,7 @@ func (me *FileSystemConnector) internalLookup(parent *Inode, name string, contex
if mount := me.findMount(parent, name); mount != nil { if mount := me.findMount(parent, name); mount != nil {
return me.lookupMountUpdate(mount) return me.lookupMountUpdate(mount)
} }
lookupNode, getattrNode := me.preLookup(parent, name) lookupNode, getattrNode := me.preLookup(parent, name)
var fi *os.FileInfo var fi *os.FileInfo
...@@ -65,14 +65,14 @@ func (me *FileSystemConnector) internalLookup(parent *Inode, name string, contex ...@@ -65,14 +65,14 @@ func (me *FileSystemConnector) internalLookup(parent *Inode, name string, contex
func (me *FileSystemConnector) preLookup(parent *Inode, name string) (lookupNode *Inode, attrNode *Inode) { func (me *FileSystemConnector) preLookup(parent *Inode, name string) (lookupNode *Inode, attrNode *Inode) {
parent.treeLock.Lock() parent.treeLock.Lock()
defer parent.treeLock.Unlock() defer parent.treeLock.Unlock()
child := parent.children[name] child := parent.children[name]
if child != nil { if child != nil {
// Make sure the child doesn't die inbetween. // Make sure the child doesn't die inbetween.
child.addLookupCount(1) child.addLookupCount(1)
return nil, child return nil, child
} }
return parent, nil return parent, nil
} }
......
...@@ -51,7 +51,6 @@ func (me *int32HandleMap) Has(h uint64) bool { ...@@ -51,7 +51,6 @@ func (me *int32HandleMap) Has(h uint64) bool {
return me.handles[uint32(h)] != nil return me.handles[uint32(h)] != nil
} }
func (me *int32HandleMap) Count() int { func (me *int32HandleMap) Count() int {
me.mutex.Lock() me.mutex.Lock()
defer me.mutex.Unlock() defer me.mutex.Unlock()
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"log" "log"
"sync" "sync"
) )
var _ = log.Println var _ = log.Println
// The inode reflects the kernel's idea of the inode. // The inode reflects the kernel's idea of the inode.
...@@ -33,7 +34,7 @@ type Inode struct { ...@@ -33,7 +34,7 @@ type Inode struct {
// Contains directories that function as mounts. The entries // Contains directories that function as mounts. The entries
// are duplicated in children. // are duplicated in children.
mounts map[string]*fileSystemMount mounts map[string]*fileSystemMount
// Use addLookupCount() to manipulate. // Use addLookupCount() to manipulate.
lookupCount int lookupCount int
......
...@@ -277,10 +277,10 @@ func TestLinkExisting(t *testing.T) { ...@@ -277,10 +277,10 @@ func TestLinkExisting(t *testing.T) {
defer me.Cleanup() defer me.Cleanup()
c := "hello" c := "hello"
err := ioutil.WriteFile(me.orig + "/file1", []byte(c), 0644) err := ioutil.WriteFile(me.orig+"/file1", []byte(c), 0644)
CheckSuccess(err) CheckSuccess(err)
err = os.Link(me.orig + "/file1", me.orig + "/file2") err = os.Link(me.orig+"/file1", me.orig+"/file2")
CheckSuccess(err) CheckSuccess(err)
f1, err := os.Lstat(me.mnt + "/file1") f1, err := os.Lstat(me.mnt + "/file1")
...@@ -294,7 +294,7 @@ func TestLinkExisting(t *testing.T) { ...@@ -294,7 +294,7 @@ func TestLinkExisting(t *testing.T) {
c1, err := ioutil.ReadFile(me.mnt + "/file1") c1, err := ioutil.ReadFile(me.mnt + "/file1")
CheckSuccess(err) CheckSuccess(err)
if string(c1) != c { if string(c1) != c {
t.Errorf("Content mismatch relative to original.") t.Errorf("Content mismatch relative to original.")
} }
} }
......
...@@ -17,9 +17,9 @@ type clientInodePath struct { ...@@ -17,9 +17,9 @@ type clientInodePath struct {
} }
type PathNodeFs struct { type PathNodeFs struct {
Debug bool Debug bool
fs FileSystem fs FileSystem
root *pathInode root *pathInode
connector *FileSystemConnector connector *FileSystemConnector
// Used for dealing with hardlinks. // Used for dealing with hardlinks.
...@@ -47,7 +47,7 @@ func (me *PathNodeFs) StatFs() *StatfsOut { ...@@ -47,7 +47,7 @@ func (me *PathNodeFs) StatFs() *StatfsOut {
return me.fs.StatFs() return me.fs.StatFs()
} }
func (me *PathNodeFs) Node(name string) (*Inode) { func (me *PathNodeFs) Node(name string) *Inode {
n, rest := me.LastNode(name) n, rest := me.LastNode(name)
if len(rest) > 0 { if len(rest) > 0 {
return nil return nil
...@@ -59,10 +59,10 @@ func (me *PathNodeFs) LastNode(name string) (*Inode, []string) { ...@@ -59,10 +59,10 @@ func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
if name == "" { if name == "" {
return me.Root().Inode(), nil return me.Root().Inode(), nil
} }
name = filepath.Clean(name) name = filepath.Clean(name)
comps := strings.Split(name, string(filepath.Separator)) comps := strings.Split(name, string(filepath.Separator))
node := me.root.Inode() node := me.root.Inode()
for i, c := range comps { for i, c := range comps {
next := node.GetChild(c) next := node.GetChild(c)
...@@ -111,8 +111,8 @@ func NewPathNodeFs(fs FileSystem) *PathNodeFs { ...@@ -111,8 +111,8 @@ func NewPathNodeFs(fs FileSystem) *PathNodeFs {
root.fs = fs root.fs = fs
me := &PathNodeFs{ me := &PathNodeFs{
fs: fs, fs: fs,
root: root, root: root,
clientInodeMap: map[uint64][]*clientInodePath{}, clientInodeMap: map[uint64][]*clientInodePath{},
} }
root.ifs = me root.ifs = me
...@@ -137,7 +137,7 @@ type pathInode struct { ...@@ -137,7 +137,7 @@ type pathInode struct {
// This is to correctly resolve hardlinks of the underlying // This is to correctly resolve hardlinks of the underlying
// real filesystem. // real filesystem.
clientInode uint64 clientInode uint64
DefaultFsNode DefaultFsNode
} }
...@@ -168,7 +168,7 @@ func (me *pathInode) GetPath() (path string) { ...@@ -168,7 +168,7 @@ func (me *pathInode) GetPath() (path string) {
if me.ifs.Debug { if me.ifs.Debug {
log.Printf("Inode %d = %q", me.Inode().nodeId, p) log.Printf("Inode %d = %q", me.Inode().nodeId, p)
} }
return p return p
} }
...@@ -215,8 +215,8 @@ func (me *pathInode) RmChild(name string, child FsNode) { ...@@ -215,8 +215,8 @@ func (me *pathInode) RmChild(name string, child FsNode) {
} else { } else {
me.ifs.clientInodeMap[ch.clientInode] = nil, false me.ifs.clientInodeMap[ch.clientInode] = nil, false
} }
} }
ch.Name = ".deleted" ch.Name = ".deleted"
ch.Parent = nil ch.Parent = nil
} }
...@@ -368,7 +368,7 @@ func (me *pathInode) Create(name string, flags uint32, mode uint32, context *Con ...@@ -368,7 +368,7 @@ func (me *pathInode) Create(name string, flags uint32, mode uint32, context *Con
file, code = me.fs.Create(fullPath, flags, mode, context) file, code = me.fs.Create(fullPath, flags, mode, context)
if code.Ok() { if code.Ok() {
pNode := me.createChild(name) pNode := me.createChild(name)
newNode = pNode newNode = pNode
fi = me.fillNewChildAttr(fullPath, pNode, context) fi = me.fillNewChildAttr(fullPath, pNode, context)
} }
return return
...@@ -387,11 +387,11 @@ func (me *pathInode) Open(flags uint32, context *Context) (file File, code Statu ...@@ -387,11 +387,11 @@ func (me *pathInode) Open(flags uint32, context *Context) (file File, code Statu
file, code = me.fs.Open(me.GetPath(), flags, context) file, code = me.fs.Open(me.GetPath(), flags, context)
if me.ifs.Debug { if me.ifs.Debug {
file = &WithFlags{ file = &WithFlags{
File: file, File: file,
Description: me.GetPath(), Description: me.GetPath(),
} }
} }
return return
} }
func (me *pathInode) Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status) { func (me *pathInode) Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status) {
...@@ -439,7 +439,7 @@ func (me *pathInode) GetAttr(file File, context *Context) (fi *os.FileInfo, code ...@@ -439,7 +439,7 @@ func (me *pathInode) GetAttr(file File, context *Context) (fi *os.FileInfo, code
if fi != nil { if fi != nil {
me.setClientInode(fi.Ino) me.setClientInode(fi.Ino)
} }
if fi != nil && !fi.IsDirectory() && fi.Nlink == 0 { if fi != nil && !fi.IsDirectory() && fi.Nlink == 0 {
fi.Nlink = 1 fi.Nlink = 1
} }
......
...@@ -31,7 +31,7 @@ type AutoUnionFs struct { ...@@ -31,7 +31,7 @@ type AutoUnionFs struct {
nameRootMap map[string]string nameRootMap map[string]string
root string root string
nodeFs *fuse.PathNodeFs nodeFs *fuse.PathNodeFs
options *AutoUnionFsOptions options *AutoUnionFsOptions
} }
......
...@@ -936,7 +936,7 @@ func (me *UnionFs) Name() string { ...@@ -936,7 +936,7 @@ func (me *UnionFs) Name() string {
type UnionFsFile struct { type UnionFsFile struct {
fuse.File fuse.File
layer int layer int
} }
func (me *UnionFsFile) GetAttr() (*os.FileInfo, fuse.Status) { func (me *UnionFsFile) GetAttr() (*os.FileInfo, fuse.Status) {
......
...@@ -588,7 +588,7 @@ func TestLink(t *testing.T) { ...@@ -588,7 +588,7 @@ func TestLink(t *testing.T) {
err := ioutil.WriteFile(fn, []byte(content), 0666) err := ioutil.WriteFile(fn, []byte(content), 0666)
CheckSuccess(err) CheckSuccess(err)
err = os.Link(wd+"/mount/file", wd + "/mount/linked") err = os.Link(wd+"/mount/file", wd+"/mount/linked")
CheckSuccess(err) CheckSuccess(err)
fi2, err := os.Lstat(wd + "/mount/linked") fi2, err := os.Lstat(wd + "/mount/linked")
...@@ -945,7 +945,6 @@ func TestDoubleOpen(t *testing.T) { ...@@ -945,7 +945,6 @@ func TestDoubleOpen(t *testing.T) {
} }
} }
func TestFdLeak(t *testing.T) { func TestFdLeak(t *testing.T) {
beforeEntries, err := ioutil.ReadDir("/proc/self/fd") beforeEntries, err := ioutil.ReadDir("/proc/self/fd")
CheckSuccess(err) CheckSuccess(err)
...@@ -957,7 +956,7 @@ func TestFdLeak(t *testing.T) { ...@@ -957,7 +956,7 @@ func TestFdLeak(t *testing.T) {
contents, err := ioutil.ReadFile(wd + "/mount/file") contents, err := ioutil.ReadFile(wd + "/mount/file")
CheckSuccess(err) CheckSuccess(err)
err = ioutil.WriteFile(wd + "/mount/file", contents, 0644) err = ioutil.WriteFile(wd+"/mount/file", contents, 0644)
CheckSuccess(err) CheckSuccess(err)
clean() clean()
...@@ -969,5 +968,3 @@ func TestFdLeak(t *testing.T) { ...@@ -969,5 +968,3 @@ func TestFdLeak(t *testing.T) {
t.Errorf("/proc/self/fd changed size: after %v before %v", len(beforeEntries), len(afterEntries)) t.Errorf("/proc/self/fd changed size: after %v before %v", len(beforeEntries), len(afterEntries))
} }
} }
...@@ -34,7 +34,7 @@ type MultiZipFs struct { ...@@ -34,7 +34,7 @@ type MultiZipFs struct {
zips map[string]*MemTreeFs zips map[string]*MemTreeFs
dirZipFileMap map[string]string dirZipFileMap map[string]string
nodeFs *fuse.PathNodeFs nodeFs *fuse.PathNodeFs
fuse.DefaultFileSystem fuse.DefaultFileSystem
} }
......
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