counter: check for external umounts

if a previously mounted container was unmounted
externally (e.g. through conmon cleanup for Podman containers), the
ref counter will lose track of it and report it as still mounted.

Closes: https://github.com/containers/storage/issues/697

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2020-08-21 11:08:55 +02:00
parent 68196e0a40
commit 051e1e6c4d
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
1 changed files with 4 additions and 0 deletions

View File

@ -51,6 +51,10 @@ func (c *RefCounter) incdec(path string, infoOp func(minfo *minfo)) int {
if c.checker.IsMounted(path) {
m.count++
}
} else if !c.checker.IsMounted(path) {
// if the unmount was performed outside of this process (e.g. conmon cleanup)
//the ref counter would lose track of it. Check if it is still mounted.
m.count = 0
}
infoOp(m)
count := m.count