Browse code

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 <shishir.mahajan@redhat.com>

Shishir Mahajan authored on 2016/05/28 03:09:37
Showing 1 changed files
... ...
@@ -160,8 +160,9 @@ func (d *Driver) Remove(id string) error {
160 160
 // Get mounts a device with given id into the root filesystem
161 161
 func (d *Driver) Get(id, mountLabel string) (string, error) {
162 162
 	mp := path.Join(d.home, "mnt", id)
163
+	rootFs := path.Join(mp, "rootfs")
163 164
 	if count := d.ctr.Increment(mp); count > 1 {
164
-		return mp, nil
165
+		return rootFs, nil
165 166
 	}
166 167
 
167 168
 	uid, gid, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps)
... ...
@@ -186,7 +187,6 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
186 186
 		return "", err
187 187
 	}
188 188
 
189
-	rootFs := path.Join(mp, "rootfs")
190 189
 	if err := idtools.MkdirAllAs(rootFs, 0755, uid, gid); err != nil && !os.IsExist(err) {
191 190
 		d.ctr.Decrement(mp)
192 191
 		d.DeviceSet.UnmountDevice(id, mp)