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
f5ebef94
Commit
f5ebef94
authored
Jan 14, 2016
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of closures in pathfs locking.
parent
9c3a422a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
18 deletions
+11
-18
fuse/pathfs/pathfs.go
fuse/pathfs/pathfs.go
+11
-18
No files found.
fuse/pathfs/pathfs.go
View file @
f5ebef94
...
@@ -25,8 +25,7 @@ type clientInodePath struct {
...
@@ -25,8 +25,7 @@ type clientInodePath struct {
//
//
// Lookups (ie. FileSystem.GetAttr) may return a inode number in its
// Lookups (ie. FileSystem.GetAttr) may return a inode number in its
// return value. The inode number ("clientInode") is used to indicate
// return value. The inode number ("clientInode") is used to indicate
// linked files. The clientInode is never exported back to the kernel;
// linked files.
// it is only used to maintain a list of all names of an inode.
type
PathNodeFs
struct
{
type
PathNodeFs
struct
{
debug
bool
debug
bool
fs
FileSystem
fs
FileSystem
...
@@ -264,16 +263,6 @@ func (n *pathInode) updateClientInodes() {
...
@@ -264,16 +263,6 @@ func (n *pathInode) updateClientInodes() {
}
}
}
}
func
(
n
*
pathInode
)
LockTree
()
func
()
{
n
.
pathFs
.
pathLock
.
Lock
()
return
func
()
{
n
.
pathFs
.
pathLock
.
Unlock
()
}
}
func
(
n
*
pathInode
)
RLockTree
()
func
()
{
n
.
pathFs
.
pathLock
.
RLock
()
return
func
()
{
n
.
pathFs
.
pathLock
.
RUnlock
()
}
}
// GetPath returns the path relative to the mount governing this
// GetPath returns the path relative to the mount governing this
// inode. It returns nil for mount if the file was deleted or the
// inode. It returns nil for mount if the file was deleted or the
// filesystem unmounted.
// filesystem unmounted.
...
@@ -326,7 +315,8 @@ func (n *pathInode) addChild(name string, child *pathInode) {
...
@@ -326,7 +315,8 @@ func (n *pathInode) addChild(name string, child *pathInode) {
child
.
Name
=
name
child
.
Name
=
name
if
child
.
clientInode
>
0
&&
n
.
pathFs
.
options
.
ClientInodes
{
if
child
.
clientInode
>
0
&&
n
.
pathFs
.
options
.
ClientInodes
{
defer
n
.
LockTree
()()
n
.
pathFs
.
pathLock
.
Lock
()
defer
n
.
pathFs
.
pathLock
.
Unlock
()
m
:=
n
.
pathFs
.
clientInodeMap
[
child
.
clientInode
]
m
:=
n
.
pathFs
.
clientInodeMap
[
child
.
clientInode
]
e
:=
&
clientInodePath
{
e
:=
&
clientInodePath
{
n
,
name
,
child
,
n
,
name
,
child
,
...
@@ -344,7 +334,8 @@ func (n *pathInode) rmChild(name string) *pathInode {
...
@@ -344,7 +334,8 @@ func (n *pathInode) rmChild(name string) *pathInode {
ch
:=
childInode
.
Node
()
.
(
*
pathInode
)
ch
:=
childInode
.
Node
()
.
(
*
pathInode
)
if
ch
.
clientInode
>
0
&&
n
.
pathFs
.
options
.
ClientInodes
{
if
ch
.
clientInode
>
0
&&
n
.
pathFs
.
options
.
ClientInodes
{
defer
n
.
LockTree
()()
n
.
pathFs
.
pathLock
.
Lock
()
defer
n
.
pathFs
.
pathLock
.
Unlock
()
m
:=
n
.
pathFs
.
clientInodeMap
[
ch
.
clientInode
]
m
:=
n
.
pathFs
.
clientInodeMap
[
ch
.
clientInode
]
idx
:=
-
1
idx
:=
-
1
...
@@ -379,7 +370,8 @@ func (n *pathInode) setClientInode(ino uint64) {
...
@@ -379,7 +370,8 @@ func (n *pathInode) setClientInode(ino uint64) {
if
ino
==
n
.
clientInode
||
!
n
.
pathFs
.
options
.
ClientInodes
{
if
ino
==
n
.
clientInode
||
!
n
.
pathFs
.
options
.
ClientInodes
{
return
return
}
}
defer
n
.
LockTree
()()
n
.
pathFs
.
pathLock
.
Lock
()
defer
n
.
pathFs
.
pathLock
.
Unlock
()
if
n
.
clientInode
!=
0
{
if
n
.
clientInode
!=
0
{
delete
(
n
.
pathFs
.
clientInodeMap
,
n
.
clientInode
)
delete
(
n
.
pathFs
.
clientInodeMap
,
n
.
clientInode
)
}
}
...
@@ -397,8 +389,9 @@ func (n *pathInode) OnForget() {
...
@@ -397,8 +389,9 @@ func (n *pathInode) OnForget() {
if
n
.
clientInode
==
0
||
!
n
.
pathFs
.
options
.
ClientInodes
{
if
n
.
clientInode
==
0
||
!
n
.
pathFs
.
options
.
ClientInodes
{
return
return
}
}
defer
n
.
LockTree
()
()
n
.
pathFs
.
pathLock
.
Lock
()
delete
(
n
.
pathFs
.
clientInodeMap
,
n
.
clientInode
)
delete
(
n
.
pathFs
.
clientInodeMap
,
n
.
clientInode
)
n
.
pathFs
.
pathLock
.
Unlock
()
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
@@ -587,7 +580,7 @@ func (n *pathInode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (
...
@@ -587,7 +580,7 @@ func (n *pathInode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (
func
(
n
*
pathInode
)
findChild
(
fi
*
fuse
.
Attr
,
name
string
,
fullPath
string
)
(
out
*
pathInode
)
{
func
(
n
*
pathInode
)
findChild
(
fi
*
fuse
.
Attr
,
name
string
,
fullPath
string
)
(
out
*
pathInode
)
{
if
fi
.
Ino
>
0
{
if
fi
.
Ino
>
0
{
unlock
:=
n
.
RLockTree
()
n
.
pathFs
.
pathLock
.
RLock
()
v
:=
n
.
pathFs
.
clientInodeMap
[
fi
.
Ino
]
v
:=
n
.
pathFs
.
clientInodeMap
[
fi
.
Ino
]
if
len
(
v
)
>
0
{
if
len
(
v
)
>
0
{
out
=
v
[
0
]
.
node
out
=
v
[
0
]
.
node
...
@@ -596,7 +589,7 @@ func (n *pathInode) findChild(fi *fuse.Attr, name string, fullPath string) (out
...
@@ -596,7 +589,7 @@ func (n *pathInode) findChild(fi *fuse.Attr, name string, fullPath string) (out
log
.
Println
(
"Found linked inode, but Nlink == 1"
,
fullPath
)
log
.
Println
(
"Found linked inode, but Nlink == 1"
,
fullPath
)
}
}
}
}
u
nlock
()
n
.
pathFs
.
pathLock
.
RU
nlock
()
}
}
if
out
==
nil
{
if
out
==
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