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
8edb1e8f
Commit
8edb1e8f
authored
Jun 24, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use HandleMap for remembering inodes.
parent
a3b1fcbf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
29 deletions
+11
-29
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+11
-29
No files found.
fuse/pathfilesystem.go
View file @
8edb1e8f
...
...
@@ -118,6 +118,7 @@ var paranoia = false
// TODO should rename to dentry?
type
inode
struct
{
Handled
Parent
*
inode
Children
map
[
string
]
*
inode
NodeId
uint64
...
...
@@ -305,22 +306,15 @@ type FileSystemConnector struct {
Debug
bool
////////////////
// inodeMapMutex protects inodeMap
inodeMapMutex
sync
.
Mutex
// Invariants: see the verify() method.
inodeMap
map
[
uint64
]
*
inode
inodeMap
*
HandleMap
rootNode
*
inode
}
func
(
me
*
FileSystemConnector
)
Statistics
()
string
{
root
:=
me
.
rootNode
me
.
inodeMapMutex
.
Lock
()
defer
me
.
inodeMapMutex
.
Unlock
()
return
fmt
.
Sprintf
(
"Mounts %20d
\n
Files %20d
\n
Inodes %20d
\n
"
,
root
.
TotalMountCount
(),
root
.
TotalOpenCount
(),
len
(
me
.
inodeMap
))
root
.
TotalOpenCount
(),
me
.
inodeMap
.
Count
(
))
}
func
(
me
*
FileSystemConnector
)
decodeFileHandle
(
h
uint64
)
*
fileBridge
{
...
...
@@ -347,28 +341,18 @@ func (me *FileSystemConnector) verify() {
if
!
paranoia
{
return
}
me
.
inodeMapMutex
.
Lock
()
defer
me
.
inodeMapMutex
.
Unlock
()
for
k
,
v
:=
range
me
.
inodeMap
{
if
v
.
NodeId
!=
k
{
panic
(
fmt
.
Sprintf
(
"nodeid mismatch %v %v"
,
v
,
k
))
}
}
me
.
inodeMap
.
verify
()
root
:=
me
.
rootNode
root
.
verify
(
me
.
rootNode
.
mountPoint
)
}
func
(
me
*
FileSystemConnector
)
newInode
(
root
bool
,
isDir
bool
)
*
inode
{
data
:=
new
(
inode
)
data
.
NodeId
=
me
.
inodeMap
.
Register
(
&
data
.
Handled
)
if
root
{
data
.
NodeId
=
FUSE_ROOT_ID
me
.
rootNode
=
data
}
else
{
data
.
NodeId
=
uint64
(
uintptr
(
unsafe
.
Pointer
(
data
)))
data
.
NodeId
=
FUSE_ROOT_ID
}
me
.
inodeMap
[
data
.
NodeId
]
=
data
if
isDir
{
data
.
Children
=
make
(
map
[
string
]
*
inode
,
initDirSize
)
}
...
...
@@ -397,8 +381,7 @@ func (me *FileSystemConnector) getInodeData(nodeid uint64) *inode {
if
nodeid
==
FUSE_ROOT_ID
{
return
me
.
rootNode
}
return
(
*
inode
)(
unsafe
.
Pointer
(
uintptr
(
nodeid
)))
return
(
*
inode
)(
unsafe
.
Pointer
(
DecodeHandle
(
nodeid
)))
}
func
(
me
*
FileSystemConnector
)
forgetUpdate
(
nodeId
uint64
,
forgetCount
int
)
{
...
...
@@ -419,10 +402,9 @@ func (me *FileSystemConnector) considerDropInode(n *inode) {
n
.
OpenCount
<=
0
if
dropInode
{
n
.
setParent
(
nil
)
me
.
inodeMapMutex
.
Lock
()
defer
me
.
inodeMapMutex
.
Unlock
()
me
.
inodeMap
[
n
.
NodeId
]
=
nil
,
false
if
n
!=
me
.
rootNode
{
me
.
inodeMap
.
Forget
(
n
.
NodeId
)
}
}
}
...
...
@@ -488,7 +470,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *inode {
func
EmptyFileSystemConnector
()
(
out
*
FileSystemConnector
)
{
out
=
new
(
FileSystemConnector
)
out
.
inodeMap
=
make
(
map
[
uint64
]
*
inode
)
out
.
inodeMap
=
NewHandleMap
(
)
rootData
:=
out
.
newInode
(
true
,
true
)
rootData
.
Children
=
make
(
map
[
string
]
*
inode
,
initDirSize
)
...
...
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