瀏覽代碼

Merge pull request #21552 from tonistiigi/aufs-mount-locks

Protect aufs mounts with locks
Michael Crosby 9 年之前
父節點
當前提交
051c5ddadc
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      daemon/graphdriver/aufs/aufs.go

+ 7 - 0
daemon/graphdriver/aufs/aufs.go

@@ -67,6 +67,7 @@ func init() {
 
 // Driver contains information about the filesystem mounted.
 type Driver struct {
+	sync.Mutex
 	root          string
 	uidMaps       []idtools.IDMap
 	gidMaps       []idtools.IDMap
@@ -418,6 +419,9 @@ func (a *Driver) getParentLayerPaths(id string) ([]string, error) {
 }
 
 func (a *Driver) mount(id string, target string, mountLabel string, layers []string) error {
+	a.Lock()
+	defer a.Unlock()
+
 	// If the id is mounted or we get an error return
 	if mounted, err := a.mounted(target); err != nil || mounted {
 		return err
@@ -432,6 +436,9 @@ func (a *Driver) mount(id string, target string, mountLabel string, layers []str
 }
 
 func (a *Driver) unmount(mountPath string) error {
+	a.Lock()
+	defer a.Unlock()
+
 	if mounted, err := a.mounted(mountPath); err != nil || !mounted {
 		return err
 	}