mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Image: Deactivate image device when unmounting container
There is no need to keep all the device-mapper devices active, we can just activate them on demand if needed.
This commit is contained in:
parent
d2ba3e2005
commit
a9ec1dbc9b
2 changed files with 30 additions and 1 deletions
|
@ -1181,7 +1181,12 @@ func (container *Container) Mounted() (bool, error) {
|
|||
}
|
||||
|
||||
func (container *Container) Unmount() error {
|
||||
return Unmount(container.RootfsPath())
|
||||
image, err := container.GetImage()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = image.Unmount(container.runtime, container.RootfsPath(), container.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
// ShortID returns a shorthand version of the container's id for convenience.
|
||||
|
|
24
image.go
24
image.go
|
@ -444,6 +444,30 @@ func (image *Image) Mount(runtime *Runtime, root, rw string, id string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (image *Image) Unmount(runtime *Runtime, root string, id string) error {
|
||||
switch runtime.GetMountMethod() {
|
||||
case MountMethodNone:
|
||||
return fmt.Errorf("No supported Unmount implementation")
|
||||
|
||||
case MountMethodAUFS:
|
||||
return Unmount(root)
|
||||
|
||||
case MountMethodDeviceMapper:
|
||||
err := syscall.Unmount(root, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Try to deactivate the device as generally there is no use for it anymore
|
||||
devices, err := runtime.GetDeviceSet()
|
||||
if err != nil {
|
||||
return err;
|
||||
}
|
||||
return devices.DeactivateDevice(id)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (image *Image) Changes(rw string) ([]Change, error) {
|
||||
layers, err := image.layers()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue