summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Goff <cpuguy83@gmail.com>2017-02-27 11:32:49 -0500
committerVictor Vieux <victorvieux@gmail.com>2017-05-04 13:56:31 -0700
commitc4bd13b65074aaf55662ae3a625fb2206aefede0 (patch)
treebd1e82fa1df6217ef68a981e0c8c820b092d1950
parent90d35abf7b3535c1c319c872900fbd76374e521c (diff)
downloaddocker-c4bd13b65074aaf55662ae3a625fb2206aefede0.tar.gz
Use lazy unmount for local volume driver unmount
This fixes issues where the underlying filesystem may be disconnected and attempting to unmount may cause a hang. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit acbfe6bc56b9357d40a452f6b3901cb2c2d40404) Signed-off-by: Victor Vieux <victorvieux@gmail.com>
-rw-r--r--pkg/mount/flags_freebsd.go1
-rw-r--r--pkg/mount/flags_linux.go2
-rw-r--r--pkg/mount/flags_unsupported.go1
-rw-r--r--pkg/mount/mount.go22
4 files changed, 7 insertions, 19 deletions
diff --git a/pkg/mount/flags_freebsd.go b/pkg/mount/flags_freebsd.go
index f166cb2f77..5f76f331b6 100644
--- a/pkg/mount/flags_freebsd.go
+++ b/pkg/mount/flags_freebsd.go
@@ -45,4 +45,5 @@ const (
RELATIME = 0
REMOUNT = 0
STRICTATIME = 0
+ mntDetach = 0
)
diff --git a/pkg/mount/flags_linux.go b/pkg/mount/flags_linux.go
index dc696dce90..25f466183e 100644
--- a/pkg/mount/flags_linux.go
+++ b/pkg/mount/flags_linux.go
@@ -82,4 +82,6 @@ const (
// it possible for the kernel to default to relatime or noatime but still
// allow userspace to override it.
STRICTATIME = syscall.MS_STRICTATIME
+
+ mntDetach = syscall.MNT_DETACH
)
diff --git a/pkg/mount/flags_unsupported.go b/pkg/mount/flags_unsupported.go
index 5564f7b3cd..9ed741e3ff 100644
--- a/pkg/mount/flags_unsupported.go
+++ b/pkg/mount/flags_unsupported.go
@@ -27,4 +27,5 @@ const (
STRICTATIME = 0
SYNCHRONOUS = 0
RDONLY = 0
+ mntDetach = 0
)
diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go
index bb4cd887f7..a57f3979b5 100644
--- a/pkg/mount/mount.go
+++ b/pkg/mount/mount.go
@@ -1,9 +1,5 @@
package mount
-import (
- "time"
-)
-
// GetMounts retrieves a list of mounts for the current running process.
func GetMounts() ([]*Info, error) {
return parseMountTable()
@@ -49,23 +45,11 @@ func ForceMount(device, target, mType, options string) error {
return mount(device, target, mType, uintptr(flag), data)
}
-// Unmount will unmount the target filesystem, so long as it is mounted.
+// Unmount lazily unmounts a filesystem on supported platforms, otherwise
+// does a normal unmount.
func Unmount(target string) error {
if mounted, err := Mounted(target); err != nil || !mounted {
return err
}
- return ForceUnmount(target)
-}
-
-// ForceUnmount will force an unmount of the target filesystem, regardless if
-// it is mounted or not.
-func ForceUnmount(target string) (err error) {
- // Simple retry logic for unmount
- for i := 0; i < 10; i++ {
- if err = unmount(target, 0); err == nil {
- return nil
- }
- time.Sleep(100 * time.Millisecond)
- }
- return
+ return unmount(target, mntDetach)
}