summaryrefslogtreecommitdiff
path: root/pkg/devicemapper
Commit message (Collapse)AuthorAgeFilesLines
* pkg/*: fix "empty-lines" (revive)Sebastiaan van Stijn2022-09-282-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pkg/directory/directory.go:9:49: empty-lines: extra empty line at the start of a block (revive) pkg/pubsub/publisher.go:8:48: empty-lines: extra empty line at the start of a block (revive) pkg/loopback/attach_loopback.go:96:69: empty-lines: extra empty line at the start of a block (revive) pkg/devicemapper/devmapper_wrapper.go:136:48: empty-lines: extra empty line at the start of a block (revive) pkg/devicemapper/devmapper.go:391:35: empty-lines: extra empty line at the end of a block (revive) pkg/devicemapper/devmapper.go:676:35: empty-lines: extra empty line at the end of a block (revive) pkg/archive/changes_posix_test.go:15:38: empty-lines: extra empty line at the end of a block (revive) pkg/devicemapper/devmapper.go:241:51: empty-lines: extra empty line at the start of a block (revive) pkg/fileutils/fileutils_test.go:17:47: empty-lines: extra empty line at the end of a block (revive) pkg/fileutils/fileutils_test.go:34:48: empty-lines: extra empty line at the end of a block (revive) pkg/fileutils/fileutils_test.go:318:32: empty-lines: extra empty line at the end of a block (revive) pkg/tailfile/tailfile.go:171:6: empty-lines: extra empty line at the end of a block (revive) pkg/tarsum/fileinfosums_test.go:16:41: empty-lines: extra empty line at the end of a block (revive) pkg/tarsum/tarsum_test.go:198:42: empty-lines: extra empty line at the start of a block (revive) pkg/tarsum/tarsum_test.go:294:25: empty-lines: extra empty line at the start of a block (revive) pkg/tarsum/tarsum_test.go:407:34: empty-lines: extra empty line at the end of a block (revive) pkg/ioutils/fswriters_test.go:52:45: empty-lines: extra empty line at the end of a block (revive) pkg/ioutils/writers_test.go:24:39: empty-lines: extra empty line at the end of a block (revive) pkg/ioutils/bytespipe_test.go:78:26: empty-lines: extra empty line at the end of a block (revive) pkg/sysinfo/sysinfo_linux_test.go:13:37: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive_linux_test.go:57:64: empty-lines: extra empty line at the end of a block (revive) pkg/archive/changes.go:248:72: empty-lines: extra empty line at the start of a block (revive) pkg/archive/changes_posix_test.go:15:38: empty-lines: extra empty line at the end of a block (revive) pkg/archive/copy.go:248:124: empty-lines: extra empty line at the end of a block (revive) pkg/archive/diff_test.go:198:44: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive.go:304:12: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive.go:749:37: empty-lines: extra empty line at the end of a block (revive) pkg/archive/archive.go:812:81: empty-lines: extra empty line at the start of a block (revive) pkg/archive/copy_unix_test.go:347:34: empty-lines: extra empty line at the end of a block (revive) pkg/system/path.go:11:39: empty-lines: extra empty line at the end of a block (revive) pkg/system/meminfo_linux.go:29:21: empty-lines: extra empty line at the end of a block (revive) pkg/plugins/plugins.go:135:32: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/response.go:71:48: empty-lines: extra empty line at the start of a block (revive) pkg/authorization/api_test.go:18:51: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/middleware_test.go:23:44: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/middleware_unix_test.go:17:46: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/api_test.go:57:45: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/response.go:83:50: empty-lines: extra empty line at the start of a block (revive) pkg/authorization/api_test.go:66:47: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/middleware_unix_test.go:45:48: empty-lines: extra empty line at the end of a block (revive) pkg/authorization/response.go:145:75: empty-lines: extra empty line at the start of a block (revive) pkg/authorization/middleware_unix_test.go:56:51: empty-lines: extra empty line at the end of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* golangci-lint: update to v1.49.0Sebastiaan van Stijn2022-09-231-1/+1
| | | | | | | | | | | | Remove the "deadcode", "structcheck", and "varcheck" linters, as they are deprecated: WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN [linters context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* fix formatting of "nolint" tags for go1.19Sebastiaan van Stijn2022-07-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | The correct formatting for machine-readable comments is; //<some alphanumeric identifier>:<options>[,<option>...][ // comment] Which basically means: - MUST NOT have a space before `<identifier>` (e.g. `nolint`) - Identified MUST be alphanumeric - MUST be followed by a colon - MUST be followed by at least one `<option>` - Optionally additional `<options>` (comma-separated) - Optionally followed by a comment Any other format will not be considered a machine-readable comment by `gofmt`, and thus formatted as a regular comment. Note that this also means that a `//nolint` (without anything after it) is considered invalid, same for `//#nosec` (starts with a `#`). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* gofmt GoDoc comments with go1.19Sebastiaan van Stijn2022-07-082-1/+2
| | | | | | | | Older versions of Go don't format comments, so committing this as a separate commit, so that we can already make these changes before we upgrade to Go 1.19. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Update to Go 1.17.0, and gofmt with Go 1.17Sebastiaan van Stijn2021-08-248-6/+11
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* reformat "nolint" commentsSebastiaan van Stijn2021-06-101-1/+1
| | | | | | Unlike regular comments, nolint comments should not have a leading space. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* gosimple: S1039: unnecessary use of fmt.SprintfSebastiaan van Stijn2021-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pkg/devicemapper/devmapper.go:383:28: S1039: unnecessary use of fmt.Sprintf (gosimple) if err := task.setMessage(fmt.Sprintf("@cancel_deferred_remove")); err != nil { ^ integration/plugin/graphdriver/external_test.go:321:18: S1039: unnecessary use of fmt.Sprintf (gosimple) http.Error(w, fmt.Sprintf("missing id"), 409) ^ integration-cli/docker_api_stats_test.go:70:31: S1039: unnecessary use of fmt.Sprintf (gosimple) _, body, err := request.Get(fmt.Sprintf("/info")) ^ integration-cli/docker_cli_build_test.go:4547:19: S1039: unnecessary use of fmt.Sprintf (gosimple) "--build-arg", fmt.Sprintf("FOO1=fromcmd"), ^ integration-cli/docker_cli_build_test.go:4548:19: S1039: unnecessary use of fmt.Sprintf (gosimple) "--build-arg", fmt.Sprintf("FOO2="), ^ integration-cli/docker_cli_build_test.go:4549:19: S1039: unnecessary use of fmt.Sprintf (gosimple) "--build-arg", fmt.Sprintf("FOO3"), // set in env ^ integration-cli/docker_cli_build_test.go:4668:32: S1039: unnecessary use of fmt.Sprintf (gosimple) cli.WithFlags("--build-arg", fmt.Sprintf("tag=latest"))) ^ integration-cli/docker_cli_build_test.go:4690:32: S1039: unnecessary use of fmt.Sprintf (gosimple) cli.WithFlags("--build-arg", fmt.Sprintf("baz=abc"))) ^ pkg/jsonmessage/jsonmessage_test.go:255:4: S1039: unnecessary use of fmt.Sprintf (gosimple) fmt.Sprintf("ID: status\n"), ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/devicemapper: fix invalid usage of reflect.SliceHeaderCuong Manh Le2020-11-031-6/+5
| | | | | | | | | | The current usage of reflect.SliceHeader violates rule 6th of unsafe.Pointer conversion. In short, reflect.SliceHeader could not be used as plain struct. See https://golang.org/pkg/unsafe/#Pointer Signed-off-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* pkg/devicemapper ignore SA4000 false positive (staticcheck)Sebastiaan van Stijn2019-09-181-0/+1
| | | | | | | | ``` pkg/devicemapper/devmapper_wrapper.go:209:206: SA4000: identical expressions on the left and right side of the '==' operator (staticcheck) ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/devicemapper: disable unused and varcheck lintersSebastiaan van Stijn2019-09-181-1/+1
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* devicemapper: remove unused errorsSebastiaan van Stijn2019-08-071-3/+0
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* devicemapper: remove unused task.setRo()Sebastiaan van Stijn2019-08-072-13/+0
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Various code-cleanupSebastiaan van Stijn2018-05-231-1/+1
| | | | | | remove unnescessary import aliases, brackets, and so on. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg: devmapper: dynamically load dm_task_deferred_removeAleksa Sarai2018-02-163-5/+139
| | | | | | | | | | | | | | | | | dm_task_deferred_remove is not supported by all distributions, due to out-dated versions of devicemapper. However, in the case where the devicemapper library was updated without rebuilding Docker (which can happen in some distributions) then we should attempt to dynamically load the relevant object rather than try to link to it. This can only be done if Docker was built dynamically, for obvious reasons. In order to avoid having issues arise when dlsym(3) was unnecessary, gate the whole dlsym(3) logic behind a buildflag that we disable by default (libdm_dlsym_deferred_remove). Signed-off-by: Aleksa Sarai <asarai@suse.de>
* Add canonical import commentDaniel Nephin2018-02-058-8/+8
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Devicemapper: ignore Nodata errors when delete thin deviceLiu Hua2018-01-022-3/+13
| | | | | | | | if thin device is deteled and the metadata exists, you can not delete related containers. This patch ignore Nodata errors for thin device deletion Signed-off-by: Liu Hua <sdu.liu@huawei.com>
* devmapper gd: disable for static buildKir Kolyshkin2017-09-171-6/+0
| | | | | | | | | | | | | | | Static build with devmapper is impossible now since libudev is required and no static version of libudev is available (as static libraries are not supported by systemd which udev is part of). This should not hurt anyone as "[t]he primary user of static builds is the Editions, and docker in docker via the containers, and none of those use device mapper". Also, since the need for static libdevmapper is gone, there is no need to self-compile libdevmapper -- let's use the one from Debian Stretch. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* Add gosimple linterDaniel Nephin2017-09-121-4/+2
| | | | | | Update gometalinter Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Optimize some wrong usage and spellingwangguoliang2017-09-071-1/+1
| | | | Signed-off-by: wgliang <liangcszzu@163.com>
* Add unconvert linterDaniel Nephin2017-08-241-1/+1
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Add deadcode linterDaniel Nephin2017-08-211-0/+1
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Merge pull request #34362 from kolyshkin/update-libdevmapperBrian Goff2017-08-144-5/+13
|\ | | | | Dockerfile*: bump devmapper library version
| * Dockerfile*: bump devmapper library versionKir Kolyshkin2017-08-014-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's use latest lvm2 sources to compile the libdevmapper library. Initial reason for compiling devmapper lib from sources was a need to have the static version of the library at hand, in order to build the static dockerd, but note that the same headers/solib are used for dynamic build (dynbinary) as well. The reason for this patch is to enable the deferral removal feature. The supplied devmapper library (and headers) are too old, lacking the needed functions, so the daemon is built with 'libdm_no_deferred_remove' build tag (see the check in hack/make.sh). Because of this, even if the kernel dm driver is perfectly able to support the feature, it can not be used. For more details and background story, see [1]. Surely, one can't just change the version number. While at it: - improve the comments; - remove obsoleted URLs; - remove s390 and ppc configure updates that are no longer needed; - use pkg-config instead of hardcoding the flags (newer lib added some more dependencies); [1] https://github.com/moby/moby/issues/34298 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* | Merge pull request #34272 from dmcgowan/update-logrusJohn Howard2017-08-012-2/+2
|\ \ | |/ |/| Update logrus to v1.0.1 (Sirupsen -> sirupsen)
| * Update logrus to v1.0.1Derek McGowan2017-07-312-2/+2
| | | | | | | | | | | | Fixes case sensitivity issue Signed-off-by: Derek McGowan <derek@mcgstyle.net>
* | pkg/devicemapper: comment nitpicksKir Kolyshkin2017-07-313-2/+3
|/ | | | | | | | | | | | 1. devmapper_wrapper_{,no_}deferred_remove.go: Comments about LibraryDeferredRemovalSupport were very totally misleading to me. This thing has nothing to do with either static or dynamic linking (but with build tags). Fix the comment accordingly. 2. devmapper.go: Reveal the source of those magic device* constants. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* devmapper_wrapper.go: fix gcc warningKir Kolyshkin2017-07-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | I am getting the following warning from gcc when compiling the daemon: > # github.com/docker/docker/pkg/devicemapper > pkg/devicemapper/devmapper_wrapper.go: In function ‘log_cb’: > pkg/devicemapper/devmapper_wrapper.go:20:2: warning: ignoring return > value of ‘vasprintf’, declared with attribute warn_unused_result > [-Wunused-result] > vasprintf(&buffer, f, ap); > ^ vasprintf(3) man page says if the function returns -1, the buffer is undefined, so we should not use it. In practice, I assume, this never happens so we just return. Introduced by https://github.com/moby/moby/pull/33845 that resulted in commit 63328c6 ("devicemapper: remove 256 character limit of libdm logs") Cc: Aleksa Sarai <asarai@suse.de> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* Merge pull request #33845 from cyphar/devicemapper-show-me-your-logsSebastiaan van Stijn2017-07-123-33/+98
|\ | | | | devicemapper: rework logging and add --storage-opt dm.libdm_log_level
| * devicemapper: change LogInit and move all callbacks to pkgAleksa Sarai2017-07-042-16/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LogInit used to act as a manual way of registering the *necessary* pkg/devicemapper logging callbacks. In addition, it was used to split up the logic of pkg/devicemapper into daemon/graphdriver/devmapper (such that some things were logged from libdm). The manual aspect of this API was completely non-sensical and was just begging for incorrect usage of pkg/devicemapper, so remove that semantic and always register our own libdm callbacks. In addition, recombine the split out logging callbacks into pkg/devicemapper so that the default logger is local to the library and also shown to be the recommended logger. This makes the code substantially easier to read. Also the new DefaultLogger now has configurable upper-bound for the log level, which allows for dynamically changing the logging level. Signed-off-by: Aleksa Sarai <asarai@suse.de>
| * devicemapper: actually remove DmLogInitVerboseAleksa Sarai2017-07-042-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | e07d3cd9a ("devmapper: Fix libdm logging") removed all of the callers of DmLogInitVerbose, but we still kept around the wrapper. However, the libdm dm_log_init_verbose API changes the verbosity of the *default* libdm logger. Because pkg/devicemapper internally *relies* on using logging callbacks to understand what errors were encountered by libdm, this wrapper is useless (it only makes sense for the default logger which we do not user). Any user not inside Docker of this function almost certainly was not using this API correctly, because pkg/devicemapper will misbehave if our logging callbacks were not registered. Signed-off-by: Aleksa Sarai <asarai@suse.de>
| * devicemapper: remove 256 character limit of libdm logsAleksa Sarai2017-07-041-7/+9
| | | | | | | | | | | | | | | | This limit is unecessary and can lead to the truncation of long libdm logs (which is quite annoying). Fixes: b440ec013 ("device-mapper: Move all devicemapper spew to log through utils.Debugf().") Signed-off-by: Aleksa Sarai <asarai@suse.de>
* | Merge pull request #33877 from rhvgoyal/sync-removalSebastiaan van Stijn2017-07-121-0/+8
|\ \ | | | | | | devicemapper: Wait for device removal if deferredRemoval=true and deferredDeletion=…
| * | Wait for device removal if deferredRemoval=true and deferredDeletion=falseVivek Goyal2017-06-301-0/+8
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There have been some cases where umount, a device can be busy for a very short duration. Maybe its udev rules, or maybe it is runc related races or probably it is something else. We don't know yet. If deferred removal is enabled but deferred deletion is not, then for the case of "docker run -ti --rm fedora bash", a container will exit, device will be deferred removed and then immediately a call will come to delete the device. It is possible that deletion will fail if device was busy at that time. A device can't be deleted if it can't be removed/deactivated first. There is only one exception and that is when deferred deletion is on. In that case graph driver will keep track of deleted device and try to delete it later and return success to caller. Always make sure that device deactivation is synchronous when device is being deleted (except the case when deferred deletion is enabled). This should also take care of small races when device is busy for a short duration and it is being deleted. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
* | [project] change syscall to /x/sys/unix|windowsChristopher Jones2017-07-112-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes most references of syscall to golang.org/x/sys/ Ones aren't changes include, Errno, Signal and SysProcAttr as they haven't been implemented in /x/sys/. Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com> [s390x] switch utsname from unsigned to signed per https://github.com/golang/sys/commit/33267e036fd93fcd26ea95b7bdaf2d8306cb743c char in s390x in the /x/sys/unix package is now signed, so change the buildtags Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
* | Spelling fixesJosh Soref2017-07-031-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * additional * ambiguous * anonymous * anything * application * because * before * building * capabilities * circumstances * commit * committer * compresses * concatenated * config * container * container's * current * definition * delimiter * disassociates * discovery * distributed * doesnotexist * downloads * duplicates * either * enhancing * enumerate * escapable * exactly * expect * expectations * expected * explicitly * false * filesystem * following * forbidden * git with * healthcheck * ignore * independent * inheritance * investigating * irrelevant * it * logging * looking * membership * mimic * minimum * modify * mountpoint * multiline * notifier * outputting * outside * overridden * override * parsable * plugins * precedence * propagation * provided * provides * registries * repositories * returning * settings * should * signals * someone * something * specifically * successfully * synchronize * they've * thinking * uninitialized * unintentionally * unmarshaling * unnamed * unreferenced * verify Signed-off-by: Josh Soref <jsoref@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* devmapper: ensure that UdevWait is called after calls to setCookieNeil Horman2017-06-191-9/+15
| | | | | | | | | | | | | Recent changes to devmapper broke the implicit requirement that UdevWait be called after every call to task.setCookie. Failure to do so results in leaks of semaphores in the LVM code, eventually leading to semaphore exhaustion. Previously this was handled by calling UdevWait in a ubiquitous defer function. While there was initially some concern with deferring the UdevWait function would cause some amount of race possibiliy, the fact that we never return the cookie value or any value used to find it, makes that possibility seem unlikely, so lets go back to that method Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
* Ensure that a device mapper task is referenced until task is completeNeil Horman2017-05-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DeviceMapper tasks in go use SetFinalizer to clean up C construct counterparts in the C LVM library. While thats well and good, it relies heavily on the exact interpretation of when the golang garbage collector determines that an object is unreachable is subject to reclaimation. While common sense would assert that for stack variables (which these DM tasks always are), are unreachable when the stack frame in which they are declared returns, thats not the case. According to this: https://golang.org/pkg/runtime/#SetFinalizer The garbage collector decides that, if a function calls into a systemcall (which task.run() always will in LVM), and there are no subsequent references to the task variable within that stack frame, then it can be reclaimed. Those conditions are met in several devmapper.go routines, and if the garbage collector runs in the middle of a deviceMapper operation, then the task can be destroyed while the operation is in progress, leading to crashes, failed operations and other unpredictable behavior. The fix is to use the KeepAlive interface: https://golang.org/pkg/runtime/#KeepAlive The KeepAlive method is effectively an empy reference that fools the garbage collector into thinking that a variable is still reachable. By adding a call to KeepAlive in the task.run() method, we can ensure that the garbage collector won't reclaim a task object until its execution within the deviceMapper C library is complete. Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
* Move UdevWait from defer to inlineNeil Horman2017-05-091-15/+9
| | | | | | | | | | | | | | | | All LVM actions in the devicemapper library are asyncronous, involving a call to a task enqueue function (dm_run_task) and a wait on a resultant udev event (UdevWait). Currently devmapper.go defers all calls to UdevWait, which discards the return value. While it still generates an error message in the log (if debugging is enabled), the calling thread is still allowed to continue as if no error has occured, leading to subsequent errors, and significant confusion when debugging, due to those subsequent errors. Given that there is no risk of panic between the task submission and the wait operation, it seems more reasonable to preform the UdevWait inline at the end of any given lvm action so that errors can be caught and returned before docker can continue and create additional failures. Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
* Make cookies for devicemapper operations uniqueNeil Horman2017-05-091-15/+15
| | | | | | | | | | | | | | | | | Currently, the devicemapper library sets cookies to correlate wait operations, which must be unique (as the lvm2 library doesn't detect duplicate cookies). The current method for cookie generation is to take the address of a cookie variable. However, because the variable is declared on the stack, execution patterns can lead to the cookie variable being declared at the same stack location, which results in a high likelyhood of duplicate cookie use, which in turn can lead to various odd lvm behaviors, which can be hard to track down (object use before create, duplicate completions, etc). Lets guarantee that the cookie we generate is unique by declaring it on the heap instead. This guarantees that the address of the variable won't be reused until such time as the UdevWait operation completes, and drops its reference to it, at which time the gc can reclaim it. Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
* Enhance error logging for failed UdevWait operations in devmapperNeil Horman2017-05-091-1/+1
| | | | | | | | If a wait event fails when preforming a devicemapper operation, it would be good to know, in addition to the cookie that its waiting on, we reported the error that was reported from the lvm2 library. Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
* Make pkg/devicemapper and pkg/loopback depend on cgo in build tagsAaron Lehmann2017-03-296-6/+6
| | | | Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
* several function names fixed in devmapper.golixiaobing100512672016-12-211-2/+2
| | | | | | Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn> Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
* fix a few golint errorsVictor Vieux2016-11-181-1/+1
| | | | Signed-off-by: Victor Vieux <victorvieux@gmail.com>
* devmapper: prevent libdevmapper from deleting device symlinks in ↵Ji.Zhilong2016-08-231-0/+21
| | | | | | | | | | | | | | | | | RemoveDeviceDeferred if there is no cookie set in dm task, or flag DM_UDEV_DISABLE_LIBRARY_FALLBACK is cleared for a DM_DEV_REMOVE task, libdevmapper will fallback to clean up the symlink under /dev/mapper by itself, no matter the device removal is executed immediately or deferred by the kernel.In some cases, the removal is deferred by the kernel, while the symlink is deleted directly by libdevmapper, when docker tries to activate the device again, the deferred removal will be canceld, but the symlink will not show up again, so docker's attempt to mount the device by the symlink will fail, and it will eventually leads to a `docker start/diff` error. Fixes #24671 Signed-off-by: Ji.Zhilong <zhilongji@gmail.com>
* Fixes Issue # 23418: Race condition between device deferred removal and ↵Shishir Mahajan2016-08-021-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | resume device. Problem Description: An example scenario that involves deferred removal 1. A new base image gets created (e.g. 'docker load -i'). The base device is activated and mounted at some point in time during image creation. 2. While image creation is in progress, a privileged container is started from another image and the host's mount name space is shared with this container ('docker run --privileged -v /:/host'). 3. Image creation completes and the base device gets unmounted. However, as the privileged container still holds a reference on the base image mount point, the base device cannot be removed right away. So it gets flagged for deferred removal. 4. Next, the privileged container terminates and thus its reference to the base image mount point gets released. The base device (which is flagged for deferred removal) may now be cleaned up by the device-mapper. This opens up an opportunity for a race between a 'kworker' thread (executing the do_deferred_remove() function) and the Docker daemon (executing the CreateSnapDevice() function). This PR cancel the deferred removal, if the device is marked for it. And reschedule the deferred removal later after the device is resumed successfully. Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
* Fix logrus formattingYong Tang2016-06-111-1/+1
| | | | | | | | | | This fix tries to fix logrus formatting by removing `f` from `logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string is not present. This fix fixes #23459. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* loopback: separate loop logic from devicemapperVincent Batts2015-12-184-293/+23
| | | | | | | | 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>
* devicemapper: remove unused type mappingVincent Batts2015-12-181-2/+1
| | | | Signed-off-by: Vincent Batts <vbatts@redhat.com>
* Make pkg/devicemapper/ log messages with a common, consistent prefix.Chris Dituri2015-12-141-53/+53
| | | | | | | | Closes #16667 Uses the prefix "devicemapper:" for all the fmt and logrus error, debug, and info messages. Signed-off-by: Chris Dituri <csdituri@gmail.com>
* Fix typos found across repositoryJustas Brazauskas2015-12-131-1/+1
| | | | Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>