Commit e9983956 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

fs: detect lookupCount underflow

If this happens, it means our node accounting is messed up.
Abort the process by panicing instead of wrapping around
to UINT_MAX.

Change-Id: Id662ab03877d44a16785bfd164a96173a3b7519f
parent 3a8e4783
......@@ -380,6 +380,8 @@ func (n *Inode) removeRef(nlookup uint64, dropPersistence bool) (forgotten bool,
n.mu.Lock()
if nlookup > 0 && dropPersistence {
log.Panic("only one allowed")
} else if nlookup > n.lookupCount {
log.Panicf("i%d lookupCount underflow: lookupCount=%d, decrement=%d", n.stableAttr.Ino, n.lookupCount, nlookup)
} else if nlookup > 0 {
n.lookupCount -= nlookup
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment