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
c4a6d9fd
Commit
c4a6d9fd
authored
Apr 22, 2015
by
Frederick Akalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make handleMap return generation on Register
parent
6944ad89
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
16 deletions
+15
-16
fuse/nodefs/fsconnector.go
fuse/nodefs/fsconnector.go
+6
-6
fuse/nodefs/fsmount.go
fuse/nodefs/fsmount.go
+1
-1
fuse/nodefs/fsops.go
fuse/nodefs/fsops.go
+1
-2
fuse/nodefs/handle.go
fuse/nodefs/handle.go
+3
-3
fuse/nodefs/handle_test.go
fuse/nodefs/handle_test.go
+4
-4
No files found.
fuse/nodefs/fsconnector.go
View file @
c4a6d9fd
...
@@ -100,8 +100,8 @@ func (c *FileSystemConnector) verify() {
...
@@ -100,8 +100,8 @@ func (c *FileSystemConnector) verify() {
func
(
c
*
rawBridge
)
childLookup
(
out
*
fuse
.
EntryOut
,
n
*
Inode
,
context
*
fuse
.
Context
)
{
func
(
c
*
rawBridge
)
childLookup
(
out
*
fuse
.
EntryOut
,
n
*
Inode
,
context
*
fuse
.
Context
)
{
n
.
Node
()
.
GetAttr
((
*
fuse
.
Attr
)(
&
out
.
Attr
),
nil
,
context
)
n
.
Node
()
.
GetAttr
((
*
fuse
.
Attr
)(
&
out
.
Attr
),
nil
,
context
)
n
.
mount
.
fillEntry
(
out
)
n
.
mount
.
fillEntry
(
out
)
out
.
Ino
=
c
.
fsConn
()
.
lookupUpdate
(
n
)
out
.
NodeId
,
out
.
Generation
=
c
.
fsConn
()
.
lookupUpdate
(
n
)
out
.
NodeId
=
out
.
Ino
out
.
Ino
=
out
.
NodeId
if
out
.
Nlink
==
0
{
if
out
.
Nlink
==
0
{
// With Nlink == 0, newer kernels will refuse link
// With Nlink == 0, newer kernels will refuse link
// operations.
// operations.
...
@@ -117,11 +117,11 @@ func (c *rawBridge) toInode(nodeid uint64) *Inode {
...
@@ -117,11 +117,11 @@ func (c *rawBridge) toInode(nodeid uint64) *Inode {
return
i
return
i
}
}
// Must run outside treeLock. Returns the nodeId.
// Must run outside treeLock. Returns the nodeId
and generation
.
func
(
c
*
FileSystemConnector
)
lookupUpdate
(
node
*
Inode
)
(
id
uint64
)
{
func
(
c
*
FileSystemConnector
)
lookupUpdate
(
node
*
Inode
)
(
id
,
generation
uint64
)
{
id
=
c
.
inodeMap
.
Register
(
&
node
.
handled
)
id
,
generation
=
c
.
inodeMap
.
Register
(
&
node
.
handled
)
c
.
verify
()
c
.
verify
()
return
id
return
}
}
// Must run outside treeLock.
// Must run outside treeLock.
...
...
fuse/nodefs/fsmount.go
View file @
c4a6d9fd
...
@@ -135,7 +135,7 @@ func (m *fileSystemMount) registerFileHandle(node *Inode, dir *connectorDir, f F
...
@@ -135,7 +135,7 @@ func (m *fileSystemMount) registerFileHandle(node *Inode, dir *connectorDir, f F
b
.
WithFlags
.
File
.
SetInode
(
node
)
b
.
WithFlags
.
File
.
SetInode
(
node
)
}
}
node
.
openFiles
=
append
(
node
.
openFiles
,
b
)
node
.
openFiles
=
append
(
node
.
openFiles
,
b
)
handle
:=
m
.
openFiles
.
Register
(
&
b
.
handled
)
handle
,
_
:=
m
.
openFiles
.
Register
(
&
b
.
handled
)
node
.
openFilesMutex
.
Unlock
()
node
.
openFilesMutex
.
Unlock
()
return
handle
,
b
return
handle
,
b
}
}
...
...
fuse/nodefs/fsops.go
View file @
c4a6d9fd
...
@@ -98,8 +98,7 @@ func (c *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOu
...
@@ -98,8 +98,7 @@ func (c *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOu
}
}
child
.
mount
.
fillEntry
(
out
)
child
.
mount
.
fillEntry
(
out
)
out
.
NodeId
=
c
.
fsConn
()
.
lookupUpdate
(
child
)
out
.
NodeId
,
out
.
Generation
=
c
.
fsConn
()
.
lookupUpdate
(
child
)
out
.
Generation
=
child
.
generation
out
.
Ino
=
out
.
NodeId
out
.
Ino
=
out
.
NodeId
return
fuse
.
OK
return
fuse
.
OK
...
...
fuse/nodefs/handle.go
View file @
c4a6d9fd
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
//
//
// This structure is thread-safe.
// This structure is thread-safe.
type
handleMap
interface
{
type
handleMap
interface
{
Register
(
obj
*
handled
)
uint64
Register
(
obj
*
handled
)
(
handle
,
generation
uint64
)
Count
()
int
Count
()
int
Decode
(
uint64
)
*
handled
Decode
(
uint64
)
*
handled
Forget
(
handle
uint64
,
count
int
)
(
bool
,
*
handled
)
Forget
(
handle
uint64
,
count
int
)
(
bool
,
*
handled
)
...
@@ -57,7 +57,7 @@ func newPortableHandleMap() *portableHandleMap {
...
@@ -57,7 +57,7 @@ func newPortableHandleMap() *portableHandleMap {
}
}
}
}
func
(
m
*
portableHandleMap
)
Register
(
obj
*
handled
)
(
handle
uint64
)
{
func
(
m
*
portableHandleMap
)
Register
(
obj
*
handled
)
(
handle
,
generation
uint64
)
{
m
.
Lock
()
m
.
Lock
()
if
obj
.
count
==
0
{
if
obj
.
count
==
0
{
if
obj
.
check
!=
0
{
if
obj
.
check
!=
0
{
...
@@ -79,7 +79,7 @@ func (m *portableHandleMap) Register(obj *handled) (handle uint64) {
...
@@ -79,7 +79,7 @@ func (m *portableHandleMap) Register(obj *handled) (handle uint64) {
}
}
obj
.
count
++
obj
.
count
++
m
.
Unlock
()
m
.
Unlock
()
return
handle
return
}
}
func
(
m
*
portableHandleMap
)
Handle
(
obj
*
handled
)
(
h
uint64
)
{
func
(
m
*
portableHandleMap
)
Handle
(
obj
*
handled
)
(
h
uint64
)
{
...
...
fuse/nodefs/handle_test.go
View file @
c4a6d9fd
...
@@ -21,8 +21,8 @@ func TestHandleMapLookupCount(t *testing.T) {
...
@@ -21,8 +21,8 @@ func TestHandleMapLookupCount(t *testing.T) {
t
.
Log
(
"portable:"
,
portable
)
t
.
Log
(
"portable:"
,
portable
)
v
:=
new
(
handled
)
v
:=
new
(
handled
)
hm
:=
newPortableHandleMap
()
hm
:=
newPortableHandleMap
()
h1
:=
hm
.
Register
(
v
)
h1
,
_
:=
hm
.
Register
(
v
)
h2
:=
hm
.
Register
(
v
)
h2
,
_
:=
hm
.
Register
(
v
)
if
h1
!=
h2
{
if
h1
!=
h2
{
t
.
Fatalf
(
"double register should reuse handle: got %d want %d."
,
h2
,
h1
)
t
.
Fatalf
(
"double register should reuse handle: got %d want %d."
,
h2
,
h1
)
...
@@ -61,7 +61,7 @@ func TestHandleMapLookupCount(t *testing.T) {
...
@@ -61,7 +61,7 @@ func TestHandleMapLookupCount(t *testing.T) {
func
TestHandleMapBasic
(
t
*
testing
.
T
)
{
func
TestHandleMapBasic
(
t
*
testing
.
T
)
{
v
:=
new
(
handled
)
v
:=
new
(
handled
)
hm
:=
newPortableHandleMap
()
hm
:=
newPortableHandleMap
()
h
:=
hm
.
Register
(
v
)
h
,
_
:=
hm
.
Register
(
v
)
t
.
Logf
(
"Got handle 0x%x"
,
h
)
t
.
Logf
(
"Got handle 0x%x"
,
h
)
if
!
hm
.
Has
(
h
)
{
if
!
hm
.
Has
(
h
)
{
t
.
Fatal
(
"Does not have handle"
)
t
.
Fatal
(
"Does not have handle"
)
...
@@ -91,7 +91,7 @@ func TestHandleMapMultiple(t *testing.T) {
...
@@ -91,7 +91,7 @@ func TestHandleMapMultiple(t *testing.T) {
hm
:=
newPortableHandleMap
()
hm
:=
newPortableHandleMap
()
for
i
:=
0
;
i
<
10
;
i
++
{
for
i
:=
0
;
i
<
10
;
i
++
{
v
:=
&
handled
{}
v
:=
&
handled
{}
h
:=
hm
.
Register
(
v
)
h
,
_
:=
hm
.
Register
(
v
)
if
hm
.
Decode
(
h
)
!=
v
{
if
hm
.
Decode
(
h
)
!=
v
{
t
.
Fatal
(
"address mismatch"
)
t
.
Fatal
(
"address mismatch"
)
}
}
...
...
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