Skip to content

Commit 83ed668

Browse files
committed
pkg/mount.Mount: speedup (remove Mounted check)
This was added in PR moby#6669 (commit f87afda) because it was otherwise impossible to do a re-mount of already mounted file system. It is way better to just remove the Mounted() check altogether. This change might potentially lead to multiple mounts to the same mount point, so I audited all the users (except tests) and it looks like no one is doing that: * volume/local maintains 'mounted' flag for every volume * pkg/chrootarchive already calls Mounted() before Mount() (so it actually parsed /proc/self/mountinfo twice, oops!) * daemon.mountVolumes() is called for docker cp only, and it is called once * daemon/graphdriver/zfs keeps track of 'mounted' status * daemon/graphdriver/devmapper: ditto * daemon.createSecretsDir() is only called once during container start Surely I might have easily missed something so this needs a careful review. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent d5595a5 commit 83ed668

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

pkg/mount/mount.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,19 @@ func Mounted(mountpoint string) (bool, error) {
9797
return len(entries) > 0, nil
9898
}
9999

100-
// Mount will mount filesystem according to the specified configuration, on the
101-
// condition that the target path is *not* already mounted. Options must be
102-
// specified like the mount or fstab unix commands: "opt1=val1,opt2=val2". See
103-
// flags.go for supported option flags.
100+
// Mount will mount filesystem according to the specified configuration.
101+
// Options must be specified like the mount or fstab unix commands:
102+
// "opt1=val1,opt2=val2". See flags.go for supported option flags.
104103
func Mount(device, target, mType, options string) error {
105104
flag, data := parseOptions(options)
106-
if flag&REMOUNT != REMOUNT {
107-
if mounted, err := Mounted(target); err != nil || mounted {
108-
return err
109-
}
110-
}
111105
return mount(device, target, mType, uintptr(flag), data)
112106
}
113107

114-
// ForceMount will mount a filesystem according to the specified configuration,
115-
// *regardless* if the target path is not already mounted. Options must be
116-
// specified like the mount or fstab unix commands: "opt1=val1,opt2=val2". See
117-
// flags.go for supported option flags.
108+
// Mount will mount filesystem according to the specified configuration.
109+
// Options must be specified like the mount or fstab unix commands:
110+
// "opt1=val1,opt2=val2". See flags.go for supported option flags.
111+
//
112+
// Deprecated: use Mount instead.
118113
func ForceMount(device, target, mType, options string) error {
119114
flag, data := parseOptions(options)
120115
return mount(device, target, mType, uintptr(flag), data)

0 commit comments

Comments
 (0)