mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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>
This commit is contained in:
parent
d90fb13de7
commit
acbfe6bc56
4 changed files with 7 additions and 19 deletions
|
@ -45,4 +45,5 @@ const (
|
||||||
RELATIME = 0
|
RELATIME = 0
|
||||||
REMOUNT = 0
|
REMOUNT = 0
|
||||||
STRICTATIME = 0
|
STRICTATIME = 0
|
||||||
|
mntDetach = 0
|
||||||
)
|
)
|
||||||
|
|
|
@ -82,4 +82,6 @@ const (
|
||||||
// it possible for the kernel to default to relatime or noatime but still
|
// it possible for the kernel to default to relatime or noatime but still
|
||||||
// allow userspace to override it.
|
// allow userspace to override it.
|
||||||
STRICTATIME = syscall.MS_STRICTATIME
|
STRICTATIME = syscall.MS_STRICTATIME
|
||||||
|
|
||||||
|
mntDetach = syscall.MNT_DETACH
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,4 +27,5 @@ const (
|
||||||
STRICTATIME = 0
|
STRICTATIME = 0
|
||||||
SYNCHRONOUS = 0
|
SYNCHRONOUS = 0
|
||||||
RDONLY = 0
|
RDONLY = 0
|
||||||
|
mntDetach = 0
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package mount
|
package mount
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetMounts retrieves a list of mounts for the current running process.
|
// GetMounts retrieves a list of mounts for the current running process.
|
||||||
func GetMounts() ([]*Info, error) {
|
func GetMounts() ([]*Info, error) {
|
||||||
return parseMountTable()
|
return parseMountTable()
|
||||||
|
@ -49,23 +45,11 @@ func ForceMount(device, target, mType, options string) error {
|
||||||
return mount(device, target, mType, uintptr(flag), data)
|
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 {
|
func Unmount(target string) error {
|
||||||
if mounted, err := Mounted(target); err != nil || !mounted {
|
if mounted, err := Mounted(target); err != nil || !mounted {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return ForceUnmount(target)
|
return unmount(target, mntDetach)
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue