From 42da0fd120db6f5b34c523212b54b88e8837efa6 Mon Sep 17 00:00:00 2001
From: jingrui <jingrui@huawei.com>
Date: Thu, 3 Jan 2019 14:09:59 +0800
Subject: [PATCH 038/111] devmapper:  devicemapper: ignore error when
 remove a device which does not exist

reason: cherry-pick commits to docker-18.09

cherry-pick from
e91268fda7 | * devicemapper: ignore error when remove a device which
does not exist

Conflicts:
	daemon/graphdriver/devmapper/deviceset.go
	pkg/devicemapper/devmapper.go

Change-Id: Ia1d33d78e4d7000c6e4bd54ec203800a0234cae5
Signed-off-by: Liu Hua <sdu.liu@huawei.com>
Signed-off-by: jingrui <jingrui@huawei.com>
---
 .../engine/daemon/graphdriver/devmapper/deviceset.go       | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/components/engine/daemon/graphdriver/devmapper/deviceset.go b/components/engine/daemon/graphdriver/devmapper/deviceset.go
index 0675b2eacd..be48d92e8d 100644
--- a/components/engine/daemon/graphdriver/devmapper/deviceset.go
+++ b/components/engine/daemon/graphdriver/devmapper/deviceset.go
@@ -2137,6 +2137,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())
 	}
-- 
2.17.1

