loadMounts(): reset counts before merging just-loaded data
Before applying mount counts that we've just loaded, reset all of the counts. If a layer that we thought was mounted was unmounted by another process, there won't be a record of it in the mounts list any more, so we wouldn't reset the mount count on our record for that layer. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
16d181a2f7
commit
8400888c44
13
layers.go
13
layers.go
|
|
@ -387,6 +387,19 @@ func (r *layerStore) loadMounts() error {
|
|||
}
|
||||
layerMounts := []layerMountPoint{}
|
||||
if err = json.Unmarshal(data, &layerMounts); len(data) == 0 || err == nil {
|
||||
// Clear all of our mount information. If another process
|
||||
// unmounted something, it (along with its zero count) won't
|
||||
// have been encoded into the version of mountpoints.json that
|
||||
// we're loading, so our count could fall out of sync with it
|
||||
// if we don't, and if we subsequently change something else,
|
||||
// we'd pass that error along to other process that reloaded
|
||||
// the data after we saved it.
|
||||
for _, layer := range r.layers {
|
||||
layer.MountPoint = ""
|
||||
layer.MountCount = 0
|
||||
}
|
||||
// All of the non-zero count values will have been encoded, so
|
||||
// we reset the still-mounted ones based on the contents.
|
||||
for _, mount := range layerMounts {
|
||||
if mount.MountPoint != "" {
|
||||
if layer, ok := r.lookup(mount.ID); ok {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
|
||||
// source: layers.go
|
||||
// source: layers.go
|
||||
|
||||
package storage
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue