From ae6468b4b9debaff88c91a3fa02d0a010b7a6322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 18 Jan 2024 14:23:32 +0100 Subject: [PATCH] c8d/mount: Use ref-counted mounter by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- daemon/snapshotter/mount.go | 38 +++++++++---------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/daemon/snapshotter/mount.go b/daemon/snapshotter/mount.go index 23c74baa74..68c727174f 100644 --- a/daemon/snapshotter/mount.go +++ b/daemon/snapshotter/mount.go @@ -13,9 +13,6 @@ import ( "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 // with optional reference counting if needed by the filesystem type Mounter interface { @@ -27,34 +24,17 @@ type Mounter interface { 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 -func NewMounter(home string, snapshotter string, idMap idtools.IdentityMapping) Mounter { - mnter := mounter{ - home: home, - snapshotter: snapshotter, - idMap: idMap, +func NewMounter(home string, snapshotter string, idMap idtools.IdentityMapping) *refCountMounter { + return &refCountMounter{ + base: mounter{ + home: home, + snapshotter: snapshotter, + idMap: idMap, + }, + rc: graphdriver.NewRefCounter(checker()), + locker: locker.New(), } - - if inSlice(refCountedFileSystems, snapshotter) { - return &refCountMounter{ - base: mnter, - rc: graphdriver.NewRefCounter(checker()), - locker: locker.New(), - } - } - - return &mnter } type refCountMounter struct {