Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
83a89fc7
Commit
83a89fc7
authored
May 09, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change BufferPool to an interface.
parent
ed9d2c4e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
21 deletions
+41
-21
fuse/api.go
fuse/api.go
+3
-3
fuse/bufferpool.go
fuse/bufferpool.go
+28
-8
fuse/default.go
fuse/default.go
+2
-2
fuse/files.go
fuse/files.go
+3
-3
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+1
-1
fuse/fuse.go
fuse/fuse.go
+1
-1
fuse/lockingfs.go
fuse/lockingfs.go
+1
-1
fuse/pathops.go
fuse/pathops.go
+1
-1
fuse/timingrawfs.go
fuse/timingrawfs.go
+1
-1
No files found.
fuse/api.go
View file @
83a89fc7
...
...
@@ -13,7 +13,7 @@ import (
// Typically, each call happens in its own goroutine, so take care to
// make the file system thread-safe.
//
// Include DefaultFileSystem to provide default null implementation of
// Include DefaultFileSystem to provide
a
default null implementation of
// required methods.
type
FileSystem
interface
{
// Attributes
...
...
@@ -69,7 +69,7 @@ type FileSystem interface {
//
// TODO - should File be thread safe?
type
File
interface
{
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
Read
(
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Truncate
(
size
uint64
)
Status
...
...
@@ -137,7 +137,7 @@ type RawFileSystem interface {
// File handling.
Create
(
header
*
InHeader
,
input
*
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
EntryOut
,
code
Status
)
Open
(
header
*
InHeader
,
input
*
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
Read
(
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
Release
(
header
*
InHeader
,
input
*
ReleaseIn
)
Write
(
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
...
...
fuse/bufferpool.go
View file @
83a89fc7
...
...
@@ -9,10 +9,30 @@ import (
var
_
=
log
.
Println
type
BufferPool
interface
{
AllocBuffer
(
size
uint32
)
[]
byte
FreeBuffer
(
slice
[]
byte
)
}
type
GcBufferPool
struct
{
}
// NewGcBufferPool is just a fallback to the standard allocation routines.
func
NewGcBufferPool
()
*
GcBufferPool
{
return
&
GcBufferPool
{}
}
func
(
me
*
GcBufferPool
)
AllocBuffer
(
size
uint32
)
[]
byte
{
return
make
([]
byte
,
size
)
}
func
(
me
*
GcBufferPool
)
FreeBuffer
(
slice
[]
byte
)
{
}
// BufferPool implements a pool of buffers that returns slices with
// capacity (2^e * PAGESIZE) for e=0,1,... which have possibly been
// used, and may contain random contents.
type
BufferPool
struct
{
type
BufferPool
Impl
struct
{
lock
sync
.
Mutex
// For each exponent a list of slice pointers.
...
...
@@ -41,14 +61,14 @@ func IntToExponent(z int) uint {
return
exp
}
func
NewBufferPool
()
*
BufferPool
{
bp
:=
new
(
BufferPool
)
func
NewBufferPool
()
*
BufferPool
Impl
{
bp
:=
new
(
BufferPool
Impl
)
bp
.
buffersByExponent
=
make
([][][]
byte
,
0
,
8
)
bp
.
outstandingBuffers
=
make
(
map
[
uintptr
]
uint
)
return
bp
}
func
(
me
*
BufferPool
)
String
()
string
{
func
(
me
*
BufferPool
Impl
)
String
()
string
{
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
s
:=
fmt
.
Sprintf
(
"created: %v
\n
outstanding %v
\n
"
,
...
...
@@ -59,7 +79,7 @@ func (me *BufferPool) String() string {
return
s
}
func
(
me
*
BufferPool
)
getBuffer
(
exponent
uint
)
[]
byte
{
func
(
me
*
BufferPool
Impl
)
getBuffer
(
exponent
uint
)
[]
byte
{
if
len
(
me
.
buffersByExponent
)
<=
int
(
exponent
)
{
return
nil
}
...
...
@@ -73,7 +93,7 @@ func (me *BufferPool) getBuffer(exponent uint) []byte {
return
result
}
func
(
me
*
BufferPool
)
addBuffer
(
slice
[]
byte
,
exp
uint
)
{
func
(
me
*
BufferPool
Impl
)
addBuffer
(
slice
[]
byte
,
exp
uint
)
{
for
len
(
me
.
buffersByExponent
)
<=
int
(
exp
)
{
me
.
buffersByExponent
=
append
(
me
.
buffersByExponent
,
make
([][]
byte
,
0
))
}
...
...
@@ -82,7 +102,7 @@ func (me *BufferPool) addBuffer(slice []byte, exp uint) {
// AllocBuffer creates a buffer of at least the given size. After use,
// it should be deallocated with FreeBuffer().
func
(
me
*
BufferPool
)
AllocBuffer
(
size
uint32
)
[]
byte
{
func
(
me
*
BufferPool
Impl
)
AllocBuffer
(
size
uint32
)
[]
byte
{
sz
:=
int
(
size
)
if
sz
<
PAGESIZE
{
sz
=
PAGESIZE
...
...
@@ -119,7 +139,7 @@ func (me *BufferPool) AllocBuffer(size uint32) []byte {
// FreeBuffer takes back a buffer if it was allocated through
// AllocBuffer. It is not an error to call FreeBuffer() on a slice
// obtained elsewhere.
func
(
me
*
BufferPool
)
FreeBuffer
(
slice
[]
byte
)
{
func
(
me
*
BufferPool
Impl
)
FreeBuffer
(
slice
[]
byte
)
{
if
slice
==
nil
{
return
}
...
...
fuse/default.go
View file @
83a89fc7
...
...
@@ -100,7 +100,7 @@ func (me *DefaultRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags
return
0
,
0
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Read
(
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
{
return
nil
,
ENOSYS
}
...
...
@@ -137,7 +137,7 @@ func (me *DefaultRawFileSystem) Ioctl(header *InHeader, input *IoctlIn) (output
////////////////////////////////////////////////////////////////
// DefaultFile
func
(
me
*
DefaultFile
)
Read
(
*
ReadIn
,
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
DefaultFile
)
Read
(
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
(
""
),
ENOSYS
}
...
...
fuse/files.go
View file @
83a89fc7
...
...
@@ -18,7 +18,7 @@ func NewReadOnlyFile(data []byte) *ReadOnlyFile {
return
f
}
func
(
me
*
ReadOnlyFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
ReadOnlyFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
end
:=
int
(
input
.
Offset
)
+
int
(
input
.
Size
)
if
end
>
len
(
me
.
data
)
{
end
=
len
(
me
.
data
)
...
...
@@ -38,7 +38,7 @@ func NewDevNullFile() *DevNullFile {
return
new
(
DevNullFile
)
}
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
{},
OK
}
...
...
@@ -63,7 +63,7 @@ type LoopbackFile struct {
DefaultFile
}
func
(
me
*
LoopbackFile
)
Read
(
input
*
ReadIn
,
buffers
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
LoopbackFile
)
Read
(
input
*
ReadIn
,
buffers
BufferPool
)
([]
byte
,
Status
)
{
slice
:=
buffers
.
AllocBuffer
(
input
.
Size
)
n
,
err
:=
me
.
file
.
ReadAt
(
slice
,
int64
(
input
.
Offset
))
...
...
fuse/fsetattr_test.go
View file @
83a89fc7
...
...
@@ -17,7 +17,7 @@ type MutableDataFile struct {
GetAttrCalled
bool
}
func
(
me
*
MutableDataFile
)
Read
(
r
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
MutableDataFile
)
Read
(
r
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
me
.
data
[
r
.
Offset
:
r
.
Offset
+
uint64
(
r
.
Size
)],
OK
}
...
...
fuse/fuse.go
View file @
83a89fc7
...
...
@@ -29,7 +29,7 @@ type MountState struct {
Debug
bool
// For efficient reads and writes.
buffers
*
BufferPool
buffers
*
BufferPool
Impl
*
LatencyMap
...
...
fuse/lockingfs.go
View file @
83a89fc7
...
...
@@ -274,7 +274,7 @@ func (me *LockingRawFileSystem) ReleaseDir(header *InHeader, h *ReleaseIn) {
me
.
RawFileSystem
.
ReleaseDir
(
header
,
h
)
}
func
(
me
*
LockingRawFileSystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Read
(
input
,
bp
)
}
...
...
fuse/pathops.go
View file @
83a89fc7
...
...
@@ -466,7 +466,7 @@ func (me *FileSystemConnector) Write(input *WriteIn, data []byte) (written uint3
return
f
.
Write
(
input
,
data
)
}
func
(
me
*
FileSystemConnector
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
FileSystemConnector
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
f
,
_
,
n
:=
me
.
getFile
(
input
.
Fh
)
if
me
.
Debug
{
me
.
fileDebug
(
input
.
Fh
,
n
)
...
...
fuse/timingrawfs.go
View file @
83a89fc7
...
...
@@ -141,7 +141,7 @@ func (me *TimingRawFileSystem) Release(header *InHeader, input *ReleaseIn) {
me
.
RawFileSystem
.
Release
(
header
,
input
)
}
func
(
me
*
TimingRawFileSystem
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
TimingRawFileSystem
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
defer
me
.
startTimer
(
"Read"
)()
return
me
.
RawFileSystem
.
Read
(
input
,
bp
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment