1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove mountedLayer Mount and Unmount

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-05-17 13:20:28 -07:00
parent 36a82c2032
commit 8bb4d31b10
8 changed files with 5 additions and 39 deletions

View file

@ -277,11 +277,6 @@ func (daemon *Daemon) restore() error {
defer wg.Done() defer wg.Done()
rm := c.RestartManager(false) rm := c.RestartManager(false)
if c.IsRunning() || c.IsPaused() { if c.IsRunning() || c.IsPaused() {
// Fix activityCount such that graph mounts can be unmounted later
if err := daemon.layerStore.ReinitRWLayer(c.RWLayer); err != nil {
logrus.Errorf("Failed to ReinitRWLayer for %s due to %s", c.ID, err)
return
}
if err := daemon.containerd.Restore(c.ID, libcontainerd.WithRestartManager(rm)); err != nil { if err := daemon.containerd.Restore(c.ID, libcontainerd.WithRestartManager(rm)); err != nil {
logrus.Errorf("Failed to restore with containerd: %q", err) logrus.Errorf("Failed to restore with containerd: %q", err)
return return

View file

@ -20,6 +20,7 @@ import (
"time" "time"
"unsafe" "unsafe"
"github.com/Microsoft/go-winio"
"github.com/Microsoft/go-winio/archive/tar" "github.com/Microsoft/go-winio/archive/tar"
"github.com/Microsoft/go-winio/backuptar" "github.com/Microsoft/go-winio/backuptar"
"github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim"
@ -31,7 +32,6 @@ import (
"github.com/docker/docker/pkg/longpath" "github.com/docker/docker/pkg/longpath"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
"github.com/docker/docker/vendor/src/github.com/Microsoft/go-winio"
"github.com/vbatts/tar-split/tar/storage" "github.com/vbatts/tar-split/tar/storage"
) )

View file

@ -105,7 +105,7 @@ func Init(base string, opt []string, uidMaps, gidMaps []idtools.IDMap) (graphdri
filesystemsCache: filesystemsCache, filesystemsCache: filesystemsCache,
uidMaps: uidMaps, uidMaps: uidMaps,
gidMaps: gidMaps, gidMaps: gidMaps,
ctr: graphdriver.NewRefCounter(graphdriver.NewFsChecker(graphdriver.FsMagicZfs)), ctr: graphdriver.NewRefCounter(graphdriver.NewDefaultChecker()),
} }
return graphdriver.NewNaiveDiffDriver(d, uidMaps, gidMaps), nil return graphdriver.NewNaiveDiffDriver(d, uidMaps, gidMaps), nil
} }

View file

@ -121,10 +121,6 @@ func (ls *mockLayerStore) GetMountID(string) (string, error) {
return "", errors.New("not implemented") return "", errors.New("not implemented")
} }
func (ls *mockLayerStore) ReinitRWLayer(layer.RWLayer) error {
return errors.New("not implemented")
}
func (ls *mockLayerStore) Cleanup() error { func (ls *mockLayerStore) Cleanup() error {
return nil return nil
} }

View file

@ -174,7 +174,6 @@ type Store interface {
CreateRWLayer(id string, parent ChainID, mountLabel string, initFunc MountInit, storageOpt map[string]string) (RWLayer, error) CreateRWLayer(id string, parent ChainID, mountLabel string, initFunc MountInit, storageOpt map[string]string) (RWLayer, error)
GetRWLayer(id string) (RWLayer, error) GetRWLayer(id string) (RWLayer, error)
GetMountID(id string) (string, error) GetMountID(id string) (string, error)
ReinitRWLayer(l RWLayer) error
ReleaseRWLayer(RWLayer) ([]Metadata, error) ReleaseRWLayer(RWLayer) ([]Metadata, error)
Cleanup() error Cleanup() error

View file

@ -495,19 +495,6 @@ func (ls *layerStore) GetMountID(id string) (string, error) {
return mount.mountID, nil return mount.mountID, nil
} }
// ReinitRWLayer reinitializes a given mount to the layerstore, specifically
// initializing the usage count. It should strictly only be used in the
// daemon's restore path to restore state of live containers.
func (ls *layerStore) ReinitRWLayer(l RWLayer) error {
ls.mountL.Lock()
defer ls.mountL.Unlock()
if _, ok := ls.mounts[l.Name()]; !ok {
return ErrMountDoesNotExist
}
return nil
}
func (ls *layerStore) ReleaseRWLayer(l RWLayer) ([]Metadata, error) { func (ls *layerStore) ReleaseRWLayer(l RWLayer) ([]Metadata, error) {
ls.mountL.Lock() ls.mountL.Lock()
defer ls.mountL.Unlock() defer ls.mountL.Unlock()

View file

@ -174,10 +174,7 @@ func getCachedLayer(l Layer) *roLayer {
} }
func getMountLayer(l RWLayer) *mountedLayer { func getMountLayer(l RWLayer) *mountedLayer {
if rl, ok := l.(*referencedRWLayer); ok { return l.(*referencedRWLayer).mountedLayer
return rl.mountedLayer
}
return l.(*mountedLayer)
} }
func createMetadata(layers ...Layer) []Metadata { func createMetadata(layers ...Layer) []Metadata {

View file

@ -49,14 +49,6 @@ func (ml *mountedLayer) Parent() Layer {
return nil return nil
} }
func (ml *mountedLayer) Mount(mountLabel string) (string, error) {
return ml.layerStore.driver.Get(ml.mountID, mountLabel)
}
func (ml *mountedLayer) Unmount() error {
return ml.layerStore.driver.Put(ml.mountID)
}
func (ml *mountedLayer) Size() (int64, error) { func (ml *mountedLayer) Size() (int64, error) {
return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent()) return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
} }
@ -101,11 +93,11 @@ type referencedRWLayer struct {
} }
func (rl *referencedRWLayer) Mount(mountLabel string) (string, error) { func (rl *referencedRWLayer) Mount(mountLabel string) (string, error) {
return rl.mountedLayer.Mount(mountLabel) return rl.layerStore.driver.Get(rl.mountedLayer.mountID, mountLabel)
} }
// Unmount decrements the activity count and unmounts the underlying layer // Unmount decrements the activity count and unmounts the underlying layer
// Callers should only call `Unmount` once per call to `Mount`, even on error. // Callers should only call `Unmount` once per call to `Mount`, even on error.
func (rl *referencedRWLayer) Unmount() error { func (rl *referencedRWLayer) Unmount() error {
return rl.mountedLayer.Unmount() return rl.layerStore.driver.Put(rl.mountedLayer.mountID)
} }