moby/daemon/graphdriver
Vivek Goyal 8c9e5e5e05 devmapper: Save and restore NextDeviceId in a file
The way thin-pool right now is designed, user space is supposed to keep
track of what device ids have already been used. If user space tries to
create a new thin/snap device and device id has already been used, thin
pool retuns -EEXIST.

Upon receiving -EEXIST, current docker implementation simply tries the
NextDeviceId++ and keeps on doing this till it finds a free device id.

This approach has two issues.

- It is little suboptimal.
- If device id already exists, current kenrel implementation spits out
  a messsage on console.

[17991.140135] device-mapper: thin: Creation of new snapshot 33 of device 3 failed.

Here kenrel is trying to tell user that device id 33 has already been used.
And this shows up for every device id docker tries till it reaches a point
where device ids are not used. So if there are thousands of container and
one is trying to create a new container after fresh docker start, expect
thousands of such warnings to flood console.

This patch saves the NextDeviceId in a file in
/var/lib/docker/devmapper/metadata/deviceset-metadata and reads it back
when docker starts. This way we don't retry lots of device ids which 
have already been used. 

There might be some device ids which are free but we will get back to them
once device numbers wrap around (24bit limit on device ids).

This patch should cut down on number of kernel warnings.

Notice that I am creating a deviceset metadata file which is a global file
for this pool. So down the line if we need to save more data we should be
able to do that.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2014-11-05 09:25:02 -05:00
..
aufs Merge pull request #8813 from jlhawn/aufs_exclude_on_tar_layer 2014-11-04 11:38:12 -05:00
btrfs mount: move the MakePrivate to pkg/mount 2014-10-30 17:04:56 -04:00
devmapper devmapper: Save and restore NextDeviceId in a file 2014-11-05 09:25:02 -05:00
graphtest update go import path and libcontainer 2014-07-24 22:19:50 +00:00
vfs Use archive.CopyWithTar in vfs.Create 2014-10-27 11:38:22 -07:00
driver.go mount: move the MakePrivate to pkg/mount 2014-10-30 17:04:56 -04:00
fsdiff.go Mass gofmt 2014-10-24 15:11:48 -07:00