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
26b2eb35
Commit
26b2eb35
authored
Jun 09, 2017
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Softcode page size, remove fuse.PAGESIZE constant.
Fixes #160.
parent
5404bf0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
19 deletions
+13
-19
fuse/bufferpool.go
fuse/bufferpool.go
+12
-9
fuse/misc.go
fuse/misc.go
+0
-7
fuse/server.go
fuse/server.go
+1
-1
fuse/types.go
fuse/types.go
+0
-2
No files found.
fuse/bufferpool.go
View file @
26b2eb35
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
package
fuse
package
fuse
import
(
import
(
"os"
"sync"
"sync"
)
)
...
@@ -46,7 +47,7 @@ type bufferPoolImpl struct {
...
@@ -46,7 +47,7 @@ type bufferPoolImpl struct {
}
}
// NewBufferPool returns a BufferPool implementation that that returns
// NewBufferPool returns a BufferPool implementation that that returns
// slices with capacity of a multiple of
PAGESIZE
, which have possibly
// slices with capacity of a multiple of
page size
, which have possibly
// been used, and may contain random contents. When using
// been used, and may contain random contents. When using
// NewBufferPool, file system handlers may not hang on to passed-in
// NewBufferPool, file system handlers may not hang on to passed-in
// buffers beyond the handler's return.
// buffers beyond the handler's return.
...
@@ -55,6 +56,8 @@ func NewBufferPool() BufferPool {
...
@@ -55,6 +56,8 @@ func NewBufferPool() BufferPool {
return
bp
return
bp
}
}
var
pageSize
=
os
.
Getpagesize
()
func
(
p
*
bufferPoolImpl
)
getPool
(
pageCount
int
)
*
sync
.
Pool
{
func
(
p
*
bufferPoolImpl
)
getPool
(
pageCount
int
)
*
sync
.
Pool
{
p
.
lock
.
Lock
()
p
.
lock
.
Lock
()
for
len
(
p
.
buffersBySize
)
<
pageCount
+
1
{
for
len
(
p
.
buffersBySize
)
<
pageCount
+
1
{
...
@@ -62,7 +65,7 @@ func (p *bufferPoolImpl) getPool(pageCount int) *sync.Pool {
...
@@ -62,7 +65,7 @@ func (p *bufferPoolImpl) getPool(pageCount int) *sync.Pool {
}
}
if
p
.
buffersBySize
[
pageCount
]
==
nil
{
if
p
.
buffersBySize
[
pageCount
]
==
nil
{
p
.
buffersBySize
[
pageCount
]
=
&
sync
.
Pool
{
p
.
buffersBySize
[
pageCount
]
=
&
sync
.
Pool
{
New
:
func
()
interface
{}
{
return
make
([]
byte
,
PAGESIZE
*
pageCount
)
},
New
:
func
()
interface
{}
{
return
make
([]
byte
,
pageSize
*
pageCount
)
},
}
}
}
}
pool
:=
p
.
buffersBySize
[
pageCount
]
pool
:=
p
.
buffersBySize
[
pageCount
]
...
@@ -72,14 +75,14 @@ func (p *bufferPoolImpl) getPool(pageCount int) *sync.Pool {
...
@@ -72,14 +75,14 @@ func (p *bufferPoolImpl) getPool(pageCount int) *sync.Pool {
func
(
p
*
bufferPoolImpl
)
AllocBuffer
(
size
uint32
)
[]
byte
{
func
(
p
*
bufferPoolImpl
)
AllocBuffer
(
size
uint32
)
[]
byte
{
sz
:=
int
(
size
)
sz
:=
int
(
size
)
if
sz
<
PAGESIZE
{
if
sz
<
pageSize
{
sz
=
PAGESIZE
sz
=
pageSize
}
}
if
sz
%
PAGESIZE
!=
0
{
if
sz
%
pageSize
!=
0
{
sz
+=
PAGESIZE
sz
+=
pageSize
}
}
pages
:=
sz
/
PAGESIZE
pages
:=
sz
/
pageSize
b
:=
p
.
getPool
(
pages
)
.
Get
()
.
([]
byte
)
b
:=
p
.
getPool
(
pages
)
.
Get
()
.
([]
byte
)
return
b
[
:
size
]
return
b
[
:
size
]
...
@@ -89,10 +92,10 @@ func (p *bufferPoolImpl) FreeBuffer(slice []byte) {
...
@@ -89,10 +92,10 @@ func (p *bufferPoolImpl) FreeBuffer(slice []byte) {
if
slice
==
nil
{
if
slice
==
nil
{
return
return
}
}
if
cap
(
slice
)
%
PAGESIZE
!=
0
||
cap
(
slice
)
==
0
{
if
cap
(
slice
)
%
pageSize
!=
0
||
cap
(
slice
)
==
0
{
return
return
}
}
pages
:=
cap
(
slice
)
/
PAGESIZE
pages
:=
cap
(
slice
)
/
pageSize
slice
=
slice
[
:
cap
(
slice
)]
slice
=
slice
[
:
cap
(
slice
)]
p
.
getPool
(
pages
)
.
Put
(
slice
)
p
.
getPool
(
pages
)
.
Put
(
slice
)
...
...
fuse/misc.go
View file @
26b2eb35
...
@@ -81,13 +81,6 @@ func CurrentOwner() *Owner {
...
@@ -81,13 +81,6 @@ func CurrentOwner() *Owner {
}
}
}
}
func
init
()
{
p
:=
syscall
.
Getpagesize
()
if
p
!=
PAGESIZE
{
log
.
Panicf
(
"page size incorrect: %d"
,
p
)
}
}
const
_UTIME_OMIT
=
((
1
<<
30
)
-
2
)
const
_UTIME_OMIT
=
((
1
<<
30
)
-
2
)
// UtimeToTimespec converts a "Time" pointer as passed to Utimens to a
// UtimeToTimespec converts a "Time" pointer as passed to Utimens to a
...
...
fuse/server.go
View file @
26b2eb35
...
@@ -163,7 +163,7 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
...
@@ -163,7 +163,7 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
singleReader
:
runtime
.
GOOS
==
"darwin"
,
singleReader
:
runtime
.
GOOS
==
"darwin"
,
}
}
ms
.
reqPool
.
New
=
func
()
interface
{}
{
return
new
(
request
)
}
ms
.
reqPool
.
New
=
func
()
interface
{}
{
return
new
(
request
)
}
ms
.
readPool
.
New
=
func
()
interface
{}
{
return
make
([]
byte
,
o
.
MaxWrite
+
PAGESIZE
)
}
ms
.
readPool
.
New
=
func
()
interface
{}
{
return
make
([]
byte
,
o
.
MaxWrite
+
pageSize
)
}
mountPoint
=
filepath
.
Clean
(
mountPoint
)
mountPoint
=
filepath
.
Clean
(
mountPoint
)
if
!
filepath
.
IsAbs
(
mountPoint
)
{
if
!
filepath
.
IsAbs
(
mountPoint
)
{
...
...
fuse/types.go
View file @
26b2eb35
...
@@ -8,8 +8,6 @@ import (
...
@@ -8,8 +8,6 @@ import (
"syscall"
"syscall"
)
)
const
PAGESIZE
=
4096
const
(
const
(
_DEFAULT_BACKGROUND_TASKS
=
12
_DEFAULT_BACKGROUND_TASKS
=
12
)
)
...
...
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