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
6e3c2542
Commit
6e3c2542
authored
Apr 21, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Verify invariant for open file count.
parent
442ffd32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+28
-9
No files found.
fuse/pathfilesystem.go
View file @
6e3c2542
...
...
@@ -20,7 +20,6 @@ type mountData struct {
unmountPending
bool
}
func
newMount
(
fs
PathFilesystem
)
*
mountData
{
return
&
mountData
{
fs
:
fs
}
}
...
...
@@ -50,6 +49,16 @@ func (me *inode) totalOpenCount() int {
return
o
}
func
(
me
*
inode
)
totalMountCount
()
int
{
o
:=
0
if
me
.
mount
!=
nil
&&
!
me
.
mount
.
unmountPending
{
o
++
}
for
_
,
v
:=
range
me
.
Children
{
o
+=
v
.
totalMountCount
()
}
return
o
}
const
initDirSize
=
20
...
...
@@ -201,12 +210,25 @@ func (me *PathFileSystemConnector) verify() {
if
!
paranoia
{
return
}
me
.
lock
.
Lock
()
defer
me
.
lock
.
Unlock
()
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
for
k
,
v
:=
range
me
.
inodeMap
{
if
v
.
NodeId
!=
k
{
panic
(
fmt
.
Sprintf
(
"nodeid mismatch %v %v"
,
v
,
k
))
}
}
me
.
inodeMap
[
FUSE_ROOT_ID
]
.
verify
()
root
:=
me
.
inodeMap
[
FUSE_ROOT_ID
]
root
.
verify
()
open
:=
root
.
totalOpenCount
()
openFiles
:=
len
(
me
.
openFiles
)
mounted
:=
root
.
totalMountCount
()
if
open
!=
openFiles
+
mounted
{
panic
(
fmt
.
Sprintf
(
"opencount mismatch %v %v %v"
,
open
,
openFiles
,
mounted
))
}
}
func
(
me
*
PathFileSystemConnector
)
newInode
()
*
inode
{
...
...
@@ -391,9 +413,7 @@ func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFilesystem) S
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
if
node
.
Parent
!=
nil
{
node
.
Parent
.
OpenCount
++
}
node
.
OpenCount
++
return
OK
}
...
...
@@ -416,7 +436,8 @@ func (me *PathFileSystemConnector) Unmount(path string) Status {
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
if
node
.
totalOpenCount
()
>
0
{
// 1 = our own mount.
if
node
.
totalOpenCount
()
>
1
{
log
.
Println
(
"Umount - busy: "
,
mount
)
return
EBUSY
}
...
...
@@ -434,9 +455,7 @@ func (me *PathFileSystemConnector) Unmount(path string) Status {
node
.
mount
=
nil
}
if
node
.
Parent
!=
nil
{
node
.
Parent
.
OpenCount
--
}
node
.
OpenCount
--
return
OK
}
...
...
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