fsImpl.ForgetInode
parent
9719d57fb6
commit
fef47a3a32
|
@ -116,8 +116,6 @@ type fsImpl struct {
|
||||||
|
|
||||||
// An index of inode by ID, for all IDs we have issued.
|
// An index of inode by ID, for all IDs we have issued.
|
||||||
//
|
//
|
||||||
// INVARIANT: For each v in inodes, v.lookupCount >= 0
|
|
||||||
//
|
|
||||||
// GUARDED_BY(mu)
|
// GUARDED_BY(mu)
|
||||||
inodes map[fuseops.InodeID]*inode
|
inodes map[fuseops.InodeID]*inode
|
||||||
|
|
||||||
|
@ -137,14 +135,14 @@ type inode struct {
|
||||||
attributes fuseops.InodeAttributes
|
attributes fuseops.InodeAttributes
|
||||||
|
|
||||||
// The current lookup count.
|
// The current lookup count.
|
||||||
lookupCount int
|
lookupCount uint64
|
||||||
|
|
||||||
// true if lookupCount has ever been positive.
|
// true if lookupCount has ever been positive.
|
||||||
lookedUp bool
|
lookedUp bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (in *inode) Forgotten() bool {
|
func (in *inode) Forgotten() bool {
|
||||||
return in.lookedUp && in.lookupCount <= 0
|
return in.lookedUp && in.lookupCount == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (in *inode) IncrementLookupCount() {
|
func (in *inode) IncrementLookupCount() {
|
||||||
|
@ -152,19 +150,23 @@ func (in *inode) IncrementLookupCount() {
|
||||||
in.lookedUp = true
|
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
|
// Helpers
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// LOCKS_REQUIRED(fs.mu)
|
// LOCKS_REQUIRED(fs.mu)
|
||||||
func (fs *fsImpl) checkInvariants() {
|
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
|
// INVARIANT: For each k in inodes, k < nextInodeID
|
||||||
for k, _ := range fs.inodes {
|
for k, _ := range fs.inodes {
|
||||||
if !(k < fs.nextInodeID) {
|
if !(k < fs.nextInodeID) {
|
||||||
|
@ -278,6 +280,21 @@ func (fs *fsImpl) GetInodeAttributes(
|
||||||
return
|
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(
|
func (fs *fsImpl) OpenFile(
|
||||||
op *fuseops.OpenFileOp) {
|
op *fuseops.OpenFileOp) {
|
||||||
var err error
|
var err error
|
||||||
|
|
Loading…
Reference in New Issue