Skip to content

Commit

Permalink
Remove mountedLayer Mount and Unmount
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crosby <[email protected]>
  • Loading branch information
crosbymichael committed May 23, 2016
1 parent 36a82c2 commit 8bb4d31
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 39 deletions.
5 changes: 0 additions & 5 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,6 @@ func (daemon *Daemon) restore() error {
defer wg.Done()
rm := c.RestartManager(false)
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 {
logrus.Errorf("Failed to restore with containerd: %q", err)
return
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"
"unsafe"

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

Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/zfs/zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func Init(base string, opt []string, uidMaps, gidMaps []idtools.IDMap) (graphdri
filesystemsCache: filesystemsCache,
uidMaps: uidMaps,
gidMaps: gidMaps,
ctr: graphdriver.NewRefCounter(graphdriver.NewFsChecker(graphdriver.FsMagicZfs)),
ctr: graphdriver.NewRefCounter(graphdriver.NewDefaultChecker()),
}
return graphdriver.NewNaiveDiffDriver(d, uidMaps, gidMaps), nil
}
Expand Down
4 changes: 0 additions & 4 deletions distribution/xfer/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ func (ls *mockLayerStore) GetMountID(string) (string, error) {
return "", errors.New("not implemented")
}

func (ls *mockLayerStore) ReinitRWLayer(layer.RWLayer) error {
return errors.New("not implemented")
}

func (ls *mockLayerStore) Cleanup() error {
return nil
}
Expand Down
1 change: 0 additions & 1 deletion layer/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ type Store interface {
CreateRWLayer(id string, parent ChainID, mountLabel string, initFunc MountInit, storageOpt map[string]string) (RWLayer, error)
GetRWLayer(id string) (RWLayer, error)
GetMountID(id string) (string, error)
ReinitRWLayer(l RWLayer) error
ReleaseRWLayer(RWLayer) ([]Metadata, error)

Cleanup() error
Expand Down
13 changes: 0 additions & 13 deletions layer/layer_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,19 +495,6 @@ func (ls *layerStore) GetMountID(id string) (string, error) {
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) {
ls.mountL.Lock()
defer ls.mountL.Unlock()
Expand Down
5 changes: 1 addition & 4 deletions layer/layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ func getCachedLayer(l Layer) *roLayer {
}

func getMountLayer(l RWLayer) *mountedLayer {
if rl, ok := l.(*referencedRWLayer); ok {
return rl.mountedLayer
}
return l.(*mountedLayer)
return l.(*referencedRWLayer).mountedLayer
}

func createMetadata(layers ...Layer) []Metadata {
Expand Down
12 changes: 2 additions & 10 deletions layer/mounted_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ func (ml *mountedLayer) Parent() Layer {
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) {
return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
}
Expand Down Expand Up @@ -101,11 +93,11 @@ type referencedRWLayer struct {
}

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
// Callers should only call `Unmount` once per call to `Mount`, even on error.
func (rl *referencedRWLayer) Unmount() error {
return rl.mountedLayer.Unmount()
return rl.layerStore.driver.Put(rl.mountedLayer.mountID)
}

0 comments on commit 8bb4d31

Please sign in to comment.