c8d/mount: Use ref-counted mounter by default
All commonly used filesystems should use ref-counted mounter, so make it the default instead of having to whitelist them. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
4f9c865edd
commit
ae6468b4b9
1 changed files with 9 additions and 29 deletions
|
@ -13,9 +13,6 @@ import (
|
||||||
"github.com/moby/sys/mountinfo"
|
"github.com/moby/sys/mountinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List of known filesystems that can't be re-mounted or have shared layers
|
|
||||||
var refCountedFileSystems = []string{"fuse-overlayfs", "overlayfs", "stargz", "zfs"}
|
|
||||||
|
|
||||||
// Mounter handles mounting/unmounting things coming in from a snapshotter
|
// Mounter handles mounting/unmounting things coming in from a snapshotter
|
||||||
// with optional reference counting if needed by the filesystem
|
// with optional reference counting if needed by the filesystem
|
||||||
type Mounter interface {
|
type Mounter interface {
|
||||||
|
@ -27,36 +24,19 @@ type Mounter interface {
|
||||||
Mounted(containerID string) (string, error)
|
Mounted(containerID string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// inSlice tests whether a string is contained in a slice of strings or not.
|
|
||||||
// Comparison is case sensitive
|
|
||||||
func inSlice(slice []string, s string) bool {
|
|
||||||
for _, ss := range slice {
|
|
||||||
if s == ss {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMounter creates a new mounter for the provided snapshotter
|
// NewMounter creates a new mounter for the provided snapshotter
|
||||||
func NewMounter(home string, snapshotter string, idMap idtools.IdentityMapping) Mounter {
|
func NewMounter(home string, snapshotter string, idMap idtools.IdentityMapping) *refCountMounter {
|
||||||
mnter := mounter{
|
return &refCountMounter{
|
||||||
|
base: mounter{
|
||||||
home: home,
|
home: home,
|
||||||
snapshotter: snapshotter,
|
snapshotter: snapshotter,
|
||||||
idMap: idMap,
|
idMap: idMap,
|
||||||
}
|
},
|
||||||
|
|
||||||
if inSlice(refCountedFileSystems, snapshotter) {
|
|
||||||
return &refCountMounter{
|
|
||||||
base: mnter,
|
|
||||||
rc: graphdriver.NewRefCounter(checker()),
|
rc: graphdriver.NewRefCounter(checker()),
|
||||||
locker: locker.New(),
|
locker: locker.New(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &mnter
|
|
||||||
}
|
|
||||||
|
|
||||||
type refCountMounter struct {
|
type refCountMounter struct {
|
||||||
rc *graphdriver.RefCounter
|
rc *graphdriver.RefCounter
|
||||||
locker *locker.Locker
|
locker *locker.Locker
|
||||||
|
|
Loading…
Reference in a new issue