Skip to content

Commit

Permalink
Remove the primaryImageStore parameter of imageTopLayerForMapping
Browse files Browse the repository at this point in the history
Just access s.imageStore directly.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Dec 5, 2022
1 parent 365d848 commit bf13cef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,10 +1332,10 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, o
// imageTopLayerForMapping does ???
// On entry:
// - ristore must be locked EITHER for reading or writing
// - primaryImageStore must be locked for writing; it might be identical to ristore.
// - s.imageStore must be locked for writing; it might be identical to ristore.
// - rlstore must be locked for writing
// - lstores must all be locked for reading
func (s *store) imageTopLayerForMapping(image *Image, ristore roImageStore, primaryImageStore rwImageStore, rlstore rwLayerStore, lstores []roLayerStore, options types.IDMappingOptions) (*Layer, error) {
func (s *store) imageTopLayerForMapping(image *Image, ristore roImageStore, rlstore rwLayerStore, lstores []roLayerStore, options types.IDMappingOptions) (*Layer, error) {
layerMatchesMappingOptions := func(layer *Layer, options types.IDMappingOptions) bool {
// If the driver supports shifting and the layer has no mappings, we can use it.
if canUseShifting(rlstore, options.UIDMap, options.GIDMap) && len(layer.UIDMap) == 0 && len(layer.GIDMap) == 0 {
Expand All @@ -1354,7 +1354,7 @@ func (s *store) imageTopLayerForMapping(image *Image, ristore roImageStore, prim
var layer, parentLayer *Layer
allStores := append([]roLayerStore{rlstore}, lstores...)
// Locate the image's top layer and its parent, if it has one.
createMappedLayer := ristore == primaryImageStore
createMappedLayer := ristore == s.imageStore
for _, s := range allStores {
store := s
// Walk the top layer list.
Expand Down Expand Up @@ -1429,8 +1429,8 @@ func (s *store) imageTopLayerForMapping(image *Image, ristore roImageStore, prim
if err != nil {
return nil, fmt.Errorf("creating an ID-mapped copy of layer %q: %w", layer.ID, err)
}
// By construction, createMappedLayer can only be true if ristore == primaryImageStore.
if err = primaryImageStore.addMappedTopLayer(image.ID, mappedLayer.ID); err != nil {
// By construction, createMappedLayer can only be true if ristore == s.imageStore.
if err = s.imageStore.addMappedTopLayer(image.ID, mappedLayer.ID); err != nil {
if err2 := rlstore.Delete(mappedLayer.ID); err2 != nil {
err = fmt.Errorf("deleting layer %q: %v: %w", mappedLayer.ID, err2, err)
}
Expand Down Expand Up @@ -1523,7 +1523,7 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
idMappingsOptions := options.IDMappingOptions
if image != "" {
if cimage.TopLayer != "" {
ilayer, err := s.imageTopLayerForMapping(cimage, imageHomeStore, s.imageStore, rlstore, lstores, idMappingsOptions)
ilayer, err := s.imageTopLayerForMapping(cimage, imageHomeStore, rlstore, lstores, idMappingsOptions)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit bf13cef

Please sign in to comment.