mirror of
https://github.com/containers/podman.git
synced 2025-11-02 23:39:52 +08:00
system df: fix image-size calculations
Fix two bugs in `system df`:
1. The total size was calculated incorrectly as it was creating the sum
of all image sizes but did not consider that a) the same image may
be listed more than once (i.e., for each repo-tag pair), and that
b) images share layers.
The total size is now calculated directly in `libimage` by taking
multi-layer use into account.
2. The reclaimable size was calculated incorrectly. This number
indicates which data we can actually remove which means the total
size minus what containers use (i.e., the "unique" size of the image
in use by containers).
NOTE: The c/storage version is pinned back to the previous commit as it
is buggy. c/common already requires the buggy version, so use a
`replace` to force/pin.
Fixes: #16135
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
11
vendor/github.com/containers/common/libimage/layer_tree.go
generated
vendored
11
vendor/github.com/containers/common/libimage/layer_tree.go
generated
vendored
@ -126,6 +126,17 @@ func (r *Runtime) layerTree() (*layerTree, error) {
|
||||
return &tree, nil
|
||||
}
|
||||
|
||||
// layersOf returns all storage layers of the specified image.
|
||||
func (t *layerTree) layersOf(image *Image) []*storage.Layer {
|
||||
var layers []*storage.Layer
|
||||
node := t.node(image.TopLayer())
|
||||
for node != nil {
|
||||
layers = append(layers, node.layer)
|
||||
node = node.parent
|
||||
}
|
||||
return layers
|
||||
}
|
||||
|
||||
// children returns the child images of parent. Child images are images with
|
||||
// either the same top layer as parent or parent being the true parent layer.
|
||||
// Furthermore, the history of the parent and child images must match with the
|
||||
|
||||
Reference in New Issue
Block a user