Browse code

Remove mountedLayer Mount and Unmount

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Michael Crosby authored on 2016/05/18 05:20:28
Showing 8 changed files
... ...
@@ -277,11 +277,6 @@ func (daemon *Daemon) restore() error {
277 277
 			defer wg.Done()
278 278
 			rm := c.RestartManager(false)
279 279
 			if c.IsRunning() || c.IsPaused() {
280
-				// Fix activityCount such that graph mounts can be unmounted later
281
-				if err := daemon.layerStore.ReinitRWLayer(c.RWLayer); err != nil {
282
-					logrus.Errorf("Failed to ReinitRWLayer for %s due to %s", c.ID, err)
283
-					return
284
-				}
285 280
 				if err := daemon.containerd.Restore(c.ID, libcontainerd.WithRestartManager(rm)); err != nil {
286 281
 					logrus.Errorf("Failed to restore with containerd: %q", err)
287 282
 					return
... ...
@@ -20,6 +20,7 @@ import (
20 20
 	"time"
21 21
 	"unsafe"
22 22
 
23
+	"github.com/Microsoft/go-winio"
23 24
 	"github.com/Microsoft/go-winio/archive/tar"
24 25
 	"github.com/Microsoft/go-winio/backuptar"
25 26
 	"github.com/Microsoft/hcsshim"
... ...
@@ -31,7 +32,6 @@ import (
31 31
 	"github.com/docker/docker/pkg/longpath"
32 32
 	"github.com/docker/docker/pkg/reexec"
33 33
 	"github.com/docker/docker/pkg/system"
34
-	"github.com/docker/docker/vendor/src/github.com/Microsoft/go-winio"
35 34
 	"github.com/vbatts/tar-split/tar/storage"
36 35
 )
37 36
 
... ...
@@ -105,7 +105,7 @@ func Init(base string, opt []string, uidMaps, gidMaps []idtools.IDMap) (graphdri
105 105
 		filesystemsCache: filesystemsCache,
106 106
 		uidMaps:          uidMaps,
107 107
 		gidMaps:          gidMaps,
108
-		ctr:              graphdriver.NewRefCounter(graphdriver.NewFsChecker(graphdriver.FsMagicZfs)),
108
+		ctr:              graphdriver.NewRefCounter(graphdriver.NewDefaultChecker()),
109 109
 	}
110 110
 	return graphdriver.NewNaiveDiffDriver(d, uidMaps, gidMaps), nil
111 111
 }
... ...
@@ -121,10 +121,6 @@ func (ls *mockLayerStore) GetMountID(string) (string, error) {
121 121
 	return "", errors.New("not implemented")
122 122
 }
123 123
 
124
-func (ls *mockLayerStore) ReinitRWLayer(layer.RWLayer) error {
125
-	return errors.New("not implemented")
126
-}
127
-
128 124
 func (ls *mockLayerStore) Cleanup() error {
129 125
 	return nil
130 126
 }
... ...
@@ -174,7 +174,6 @@ type Store interface {
174 174
 	CreateRWLayer(id string, parent ChainID, mountLabel string, initFunc MountInit, storageOpt map[string]string) (RWLayer, error)
175 175
 	GetRWLayer(id string) (RWLayer, error)
176 176
 	GetMountID(id string) (string, error)
177
-	ReinitRWLayer(l RWLayer) error
178 177
 	ReleaseRWLayer(RWLayer) ([]Metadata, error)
179 178
 
180 179
 	Cleanup() error
... ...
@@ -495,19 +495,6 @@ func (ls *layerStore) GetMountID(id string) (string, error) {
495 495
 	return mount.mountID, nil
496 496
 }
497 497
 
498
-// ReinitRWLayer reinitializes a given mount to the layerstore, specifically
499
-// initializing the usage count. It should strictly only be used in the
500
-// daemon's restore path to restore state of live containers.
501
-func (ls *layerStore) ReinitRWLayer(l RWLayer) error {
502
-	ls.mountL.Lock()
503
-	defer ls.mountL.Unlock()
504
-
505
-	if _, ok := ls.mounts[l.Name()]; !ok {
506
-		return ErrMountDoesNotExist
507
-	}
508
-	return nil
509
-}
510
-
511 498
 func (ls *layerStore) ReleaseRWLayer(l RWLayer) ([]Metadata, error) {
512 499
 	ls.mountL.Lock()
513 500
 	defer ls.mountL.Unlock()
... ...
@@ -174,10 +174,7 @@ func getCachedLayer(l Layer) *roLayer {
174 174
 }
175 175
 
176 176
 func getMountLayer(l RWLayer) *mountedLayer {
177
-	if rl, ok := l.(*referencedRWLayer); ok {
178
-		return rl.mountedLayer
179
-	}
180
-	return l.(*mountedLayer)
177
+	return l.(*referencedRWLayer).mountedLayer
181 178
 }
182 179
 
183 180
 func createMetadata(layers ...Layer) []Metadata {
... ...
@@ -49,14 +49,6 @@ func (ml *mountedLayer) Parent() Layer {
49 49
 	return nil
50 50
 }
51 51
 
52
-func (ml *mountedLayer) Mount(mountLabel string) (string, error) {
53
-	return ml.layerStore.driver.Get(ml.mountID, mountLabel)
54
-}
55
-
56
-func (ml *mountedLayer) Unmount() error {
57
-	return ml.layerStore.driver.Put(ml.mountID)
58
-}
59
-
60 52
 func (ml *mountedLayer) Size() (int64, error) {
61 53
 	return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
62 54
 }
... ...
@@ -101,11 +93,11 @@ type referencedRWLayer struct {
101 101
 }
102 102
 
103 103
 func (rl *referencedRWLayer) Mount(mountLabel string) (string, error) {
104
-	return rl.mountedLayer.Mount(mountLabel)
104
+	return rl.layerStore.driver.Get(rl.mountedLayer.mountID, mountLabel)
105 105
 }
106 106
 
107 107
 // Unmount decrements the activity count and unmounts the underlying layer
108 108
 // Callers should only call `Unmount` once per call to `Mount`, even on error.
109 109
 func (rl *referencedRWLayer) Unmount() error {
110
-	return rl.mountedLayer.Unmount()
110
+	return rl.layerStore.driver.Put(rl.mountedLayer.mountID)
111 111
 }