Check if the layer is actually mounted.
There are cases where the storage database gets out of whack with whether or not the storage is actually mounted. We need to check before returning the mount point. 1 A user could go in and umount the storage. 2 If the storage was mounted in a different mount namespace and then the mount namespace goes away the counter will never get decremented even though the mount point was removed. 3. If storage runtime is on non tmpfs storage a system reboot could be done that will not clear the mount count. This patch will fix the problem with the layer not being mounted, but we still have a problem in that we can't figure out when to umount the image. Not sure that is a solveable problem. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
d8c256832f
commit
522b6498e5
10
layers.go
10
layers.go
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/containers/storage/pkg/ioutils"
|
||||
"github.com/containers/storage/pkg/mount"
|
||||
"github.com/containers/storage/pkg/stringid"
|
||||
"github.com/containers/storage/pkg/system"
|
||||
"github.com/containers/storage/pkg/tarlog"
|
||||
|
|
@ -776,9 +777,18 @@ func (r *layerStore) Mount(id string, options drivers.MountOpts) (string, error)
|
|||
return "", ErrLayerUnknown
|
||||
}
|
||||
if layer.MountCount > 0 {
|
||||
mounted, err := mount.Mounted(layer.MountPoint)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// If the container is not mounted then we have a condition
|
||||
// where the kernel umounted the mount point. This means
|
||||
// that the mount count never got decremented.
|
||||
if mounted {
|
||||
layer.MountCount++
|
||||
return layer.MountPoint, r.saveMounts()
|
||||
}
|
||||
}
|
||||
if options.MountLabel == "" {
|
||||
options.MountLabel = layer.MountLabel
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue