提交 fd518244 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!6 Support devicemapper

Merge pull request !6 from wangfengtu/support_devicemapper
......@@ -33,7 +33,7 @@ GO_LDFLAGS="-s -w -extldflags -static -X main.gitCommit=${GIT_COMMIT} -X main.bu
GOTMPDIR=/tmp/isulad-kit
# ifeq ($(DISABLE_CGO), 1)
override BUILDTAGS = containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp
override BUILDTAGS = containers_image_ostree_stub exclude_graphdriver_btrfs containers_image_openpgp
# endif
.PHONY: all isulad_kit static clean
......
......@@ -617,24 +617,17 @@ func (s *grpcImageService) GraphdriverStatus(ctx context.Context, req *pb.Graphd
}, err
}
var gotBackingFs, gotSupportsDType, gotNativeOverlayDiff bool
var gotBackingFs bool
resp := &pb.GraphdriverStatusResponse{}
for _, kv := range status {
switch kv[0] {
case "Backing Filesystem":
resp.BackingFs = kv[1]
if kv[0] == "Backing Filesystem" {
gotBackingFs = true
case "Supports d_type":
resp.SupportsDType = (kv[1] == "true")
gotSupportsDType = true
case "Native Overlay Diff":
resp.NativeOverlayDiff = (kv[1] == "true")
gotNativeOverlayDiff = true
}
resp.Status += fmt.Sprintf("%s: %s\n", kv[0], kv[1])
}
if gotBackingFs != true || gotSupportsDType != true || gotNativeOverlayDiff != true {
err := errors.New("Internal error, failed to get all infomation")
if !gotBackingFs {
err := errors.New("Internal error, failed to get backing filesystem")
return &pb.GraphdriverStatusResponse{
Errmsg: err.Error(),
Cc: 1,
......
%global _version 1.0.12
%global _release 20190809.172307.git763c5091
%global _release 20200211.091049.gita4ddcad0
Name: iSulad-kit
Version: %{_version}
Release: %{_release}
......@@ -13,6 +13,7 @@ Source0: iSulad-kit-1.0.tar.gz
BuildRequires: golang >= 1.8.3
BuildRequires: gpgme gpgme-devel
BuildRequires: device-mapper-devel
%description
A tool for downloading iSulad images, written in go language
......
此差异已折叠。
......@@ -139,11 +139,9 @@ message LoadImageResponose {
message GraphdriverStatusRequest {}
message GraphdriverStatusResponse {
string backing_fs = 1;
bool supports_d_type = 2;
bool native_overlay_diff = 3;
string errmsg = 4;
uint32 cc = 5;
string status = 1;
string errmsg = 2;
uint32 cc = 3;
}
message ContainerFsUsageRequest {
......
From b3c73e162e513a87ba565e6d3d6a2cb757a80303 Mon Sep 17 00:00:00 2001
From 749440db85ed769d3f802c81295cb64a3c75037a Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Tue, 2 Apr 2019 23:37:17 -0400
Subject: [PATCH 01/36] add image load time and append image names
Subject: [PATCH 01/37] add image load time and append image names
reason: 1. add image load time
2. append image names when pull image
......
From 3d556cb752db8f97ae25a3854620dfa989f5aeca Mon Sep 17 00:00:00 2001
From 7d821b1e50259088a49842f8aedae46626270b25 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Thu, 4 Apr 2019 11:03:15 -0400
Subject: [PATCH 02/36] add image integration check
Subject: [PATCH 02/37] add image integration check
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 7a3df9a04c292e0b0cae38366d1951e9d5df8002 Mon Sep 17 00:00:00 2001
From 36bd96c24b1ada400cd3bbf0aafa46e459ae7083 Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Tue, 9 Apr 2019 01:32:27 -0400
Subject: [PATCH 03/36] vendor: support setting rootfs quota
Subject: [PATCH 03/37] vendor: support setting rootfs quota
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
---
......
From af595cb8d35650669d1538025bb13acbb7a18c1a Mon Sep 17 00:00:00 2001
From dc415e04837a816ef8656b2eab5125069e3b1107 Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Tue, 9 Apr 2019 12:19:49 -0400
Subject: [PATCH 04/36] isulad-kit-vendor: check overlay support as docker
Subject: [PATCH 04/37] isulad-kit-vendor: check overlay support as docker
we may got failed if always detect multi lower layer mount,
when writed data more than rootfs quota for arm machine
......
From affca7e33fa41a745803421c7b5f31354675b62b Mon Sep 17 00:00:00 2001
From 5ae6ad5bcbe8c393d008a5ab6cf8b298d1009b0b Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Tue, 16 Apr 2019 00:44:20 -0400
Subject: [PATCH 05/36] isulad-kit-vendor: fix parseSize of float accurancy
Subject: [PATCH 05/37] isulad-kit-vendor: fix parseSize of float accurancy
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
---
......
From 4cd9b07d81ab01cd50dbb1a55120ae864413a7d8 Mon Sep 17 00:00:00 2001
From b1c4418ededd518c036f112d580aedf3c03b0e7e Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Tue, 16 Apr 2019 10:53:52 -0400
Subject: [PATCH 06/36] limit the minimum size of rootfs quota to 4k
Subject: [PATCH 06/37] limit the minimum size of rootfs quota to 4k
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
---
......
From f5bdf22f390f2d20af29636098d63cdaaef6468c Mon Sep 17 00:00:00 2001
From f5f6a6e55afd1353ceea2f74527f5a203225a096 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Thu, 18 Apr 2019 05:04:18 -0400
Subject: [PATCH 07/36] delete: try to delete metadata before image data
Subject: [PATCH 07/37] delete: try to delete metadata before image data
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 60cdcc3e99ff0b382a5ca539bbc50328f1707ee9 Mon Sep 17 00:00:00 2001
From 654c62f8394df45c44e17986dab6627ee4d96e64 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Fri, 19 Apr 2019 17:15:29 +0800
Subject: [PATCH 08/36] same add group should skip
Subject: [PATCH 08/37] same add group should skip
same add group should skip
......
From 4b188352b46166957f89c4101828fbdeb5d50eae Mon Sep 17 00:00:00 2001
From b9e6b87b78147729e6dcd4f955de09eaec4c53de Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Thu, 25 Apr 2019 18:00:18 +0800
Subject: [PATCH 09/36] optimize concurrent run
Subject: [PATCH 09/37] optimize concurrent run
Signed-off-by: LiuHao <liuhao27@huawei.com>
---
......
From e10a727c2ec3b1c35fbc3d7928ab1c987ded5f0c Mon Sep 17 00:00:00 2001
From 420a2ec5ae34d42c6361f3123307874cd0ff0a1e Mon Sep 17 00:00:00 2001
From: WuJing <wujing50@huawei.com>
Date: Mon, 29 Apr 2019 16:46:09 +0800
Subject: [PATCH 10/36] abnormal scene container restart failure
Subject: [PATCH 10/37] abnormal scene container restart failure
Solve the problem that the mountpoint.json write
fails due to an abnormal condition, causing the container to fail to
......
From eef14df9dbcdc8ed98df2e1ca34a2c96fb1ca6ce Mon Sep 17 00:00:00 2001
From c9890f1fb754921b3a90ce598dfe458c8c6c345f Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Thu, 2 May 2019 11:25:07 +0800
Subject: [PATCH 11/36] optimize isulad_kit operator
Subject: [PATCH 11/37] optimize isulad_kit operator
get mountpoint from driver
......
From 3f8136d741d43733b748282437ab1cefbbc40ef4 Mon Sep 17 00:00:00 2001
From 9d010779f6255b43b4843e882db9d5b0495253ce Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Thu, 2 May 2019 11:56:34 +0800
Subject: [PATCH 12/36] fix compile error
Subject: [PATCH 12/37] fix compile error
fix compile error
......
From 4a4aa498b60f093a746bc65b7c5781aed9e15ac1 Mon Sep 17 00:00:00 2001
From 5167f076622fa190ff3ae2af6b0bd3e61ceebe4d Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Tue, 7 May 2019 03:40:58 -0400
Subject: [PATCH 13/36] rmi: try to remove all layers info when rmi
Subject: [PATCH 13/37] rmi: try to remove all layers info when rmi
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 2724c1b047a7b6aea3c7faee96c38a12089f379e Mon Sep 17 00:00:00 2001
From 3a59a13f5b103980ef01fa4aa3d0f8c276e3fa0e Mon Sep 17 00:00:00 2001
From: WuJing <wujing50@huawei.com>
Date: Mon, 13 May 2019 09:31:43 +0800
Subject: [PATCH 14/36] isulad-kit-vendor: ensure remove container rootfs dir
Subject: [PATCH 14/37] isulad-kit-vendor: ensure remove container rootfs dir
when errmsg contain "File name too long"
Signed-off-by: WuJing <wujing50@huawei.com>
......
From 315cf6d215b17c6f052ca4cbb1d6105769f9df65 Mon Sep 17 00:00:00 2001
From a28065dbd5df1702ce2148560836442c19ac6863 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Mon, 13 May 2019 04:58:15 -0400
Subject: [PATCH 15/36] split mountpoints.json and layers.json in save
Subject: [PATCH 15/37] split mountpoints.json and layers.json in save
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 46a60027c865a9d0b8526a29843a2c2faf669cc3 Mon Sep 17 00:00:00 2001
From ddb631ff907033a74f101dece5760913b8dcd43c Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Mon, 20 May 2019 10:05:08 -0400
Subject: [PATCH 16/36] isulad-kit-vendor: fix bug of concurrent run with quota
Subject: [PATCH 16/37] isulad-kit-vendor: fix bug of concurrent run with quota
reason: setProjectQuota using common mutex to avoid set the same
project id for diffrent containers, this may also get the same
......
From 68685fc92cd849a9d5dfedfbf5039a7326f7e8d9 Mon Sep 17 00:00:00 2001
From 193e4048d49956aff329fe2fa63b423c1cb713c1 Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Mon, 20 May 2019 10:31:12 -0400
Subject: [PATCH 17/36] isulad-kit-vendor: fix compile error
Subject: [PATCH 17/37] isulad-kit-vendor: fix compile error
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
---
......
From a9be184d2c7e7e3a1d70297bfcf0185eb249efde Mon Sep 17 00:00:00 2001
From ea69ffc60a7c3a93e4ebef0ea1497f1d0e8e5dcf Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Mon, 20 May 2019 10:45:55 -0400
Subject: [PATCH 18/36] remove unused code
Subject: [PATCH 18/37] remove unused code
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
---
......
From 2496c8e1029b1c51a8ebd47e77b9eb02f4a10815 Mon Sep 17 00:00:00 2001
From c91a85aae78398cd6dcbe0b38c1af2da752aa946 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Sat, 25 May 2019 16:45:28 +0800
Subject: [PATCH 19/36] optimize mount operator
Subject: [PATCH 19/37] optimize mount operator
1. split mountpoints.json to each container
2. refactor mount operator
......
From b4174d72b1efc7323b197f5a2ba8a55acdbb4e03 Mon Sep 17 00:00:00 2001
From 5001edbbd86cfd7164b290ff9d3bee746fb2d375 Mon Sep 17 00:00:00 2001
From: WuJing <wujing50@huawei.com>
Date: Mon, 10 Jun 2019 10:54:43 +0800
Subject: [PATCH 20/36] Fix file retention bug
Subject: [PATCH 20/37] Fix file retention bug
Signed-off-by: WuJing <wujing50@huawei.com>
---
......
From 291a1e0293b99682aa06344060c37c729490cb62 Mon Sep 17 00:00:00 2001
From cf6464af330439fbf7763e9ba7456515600e944f Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Mon, 10 Jun 2019 09:41:44 -0400
Subject: [PATCH 21/36] set layer MountCount = 0 without mount point file
Subject: [PATCH 21/37] set layer MountCount = 0 without mount point file
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 65c6f8c935e097cdb327dac340c47ee0a4471602 Mon Sep 17 00:00:00 2001
From f23d263ccf551017bc86a13f0bf04c3ee9873ede Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Tue, 18 Jun 2019 14:12:33 +0800
Subject: [PATCH 22/36] encrypt auth config and add lock
Subject: [PATCH 22/37] encrypt auth config and add lock
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
......
From a061147df6c1d3b4b205657eee2d6055afc115ff Mon Sep 17 00:00:00 2001
From 2fbb90f68f87597569cd686085b239f62060fbeb Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Thu, 4 Jul 2019 16:19:56 +0800
Subject: [PATCH 23/36] Change perm and add max file size check
Subject: [PATCH 23/37] Change perm and add max file size check
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
......
From 8d0d631cb2cdf258ef9f1e89ba3497fc72fbfd1f Mon Sep 17 00:00:00 2001
From bbfe1a3844ff4d88aaae519123b937cecee514ad Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Thu, 18 Jul 2019 06:20:49 -0400
Subject: [PATCH 24/36] force remove dir with rm -rf in overlay
Subject: [PATCH 24/37] force remove dir with rm -rf in overlay
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 782c955510a07fc1d6f1c5fb7a485cd43c93ff8d Mon Sep 17 00:00:00 2001
From 1a3be010a715df71af3f1b61246ff75348d8a452 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Mon, 22 Jul 2019 03:52:09 -0400
Subject: [PATCH 25/36] EnsureRemoveAll make retry count from 5 to 50
Subject: [PATCH 25/37] EnsureRemoveAll make retry count from 5 to 50
Signed-off-by: LiFeng <lifeng68@huawei.com>
---
......
From 28aa24ed1ec091bd61e13692e65050430cbfb867 Mon Sep 17 00:00:00 2001
From 523e6a902a1e2dae947421370e40cfac5725934f Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Fri, 26 Jul 2019 05:02:55 -0400
Subject: [PATCH 26/36] report error log when openDir failed
Subject: [PATCH 26/37] report error log when openDir failed
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
---
......
From 6ae84f437fb15f87b5381ed056612bab9bfba611 Mon Sep 17 00:00:00 2001
From 6ff1ba894899239f57deec966b9b9e2d1f2d4e98 Mon Sep 17 00:00:00 2001
From: TanYiFeng <tanyifeng1@huawei.com>
Date: Fri, 9 Aug 2019 04:56:23 -0400
Subject: [PATCH 27/36] ignore ENOENT if direcotry has been removed when find
Subject: [PATCH 27/37] ignore ENOENT if direcotry has been removed when find
next project id
Signed-off-by: TanYiFeng <tanyifeng1@huawei.com>
......
From 38a5d508cb9593d5d7b70c3361eff903974027f5 Mon Sep 17 00:00:00 2001
From 423545e527d373ea976884fd05ffef25ce8e7be2 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Fri, 9 Aug 2019 17:07:33 +0800
Subject: [PATCH 28/36] fixbug: cause by remove container.json in run dir
Subject: [PATCH 28/37] fixbug: cause by remove container.json in run dir
Start container will load container.json in run dir.
If it is not exist, start container will failed.
......
From eed1348a99a18c42089e158e08e35cd7798c606c Mon Sep 17 00:00:00 2001
From 61ceed8464bf6a2767f2dd9c62eb9da14391fe4a Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Tue, 26 Nov 2019 22:06:55 -0500
Subject: [PATCH 29/36] Performace optimization
Subject: [PATCH 29/37] Performace optimization
1.Seprate big json file to small json files.
2.Migation json files for above change.
......
From 7e0daaa3f830df102cc0b9786489c7b5b0557632 Mon Sep 17 00:00:00 2001
From 5bac67122bb7b5befd503974dbc4274c7d95e820 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Mon, 18 Nov 2019 21:20:52 -0500
Subject: [PATCH 30/36] Support load multiple images
Subject: [PATCH 30/37] Support load multiple images
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
......
From 53aca5c99d9d5eb93543dfddf0586b5946ed5f99 Mon Sep 17 00:00:00 2001
From 24f58184c79c7de74ea52fd6781679e3a047a2c6 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Fri, 29 Nov 2019 03:21:02 -0500
Subject: [PATCH 31/36] SWR response "406: Not Acceptable" if oci image in
Subject: [PATCH 31/37] SWR response "406: Not Acceptable" if oci image in
first
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
......
From 6af87b667a88261c5fcdf32084b6ba6ecffaf5aa Mon Sep 17 00:00:00 2001
From fecd27d50474bbbcd5f2a8d5ed6240872901bdab Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Thu, 5 Dec 2019 10:13:52 +0800
Subject: [PATCH 32/36] log message of get mountpoint failed
Subject: [PATCH 32/37] log message of get mountpoint failed
Signed-off-by: LiuHao <liuhao27@huawei.com>
---
......
From 4707f8e197c0e866fb4b6baaf27ef4bae95d35ca Mon Sep 17 00:00:00 2001
From 599d6b66660450c8e0a295969e4dd89320ea2364 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Wed, 18 Dec 2019 07:29:06 -0500
Subject: [PATCH 33/36] Save config to disk if images's name is removed
Subject: [PATCH 33/37] Save config to disk if images's name is removed
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
......
From ab310e61892b3449623b3364b178319a310a91fc Mon Sep 17 00:00:00 2001
From ce4593eef5016d2ce5e937655e79eb1f18239efa Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Mon, 30 Dec 2019 10:20:56 +0800
Subject: [PATCH 34/36] Try to repair lowers file if current layer is reusing
Subject: [PATCH 34/37] Try to repair lowers file if current layer is reusing
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
......
From 189ac377307c9041399f45a6a8ed05fb67368b38 Mon Sep 17 00:00:00 2001
From e4a16f7d3bb9ad7a75bdd58d4c54c4e8b09e8697 Mon Sep 17 00:00:00 2001
From: Matthew Heon <matthew.heon@pm.me>
Date: Wed, 5 Jun 2019 15:07:44 -0400
Subject: [PATCH 35/36] Fix CVE-2018-15664
Subject: [PATCH 35/37] Fix CVE-2018-15664
Cherry-pick moby/moby #39292 for CVE-2018-15664 fixes
......
From c65d63c0c34d1b4fb60f7b481829560a9913b0d5 Mon Sep 17 00:00:00 2001
From dfba4591d298351872265e341cdb2a947e780420 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Fri, 17 Jan 2020 02:50:13 -0500
Subject: [PATCH 36/36] Change interface of AES
Subject: [PATCH 36/37] Change interface of AES
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
......
From 415fb96c0f9d02f92acd1392209e95749d916b52 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Sun, 19 Jan 2020 11:25:09 +0800
Subject: [PATCH 37/37] Fix some devicemapper bugs
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
.../storage/drivers/devmapper/deviceset.go | 74 +++++++++++++++++--
.../storage/drivers/devmapper/driver.go | 44 ++++++++---
.../storage/drivers/devmapper/sem_stat.go | 36 +++++++++
.../storage/pkg/devicemapper/devmapper.go | 65 ++++++++++++++--
.../pkg/devicemapper/devmapper_wrapper.go | 72 ++++++++++++++++++
vendor/github.com/containers/storage/store.go | 7 +-
6 files changed, 274 insertions(+), 24 deletions(-)
create mode 100644 vendor/github.com/containers/storage/drivers/devmapper/sem_stat.go
diff --git a/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go b/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
index b6f22e9..4ebad51 100644
--- a/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
+++ b/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
@@ -34,13 +34,16 @@ import (
)
var (
- defaultDataLoopbackSize int64 = 100 * 1024 * 1024 * 1024
- defaultMetaDataLoopbackSize int64 = 2 * 1024 * 1024 * 1024
- defaultBaseFsSize uint64 = 10 * 1024 * 1024 * 1024
- defaultThinpBlockSize uint32 = 128 // 64K = 128 512b sectors
- defaultUdevSyncOverride = false
- maxDeviceID = 0xffffff // 24 bit, pool limit
- deviceIDMapSz = (maxDeviceID + 1) / 8
+ defaultDataLoopbackSize int64 = 100 * 1024 * 1024 * 1024
+ defaultMetaDataLoopbackSize int64 = 2 * 1024 * 1024 * 1024
+ defaultBaseFsSize uint64 = 10 * 1024 * 1024 * 1024
+ defaultThinpBlockSize uint32 = 128 // 64K = 128 512b sectors
+ defaultUdevSyncOverride = false
+ maxDeviceID = 0xffffff // 24 bit, pool limit
+ deviceIDMapSz = (maxDeviceID + 1) / 8
+ // The default timeout for latest systemd on RTOS and EulerOS is 180s
+ // we use 185s to make sure the timeout really happened.
+ defaultUdevWaitTimeout = 185
driverDeferredRemovalSupport = false
enableDeferredRemoval = false
enableDeferredDeletion = false
@@ -1409,6 +1412,8 @@ func (devices *DeviceSet) rollbackTransaction() error {
devices.markDeviceIDFree(devices.DeviceID)
}
+ delete(devices.Devices, dinfo.Hash)
+
if err := devices.removeTransactionMetaData(); err != nil {
logrus.Errorf("devmapper: Unable to remove transaction meta file %s: %s", devices.transactionMetaFile(), err)
}
@@ -1746,6 +1751,35 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) {
devices.devicePrefix = fmt.Sprintf("container-%d:%d-%d", major(st.Dev), minor(st.Dev), st.Ino)
logrus.Debugf("devmapper: Generated prefix: %s", devices.devicePrefix)
+ deviceNames, err := devicemapper.GetDeviceList()
+ if err != nil {
+ logrus.Debugf("devmapper: Failed to get device list: %s", err)
+ }
+
+ for _, name := range deviceNames {
+ if !strings.HasPrefix(name, devices.devicePrefix) {
+ continue
+ }
+ _, length, _, _, err := devicemapper.GetStatus(name)
+ if err != nil {
+ logrus.Warnf("devmapper: get device status(%s): %s", name, err)
+ continue
+ }
+ // remove broken device
+ if length == 0 {
+ if err := devicemapper.RemoveDevice(name); err != nil {
+ logrus.Warnf("devmapper: remove broken device(%s): %s", name, err)
+ }
+ logrus.Debugf("devmapper: remove broken device: %s", name)
+ }
+ if _, err := os.Stat(filepath.Join("/dev/mapper/", name)); err != nil {
+ if err := devicemapper.RemoveDevice(name); err != nil {
+ logrus.Warnf("devmapper: remove incompelete device(%s): %v", name, err)
+ }
+ logrus.Debugf("devmapper: remove incompelete device: %s", name)
+ }
+ }
+
// Check for the existence of the thin-pool device
poolExists, err := devices.thinPoolExists(devices.getPoolName())
if err != nil {
@@ -2161,6 +2195,13 @@ func (devices *DeviceSet) deactivateDeviceMode(info *devInfo, deferredRemove boo
if deferredRemove {
err = devicemapper.RemoveDeviceDeferred(info.Name())
+ if err != nil {
+ if err == devicemapper.ErrEnxio {
+ logrus.Warnf("devmapper: device %s has gone", info.Name())
+ return nil
+ }
+ return err
+ }
} else {
err = devices.removeDevice(info.Name())
}
@@ -2445,6 +2486,18 @@ func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error {
}
logrus.Debug("devmapper: Unmount done")
+ // Remove the mountpoint here. Removing the mountpoint (in newer kernels)
+ // will cause all other instances of this mount in other mount namespaces
+ // to be killed (this is an anti-DoS measure that is necessary for things
+ // like devicemapper). This is necessary to avoid cases where a libdm mount
+ // that is present in another namespace will cause subsequent RemoveDevice
+ // operations to fail. We ignore any errors here because this may fail on
+ // older kernels which don't have
+ // torvalds/linux@8ed936b5671bfb33d89bc60bdcc7cf0470ba52fe applied.
+ if err := os.Remove(mountPath); err != nil {
+ logrus.Debugf("devmapper: error doing a remove on unmounted device %s: %v", mountPath, err)
+ }
+
return devices.deactivateDevice(info)
}
@@ -2665,6 +2718,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
foundBlkDiscard := false
var lvmSetupConfig directLVMConfig
+ udevWaitTimeout := int64(defaultUdevWaitTimeout)
testMode := false
for _, option := range options {
key, val, err := parsers.ParseKeyValueOpt(option)
@@ -2815,6 +2869,11 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
devicemapper.LogInit(devicemapper.DefaultLogger{
Level: int(level),
})
+ case "dm.udev_wait_timeout":
+ udevWaitTimeout, err = strconv.ParseInt(val, 10, 32)
+ if err != nil {
+ return nil, err
+ }
case "test":
testMode, err = strconv.ParseBool(val)
if err != nil {
@@ -2824,6 +2883,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
return nil, fmt.Errorf("devmapper: Unknown option %s", key)
}
}
+ devicemapper.SetUdevWaitTimtout(udevWaitTimeout)
if !testMode {
if err := validateLVMConfig(lvmSetupConfig); err != nil {
diff --git a/vendor/github.com/containers/storage/drivers/devmapper/driver.go b/vendor/github.com/containers/storage/drivers/devmapper/driver.go
index 39a4fbe..f80643f 100644
--- a/vendor/github.com/containers/storage/drivers/devmapper/driver.go
+++ b/vendor/github.com/containers/storage/drivers/devmapper/driver.go
@@ -14,9 +14,10 @@ import (
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/locker"
"github.com/containers/storage/pkg/mount"
- "github.com/containers/storage/pkg/system"
units "github.com/docker/go-units"
+ "github.com/pkg/errors"
"github.com/sirupsen/logrus"
+ "golang.org/x/sys/unix"
)
func init() {
@@ -40,10 +41,6 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
return nil, err
}
- if err := mount.MakePrivate(home); err != nil {
- return nil, err
- }
-
d := &Driver{
DeviceSet: deviceSet,
home: home,
@@ -94,6 +91,14 @@ func (d *Driver) Status() [][2]string {
if vStr, err := devicemapper.GetLibraryVersion(); err == nil {
status = append(status, [2]string{"Library Version", vStr})
}
+
+ usz, mni, err := checkSemSetStat()
+ status = append(status, [2]string{"Semaphore Set Used", fmt.Sprintf("%d", usz)})
+ status = append(status, [2]string{"Semaphore Set Total", fmt.Sprintf("%d", mni)})
+ if err != nil {
+ status = append(status, [2]string{"WARNING", fmt.Sprintf("%v", err)})
+ }
+
return status
}
@@ -109,18 +114,25 @@ func (d *Driver) Metadata(id string) (map[string]string, error) {
metadata["DeviceId"] = strconv.Itoa(m.deviceID)
metadata["DeviceSize"] = strconv.FormatUint(m.deviceSize, 10)
metadata["DeviceName"] = m.deviceName
+ metadata["MergedDir"] = path.Join(d.home, "mnt", id, "rootfs")
return metadata, nil
}
// Cleanup unmounts a device.
func (d *Driver) Cleanup() error {
err := d.DeviceSet.Shutdown(d.home)
+ umountErr := mount.RecursiveUnmount(d.home)
+
+ // in case we have two errors, prefer the one from Shutdown()
+ if err != nil {
+ return err
+ }
- if err2 := mount.Unmount(d.home); err == nil {
- err = err2
+ if umountErr != nil {
+ return errors.Wrapf(umountErr, "error unmounting %s", d.home)
}
- return err
+ return nil
}
// CreateReadWrite creates a layer that is writable for use as a container
@@ -158,7 +170,21 @@ func (d *Driver) Remove(id string) error {
if err := d.DeviceSet.DeleteDevice(id, false); err != nil {
return fmt.Errorf("failed to remove device %s: %v", id, err)
}
- return system.EnsureRemoveAll(path.Join(d.home, "mnt", id))
+
+ // Most probably the mount point is already removed on Put()
+ // (see DeviceSet.UnmountDevice()), but just in case it was not
+ // let's try to remove it here as well, ignoring errors as
+ // an older kernel can return EBUSY if e.g. the mount was leaked
+ // to other mount namespaces. A failure to remove the container's
+ // mount point is not important and should not be treated
+ // as a failure to remove the container.
+ mp := path.Join(d.home, "mnt", id)
+ err := unix.Rmdir(mp)
+ if err != nil && !os.IsNotExist(err) {
+ logrus.WithField("storage-driver", "devicemapper").Warnf("unable to remove mount point %q: %s", mp, err)
+ }
+
+ return nil
}
// Get mounts a device with given id into the root filesystem
diff --git a/vendor/github.com/containers/storage/drivers/devmapper/sem_stat.go b/vendor/github.com/containers/storage/drivers/devmapper/sem_stat.go
new file mode 100644
index 0000000..2aa90c1
--- /dev/null
+++ b/vendor/github.com/containers/storage/drivers/devmapper/sem_stat.go
@@ -0,0 +1,36 @@
+// Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
+// iSulad-kit licensed under the Mulan PSL v1.
+// You can use this software according to the terms and conditions of the Mulan PSL v1.
+// You may obtain a copy of Mulan PSL v1 at:
+// http://license.coscl.org.cn/MulanPSL
+// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
+// PURPOSE.
+// See the Mulan PSL v1 for more details.
+// Description: iSulad image kit
+// Author: liruilin
+// Create: 2019-01-19
+
+package devmapper
+
+/*
+#include <sys/types.h>
+#include <sys/sem.h>
+int mysemctl(int cmd, struct seminfo *p){
+ return semctl(0, 0, cmd, p);
+}
+*/
+import "C"
+import (
+ "fmt"
+)
+
+func checkSemSetStat() (int, int, error) {
+ var seminfo *C.struct_seminfo = new(C.struct_seminfo)
+ C.mysemctl(C.SEM_INFO, seminfo)
+ var err error = nil
+ if seminfo.semusz == seminfo.semmni {
+ err = fmt.Errorf("system semaphore nums has attached limit: %d", int(seminfo.semusz))
+ }
+ return int(seminfo.semusz), int(seminfo.semmni), err
+}
diff --git a/vendor/github.com/containers/storage/pkg/devicemapper/devmapper.go b/vendor/github.com/containers/storage/pkg/devicemapper/devmapper.go
index 6a0ac24..48d760c 100644
--- a/vendor/github.com/containers/storage/pkg/devicemapper/devmapper.go
+++ b/vendor/github.com/containers/storage/pkg/devicemapper/devmapper.go
@@ -7,6 +7,7 @@ import (
"fmt"
"os"
"runtime"
+ "time"
"unsafe"
"github.com/sirupsen/logrus"
@@ -54,11 +55,13 @@ var (
ErrTaskGetDeps = errors.New("dm_task_get_deps failed")
ErrTaskGetInfo = errors.New("dm_task_get_info failed")
ErrTaskGetDriverVersion = errors.New("dm_task_get_driver_version failed")
+ ErrTaskGetNames = errors.New("dm_task_get_names failed")
ErrTaskDeferredRemove = errors.New("dm_task_deferred_remove failed")
ErrTaskSetCookie = errors.New("dm_task_set_cookie failed")
ErrNilCookie = errors.New("cookie ptr can't be nil")
ErrGetBlockSize = errors.New("Can't get block size")
ErrUdevWait = errors.New("wait on udev cookie failed")
+ ErrUdevWaitTimeout = errors.New("wait on udev cookie time out")
ErrSetDevDir = errors.New("dm_set_dev_dir failed")
ErrGetLibraryVersion = errors.New("dm_get_library_version failed")
ErrCreateRemoveTask = errors.New("Can't create task of type deviceRemove")
@@ -70,9 +73,11 @@ var (
)
var (
- dmSawBusy bool
- dmSawExist bool
- dmSawEnxio bool // No Such Device or Address
+ dmSawBusy bool
+ dmSawExist bool
+ dmSawEnxio bool // No Such Device or Address
+ dmSawEnoData bool // No data available
+ dmUdevWaitTimeout int64
)
type (
@@ -236,6 +241,14 @@ func (t *Task) getInfoWithDeferred() (*Info, error) {
return info, nil
}
+func (t *Task) getDeviceList() ([]string, error) {
+ res := DmTaskGetNames(t.unmanaged)
+ if res == nil {
+ return nil, ErrTaskGetNames
+ }
+ return res, nil
+}
+
func (t *Task) getDriverVersion() (string, error) {
res := DmTaskGetDriverVersion(t.unmanaged)
if res == "" {
@@ -254,13 +267,36 @@ func (t *Task) getNextTarget(next unsafe.Pointer) (nextPtr unsafe.Pointer, start
// UdevWait waits for any processes that are waiting for udev to complete the specified cookie.
func UdevWait(cookie *uint) error {
- if res := DmUdevWait(*cookie); res != 1 {
- logrus.Debugf("devicemapper: Failed to wait on udev cookie %d, %d", *cookie, res)
- return ErrUdevWait
+ chError := make(chan error)
+ go func() {
+ if res := DmUdevWait(*cookie); res != 1 {
+ logrus.Debugf("Failed to wait on udev cookie %d", *cookie)
+ chError <- ErrUdevWait
+ }
+ chError <- nil
+ }()
+ select {
+ case err := <-chError:
+ return err
+ case <-time.After(time.Second * time.Duration(dmUdevWaitTimeout)):
+ logrus.Errorf("Failed to wait on udev cookie %d: timeout %v", *cookie, dmUdevWaitTimeout)
+ if res := DmUdevComplete(*cookie); res != 1 {
+ // This is bad to return here
+ logrus.Errorf("Failed to complete udev cookie %d on udev wait timeout", *cookie)
+ return ErrUdevWaitTimeout
+ }
+ // wait DmUdevWait return after DmUdevComplete
+ <-chError
+ return ErrUdevWaitTimeout
}
return nil
}
+// SetUdevWaitTimtout sets udev wait timeout
+func SetUdevWaitTimtout(t int64) {
+ dmUdevWaitTimeout = t
+}
+
// SetDevDir sets the dev folder for the device mapper library (usually /dev).
func SetDevDir(dir string) error {
if res := DmSetDevDir(dir); res != 1 {
@@ -543,6 +579,18 @@ func GetInfoWithDeferred(name string) (*Info, error) {
return task.getInfoWithDeferred()
}
+// GetDevices get all device name
+func GetDeviceList() ([]string, error) {
+ task := TaskCreate(deviceList)
+ if task == nil {
+ return nil, fmt.Errorf("devicemapper: Can't create deviceList task")
+ }
+ if err := task.run(); err != nil {
+ return nil, err
+ }
+ return task.getDeviceList()
+}
+
// GetDriverVersion is the programmatic example of "dmsetup version".
// It outputs version information of the driver.
func GetDriverVersion() (string, error) {
@@ -710,10 +758,15 @@ func DeleteDevice(poolName string, deviceID int) error {
}
dmSawBusy = false
+ dmSawEnoData = false
if err := task.run(); err != nil {
if dmSawBusy {
return ErrBusy
}
+ if dmSawEnoData {
+ logrus.Debugf("devicemapper: Device(id: %d) from pool(%s) does not exist", deviceID, poolName)
+ return nil
+ }
return fmt.Errorf("devicemapper: Error running DeleteDevice %s", err)
}
return nil
diff --git a/vendor/github.com/containers/storage/pkg/devicemapper/devmapper_wrapper.go b/vendor/github.com/containers/storage/pkg/devicemapper/devmapper_wrapper.go
index 190d83d..b7fd8b8 100644
--- a/vendor/github.com/containers/storage/pkg/devicemapper/devmapper_wrapper.go
+++ b/vendor/github.com/containers/storage/pkg/devicemapper/devmapper_wrapper.go
@@ -6,6 +6,9 @@ package devicemapper
#define _GNU_SOURCE
#include <libdevmapper.h>
#include <linux/fs.h> // FIXME: present only for BLKGETSIZE64, maybe we can remove it?
+#include <string.h>
+#include <stdlib.h>
+
// FIXME: Can't we find a way to do the logging in pure Go?
extern void StorageDevmapperLogCallback(int level, char *file, int line, int dm_errno_or_class, char *str);
@@ -32,6 +35,51 @@ static void log_with_errno_init()
{
dm_log_with_errno_init(log_cb);
}
+
+// FIXME: how to use dm_task_get_names directly
+static char **local_dm_task_get_names(struct dm_task *dmt, unsigned int *size) {
+ struct dm_names *ns, *ns1;
+ unsigned next = 0;
+ char **result;
+ int i = 0;
+
+ if (!(ns = dm_task_get_names(dmt)))
+ return NULL;
+
+ // No devices found
+ if (!ns->dev)
+ return NULL;
+
+ // calucate the total devices
+ ns1 = ns;
+ *size = 0;
+ do {
+ ns1 = (struct dm_names *)((char *) ns1 + next);
+ (*size)++;
+ next = ns1->next;
+ } while (next);
+
+ result = malloc(sizeof(char *)* (*size));
+ if (!result)
+ return NULL;
+
+ next = 0;
+ do {
+ ns = (struct dm_names *)((char *) ns + next);
+ result[i++] = strdup(ns->name);
+ next = ns->next;
+ } while (next);
+
+ return result;
+}
+
+void free_devices_names(char **names, unsigned int size) {
+ int i;
+
+ for (i = 0; i < size; i++)
+ free(names[i]);
+ free(names);
+}
*/
import "C"
@@ -69,6 +117,7 @@ var (
DmTaskGetDeps = dmTaskGetDepsFct
DmTaskGetInfo = dmTaskGetInfoFct
DmTaskGetDriverVersion = dmTaskGetDriverVersionFct
+ DmTaskGetNames = dmTaskGetNamesFct
DmTaskRun = dmTaskRunFct
DmTaskSetAddNode = dmTaskSetAddNodeFct
DmTaskSetCookie = dmTaskSetCookieFct
@@ -77,6 +126,7 @@ var (
DmTaskSetRo = dmTaskSetRoFct
DmTaskSetSector = dmTaskSetSectorFct
DmUdevWait = dmUdevWaitFct
+ DmUdevComplete = dmUdevCompleteFct
DmUdevSetSyncSupport = dmUdevSetSyncSupportFct
DmUdevGetSyncSupport = dmUdevGetSyncSupportFct
DmCookieSupported = dmCookieSupportedFct
@@ -189,6 +239,24 @@ func dmTaskGetInfoFct(task *cdmTask, info *Info) int {
return int(C.dm_task_get_info((*C.struct_dm_task)(task), &Cinfo))
}
+func dmTaskGetNamesFct(task *cdmTask) []string {
+ var res []string
+ var names []*C.char
+ len := C.uint(0)
+ Cnames := C.local_dm_task_get_names((*C.struct_dm_task)(task), &len)
+ defer C.free_devices_names(Cnames, len)
+
+ hdr := (*reflect.SliceHeader)(unsafe.Pointer(&names))
+ hdr.Cap = int(len)
+ hdr.Len = int(len)
+ hdr.Data = uintptr(unsafe.Pointer(Cnames))
+
+ for _, name := range names {
+ res = append(res, C.GoString(name))
+ }
+ return res
+}
+
func dmTaskGetDriverVersionFct(task *cdmTask) string {
buffer := C.malloc(128)
defer C.free(buffer)
@@ -227,6 +295,10 @@ func dmUdevWaitFct(cookie uint) int {
return int(C.dm_udev_wait(C.uint32_t(cookie)))
}
+func dmUdevCompleteFct(cookie uint) int {
+ return int(C.dm_udev_complete(C.uint32_t(cookie)))
+}
+
func dmCookieSupportedFct() int {
return int(C.dm_cookie_supported())
}
diff --git a/vendor/github.com/containers/storage/store.go b/vendor/github.com/containers/storage/store.go
index f346dc9..2ebd558 100644
--- a/vendor/github.com/containers/storage/store.go
+++ b/vendor/github.com/containers/storage/store.go
@@ -2833,12 +2833,15 @@ func (s *store) Unmount(id string, force bool) (bool, error) {
if err != nil {
return false, err
}
+
rlstore.Lock()
- defer rlstore.Unlock()
if modified, err := rlstore.Modified(); modified || err != nil {
rlstore.Load()
}
- if rlstore.Exists(id) {
+ exist := rlstore.Exists(id)
+ rlstore.Unlock()
+
+ if exist {
return rlstore.Unmount(id, force)
}
return false, ErrLayerUnknown
--
2.19.1
......@@ -34,3 +34,4 @@
0034-Try-to-repair-lowers-file-if-current-layer-is-reusin.patch
0035-Fix-CVE-2018-15664.patch
0036-Change-interface-of-AES.patch
0037-Fix-some-devicemapper-bugs.patch
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册