Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
Kirill Smelkov
jacobsa-fuse
Commits
fef47a3a
Commit
fef47a3a
authored
Mar 31, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fsImpl.ForgetInode
parent
9719d57f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
11 deletions
+28
-11
samples/forgetfs/forget_fs.go
samples/forgetfs/forget_fs.go
+28
-11
No files found.
samples/forgetfs/forget_fs.go
View file @
fef47a3a
...
...
@@ -116,8 +116,6 @@ type fsImpl struct {
// An index of inode by ID, for all IDs we have issued.
//
// INVARIANT: For each v in inodes, v.lookupCount >= 0
//
// GUARDED_BY(mu)
inodes
map
[
fuseops
.
InodeID
]
*
inode
...
...
@@ -137,14 +135,14 @@ type inode struct {
attributes
fuseops
.
InodeAttributes
// The current lookup count.
lookupCount
int
lookupCount
uint64
// true if lookupCount has ever been positive.
lookedUp
bool
}
func
(
in
*
inode
)
Forgotten
()
bool
{
return
in
.
lookedUp
&&
in
.
lookupCount
<
=
0
return
in
.
lookedUp
&&
in
.
lookupCount
=
=
0
}
func
(
in
*
inode
)
IncrementLookupCount
()
{
...
...
@@ -152,19 +150,23 @@ func (in *inode) IncrementLookupCount() {
in
.
lookedUp
=
true
}
func
(
in
*
inode
)
DecrementLookupCount
(
n
uint64
)
{
if
in
.
lookupCount
<
n
{
panic
(
fmt
.
Sprintf
(
"Overly large decrement: %v, %v"
,
in
.
lookupCount
,
n
))
}
in
.
lookupCount
-=
n
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
fsImpl
)
checkInvariants
()
{
// INVARIANT: For each v in inodes, v.lookupCount >= 0
for
_
,
v
:=
range
fs
.
inodes
{
if
!
(
v
.
lookupCount
>=
0
)
{
panic
(
"Negative lookup count"
)
}
}
// INVARIANT: For each k in inodes, k < nextInodeID
for
k
,
_
:=
range
fs
.
inodes
{
if
!
(
k
<
fs
.
nextInodeID
)
{
...
...
@@ -278,6 +280,21 @@ func (fs *fsImpl) GetInodeAttributes(
return
}
func
(
fs
*
fsImpl
)
ForgetInode
(
op
*
fuseops
.
ForgetInodeOp
)
{
var
err
error
defer
fuseutil
.
RespondToOp
(
op
,
&
err
)
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
// Find the inode and decrement its count.
in
:=
fs
.
findInodeByID
(
op
.
Inode
)
in
.
DecrementLookupCount
(
op
.
N
)
return
}
func
(
fs
*
fsImpl
)
OpenFile
(
op
*
fuseops
.
OpenFileOp
)
{
var
err
error
...
...
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