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
d415f3e7
Commit
d415f3e7
authored
Apr 22, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use memory addresses as node ids.
Saves a mutex and a map lookup.
parent
990f3c11
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+19
-20
No files found.
fuse/pathfilesystem.go
View file @
d415f3e7
...
...
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"sync"
"unsafe"
)
type
mountData
struct
{
...
...
@@ -158,7 +159,7 @@ type FileSystemConnector struct {
// Invariants: see the verify() method.
inodeMap
map
[
uint64
]
*
inode
nextFreeInode
uint64
rootNode
*
inode
// Open files/directories.
fileLock
sync
.
RWMutex
...
...
@@ -173,7 +174,7 @@ func (me *FileSystemConnector) DebugString() string {
me
.
fileLock
.
RLock
()
defer
me
.
fileLock
.
RUnlock
()
root
:=
me
.
inodeMap
[
FUSE_ROOT_ID
]
root
:=
me
.
rootNode
return
fmt
.
Sprintf
(
"Mounts %20d
\n
Files %20d
\n
Inodes %20d
\n
"
,
root
.
totalMountCount
(),
len
(
me
.
openFiles
),
len
(
me
.
inodeMap
))
...
...
@@ -233,12 +234,12 @@ func (me *FileSystemConnector) verify() {
if
v
.
NodeId
!=
k
{
panic
(
fmt
.
Sprintf
(
"nodeid mismatch %v %v"
,
v
,
k
))
}
if
v
.
Parent
==
nil
&&
v
.
NodeId
!=
FUSE_ROOT_ID
{
if
v
.
Parent
==
nil
&&
v
!=
me
.
rootNode
{
hiddenOpen
+=
v
.
OpenCount
}
}
root
:=
me
.
inodeMap
[
FUSE_ROOT_ID
]
root
:=
me
.
rootNode
root
.
verify
()
open
:=
root
.
totalOpenCount
()
...
...
@@ -249,11 +250,14 @@ func (me *FileSystemConnector) verify() {
}
}
func
(
me
*
FileSystemConnector
)
newInode
()
*
inode
{
func
(
me
*
FileSystemConnector
)
newInode
(
root
bool
)
*
inode
{
data
:=
new
(
inode
)
data
.
NodeId
=
me
.
nextFreeInode
me
.
nextFreeInode
++
if
root
{
data
.
NodeId
=
FUSE_ROOT_ID
me
.
rootNode
=
data
}
else
{
data
.
NodeId
=
uint64
(
uintptr
(
unsafe
.
Pointer
(
data
)))
}
me
.
inodeMap
[
data
.
NodeId
]
=
data
return
data
...
...
@@ -267,7 +271,7 @@ func (me *FileSystemConnector) lookupUpdate(parent *inode, name string, isDir bo
data
,
ok
:=
parent
.
Children
[
name
]
if
!
ok
{
data
=
me
.
newInode
()
data
=
me
.
newInode
(
false
)
data
.
Name
=
name
data
.
setParent
(
parent
)
if
isDir
{
...
...
@@ -279,14 +283,11 @@ func (me *FileSystemConnector) lookupUpdate(parent *inode, name string, isDir bo
}
func
(
me
*
FileSystemConnector
)
getInodeData
(
nodeid
uint64
)
*
inode
{
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
val
:=
me
.
inodeMap
[
nodeid
]
if
val
==
nil
{
panic
(
fmt
.
Sprintf
(
"inode %v unknown"
,
nodeid
))
if
nodeid
==
FUSE_ROOT_ID
{
return
me
.
rootNode
}
return
val
return
(
*
inode
)(
unsafe
.
Pointer
(
uintptr
(
nodeid
)))
}
func
(
me
*
FileSystemConnector
)
forgetUpdate
(
nodeId
uint64
,
forgetCount
int
)
{
...
...
@@ -351,7 +352,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *inode {
me
.
lock
.
RLock
()
defer
me
.
lock
.
RUnlock
()
node
:=
me
.
inodeMap
[
FUSE_ROOT_ID
]
node
:=
me
.
rootNode
for
i
,
component
:=
range
comps
{
if
len
(
component
)
==
0
{
continue
...
...
@@ -374,9 +375,7 @@ func EmptyFileSystemConnector() (out *FileSystemConnector) {
out
.
inodeMap
=
make
(
map
[
uint64
]
*
inode
)
out
.
openFiles
=
make
(
map
[
uint64
]
interface
{})
out
.
nextFreeInode
=
FUSE_ROOT_ID
rootData
:=
out
.
newInode
()
rootData
.
NodeId
=
FUSE_ROOT_ID
rootData
:=
out
.
newInode
(
true
)
rootData
.
Type
=
ModeToType
(
S_IFDIR
)
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