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
2882eb9e
Commit
2882eb9e
authored
Mar 26, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a verify() method to PathFileSystemConnector.
Fix a corner cases with RENAME. Fix a inode leak with FORGET.
parent
703cbead
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
fuse/loopback_test.go
fuse/loopback_test.go
+2
-1
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+35
-1
No files found.
fuse/loopback_test.go
View file @
2882eb9e
...
...
@@ -39,7 +39,8 @@ type testCase struct {
// Create and mount filesystem.
func
(
me
*
testCase
)
Setup
(
t
*
testing
.
T
)
{
me
.
tester
=
t
paranoia
=
true
const
name
string
=
"hello.txt"
const
subdir
string
=
"subdir"
...
...
fuse/pathfilesystem.go
View file @
2882eb9e
...
...
@@ -33,6 +33,9 @@ func newMount(fs PathFilesystem) *mountData {
return
&
mountData
{
fs
:
fs
}
}
// Tests should set to true.
var
paranoia
=
false
// TODO should rename to dentry?
type
inodeData
struct
{
Parent
*
inodeData
...
...
@@ -48,6 +51,19 @@ type inodeData struct {
mount
*
mountData
}
func
(
me
*
inodeData
)
verify
(
c
*
PathFileSystemConnector
)
{
if
me
.
Parent
!=
nil
{
k
:=
inodeDataKey
(
me
.
Parent
.
NodeId
,
me
.
Name
)
n
:=
c
.
lookup
(
k
)
if
n
!=
me
{
panic
(
fmt
.
Sprintf
(
"parent/child relation corrupted %v %v %v"
,
k
,
n
,
me
))
}
}
else
{
// may both happen for deleted and root node.
}
}
// Should implement some hash table method instead?
func
inodeDataKey
(
parentInode
uint64
,
name
string
)
string
{
return
string
(
parentInode
)
+
":"
+
name
...
...
@@ -129,6 +145,18 @@ type PathFileSystemConnector struct {
Debug
bool
}
func
(
me
*
PathFileSystemConnector
)
verify
()
{
if
!
paranoia
{
return
}
for
k
,
v
:=
range
me
.
inodePathMapByInode
{
if
v
.
NodeId
!=
k
{
panic
(
fmt
.
Sprintf
(
"Nodeid mismatch"
,
k
,
v
.
NodeId
,
v
))
}
v
.
verify
(
me
)
}
}
// Must be called with lock held.
func
(
me
*
PathFileSystemConnector
)
setParent
(
data
*
inodeData
,
parentId
uint64
)
{
newParent
:=
me
.
inodePathMapByInode
[
parentId
]
...
...
@@ -165,6 +193,8 @@ func (me *PathFileSystemConnector) lookup(key string) *inodeData {
}
func
(
me
*
PathFileSystemConnector
)
lookupUpdate
(
nodeId
uint64
,
name
string
)
*
inodeData
{
defer
me
.
verify
()
key
:=
inodeDataKey
(
nodeId
,
name
)
data
:=
me
.
lookup
(
key
)
if
data
!=
nil
{
...
...
@@ -201,6 +231,7 @@ func (me *PathFileSystemConnector) getInodeData(nodeid uint64) *inodeData {
}
func
(
me
*
PathFileSystemConnector
)
forgetUpdate
(
nodeId
uint64
,
forgetCount
int
)
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
...
...
@@ -214,12 +245,14 @@ func (me *PathFileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int)
}
if
data
.
LookupCount
<=
0
&&
data
.
RefCount
<=
0
&&
(
data
.
mount
==
nil
||
data
.
mount
.
unmountPending
)
{
me
.
inodePathMapByInode
[
nodeId
]
=
nil
,
false
me
.
inodePathMap
[
data
.
Key
()]
=
nil
,
false
}
}
}
func
(
me
*
PathFileSystemConnector
)
renameUpdate
(
oldParent
uint64
,
oldName
string
,
newParent
uint64
,
newName
string
)
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
...
...
@@ -259,11 +292,11 @@ func (me *PathFileSystemConnector) renameUpdate(oldParent uint64, oldName string
me
.
inodePathMap
[
target
.
Key
()]
=
target
}
me
.
inodePathMap
[
data
.
Key
()]
=
data
}
func
(
me
*
PathFileSystemConnector
)
unlinkUpdate
(
nodeid
uint64
,
name
string
)
{
defer
me
.
verify
()
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
...
...
@@ -272,6 +305,7 @@ func (me *PathFileSystemConnector) unlinkUpdate(nodeid uint64, name string) {
if
data
!=
nil
{
me
.
inodePathMap
[
oldKey
]
=
nil
,
false
data
.
Parent
=
nil
me
.
unrefNode
(
data
)
}
}
...
...
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