소스 검색

aufs: use mount.Unmount

1. Use mount.Unmount() which ignores EINVAL ("not mounted") error,
and provides better error diagnostics (so we don't have to explicitly
add target to error messages).

2. Since we're ignoring "not mounted" error, we can call
multiple unmounts without any locking -- but since "auplink flush"
is still involved and can produce an error in logs, let's keep
the check for fs being mounted (it's just a statfs so should be fast).

2. While at it, improve the "can't unmount" error message in Put().

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 4beee98026feabe4f4f0468215b8fd9b56f90d5e)
Kir Kolyshkin 6 년 전
부모
커밋
d1eae89590
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 4 4
      daemon/graphdriver/aufs/aufs.go
  2. 2 2
      daemon/graphdriver/aufs/mount.go

+ 4 - 4
daemon/graphdriver/aufs/aufs.go

@@ -326,11 +326,11 @@ func (a *Driver) Remove(id string) error {
 			break
 			break
 		}
 		}
 
 
-		if err != unix.EBUSY {
-			return errors.Wrapf(err, "aufs: unmount error: %s", mountpoint)
+		if errors.Cause(err) != unix.EBUSY {
+			return errors.Wrap(err, "aufs: unmount error")
 		}
 		}
 		if retries >= 5 {
 		if retries >= 5 {
-			return errors.Wrapf(err, "aufs: unmount error after retries: %s", mountpoint)
+			return errors.Wrap(err, "aufs: unmount error after retries")
 		}
 		}
 		// If unmount returns EBUSY, it could be a transient error. Sleep and retry.
 		// If unmount returns EBUSY, it could be a transient error. Sleep and retry.
 		retries++
 		retries++
@@ -436,7 +436,7 @@ func (a *Driver) Put(id string) error {
 
 
 	err := a.unmount(m)
 	err := a.unmount(m)
 	if err != nil {
 	if err != nil {
-		logger.Debugf("Failed to unmount %s aufs: %v", id, err)
+		logger.WithError(err).WithField("method", "Put()").Warn()
 	}
 	}
 	return err
 	return err
 }
 }

+ 2 - 2
daemon/graphdriver/aufs/mount.go

@@ -5,7 +5,7 @@ package aufs // import "github.com/docker/docker/daemon/graphdriver/aufs"
 import (
 import (
 	"os/exec"
 	"os/exec"
 
 
-	"golang.org/x/sys/unix"
+	"github.com/docker/docker/pkg/mount"
 )
 )
 
 
 // Unmount the target specified.
 // Unmount the target specified.
@@ -13,5 +13,5 @@ func Unmount(target string) error {
 	if err := exec.Command("auplink", target, "flush").Run(); err != nil {
 	if err := exec.Command("auplink", target, "flush").Run(); err != nil {
 		logger.WithError(err).Warnf("Couldn't run auplink before unmount %s", target)
 		logger.WithError(err).Warnf("Couldn't run auplink before unmount %s", target)
 	}
 	}
-	return unix.Unmount(target, 0)
+	return mount.Unmount(target)
 }
 }