Commit d0f58fe6 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Gofmt.

parent 3aed656d
...@@ -106,11 +106,11 @@ func AnalyzeBenchmarkRuns(label string, times []float64) { ...@@ -106,11 +106,11 @@ func AnalyzeBenchmarkRuns(label string, times []float64) {
fmt.Printf( fmt.Printf(
"%s: %d samples\n"+ "%s: %d samples\n"+
"avg %.3fms +/- %.0f%% "+ "avg %.3fms +/- %.0f%% "+
"median %.3fms, 10%%tiles: [-%.0f%%, +%.0f%%]\n", "median %.3fms, 10%%tiles: [-%.0f%%, +%.0f%%]\n",
label, label,
len(times), avg, 100.0 * 2*stddev/avg, len(times), avg, 100.0*2*stddev/avg,
median, 100*(median - perc10)/median, 100*(perc90-median)/median) median, 100*(median-perc10)/median, 100*(perc90-median)/median)
} }
func RunBulkStat(runs int, threads int, sleepTime time.Duration, files []string) (results []float64) { func RunBulkStat(runs int, threads int, sleepTime time.Duration, files []string) (results []float64) {
......
...@@ -144,7 +144,6 @@ type PathNodeFsOptions struct { ...@@ -144,7 +144,6 @@ type PathNodeFsOptions struct {
ClientInodes bool ClientInodes bool
} }
// A File object should be returned from FileSystem.Open and // A File object should be returned from FileSystem.Open and
// FileSystem.Create. Include DefaultFile into the struct to inherit // FileSystem.Create. Include DefaultFile into the struct to inherit
// a default null implementation. // a default null implementation.
......
...@@ -17,7 +17,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte ...@@ -17,7 +17,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte
return code return code
} }
dst, code := destFs.Create(destFile, uint32(os.O_WRONLY | os.O_CREATE | os.O_TRUNC), attr.Mode, context) dst, code := destFs.Create(destFile, uint32(os.O_WRONLY|os.O_CREATE|os.O_TRUNC), attr.Mode, context)
if !code.Ok() { if !code.Ok() {
return code return code
} }
......
...@@ -44,7 +44,7 @@ func (f *DataFile) Read(buf []byte, off int64) (res ReadResult, code Status) { ...@@ -44,7 +44,7 @@ func (f *DataFile) Read(buf []byte, off int64) (res ReadResult, code Status) {
if end > len(f.data) { if end > len(f.data) {
end = len(f.data) end = len(f.data)
} }
return &ReadResultData{f.data[off:end]}, OK return &ReadResultData{f.data[off:end]}, OK
} }
...@@ -100,9 +100,9 @@ func (f *LoopbackFile) String() string { ...@@ -100,9 +100,9 @@ func (f *LoopbackFile) String() string {
func (f *LoopbackFile) Read(buf []byte, off int64) (res ReadResult, code Status) { func (f *LoopbackFile) Read(buf []byte, off int64) (res ReadResult, code Status) {
return &ReadResultFd{ return &ReadResultFd{
Fd: f.File.Fd(), Fd: f.File.Fd(),
Off: off, Off: off,
Sz: len(buf), Sz: len(buf),
}, OK }, OK
} }
......
...@@ -74,7 +74,7 @@ func NewFileSystemConnector(nodeFs NodeFileSystem, opts *FileSystemOptions) (c * ...@@ -74,7 +74,7 @@ func NewFileSystemConnector(nodeFs NodeFileSystem, opts *FileSystemOptions) (c *
// FUSE does not issue a LOOKUP for 1 (obviously), but it does // FUSE does not issue a LOOKUP for 1 (obviously), but it does
// issue a forget. This lookupUpdate is to make the counts match. // issue a forget. This lookupUpdate is to make the counts match.
c.lookupUpdate(c.rootNode) c.lookupUpdate(c.rootNode)
return c return c
} }
......
...@@ -23,11 +23,11 @@ func (f *MutableDataFile) String() string { ...@@ -23,11 +23,11 @@ func (f *MutableDataFile) String() string {
} }
func (f *MutableDataFile) Read(buf []byte, off int64) (ReadResult, Status) { func (f *MutableDataFile) Read(buf []byte, off int64) (ReadResult, Status) {
end := int(off)+len(buf) end := int(off) + len(buf)
if end > len(f.data) { if end > len(f.data) {
end = len(f.data) end = len(f.data)
} }
return &ReadResultData{Data: f.data[off:end]}, OK return &ReadResultData{Data: f.data[off:end]}, OK
} }
...@@ -40,7 +40,7 @@ func (f *MutableDataFile) Write(d []byte, off int64) (uint32, Status) { ...@@ -40,7 +40,7 @@ func (f *MutableDataFile) Write(d []byte, off int64) (uint32, Status) {
} }
copy(f.data[off:end], d) copy(f.data[off:end], d)
f.Attr.Size = uint64(len(f.data)) f.Attr.Size = uint64(len(f.data))
return uint32(end - off), OK return uint32(end - off), OK
} }
...@@ -158,7 +158,7 @@ func TestDataReadLarge(t *testing.T) { ...@@ -158,7 +158,7 @@ func TestDataReadLarge(t *testing.T) {
dir, clean := setupFAttrTest(t, fs) dir, clean := setupFAttrTest(t, fs)
defer clean() defer clean()
content := RandomData(385*1023) content := RandomData(385 * 1023)
fn := dir + "/file" fn := dir + "/file"
err := ioutil.WriteFile(fn, []byte(content), 0644) err := ioutil.WriteFile(fn, []byte(content), 0644)
CheckSuccess(err) CheckSuccess(err)
...@@ -168,7 +168,6 @@ func TestDataReadLarge(t *testing.T) { ...@@ -168,7 +168,6 @@ func TestDataReadLarge(t *testing.T) {
CompareSlices(t, back, content) CompareSlices(t, back, content)
} }
func TestFSetAttr(t *testing.T) { func TestFSetAttr(t *testing.T) {
fs := &FSetAttrFs{} fs := &FSetAttrFs{}
dir, clean := setupFAttrTest(t, fs) dir, clean := setupFAttrTest(t, fs)
...@@ -215,4 +214,3 @@ func TestFSetAttr(t *testing.T) { ...@@ -215,4 +214,3 @@ func TestFSetAttr(t *testing.T) {
} }
// TODO - test chown if run as root. // TODO - test chown if run as root.
} }
...@@ -15,8 +15,8 @@ type Inode struct { ...@@ -15,8 +15,8 @@ type Inode struct {
// Generation number of the inode. Each (re)use of an inode // Generation number of the inode. Each (re)use of an inode
// should have a unique generation number. // should have a unique generation number.
generation uint64 generation uint64
// Number of open files and its protection. // Number of open files and its protection.
openFilesMutex sync.Mutex openFilesMutex sync.Mutex
openFiles []*openedFile openFiles []*openedFile
......
...@@ -121,7 +121,7 @@ func TestTouch(t *testing.T) { ...@@ -121,7 +121,7 @@ func TestTouch(t *testing.T) {
ts := NewTestCase(t) ts := NewTestCase(t)
defer ts.Cleanup() defer ts.Cleanup()
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(ts.origFile, []byte(contents), 0700) err := ioutil.WriteFile(ts.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
err = os.Chtimes(ts.mountFile, time.Unix(42, 0), time.Unix(43, 0)) err = os.Chtimes(ts.mountFile, time.Unix(42, 0), time.Unix(43, 0))
...@@ -167,7 +167,7 @@ func TestRemove(t *testing.T) { ...@@ -167,7 +167,7 @@ func TestRemove(t *testing.T) {
tc := NewTestCase(t) tc := NewTestCase(t)
defer tc.Cleanup() defer tc.Cleanup()
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700) err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
...@@ -290,7 +290,7 @@ func TestLinkExisting(t *testing.T) { ...@@ -290,7 +290,7 @@ func TestLinkExisting(t *testing.T) {
back, err := ioutil.ReadFile(tc.mnt + "/file1") back, err := ioutil.ReadFile(tc.mnt + "/file1")
CheckSuccess(err) CheckSuccess(err)
CompareSlices(t, back, c) CompareSlices(t, back, c)
} }
// Deal correctly with hard links implied by matching client inode // Deal correctly with hard links implied by matching client inode
...@@ -324,7 +324,7 @@ func TestSymlink(t *testing.T) { ...@@ -324,7 +324,7 @@ func TestSymlink(t *testing.T) {
defer tc.Cleanup() defer tc.Cleanup()
t.Log("testing symlink/readlink.") t.Log("testing symlink/readlink.")
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700) err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
...@@ -355,7 +355,7 @@ func TestRename(t *testing.T) { ...@@ -355,7 +355,7 @@ func TestRename(t *testing.T) {
tc := NewTestCase(t) tc := NewTestCase(t)
defer tc.Cleanup() defer tc.Cleanup()
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700) err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
sd := tc.mnt + "/testRename" sd := tc.mnt + "/testRename"
...@@ -434,7 +434,7 @@ func TestAccess(t *testing.T) { ...@@ -434,7 +434,7 @@ func TestAccess(t *testing.T) {
tc := NewTestCase(t) tc := NewTestCase(t)
defer tc.Cleanup() defer tc.Cleanup()
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700) err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
err = os.Chmod(tc.origFile, 0) err = os.Chmod(tc.origFile, 0)
...@@ -473,7 +473,7 @@ func TestReaddir(t *testing.T) { ...@@ -473,7 +473,7 @@ func TestReaddir(t *testing.T) {
tc := NewTestCase(t) tc := NewTestCase(t)
defer tc.Cleanup() defer tc.Cleanup()
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700) err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
err = os.Mkdir(tc.origSubdir, 0777) err = os.Mkdir(tc.origSubdir, 0777)
...@@ -506,7 +506,7 @@ func TestFSync(t *testing.T) { ...@@ -506,7 +506,7 @@ func TestFSync(t *testing.T) {
tc := NewTestCase(t) tc := NewTestCase(t)
defer tc.Cleanup() defer tc.Cleanup()
contents := []byte{1,2,3} contents := []byte{1, 2, 3}
err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700) err := ioutil.WriteFile(tc.origFile, []byte(contents), 0700)
CheckSuccess(err) CheckSuccess(err)
...@@ -549,7 +549,7 @@ func RandomData(size int) []byte { ...@@ -549,7 +549,7 @@ func RandomData(size int) []byte {
if left < len(block) { if left < len(block) {
block = block[:left] block = block[:left]
} }
copy(content[start:], block) copy(content[start:], block)
start += len(block) start += len(block)
} }
...@@ -565,7 +565,7 @@ func CompareSlices(t *testing.T, got, want []byte) { ...@@ -565,7 +565,7 @@ func CompareSlices(t *testing.T, got, want []byte) {
break break
} }
if want[i] != got[i] { if want[i] != got[i] {
t.Errorf("content mismatch byte %d, got %d want %d.", i, got[i], want[i]) t.Errorf("content mismatch byte %d, got %d want %d.", i, got[i], want[i])
break break
} }
} }
...@@ -576,7 +576,7 @@ func TestReadLargeMemCheck(t *testing.T) { ...@@ -576,7 +576,7 @@ func TestReadLargeMemCheck(t *testing.T) {
ts := NewTestCase(t) ts := NewTestCase(t)
defer ts.Cleanup() defer ts.Cleanup()
content := RandomData(385*1023) content := RandomData(385 * 1023)
err := ioutil.WriteFile(ts.origFile, []byte(content), 0644) err := ioutil.WriteFile(ts.origFile, []byte(content), 0644)
CheckSuccess(err) CheckSuccess(err)
...@@ -598,7 +598,7 @@ func TestReadLargeMemCheck(t *testing.T) { ...@@ -598,7 +598,7 @@ func TestReadLargeMemCheck(t *testing.T) {
} }
runtime.ReadMemStats(&after) runtime.ReadMemStats(&after)
delta := int((after.TotalAlloc - before.TotalAlloc)) delta := int((after.TotalAlloc - before.TotalAlloc))
delta = (delta - 40000)/ N delta = (delta - 40000) / N
limit := 5000 limit := 5000
if delta > limit { if delta > limit {
...@@ -610,7 +610,7 @@ func TestReadLarge(t *testing.T) { ...@@ -610,7 +610,7 @@ func TestReadLarge(t *testing.T) {
ts := NewTestCase(t) ts := NewTestCase(t)
defer ts.Cleanup() defer ts.Cleanup()
content := RandomData(385*1023) content := RandomData(385 * 1023)
err := ioutil.WriteFile(ts.origFile, []byte(content), 0644) err := ioutil.WriteFile(ts.origFile, []byte(content), 0644)
CheckSuccess(err) CheckSuccess(err)
......
...@@ -408,9 +408,9 @@ func (ms *MountState) TrySplice(header []byte, req *request, fdData *ReadResultF ...@@ -408,9 +408,9 @@ func (ms *MountState) TrySplice(header []byte, req *request, fdData *ReadResultF
header = req.serializeHeader(n) header = req.serializeHeader(n)
newFd := ReadResultFd{ newFd := ReadResultFd{
Fd: pair.ReadFd(), Fd: pair.ReadFd(),
Off: -1, Off: -1,
Sz: n, Sz: n,
} }
return ms.TrySplice(header, req, &newFd) return ms.TrySplice(header, req, &newFd)
} }
...@@ -477,6 +477,7 @@ func (ms *MountState) writeEntryNotify(parent uint64, name string) Status { ...@@ -477,6 +477,7 @@ func (ms *MountState) writeEntryNotify(parent uint64, name string) Status {
} }
var defaultBufferPool BufferPool var defaultBufferPool BufferPool
func init() { func init() {
defaultBufferPool = NewBufferPool() defaultBufferPool = NewBufferPool()
} }
...@@ -37,7 +37,7 @@ func TestMemoryPressure(t *testing.T) { ...@@ -37,7 +37,7 @@ func TestMemoryPressure(t *testing.T) {
conn := NewFileSystemConnector(nfs, o) conn := NewFileSystemConnector(nfs, o)
state := NewMountState(conn) state := NewMountState(conn)
bufs := NewBufferPool() bufs := NewBufferPool()
err = state.Mount(dir, &MountOptions{Buffers: bufs}) err = state.Mount(dir, &MountOptions{Buffers: bufs})
if err != nil { if err != nil {
t.Fatalf("mount failed: %v", err) t.Fatalf("mount failed: %v", err)
......
...@@ -5,8 +5,6 @@ import ( ...@@ -5,8 +5,6 @@ import (
"syscall" "syscall"
) )
// ReadResultData is the read return for returning bytes directly. // ReadResultData is the read return for returning bytes directly.
type ReadResultData struct { type ReadResultData struct {
// Raw bytes for the read. // Raw bytes for the read.
...@@ -27,7 +25,7 @@ type ReadResultFd struct { ...@@ -27,7 +25,7 @@ type ReadResultFd struct {
Fd uintptr Fd uintptr
// Offset within Fd, or -1 to use current offset. // Offset within Fd, or -1 to use current offset.
Off int64 Off int64
// Size of data to be loaded. Actual data available may be // Size of data to be loaded. Actual data available may be
// less at the EOF. // less at the EOF.
...@@ -53,4 +51,3 @@ func (r *ReadResultFd) Bytes(buf []byte) []byte { ...@@ -53,4 +51,3 @@ func (r *ReadResultFd) Bytes(buf []byte) []byte {
func (r *ReadResultFd) Size() int { func (r *ReadResultFd) Size() int {
return r.Sz return r.Sz
} }
...@@ -108,7 +108,7 @@ func (r *request) OutputDebug() string { ...@@ -108,7 +108,7 @@ func (r *request) OutputDebug() string {
flatStr = fmt.Sprintf(" %q", s) flatStr = fmt.Sprintf(" %q", s)
} else { } else {
spl := "" spl := ""
if r.fdData != nil { if r.fdData != nil {
spl = " (splice)" spl = " (splice)"
} }
flatStr = fmt.Sprintf(" %d bytes data%s\n", r.flatDataSize(), spl) flatStr = fmt.Sprintf(" %d bytes data%s\n", r.flatDataSize(), spl)
......
...@@ -48,4 +48,3 @@ type Owner raw.Owner ...@@ -48,4 +48,3 @@ type Owner raw.Owner
type Context raw.Context type Context raw.Context
type StatfsOut raw.StatfsOut type StatfsOut raw.StatfsOut
...@@ -15,7 +15,6 @@ var accessFlagName map[int]string ...@@ -15,7 +15,6 @@ var accessFlagName map[int]string
var writeFlagNames map[int]string var writeFlagNames map[int]string
var readFlagNames map[int]string var readFlagNames map[int]string
func init() { func init() {
writeFlagNames = map[int]string{ writeFlagNames = map[int]string{
WRITE_CACHE: "CACHE", WRITE_CACHE: "CACHE",
......
...@@ -63,7 +63,8 @@ func (me *pairPool) get() (p *Pair, err error) { ...@@ -63,7 +63,8 @@ func (me *pairPool) get() (p *Pair, err error) {
return newSplicePair() return newSplicePair()
} }
var discardBuffer [32*1024]byte var discardBuffer [32 * 1024]byte
func DiscardAll(r io.Reader) { func DiscardAll(r io.Reader) {
buf := discardBuffer[:] buf := discardBuffer[:]
for { for {
...@@ -76,7 +77,7 @@ func DiscardAll(r io.Reader) { ...@@ -76,7 +77,7 @@ func DiscardAll(r io.Reader) {
func (me *pairPool) done(p *Pair) { func (me *pairPool) done(p *Pair) {
DiscardAll(p.r) DiscardAll(p.r)
me.Lock() me.Lock()
defer me.Unlock() defer me.Unlock()
me.usedCount-- me.usedCount--
......
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