diff options
author | Urvashi Mohnani <umohnani@redhat.com> | 2019-09-12 13:56:35 -0400 |
---|---|---|
committer | Urvashi Mohnani <umohnani@redhat.com> | 2019-09-12 13:56:35 -0400 |
commit | 8f622761b77de8bb61f3fa0c809a2cb14cfb4025 (patch) | |
tree | ac03c8449752294cce231c4cededb05732ae01c5 | |
parent | 43d6f9d234681479f77b7678466f4aef36089915 (diff) | |
download | podman-8f622761b77de8bb61f3fa0c809a2cb14cfb4025.tar.gz podman-8f622761b77de8bb61f3fa0c809a2cb14cfb4025.tar.bz2 podman-8f622761b77de8bb61f3fa0c809a2cb14cfb4025.zip |
Vendor more deadlock fixes from c/storage
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
-rw-r--r-- | vendor/github.com/containers/storage/layers.go | 51 | ||||
-rw-r--r-- | vendor/github.com/containers/storage/layers_ffjson.go | 2 |
2 files changed, 31 insertions, 22 deletions
diff --git a/vendor/github.com/containers/storage/layers.go b/vendor/github.com/containers/storage/layers.go index cb975e2a0..a60d25688 100644 --- a/vendor/github.com/containers/storage/layers.go +++ b/vendor/github.com/containers/storage/layers.go @@ -353,7 +353,7 @@ func (r *layerStore) Load() error { } if cleanup, ok := layer.Flags[incompleteFlag]; ok { if b, ok := cleanup.(bool); ok && b { - err = r.Delete(layer.ID) + err = r.deleteInternal(layer.ID) if err != nil { break } @@ -935,7 +935,7 @@ func (r *layerStore) tspath(id string) string { return filepath.Join(r.layerdir, id+tarSplitSuffix) } -func (r *layerStore) Delete(id string) error { +func (r *layerStore) deleteInternal(id string) error { if !r.IsReadWrite() { return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to delete layers at %q", r.layerspath()) } @@ -944,23 +944,7 @@ func (r *layerStore) Delete(id string) error { return ErrLayerUnknown } id = layer.ID - // The layer may already have been explicitly unmounted, but if not, we - // should try to clean that up before we start deleting anything at the - // driver level. - mountCount, err := r.Mounted(id) - if err != nil { - return errors.Wrapf(err, "error checking if layer %q is still mounted", id) - } - for mountCount > 0 { - if _, err := r.Unmount(id, false); err != nil { - return err - } - mountCount, err = r.Mounted(id) - if err != nil { - return errors.Wrapf(err, "error checking if layer %q is still mounted", id) - } - } - err = r.driver.Remove(id) + err := r.driver.Remove(id) if err == nil { os.Remove(r.tspath(id)) delete(r.byid, id) @@ -996,11 +980,36 @@ func (r *layerStore) Delete(id string) error { label.ReleaseLabel(mountLabel) } } - if err = r.Save(); err != nil { + } + return err +} + +func (r *layerStore) Delete(id string) error { + layer, ok := r.lookup(id) + if !ok { + return ErrLayerUnknown + } + id = layer.ID + // The layer may already have been explicitly unmounted, but if not, we + // should try to clean that up before we start deleting anything at the + // driver level. + mountCount, err := r.Mounted(id) + if err != nil { + return errors.Wrapf(err, "error checking if layer %q is still mounted", id) + } + for mountCount > 0 { + if _, err := r.Unmount(id, false); err != nil { return err } + mountCount, err = r.Mounted(id) + if err != nil { + return errors.Wrapf(err, "error checking if layer %q is still mounted", id) + } } - return err + if err := r.deleteInternal(id); err != nil { + return err + } + return r.Save() } func (r *layerStore) Lookup(name string) (id string, err error) { diff --git a/vendor/github.com/containers/storage/layers_ffjson.go b/vendor/github.com/containers/storage/layers_ffjson.go index 09b5d0f33..125b5d8c9 100644 --- a/vendor/github.com/containers/storage/layers_ffjson.go +++ b/vendor/github.com/containers/storage/layers_ffjson.go @@ -1,5 +1,5 @@ // Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT. -// source: ./layers.go +// source: layers.go package storage |