Граф коммитов

478 Коммитов

Автор SHA1 Сообщение Дата
Brian Goff 55c91f2ab9 Fix some issues with concurrency in aufs.
Adds a benchmark to measure performance under concurrent actions.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-02-25 14:32:13 -05:00
Stefan Weil 2eee613326 Fix some typos in comments and strings
Most of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-02-22 20:27:15 +01:00
Kai Qiang Wu(Kennan) c33cdf9ee3 Fix the typo
Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
2016-02-16 07:00:01 +00:00
Phil Estes 922986b76e Add proper refcounting to zfs graphdriver
Fixes issues with layer remounting (e.g. a running container which then
has `docker cp` used to copy files in or out) by applying the same
refcounting implementation that exists in other graphdrivers like
overlay and aufs.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-02-11 01:00:54 -05:00
Stefan J. Wernli 041a9510c6 Fixing 'docker save' on Windows.
Save was failing file integrity checksums due to bugs in both
Windows and Docker. This commit includes fixes to file time handling
in tarexport and system.chtimes that are necessary along with
the Windows platform fixes to correctly support save. With this
change, sysfile_backups for windowsfilter driver are no longer
needed, so that code is removed.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-02-08 18:08:49 -08:00
David Calavera a93cb2b856 Merge pull request #20045 from estesp/zfs-userns-permissions-fix
Fix ZFS permissions bug with user namespaces
2016-02-05 15:32:43 -08:00
Phil Estes aef0995b02 Fix ZFS permissions bug with user namespaces
Fix root directory of the mountpoint being owned by real root. This is
unique to ZFS because of the way file mountpoints are created using the
ZFS tooling, and the remapping that happens at layer unpack doesn't
impact this root (already created) holding directory for the layer.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-02-05 14:37:33 -05:00
Liu Bo b2e27fee53 Graphdriver/btrfs: Avoid using single d.Get()
For btrfs driver, in d.Create(), Get() of parentDir is called but not followed
by Put().

If we apply SElinux mount label, we need to mount btrfs subvolumes in d.Get(),
without a Put() would end up with a later Remove() failure on
"Device resourse is busy".

This calls the subvolume helper function directly in d.Create().

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
2016-02-04 10:25:24 -08:00
Tonis Tiigi b9a395c85d Remove case sensitive duplicate dir in vendor
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-02-03 13:06:32 -08:00
Kai Qiang Wu(Kennan) feda5d7684 Make btrfs call same interface as others
Most storage drivers call graphdriver.GetFSMagic(home),
it is more clean to easy to maintain. So btrfs need to
adopt such change.

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
2016-02-01 07:50:21 +00:00
Phil Estes 67d86d10d8 Merge pull request #19216 from scaleoutsean/master
Add GPFS filesystem IDs
2016-01-22 21:27:03 -05:00
scaleoutsean bdc8241da9 Add GPFS
Signed-off-by: Sean Lee <seanlee@tw.ibm.com>
2016-01-22 21:12:47 +08:00
Tibor Vass d2448a0c20 Merge pull request #19524 from LK4D4/iocopy_writeto
Use bufio.Reader in io.Copy source for overlay.copyRegular
2016-01-21 15:37:12 -05:00
Alexander Morozov 3f5e1c69b3 Use pools.Copy instead of io.Copy for overlay.copyRegular
That function is pretty heavy used on container start. Autoallocating
buffer can be painful.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-01-21 08:53:37 -08:00
Tonis Tiigi 98d0997894 Revert "Copy aufs hardlinks to top layer"
This reverts commit ef05b83417.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-01-21 07:52:50 -08:00
Sebastiaan van Stijn 661d75f398 Merge pull request #19123 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
Phil Estes 72e65e8793 Fix btrfs subvolume snapshot dir perms for user namespaces
Make sure btrfs mounted subvolumes are owned properly when a remapped
root exists (user namespaces are enabled, for example)

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-01-07 23:05:28 -05:00
Tõnis Tiigi fe550a1f17 Merge pull request #19093 from estesp/userns-root-rework
Allow root non-userns metadata backwards compatibility
2016-01-06 09:48:37 -08:00
Phil Estes e8532023f2 Allow root non-userns metadata backwards compatibility
Instead of creating a "0.0" subdirectory and migrating graphroot
metadata into it when user namespaces are available in the daemon
(currently only in experimental), change the graphroot dir permissions
to only include the execute bit for "other" users.

This allows easy migration to and from user namespaces and will allow
easier integration of user namespace support into the master build.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-01-05 11:51:14 -05:00
Tonis Tiigi 0641429ad8 Use direct filesystem access for tar-split on aufs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-01-04 09:41:02 -08:00
Daniel Nephin 91154e9235 Move graph driver registration out of the daemon package.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2015-12-28 13:02:24 -05:00
Daniel Nephin f5916b10ae Remove the graph driver from the daemon, move it into the layer store.
Support restoreCustomImage for windows with a new interface to extract
the graph driver from the LayerStore.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2015-12-28 12:55:48 -05:00
Shijiang Wei de7f6cf16b ingnore the NotExist error when removing inexistent files
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2015-12-25 15:19:48 +08:00
Daniel Nephin 0673361ef6 Remove migrateIfDownlevel and aufs migration from docker pre-0.7
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2015-12-22 16:45:42 -05: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
Vincent Batts f57d56350e Merge pull request #18686 from cpuguy83/fix_btrfs_subvol_delete_panic
Fix btrfs recursive btrfs subvol delete
2015-12-16 14:26:40 -05:00
David Calavera b44b5bbc8b Merge pull request #18682 from calavera/replace_units_package
Replace pkg/units with docker/go-units.
2015-12-16 10:48:59 -08: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 baba1a8493 reorder imports with goimports
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2015-12-16 16:50:25 +01:00
Brian Goff f9befce2d3 Fix btrfs recursive btrfs subvol delete
Really fixing 2 things:

1. Panic when any error is detected while walking the btrfs graph dir on
removal due to no error check.
2. Nested subvolumes weren't actually being removed due to passing in
the wrong path

On point 2, for a path detected as a nested subvolume, we were calling
`subvolDelete("/path/to/subvol", "subvol")`, where the last part of the
path was duplicated due to a logic error, and as such actually causing
point #1 since `subvolDelete` joins the two arguemtns, and
`/path/to/subvol/subvol` (the joined version) doesn't exist.

Also adds a test for nested subvol delete.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-12-15 18:12:40 -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 #16667

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
Phil Estes 191cefbaca Fix overlay and user namespace permissions
All underlay dirs need proper remapped ownership. This bug was masked by the
fact that the setupInitLayer code was chown'ing the dirs at startup
time. Since that bug is now fixed, it revealed this permissions issue.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-12-08 14:28:28 -05:00
Liu Hua 451f751773 fix Put without Get in aufs
this Patch is ported from 3916561619

Signed-off-by: Liu Hua <sdu.liu@huawei.com>
2015-12-03 22:22:25 +08: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
Tonis Tiigi 4352da7803 Update daemon and docker core to use new content addressable storage
Add distribution package for managing pulls and pushes. This is based on
the old code in the graph package, with major changes to work with the
new image/layer model.

Add v1 migration code.

Update registry, api/*, and daemon packages to use the reference
package's types where applicable.

Update daemon package to use image/layer/tag stores instead of the graph
package

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-11-24 09:40:25 -08:00
Michael Crosby 1ecb9a40db Merge pull request #17974 from anusha-ragunathan/fsMagic
Fix devmapper backend in docker info
2015-11-17 11:44:48 -08:00
Alexander Morozov 4dda67b801 Merge pull request #16452 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 #17479 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
Vincent Batts 1066725395 Merge pull request #16774 from tonistiigi/15643-aufs-plnk
Copy aufs hardlinks to top layer
2015-11-11 07:59:41 +01: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
David Calavera 58b270c338 Merge pull request #17431 from vdemeester/hope-it-does-not-broke-everything-again
Another try at dockerversion placeholder for library import
2015-11-09 13:15:50 -08:00
Vincent Demeester 8054a30387 dockerversion placeholder for library import
- Add a *version* file placeholder.
- Update autogen and builds to use it and an autogen build flag

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-11-09 19:32:46 +01:00
Vincent Batts 10df5647bd Merge pull request #17757 from rhvgoyal/log-blkid-failure
devmapper: Provide more error information if blkid fails
2015-11-07 09:16:14 -05:00
David Calavera 1ba280a8db Merge pull request #17576 from Microsoft/10662-graphtest
Windows: Fix daemon\graphdriver\graphtest
2015-11-06 15:13:31 -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
John Howard 8764967381 Windows: Fix daemon\graphdriver\graphtest
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-10-31 21:14:18 -07:00
Brian Goff b78ca243d9 Revert "dockerversion placeholder for library-import"
This reverts commit d5cd032a86.

Commit caused issues on systems with case-insensitive filesystems.
Revert for now

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-10-27 21:23:53 -04:00
Vincent Demeester d5cd032a86 dockerversion placeholder for library-import
- Move autogen/dockerversion to version
- Update autogen and "builds" to use this package and a build flag

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-10-27 20:36:07 +01: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 #16303 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
Tonis Tiigi ef05b83417 Copy aufs hardlinks to top layer
Show warning if old method is used.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-10-12 20:44:32 -07:00
Tonis Tiigi 504e67b867 Calculate hash based image IDs on pull
Generate a hash chain involving the image configuration, layer digests,
and parent image hashes. Use the digests to compute IDs for each image
in a manifest, instead of using the remotely specified IDs.

To avoid breaking users' caches, check for images already in the graph
under old IDs, and avoid repulling an image if the version on disk under
the legacy ID ends up with the same digest that was computed from the
manifest for that image.

When a calculated ID already exists in the graph but can't be verified,
continue trying SHA256(digest) until a suitable ID is found.

"save" and "load" are not changed to use a similar scheme. "load" will
preserve the IDs present in the tar file.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-10-12 10:51:28 -07:00
Hu Keping a066b94ef0 Comment: add some lines back
Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-10-12 19:34:58 +08: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
Brian Goff 3b16cb15b4 Do not probe plugins for graph init unless `-s`
When `-s` is not specified, there is no need to ask if there is a plugin
with the specified name.

This speeds up unit tests dramatically since they don't need to wait the
timeout period for each call to `graphdriver.New`.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-10-09 12:02:54 -04:00
Michael Crosby 6d9a84bcd0 Merge pull request #16152 from chlunde/devmapper-mount-flags
Use pkg/mount to support more flags in dm.mountopt
2015-10-08 16:02:50 -07:00
Jess Frazelle 4c55464dd3 Merge pull request #13777 from cpuguy83/graphdriver_extpoints
Create extpoint for graphdrivers
2015-10-08 13:46:42 -07:00
Arnaud Porterie b3b9fe8c77 Merge pull request #15868 from crosbymichael/aufs-data
Add aufs data structure for added mount information
2015-10-08 11:17:20 -07:00
Alexander Morozov 6654b0e05f Merge pull request #16852 from estesp/overlay-cleanup
Simplify dir removal in overlay driver
2015-10-08 08:44:50 -07:00
Vincent Batts c3e5364813 Merge pull request #16823 from rhvgoyal/check-thin-pool
devmapper: Make sure device is a thin pool device
2015-10-08 11:27:53 -04:00
Phil Estes 6ed11b5374 Simplify dir removal in overlay driver
There is no need to call `os.Stat` on the driver filesystem path of a
container as `os.RemoveAll` already handles (properly) the case where
the path no longer exists.

Given the results of the stat() were not even being used,  there is no
value in erroring out because of the stat call failure, and worse, it
prevents daemon cleanup of containers in "Dead" state unless you re-create
directories that were already removed via a manual cleanup after a
failure.  This brings removal in overlay in line with aufs/devicemapper
drivers which don't error out if the filesystem path no longer exists.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-10-08 11:04:00 -04:00
Vincent Demeester 53d2429164 Merge pull request #16780 from Microsoft/jjh/vfs-build-tags
Fix VFS build tags
2015-10-08 09:43:06 +02: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
John Howard 7db08b4e62 Fix VFS build tags
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-10-05 15:52:09 -07: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
Jess Frazelle 134fefbaa2 Merge pull request #16490 from Microsoft/10662-mtimefix
Fixed file modified time not changing on windows
2015-10-02 12:06:03 -07:00
Jess Frazelle aa2e3247cb Merge pull request #16470 from tonistiigi/fix-aufs-opq
Add basic support for .wh..wh..opq
2015-10-02 11:28:33 -07:00
Darren Stahl 40b77af234 Fixed file modified time not changing on Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2015-10-01 10:45:32 -07: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
David Calavera 1fffc7a89d Fix golint issues on the windows graph driver.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-09-29 18:32:45 -04:00
Tonis Tiigi 2fb5d0c323 Add constants for AUFS whiteout files
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-09-29 11:21:45 -07:00
Tonis Tiigi 00e3277107 Add basic support for .wh..wh..opq
This fixes the case where directory is removed in
aufs and then the same layer is imported to a
different graphdriver.

Currently when you do `rm -rf /foo && mkdir /foo`
in a layer in aufs the files under `foo` would
only be be hidden on aufs.

The problems with this fix:

1) When a new diff is recreated from non-aufs driver
the `opq` files would not be there. This should not
mean layer differences for the user but still
different content in the tar (one would have one
`opq` file, the others would have `.wh.*` for every
file inside that folder). This difference also only
happens if the tar-split file isn’t stored for the
layer.

2) New files that have the filenames before `.wh..wh..opq`
when they are sorted do not get picked up by non-aufs
graphdrivers. Fixing this would require a bigger
refactoring that is planned in the future.


Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-09-29 08:22:25 -07: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