Commit Graph

15 Commits

Author SHA1 Message Date
Alexander Larsson 2ffef1b7eb devmapper: Avoid AB-BA deadlock
We currently drop the global lock while holding a per-device lock when
waiting for device removal, and then we re-aquire it when the sleep is done.
This is causing a AB-BA deadlock if anyone at the same time tries to do any
operation on that device like this:

thread A:             thread B
grabs global lock
grabs device lock
releases global lock
sleeps
                      grabs global lock
                      blocks on device lock
wakes up
blocks on global lock

To trigger this you can for instance do:

ID=`docker run -d fedora sleep 5`
cd /var/lib/docker/devicemapper/mnt/$ID
docker wait $ID
docker rm $ID &
docker rm $ID

The unmount will fail due to the mount being busy thus causing the
timeout and the second rm will then trigger the deadlock.

We fix this by adding a lock ordering such that the device locks
are always grabbed before the global lock. This is safe since the
device lookups now have a separate lock.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson 70826e8b3f devmapper: Add lock to protext Devices map
Currently access to the Devices map is serialized by the main
DeviceSet lock, but we need to access it outside that lock, so we
add a separate lock for this and grab that everywhere we modify
or read the map.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson e01b71cebe devmapper: Add lookupDevice() helper
This centralizes the lookup of devices so it is only done in one place.
This will be needed later when we change the locking for it.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson 74edcaf1e8 devmapper: Pass info rather than hash to setInitialized
We already have this at the caller, no need to look up again.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson 5955846774 devmapper: Pass info rather than hash to deactivateDevice()
We already have the info in most cases, no need to look this up multiple times.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson 8e39b35c7c devmapper: Pass info rather than hash to deleteDevice
All the callers already have the info, no need for an extra lookup.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson e5394e35c7 devmapper: Pass info rather than hash to activateDeviceIfNeeded
There is no need to look this up again, we have it already in all callers.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-02 09:05:00 +02:00
Alexander Larsson 66c5e19f9b devmapper: Ensure we shut down thin pool cleanly.
The change in commit a9fa1a13c3
made us only deactivate devices that were mounted. Unfortunately
this made us not deactivate the base device. Which caused
us to not be able to deactivate the pool.

This fixes that by always just deactivating the base device.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-03-28 15:58:14 +01:00
unclejack 303a954151 Merge pull request #4838 from crosbymichael/btrfs-ftw
Promote btrfs
2014-03-27 19:55:25 +02:00
Dan Walsh 4c43566925 This patch adds SELinux labeling support.
docker will run the process(es) within the container with an SELinux label and will label
all of  the content within the container with mount label.  Any temporary file systems
created within the container need to be mounted with the same mount label.

The user can override the process label by specifying

-Z With a string of space separated options.

-Z "user=unconfined_u role=unconfined_r type=unconfined_t level=s0"

Would cause the process label to run with unconfined_u:unconfined_r:unconfined_t:s0"

By default the processes will run execute within the container as svirt_lxc_net_t.
All of the content in the container as svirt_sandbox_file_t.

The process mcs level is based of the PID of the docker process that is creating the container.

If you run the container in --priv mode, the labeling will be disabled.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-03-26 15:30:40 -04:00
Michael Crosby 68dd722e3c Promote btrfs
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-03-24 14:15:04 +00:00
Alexander Larsson a9fa1a13c3 devicemapper: Better/faster shutdown
Right now shutdown is looping over *all* devicemapper
devices and actively deactivating them, this is pretty
slow if you have a lot of non-active containers. We
instead only deactivate the devices that are mounted.

We also do the shutdown unmount using MNT_DETACH which
forces the unmount in the global namespace, even if it
is busy because of some container having it mounted.
This means the device will be freed when that container
exits.

Also, we move the call to waitClose to deactivateDevice
because all callers of any of them call both anyway.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-03-20 17:38:35 +01:00
Alexander Larsson a70beda1ec devmapper: Increase timeout in waitClose to 10sec
As reported in https://github.com/dotcloud/docker/issues/4389 we're
currently seeing timeouts in waitClose on some systems. We already
bumped the timeout in waitRemove() in
https://github.com/dotcloud/docker/issues/4504.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-03-18 15:54:40 +01:00
Michael Crosby 2bddcd68b4 Gofmt imports
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-03-17 11:41:28 -07:00
Michael Crosby 96c4816cef Move graphdrivers into runtime top level pkg
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-03-17 11:40:12 -07:00