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
Kirill Smelkov
go-fuse
Commits
b4cc1627
Commit
b4cc1627
authored
Jul 15, 2017
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: add pollhack that compiles on Darwin too
parent
6416abc3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
27 deletions
+83
-27
fuse/poll.go
fuse/poll.go
+9
-0
fuse/poll_darwin.go
fuse/poll_darwin.go
+49
-0
fuse/poll_linux.go
fuse/poll_linux.go
+25
-0
fuse/server.go
fuse/server.go
+0
-27
No files found.
fuse/poll.go
0 → 100644
View file @
b4cc1627
package
fuse
// Go 1.9 introduces polling for file I/O. The implementation causes
// the runtime's epoll to take up the last GOMAXPROCS slot, and if
// that happens, we won't have any threads left to service FUSE's
// _OP_POLL request. Prevent this by forcing _OP_POLL to happen, so we
// can say ENOSYS and prevent further _OP_POLL requests.
const
pollHackName
=
".go-fuse-epoll-hack"
const
pollHackInode
=
^
uint64
(
0
)
fuse/poll_darwin.go
0 → 100644
View file @
b4cc1627
package
fuse
import
(
"path/filepath"
"syscall"
"unsafe"
)
type
pollFd
struct
{
Fd
int32
Events
int16
Revents
int16
}
func
sysPoll
(
fds
[]
pollFd
,
timeout
int
)
(
n
int
,
err
error
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
syscall
.
SYS_POLL
,
uintptr
(
unsafe
.
Pointer
(
&
fds
[
0
])),
uintptr
(
len
(
fds
)),
uintptr
(
timeout
))
n
=
int
(
r0
)
if
e1
!=
0
{
err
=
syscall
.
Errno
(
e1
)
}
return
n
,
err
}
func
pollHack
(
mountPoint
string
)
error
{
const
(
POLLIN
=
0x1
POLLPRI
=
0x2
POLLOUT
=
0x4
POLLRDHUP
=
0x2000
POLLERR
=
0x8
POLLHUP
=
0x10
)
fd
,
err
:=
syscall
.
Open
(
filepath
.
Join
(
mountPoint
,
pollHackName
),
syscall
.
O_CREAT
|
syscall
.
O_TRUNC
|
syscall
.
O_RDWR
,
0644
)
if
err
!=
nil
{
return
err
}
pollData
:=
[]
pollFd
{{
Fd
:
int32
(
fd
),
Events
:
POLLIN
|
POLLPRI
|
POLLOUT
,
}}
// Trigger _OP_POLL, so we can say ENOSYS. We don't care about
// the return value.
sysPoll
(
pollData
,
0
)
syscall
.
Close
(
fd
)
return
nil
}
fuse/poll_linux.go
0 → 100644
View file @
b4cc1627
package
fuse
import
(
"path/filepath"
"syscall"
"golang.org/x/sys/unix"
)
func
pollHack
(
mountPoint
string
)
error
{
fd
,
err
:=
syscall
.
Creat
(
filepath
.
Join
(
mountPoint
,
pollHackName
),
syscall
.
O_CREAT
)
if
err
!=
nil
{
return
err
}
pollData
:=
[]
unix
.
PollFd
{{
Fd
:
int32
(
fd
),
Events
:
unix
.
POLLIN
|
unix
.
POLLPRI
|
unix
.
POLLOUT
,
}}
// Trigger _OP_POLL, so we can say ENOSYS. We don't care about
// the return value.
unix
.
Poll
(
pollData
,
0
)
syscall
.
Close
(
fd
)
return
nil
}
fuse/server.go
View file @
b4cc1627
...
...
@@ -15,8 +15,6 @@ import (
"syscall"
"time"
"unsafe"
"golang.org/x/sys/unix"
)
const
(
...
...
@@ -57,9 +55,6 @@ type Server struct {
ready
chan
error
}
const
pollHackName
=
".go-fuse-epoll-hack"
const
pollHackInode
=
^
uint64
(
0
)
// SetDebug is deprecated. Use MountOptions.Debug instead.
func
(
ms
*
Server
)
SetDebug
(
dbg
bool
)
{
// This will typically trigger the race detector.
...
...
@@ -598,25 +593,3 @@ func (ms *Server) WaitMount() error {
}
return
pollHack
(
ms
.
mountPoint
)
}
// Go 1.9 introduces polling for file I/O. The implementation causes
// the runtime's epoll to take up the last GOMAXPROCS slot, and if
// that happens, we won't have any threads left to service FUSE's
// _OP_POLL request. Prevent this by forcing _OP_POLL to happen, so we
// can say ENOSYS and prevent further _OP_POLL requests.
func
pollHack
(
mountPoint
string
)
error
{
fd
,
err
:=
syscall
.
Creat
(
filepath
.
Join
(
mountPoint
,
pollHackName
),
syscall
.
O_CREAT
)
if
err
!=
nil
{
return
err
}
pollData
:=
[]
unix
.
PollFd
{{
Fd
:
int32
(
fd
),
Events
:
unix
.
POLLIN
|
unix
.
POLLPRI
|
unix
.
POLLOUT
,
}}
// Trigger _OP_POLL, so we can say ENOSYS. We don't care about
// the return value.
unix
.
Poll
(
pollData
,
0
)
syscall
.
Close
(
fd
)
return
nil
}
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