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
34f928bf
Commit
34f928bf
authored
Mar 01, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: reinstate atomics.
When using automatic NodeIds, we can still have a race.
parent
037f7b0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
nodefs/default.go
nodefs/default.go
+25
-3
No files found.
nodefs/default.go
View file @
34f928bf
...
@@ -7,7 +7,9 @@ package nodefs
...
@@ -7,7 +7,9 @@ package nodefs
import
(
import
(
"context"
"context"
"log"
"log"
"sync/atomic"
"time"
"time"
"unsafe"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
)
)
...
@@ -22,12 +24,32 @@ type DefaultOperations struct {
...
@@ -22,12 +24,32 @@ type DefaultOperations struct {
// check that we have implemented all interface methods
// check that we have implemented all interface methods
var
_
Operations
=
&
DefaultOperations
{}
var
_
Operations
=
&
DefaultOperations
{}
func
(
dn
*
DefaultOperations
)
setInode
(
inode
*
Inode
)
{
// set/retrieve inode.
dn
.
inode_
=
inode
//
// node -> inode association, can be simultaneously tried to be set, if for e.g.
//
// root
// / \
// dir1 dir2
// \ /
// file
//
// dir1.Lookup("file") and dir2.Lookup("file") are executed simultaneously.
//
// If not using FileID, the mapping in rawBridge does not help. So,
// use atomics so that only one set can win.
//
// To read node.inode atomic.LoadPointer is used, however it is not expensive
// since it translates to regular MOVQ on amd64.
func
(
dn
*
DefaultOperations
)
setInode
(
inode
*
Inode
)
*
Inode
{
return
atomic
.
CompareAndSwapPointer
(
(
*
unsafe
.
Pointer
)(
unsafe
.
Pointer
(
&
dn
.
inode_
)),
nil
,
unsafe
.
Pointer
(
inode
))
}
}
func
(
dn
*
DefaultOperations
)
inode
()
*
Inode
{
func
(
dn
*
DefaultOperations
)
inode
()
*
Inode
{
return
dn
.
inode_
return
(
*
Inode
)(
atomic
.
LoadPointer
(
(
*
unsafe
.
Pointer
)(
unsafe
.
Pointer
(
&
dn
.
inode_
))))
}
}
func
(
n
*
DefaultOperations
)
Lookup
(
ctx
context
.
Context
,
name
string
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Lookup
(
ctx
context
.
Context
,
name
string
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
...
...
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