Skip to content

Commit

Permalink
Run gofmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwen committed Sep 8, 2011
1 parent aaa7e24 commit 2003d2b
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 54 deletions.
14 changes: 6 additions & 8 deletions benchmark/stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,9 @@ func TestingBOnePass(b *testing.B, threads int, sleepTime float64, files []strin
return results
}


func BenchmarkCFuseThreadedStat(b *testing.B) {
log.Println("benchmarking CFuse")

lines := GetTestLines()
unique := map[string]int{}
for _, l := range lines {
Expand All @@ -220,7 +219,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
unique[dir] = 1
dir = filepath.Clean(dir)
dir, _ = filepath.Split(dir)
}
}
}

out := []string{}
Expand All @@ -235,11 +234,11 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
f.Write([]byte(fmt.Sprintf("/%s\n", k)))
}
f.Close()

log.Println("Written:", f.Name())
mountPoint := fuse.MakeTempDir()
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.Start()

Expand All @@ -248,7 +247,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
stop := exec.Command(bin, "-u", mountPoint)
CheckSuccess(err)
defer stop.Run()

for i, l := range lines {
lines[i] = filepath.Join(mountPoint, l)
}
Expand All @@ -259,6 +258,5 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
log.Println("N = ", b.N)
threads := runtime.GOMAXPROCS(0)
results := TestingBOnePass(b, threads, ttl*1.2, lines)
AnalyzeBenchmarkRuns(results)
AnalyzeBenchmarkRuns(results)
}

6 changes: 3 additions & 3 deletions fuse/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ type FsNode interface {
// The following are called by the FileSystemConnector
Inode() *Inode
SetInode(node *Inode)

// RmChild and AddChild run inside the critical section for
// the mutex behind Inode().LockTree().
RmChild(name string, child FsNode)
AddChild(name string, child FsNode)

Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status)
OnForget()

// Misc.
Access(mode uint32, context *Context) (code Status)
Readlink(c *Context) ([]byte, Status)
Expand Down Expand Up @@ -160,7 +160,7 @@ type WithFlags struct {

// For debugging.
Description string

// Put FOPEN_* flags here.
FuseFlags uint32

Expand Down
4 changes: 2 additions & 2 deletions fuse/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F
return f, c
}
return &WithFlags{
File: f,
File: f,
FuseFlags: FOPEN_KEEP_CACHE,
}, c

Expand Down Expand Up @@ -108,7 +108,7 @@ func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile
data := bytes.Repeat([]byte{42}, me.Length)
f := NewReadOnlyFile(data)
return &WithFlags{
File: f,
File: f,
FuseFlags: FOPEN_NONSEEKABLE,
}, OK
}
Expand Down
3 changes: 1 addition & 2 deletions fuse/fsconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (me *FileSystemConnector) createChild(parent *Inode, name string, fi *os.Fi
child = fsi.Inode()
child.addLookupCount(1)
}

out = parent.mount.fileInfoToEntry(fi)
out.Ino = child.nodeId
out.NodeId = child.nodeId
Expand Down Expand Up @@ -337,4 +337,3 @@ func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64)
func (me *FileSystemConnector) EntryNotify(dir *Inode, name string) Status {
return me.fsInit.EntryNotify(dir.nodeId, name)
}

9 changes: 3 additions & 6 deletions fuse/fsmount.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type openedFile struct {

WithFlags

dir rawDir
dir rawDir
}

type fileSystemMount struct {
Expand Down Expand Up @@ -50,8 +50,6 @@ func (me *fileSystemMount) mountName() string {
return ""
}



func (me *fileSystemMount) setOwner(attr *Attr) {
if me.options.Owner != nil {
attr.Owner = *me.options.Owner
Expand Down Expand Up @@ -109,9 +107,9 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
node.openFilesMutex.Lock()
defer node.openFilesMutex.Unlock()
b := &openedFile{
dir: dir,
dir: dir,
WithFlags: WithFlags{
File: f,
File: f,
OpenFlags: flags,
},
}
Expand Down Expand Up @@ -139,4 +137,3 @@ func (me *fileSystemMount) negativeEntry() *EntryOut {
SplitNs(me.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec)
return out
}

6 changes: 3 additions & 3 deletions fuse/fsops.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (me *FileSystemConnector) internalLookup(parent *Inode, name string, contex
if mount := me.findMount(parent, name); mount != nil {
return me.lookupMountUpdate(mount)
}

lookupNode, getattrNode := me.preLookup(parent, name)

var fi *os.FileInfo
Expand All @@ -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) {
parent.treeLock.Lock()
defer parent.treeLock.Unlock()

child := parent.children[name]
if child != nil {
// Make sure the child doesn't die inbetween.
child.addLookupCount(1)
return nil, child
}

return parent, nil
}

Expand Down
1 change: 0 additions & 1 deletion fuse/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (me *int32HandleMap) Has(h uint64) bool {
return me.handles[uint32(h)] != nil
}


func (me *int32HandleMap) Count() int {
me.mutex.Lock()
defer me.mutex.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion fuse/inode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"sync"
)

var _ = log.Println

// The inode reflects the kernel's idea of the inode.
Expand Down Expand Up @@ -33,7 +34,7 @@ type Inode struct {

// Contains directories that function as mounts. The entries
// are duplicated in children.
mounts map[string]*fileSystemMount
mounts map[string]*fileSystemMount

// Use addLookupCount() to manipulate.
lookupCount int
Expand Down
8 changes: 4 additions & 4 deletions fuse/loopback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ func TestLinkExisting(t *testing.T) {
defer me.Cleanup()

c := "hello"
err := ioutil.WriteFile(me.orig + "/file1", []byte(c), 0644)

err := ioutil.WriteFile(me.orig+"/file1", []byte(c), 0644)
CheckSuccess(err)
err = os.Link(me.orig + "/file1", me.orig + "/file2")
err = os.Link(me.orig+"/file1", me.orig+"/file2")
CheckSuccess(err)

f1, err := os.Lstat(me.mnt + "/file1")
Expand All @@ -294,7 +294,7 @@ func TestLinkExisting(t *testing.T) {
c1, err := ioutil.ReadFile(me.mnt + "/file1")
CheckSuccess(err)
if string(c1) != c {
t.Errorf("Content mismatch relative to original.")
t.Errorf("Content mismatch relative to original.")
}
}

Expand Down
32 changes: 16 additions & 16 deletions fuse/pathfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type clientInodePath struct {
}

type PathNodeFs struct {
Debug bool
fs FileSystem
root *pathInode
Debug bool
fs FileSystem
root *pathInode
connector *FileSystemConnector

// Used for dealing with hardlinks.
Expand Down Expand Up @@ -47,7 +47,7 @@ func (me *PathNodeFs) StatFs() *StatfsOut {
return me.fs.StatFs()
}

func (me *PathNodeFs) Node(name string) (*Inode) {
func (me *PathNodeFs) Node(name string) *Inode {
n, rest := me.LastNode(name)
if len(rest) > 0 {
return nil
Expand All @@ -59,10 +59,10 @@ func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
if name == "" {
return me.Root().Inode(), nil
}

name = filepath.Clean(name)
comps := strings.Split(name, string(filepath.Separator))

node := me.root.Inode()
for i, c := range comps {
next := node.GetChild(c)
Expand Down Expand Up @@ -111,8 +111,8 @@ func NewPathNodeFs(fs FileSystem) *PathNodeFs {
root.fs = fs

me := &PathNodeFs{
fs: fs,
root: root,
fs: fs,
root: root,
clientInodeMap: map[uint64][]*clientInodePath{},
}
root.ifs = me
Expand All @@ -137,7 +137,7 @@ type pathInode struct {
// This is to correctly resolve hardlinks of the underlying
// real filesystem.
clientInode uint64

DefaultFsNode
}

Expand Down Expand Up @@ -168,7 +168,7 @@ func (me *pathInode) GetPath() (path string) {
if me.ifs.Debug {
log.Printf("Inode %d = %q", me.Inode().nodeId, p)
}

return p
}

Expand Down Expand Up @@ -215,8 +215,8 @@ func (me *pathInode) RmChild(name string, child FsNode) {
} else {
me.ifs.clientInodeMap[ch.clientInode] = nil, false
}
}
}

ch.Name = ".deleted"
ch.Parent = nil
}
Expand Down Expand Up @@ -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)
if code.Ok() {
pNode := me.createChild(name)
newNode = pNode
newNode = pNode
fi = me.fillNewChildAttr(fullPath, pNode, context)
}
return
Expand All @@ -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)
if me.ifs.Debug {
file = &WithFlags{
File: file,
File: file,
Description: me.GetPath(),
}
}
return
return
}

func (me *pathInode) Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status) {
Expand Down Expand Up @@ -439,7 +439,7 @@ func (me *pathInode) GetAttr(file File, context *Context) (fi *os.FileInfo, code
if fi != nil {
me.setClientInode(fi.Ino)
}

if fi != nil && !fi.IsDirectory() && fi.Nlink == 0 {
fi.Nlink = 1
}
Expand Down
2 changes: 1 addition & 1 deletion unionfs/autounion.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type AutoUnionFs struct {
nameRootMap map[string]string
root string

nodeFs *fuse.PathNodeFs
nodeFs *fuse.PathNodeFs
options *AutoUnionFsOptions
}

Expand Down
2 changes: 1 addition & 1 deletion unionfs/unionfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ func (me *UnionFs) Name() string {

type UnionFsFile struct {
fuse.File
layer int
layer int
}

func (me *UnionFsFile) GetAttr() (*os.FileInfo, fuse.Status) {
Expand Down
7 changes: 2 additions & 5 deletions unionfs/unionfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func TestLink(t *testing.T) {
err := ioutil.WriteFile(fn, []byte(content), 0666)
CheckSuccess(err)

err = os.Link(wd+"/mount/file", wd + "/mount/linked")
err = os.Link(wd+"/mount/file", wd+"/mount/linked")
CheckSuccess(err)

fi2, err := os.Lstat(wd + "/mount/linked")
Expand Down Expand Up @@ -945,7 +945,6 @@ func TestDoubleOpen(t *testing.T) {
}
}


func TestFdLeak(t *testing.T) {
beforeEntries, err := ioutil.ReadDir("/proc/self/fd")
CheckSuccess(err)
Expand All @@ -957,7 +956,7 @@ func TestFdLeak(t *testing.T) {
contents, err := ioutil.ReadFile(wd + "/mount/file")
CheckSuccess(err)

err = ioutil.WriteFile(wd + "/mount/file", contents, 0644)
err = ioutil.WriteFile(wd+"/mount/file", contents, 0644)
CheckSuccess(err)

clean()
Expand All @@ -969,5 +968,3 @@ func TestFdLeak(t *testing.T) {
t.Errorf("/proc/self/fd changed size: after %v before %v", len(beforeEntries), len(afterEntries))
}
}


2 changes: 1 addition & 1 deletion zipfs/multizip.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type MultiZipFs struct {
zips map[string]*MemTreeFs
dirZipFileMap map[string]string

nodeFs *fuse.PathNodeFs
nodeFs *fuse.PathNodeFs
fuse.DefaultFileSystem
}

Expand Down

0 comments on commit 2003d2b

Please sign in to comment.