From bd261166b3c9f1f9db12a4b9e25bd1820b6bdd5f Mon Sep 17 00:00:00 2001 From: Shishir Mahajan Date: Fri, 27 May 2016 14:09:37 -0400 Subject: [PATCH] Fixes Issue # 22992: docker commit failing. 1) docker create / run / start: this would create a snapshot device and mounts it onto the filesystem. So the first time GET operation is called. it will create the rootfs directory and return the path to rootfs 2) Now when I do docker commit. It will call the GET operation second time. This time the refcount will check that the count > 1 (count=2). so the rootfs already exists, it will just return the path to rootfs. Earlier it was just returning the mp: /var/lib/docker/devicemapper/mnt/{ID} and hence the inconsistent paths error. Signed-off-by: Shishir Mahajan Upstream-commit: 09d0720e2fb6e30ee018887399f353f93ac2d421 Component: engine --- components/engine/daemon/graphdriver/devmapper/driver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/daemon/graphdriver/devmapper/driver.go b/components/engine/daemon/graphdriver/devmapper/driver.go index 38fa3ece70..4a8296b66a 100644 --- a/components/engine/daemon/graphdriver/devmapper/driver.go +++ b/components/engine/daemon/graphdriver/devmapper/driver.go @@ -160,8 +160,9 @@ func (d *Driver) Remove(id string) error { // Get mounts a device with given id into the root filesystem func (d *Driver) Get(id, mountLabel string) (string, error) { mp := path.Join(d.home, "mnt", id) + rootFs := path.Join(mp, "rootfs") if count := d.ctr.Increment(mp); count > 1 { - return mp, nil + return rootFs, nil } uid, gid, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps) @@ -186,7 +187,6 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { return "", err } - rootFs := path.Join(mp, "rootfs") if err := idtools.MkdirAllAs(rootFs, 0755, uid, gid); err != nil && !os.IsExist(err) { d.ctr.Decrement(mp) d.DeviceSet.UnmountDevice(id, mp)