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
5bb5947a
Commit
5bb5947a
authored
May 26, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow buffer pool to be specified in MountOptions.
parent
ddad1bed
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
+23
-10
fuse/api.go
fuse/api.go
+3
-0
fuse/mountstate.go
fuse/mountstate.go
+12
-8
fuse/pressure_test.go
fuse/pressure_test.go
+8
-2
No files found.
fuse/api.go
View file @
5bb5947a
...
...
@@ -232,6 +232,9 @@ type MountOptions struct {
// file system implements extended attributes, and you are not
// interested in security labels.
IgnoreSecurityLabels
bool
// ignoring labels should be provided as a fusermount mount option.
// If given, use this buffer pool instead of the global one.
Buffers
BufferPool
}
// DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
...
...
fuse/mountstate.go
View file @
5bb5947a
...
...
@@ -32,9 +32,6 @@ type MountState struct {
// Dump debug info onto stdout.
Debug
bool
// For efficient reads and writes.
buffers
*
BufferPoolImpl
latencies
*
LatencyMap
opts
*
MountOptions
...
...
@@ -66,6 +63,9 @@ func (ms *MountState) Mount(mountPoint string, opts *MountOptions) error {
}
}
o
:=
*
opts
if
o
.
Buffers
==
nil
{
o
.
Buffers
=
defaultBufferPool
}
if
o
.
MaxWrite
<
0
{
o
.
MaxWrite
=
0
}
...
...
@@ -136,7 +136,6 @@ func NewMountState(fs RawFileSystem) *MountState {
ms
:=
new
(
MountState
)
ms
.
mountPoint
=
""
ms
.
fileSystem
=
fs
ms
.
buffers
=
NewBufferPool
()
return
ms
}
...
...
@@ -155,7 +154,7 @@ func (ms *MountState) OperationCounts() map[string]int {
}
func
(
ms
*
MountState
)
BufferPoolStats
()
string
{
s
:=
ms
.
b
uffers
.
String
()
s
:=
ms
.
opts
.
B
uffers
.
String
()
var
r
int
ms
.
reqMu
.
Lock
()
...
...
@@ -230,7 +229,7 @@ func (ms *MountState) returnRequest(req *request) {
ms
.
recordStats
(
req
)
if
req
.
bufferPoolOutputBuf
!=
nil
{
ms
.
b
uffers
.
FreeBuffer
(
req
.
bufferPoolOutputBuf
)
ms
.
opts
.
B
uffers
.
FreeBuffer
(
req
.
bufferPoolOutputBuf
)
req
.
bufferPoolOutputBuf
=
nil
}
...
...
@@ -330,9 +329,9 @@ func (ms *MountState) AllocOut(req *request, size uint32) []byte {
return
req
.
bufferPoolOutputBuf
}
if
req
.
bufferPoolOutputBuf
!=
nil
{
ms
.
b
uffers
.
FreeBuffer
(
req
.
bufferPoolOutputBuf
)
ms
.
opts
.
B
uffers
.
FreeBuffer
(
req
.
bufferPoolOutputBuf
)
}
req
.
bufferPoolOutputBuf
=
ms
.
b
uffers
.
AllocBuffer
(
size
)
req
.
bufferPoolOutputBuf
=
ms
.
opts
.
B
uffers
.
AllocBuffer
(
size
)
return
req
.
bufferPoolOutputBuf
}
...
...
@@ -470,3 +469,8 @@ func (ms *MountState) writeEntryNotify(parent uint64, name string) Status {
}
return
result
}
var
defaultBufferPool
BufferPool
func
init
()
{
defaultBufferPool
=
NewBufferPool
()
}
fuse/pressure_test.go
View file @
5bb5947a
...
...
@@ -33,7 +33,12 @@ func TestMemoryPressure(t *testing.T) {
CheckSuccess
(
err
)
nfs
:=
NewPathNodeFs
(
fs
,
nil
)
o
:=
&
FileSystemOptions
{
PortableInodes
:
true
}
state
,
_
,
err
:=
MountNodeFileSystem
(
dir
,
nfs
,
o
)
conn
:=
NewFileSystemConnector
(
nfs
,
o
)
state
:=
NewMountState
(
conn
)
bufs
:=
NewBufferPool
()
err
=
state
.
Mount
(
dir
,
&
MountOptions
{
Buffers
:
bufs
})
if
err
!=
nil
{
t
.
Fatalf
(
"mount failed: %v"
,
err
)
}
...
...
@@ -58,7 +63,8 @@ func TestMemoryPressure(t *testing.T) {
}(
i
)
}
time
.
Sleep
(
100
*
time
.
Millisecond
)
created
:=
state
.
buffers
.
createdBuffers
+
state
.
outstandingReadBufs
created
:=
bufs
.
createdBuffers
+
state
.
outstandingReadBufs
t
.
Logf
(
"Have %d read bufs"
,
state
.
outstandingReadBufs
)
if
created
>
2
*
_MAX_READERS
{
t
.
Errorf
(
"created %d buffers, max reader %d"
,
created
,
_MAX_READERS
)
...
...
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