shykes/docker — pull request #66 by alexlarsson (2013-11-22 12:48:45+00:00)
Title: Remove 42-layer limit for aufs backend

We modify the aufs layout such that each image can have
either a "diff" directory containing an AUFS style layer, or a
"rootfs" directory, containing a full filesystem image.

driver.Create() is modified so that it knows if the created layer is
an image or not, and whenever we're creating an image that would
be 41 layers (which will not work for containers due to 2 extra layers
for init and rw) we instead create a completely new rootfs directory.

Whenever we mount an image/container we only go up to (and including)
the nearest rootfs, which means that no matter how deep the hierarchies
are we never get more than 42 aufs layers.

When we manally apply layers we use ApplyLayerDir and tell it to
hardlink regular files, which means that most of the diskspace for
layers are shared even if there are more than 42 layers. This is safe
because we never do in-place modification of files in images during
applyLayer so no changes will reach the lower layers due to the
hardlinks.

All the Differ methods in the aufs driver return ErrDriverNotImplemented
if the layer has a rootfs, which means we fall back to the standard
implementation of these.