1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
Commit graph

228 commits

Author SHA1 Message Date
Sebastiaan van Stijn
661d75f398 Merge pull request from shishir-a412ed/rootfs_size_configurable
daemon option (--storage-opt dm.basesize) for increasing the base device size on daemon restart
2016-01-13 13:22:08 -08:00
Shishir Mahajan
e47112d3e8 daemon option (--storage-opt dm.basesize) for increasing the base device size on daemon restart
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
2016-01-13 13:57:31 -05:00
Vivek Goyal
2dccb562df Mark device ID free only if device actually got deleted
Right now if somebody has enabled deferred device deletion, then
deleteTransaction() returns success even if device could not be deleted. It
has been marked for deferred deletion. Right now we will mark device ID free
and potentially use it again when somebody tries to create new container. And
that's wrong. Device ID is not free yet. It will become free once devices
has actually been deleted by the goroutine later.

So move the location of call to markDeviceIDFree() to a place where we know
device actually got deleted and was not marked for deferred deletion.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2016-01-11 18:57:37 +00:00
Vincent Batts
af59752712 loopback: separate loop logic from devicemapper
The loopback logic is not technically exclusive to the devicemapper
driver. This reorganizes the code such that the loopback code is usable
outside of the devicemapper package and driver.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2015-12-18 10:57:43 -05:00
David Calavera
4fef42ba20 Replace pkg/units with docker/go-units.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-16 12:26:49 -05:00
Antonio Murdaca
f22ee02c6d devmapper: store base device fs type
After the very first init of the graph `docker info` correctly shows the
base fs type under `Backing Filesystem`. This information isn't stored
anywhere. After a restart (w/o erasing `/var/lib/docker`) `docker info`
shows an empty string under `Backing Filesystem`.
This patch records the base fs type after the first run in the metadata
or, to fix old devices that don't have this info in the metadata, just
probe the fs type of the base device at graph startup.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2015-12-15 09:33:19 +01:00
Chris Dituri
0aa6ace6e6 Make daemon/graphdriver/devmapper log messages with a common, consistent prefix.
Closes 

Uses the prefix "devmapper:" for all the fmt and logrus error, debug, and info messages.

Signed-off-by: Chris Dituri <csdituri@gmail.com>
2015-12-14 21:35:13 -06:00
Justas Brazauskas
927b334ebf Fix typos found across repository
Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
2015-12-13 18:04:12 +02:00
Christopher Jones
7c077c2c34 Fixed typo change deivce to device.
This changes deivce to device in daemon, test and docs.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2015-12-10 15:23:05 -06:00
Antonio Murdaca
037cbcec98 devmapper: remove unused var
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2015-12-10 08:28:02 +01:00
Liu Hua
f7bdb97357 Fix Put without Get in devicemapper
Signed-off-by: Liu Hua <sdu.liu@huawei.com>
2015-12-03 22:22:25 +08:00
Vivek Goyal
a489e685c0 devmapper: Log start and end of filesystem creation
ext4 filesystem creation can take a long time on 100G thin device and
systemd might time out and kill docker service. Often user is left thinking
why docker is taking so long and logs don't give any hint. Log an info
message in journal for start and end of filesystem creation. That way
a user can look at logs and figure out that filesystem creation is
taking long time.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-12-01 13:05:46 +00:00
Michael Crosby
1ecb9a40db Merge pull request from anusha-ragunathan/fsMagic
Fix devmapper backend in docker info
2015-11-17 11:44:48 -08:00
Alexander Morozov
4dda67b801 Merge pull request from rhatdan/btrfs-selinux
Relabel BTRFS Content on container Creation
2015-11-17 11:03:40 -08:00
Sebastiaan van Stijn
cf824d9749 Merge pull request from coolljt0725/show_warning
Show warning when user specify dm.basesize for already initialized devicemapper driver
2015-11-15 08:51:33 +01:00
Anusha Ragunathan
fdc2641c2b Fix devmapper backend in docker info
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2015-11-13 21:05:47 -08:00
Dan Walsh
1716d497a4 Relabel BTRFS Content on container Creation
This change will allow us to run SELinux in a container with
BTRFS back end.  We continue to work on fixing the kernel/BTRFS
but this change will allow SELinux Security separation on BTRFS.

It basically relabels the content on container creation.

Just relabling -init directory in BTRFS use case. Everything looks like it
works. I don't believe tar/achive stores the SELinux labels, so we are good
as far as docker commit.

Tested Speed on startup with BTRFS on top of loopback directory. BTRFS
not on loopback should get even better perfomance on startup time.  The
more inodes inside of the container image will increase the relabel time.

This patch will give people who care more about security the option of
runnin BTRFS with SELinux.  Those who don't want to take the slow down
can disable SELinux either in individual containers or for all containers
by continuing to disable SELinux in the daemon.

Without relabel:

> time docker run --security-opt label:disable fedora echo test
test

real    0m0.918s
user    0m0.009s
sys    0m0.026s

With Relabel

test

real    0m1.942s
user    0m0.007s
sys    0m0.030s

Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2015-11-11 14:49:27 -05:00
Vivek Goyal
07ff17fb85 devmapper: Switch to xfs as default filesystem if supported
If platform supports xfs filesystem then use xfs as default filesystem 
for container rootfs instead of ext4. Reason being that ext4 is pre-allcating
lot of metadata (around 1.8GB on 100G thin volume) and that can take long
enough on AWS storage that systemd times out and docker fails to start.

If one disables pre-allocation of ext4 metadata, then it will be allocated
when containers are mounted and we will have multiple copies of metadata
per container. For a 100G thin device, it was around 1.5GB of metadata
per container.

ext4 has an optimization to skip zeroing if discards are issued and
underlying device guarantees that zero will be returned when discarded
blocks are read back. devicemapper thin devices don't offer that guarantee
so ext4 optimization does not kick in. In fact given discards are optional
and can be dropped on the floor if need be, it looks like it might not be
possible to guarantee that all the blocks got discarded and if read back
zero will be returned.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-11-11 12:07:35 -05:00
Vivek Goyal
83a34e000b devmapper: Warn if user specified a filesytem and base device already has fs
If user wants to use a filesystem it can be specified using dm.fs=<filesystem>
option. It is possible that docker already had base image and a filesystem
on that. Later if user wants to change file system using dm.fs= option
and restarts docker, that's not possible. Warn user about it.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-11-11 12:07:35 -05:00
Lei Jitang
e035d27223 Show warning when user specify dm.basesize for already initialized devicemapper drive
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-11-10 14:50:19 +08:00
Vivek Goyal
2c8b7c597a devmapper: Provide more error information if blkid fails
Right now if blkid fails we are just logging a debug message and don;t return
the actual error to caller. Caller gets the error message that thin pool
base device UUID verification failed and it might give impression that thin
pool changed. But that's not the case. Thin pool is in such a state that we
could not even query the thin device UUID. Retrun error message appropriately
to make situation more clear.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-11-06 08:21:20 -05:00
David Calavera
3b5fac462d Remove LXC support.
The LXC driver was deprecated in Docker 1.8.
Following the deprecation rules, we can remove a deprecated feature
after two major releases. LXC won't be supported anymore starting on Docker 1.10.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-11-05 17:09:57 -05:00
Vivek Goyal
2f16895ee9 devmapper: Drop devices lock before returning from function
cleanupDeleted() takes devices.Lock() but does not drop it if there are
no deleted devices. Hence docker deadlocks if one is using deferred
device deletion feature. (--storage-opt dm.use_deferred_deletion=true).

Fix it. Drop the lock before returning.

Also added a unit test case to make sure in future this can be easily
detected if somebody changes the function.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-19 17:51:17 -04:00
Vincent Demeester
5ecbc9747f Merge pull request from coolljt0725/add_docker_info_show_base_size
Add docker info show base filesystem size of container/image when use devicemapper
2015-10-13 14:43:52 +02:00
Lei Jitang
5c374c7137 Add docker info show base filesystem size of container/image when use devicemapper
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-10-10 22:52:05 +08:00
Phil Estes
442b45628e Add user namespace (mapping) support to the Docker engine
Adds support for the daemon to handle user namespace maps as a
per-daemon setting.

Support for handling uid/gid mapping is added to the builder,
archive/unarchive packages and functions, all graphdrivers (except
Windows), and the test suite is updated to handle user namespace daemon
rootgraph changes.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-10-09 17:47:37 -04:00
Michael Crosby
6d9a84bcd0 Merge pull request from chlunde/devmapper-mount-flags
Use pkg/mount to support more flags in dm.mountopt
2015-10-08 16:02:50 -07:00
Vivek Goyal
6d2d0a74e8 devmapper: Make sure device is a thin pool device
Right now we check for the existence of device but don't make sure it is
a thin pool device. We assume it is a thin pool device and call poolStatus()
on the device which returns an error EOF. And that error does not tell
anything.

So before we reach the stage of calling poolStatus() make sure we are working
with a thin pool device otherwise error out.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-07 16:28:49 -04:00
Vivek Goyal
87de04005d devmapper: Implement a goroutine to cleanup deleted devices
Start a goroutine which runs every 30 seconds and if there are deferred
deleted devices, it tries to clean those up.

Also it moves the call to cleanupDeletedDevices() into goroutine and
moves the locking completely inside the function. Now function does not
assume that device lock is held at the time of entry.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 17:37:21 -04:00
Vivek Goyal
d295dc6652 devmapper: Keep track of number of deleted devices
Keep track of number of deleted devices and export this information through
"docker info".

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 17:37:21 -04:00
Vivek Goyal
d929589c1f devmapper: Implement deferred deletion functionality
Finally here is the patch to implement deferred deletion functionality.
Deferred deleted devices are marked as "Deleted" in device meta file. 

First we try to delete the device and only if deletion fails and user has
enabled deferred deletion, device is marked for deferred deletion.

When docker starts up again, we go through list of deleted devices and
try to delete these again.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 17:37:21 -04:00
Vivek Goyal
51e059e7e9 devmapper: Provide option to enabled deferred device deletion
Provide a command line option dm.use_deferred_deletion to enable deferred
device deletion feature. By default feature will be turned off.

Not sure if there is much value in deferred deletion being turned on
without deferred removal being turned on. So for now, this feature can
be enabled only if deferred removal is on.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 17:37:21 -04:00
Vivek Goyal
6b8b4feaa1 devmapper: construct used device ID map from device Hash map
Currently during startup we walk through all the device files and read
their device ID and mark in a bitmap that device id is used.

We are anyway going through all device files. So we can as well load all
that data into device hash map. This will save us little time when
container is actually launched later.

Also this will help with later patches where cleanup deferred device
wants to go through all the devices and see which have been marked for
deletion and delete these.

So re-organize the code a bit.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 17:37:21 -04:00
Vivek Goyal
0fcd485626 devmapper: Move UUID setup and verification code in a function
Simplify setupBaseImage() even further. Move some more code in a separate
function. Pure code reorganization. No functionality change.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 08:38:03 -04:00
Vivek Goyal
69051ec0a5 devmapper: Move thin pool related checks in a function
Move thin pool related checks in a separate function. Pure code reorganization.
Makes reading code easier.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 08:38:03 -04:00
Vivek Goyal
efc1ddd7e3 devmapper: Move base device creation in separate function
This moves base device creation function in a separate function. Pure
code reorganization. Makes reading code little easier.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-06 08:38:03 -04:00
Vivek Goyal
482eca3099 devmapper: Few code cleanups
This patch does three things. Following are the descriptions.

===
Create a separate function for delete transactions so that parent function
is little smaller.

Also close transaction if an error happens.
===
When docker is being shutdown, save deviceset metadata first before
trying to remove the devices. Generally caller gives only 10 seconds
for shutdown to complete and then kills it after that. So if some device
is busy, we will wait 20 seconds for it removal and never be able to save
metadata. So first save metadata and then deal with device removal.
===
Move issue discard operation in a separate function. This makes reading code
little easier.

Also don't issue discards if device is still open. That means devices is
still probably being used and issuing discards is not a good idea.

This is especially true in case of deferred deletion. We want to issue
discards when device is not open. At that time device can be deleted too.
Otherwise we will issue discards and deletion will actually fail. Later
we will try deletion again and issue discards again and deletion will
fail again as device is open and busy.

So this will ensure that discards are issued once when device is not open
and it can actually be deleted.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-05 09:02:31 -04:00
Vivek Goyal
289145ecc6 devmapper: Get rid of metaData.devicesLock
Right now we seem to have 3 locks. 

- devinfo.lock
  This is a per device lock

- metaData.devicesLock

  This is supposedely protecting map of devices.

- Global DeviceSet lock

  This is protecting map of devices as well as serializing calls to libdevmapper.

Semantics of per devices lock and global deviceset lock seem to be very clear.
Even ordering between these two locks has been defined properly.

What is not clear is the need and ordering of metaData.devicesLock. Looks like
this lock is not necessary and global DeviceSet lock should be used to
protect map of devices as it is part of DeviceSet.

This patchset gets rid of metaData.devicesLock and instead uses DeviceSet
lock to protect map of devices.

Also at couple of places during initialization takes devices.Lock(). That
is not strictly necessary as there is supposed to be one thread of execution
during initializaiton. Still it makes the code clearer.

I think this makes code more clear and easier to understand and easier to
make further changes.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-01 13:02:55 -04:00
Vivek Goyal
73f8b46d84 devmapper: Get rid of unused function HasActivatedDevice()
Looks like nobody is calling HasActivatedDevice(). Get rid of it.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-10-01 07:59:12 -04:00
Vivek Goyal
94caae2477 devmapper: Move maxDeviceID check in loadMetadata
maxDeviceID is upper limit on device Id thin pool can support. Right now
we have this check only during startup. It is a good idea to move this
check in loadMetadata so that any time a device file is loaded and if it
is corrupted and device Id is more than maxDevieceID, it will be detected
right then and there.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-09-30 18:54:06 -04:00
Vivek Goyal
39081eb3aa devmapper: Use deactivateDevice() instead of removeDevice() in deleteDevice()
Use deactivateDevice() instead of removeDevice() directly. This will make
sure for device deletion, deferred removal is used if user has configured
it in. Also this makes reading code litle easier as there is single function
to remove a device and that is deactivateDevice().

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-09-30 18:54:06 -04:00
Vivek Goyal
e97e46b737 devmapper: Fail device deletion early if device is still mounted
If a device is still mounted at the time of DeleteDevice(), that means
higher layers have not called Put() properly on the device and are trying
to delete it. This is a bug in the code where Get() and Put() have not been
properly paired up. Fail device deletion if it is still mounted.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-09-30 15:21:22 -04:00
Vivek Goyal
f5c0eb9ffe devmapper: Fix comments and for HasDevice() and Exists()
Exists() and HasDevice() just check if device file exists or not. It does
not say anything about if device is mounted or not. Fix comments.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-09-30 15:21:22 -04:00
Vivek Goyal
ba02bf31cb devmapper: Do not load transaction meta file in device Hash map
device has map (device.Devices), contains valid devices and we skip all
the files which are not device files. transaction metadata file is not
device file. Skip this file when devices files are being read and loaded
into map.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-09-30 15:21:22 -04:00
Carl Henrik Lunde
9a64f2bbb3 Use pkg/mount to support more flags in dm.mountopt
The mount syscall does not handle string flags like "noatime",
we must use bitmasks like MS_NOATIME instead.

pkg/mount.Mount already handles this work.

Signed-off-by: Carl Henrik Lunde <chlunde@ping.uio.no>
2015-09-24 21:14:41 +02:00
Chun Chen
2458452a3b Try to resize data and metadata loopback file when initiating devicemapper
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-09-24 09:31:00 +08:00
Vincent Demeester
6990b76a69 Lint package pkg/devicemapper
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-09-05 23:15:13 +02:00
Shishir Mahajan
4870fb36d4 Warning message for lvm devmapper running on top of loopback devices
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
2015-08-31 10:35:48 -04:00
Miguel Morales
95e3a4ca6d Typo fix then -> than
Signed-off-by: Miguel Morales <mimoralea@hp.com>
2015-08-28 10:44:39 -05:00
Laszlo Meszaros
78676f19c1 deviceset.go: fixed link in warning about udex sync is not supported
Signed-off-by: Laszlo Meszaros <lacienator@gmail.com>
2015-08-19 14:16:40 +02:00