blob: 40a9ac6aaeb0af933f3b36858e34a1801f07eb96 [file] [log] [blame]
Lorenz Brun37050122021-03-30 14:00:27 +02001Copyright 2020 The Monogon Project Authors.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14
15
16From f0c9fc613c15e30453295beb25bf73763a4a82df Mon Sep 17 00:00:00 2001
17From: Lorenz Brun <lorenz@brun.one>
18Date: Mon, 29 Mar 2021 13:56:06 +0200
19Subject: [PATCH] Removed questionable block device pseudo-locks
20
21This code implements a weird sort of lock using Linux loop devices. It's not exclusive (multiple loop devices per
22backing device are supported) and the devices themselves are not accessed. The lock is also not exclusive as multiple
23loop devices per backing device are allowed. The only mention of why any of this is done is in the comment below, stating
24that it is possible that a device can be removed and another device can be attached with the same name. In Metropolis
25this is not a problem as our CSI/Provisioner setup exercises tight control over devices, thus silent removals are not
26possible.
27
28Because this code calls the losetup utility which Metropolis doesn't want to ship and also repeatedly lists loop devices
29in an inefficient manner which will cause problems with the anticipated density of VM-hosting Metropolis nodes and
30does nothing for us, let's just nuke it instead of rewriting it against //metropolis/pkg/loop.
31---
32 pkg/volume/util/util.go | 18 ------------------
33 1 file changed, 18 deletions(-)
34
35diff --git a/pkg/volume/util/util.go b/pkg/volume/util/util.go
36index 367e05a0d1a..f53f1dcbb4e 100644
37--- a/pkg/volume/util/util.go
38+++ b/pkg/volume/util/util.go
39@@ -527,17 +527,6 @@ func MapBlockVolume(
40 return fmt.Errorf("blkUtil.MapDevice failed. devicePath: %s, podVolumeMapPath:%s, volumeMapName: %s, bindMount: %v: %v",
41 devicePath, podVolumeMapPath, volumeMapName, false, mapErr)
42 }
43-
44- // Take file descriptor lock to keep a block device opened. Otherwise, there is a case
45- // that the block device is silently removed and attached another device with the same name.
46- // Container runtime can't handle this problem. To avoid unexpected condition fd lock
47- // for the block device is required.
48- _, mapErr = blkUtil.AttachFileDevice(filepath.Join(globalMapPath, string(podUID)))
49- if mapErr != nil {
50- return fmt.Errorf("blkUtil.AttachFileDevice failed. globalMapPath:%s, podUID: %s: %v",
51- globalMapPath, string(podUID), mapErr)
52- }
53-
54 return nil
55 }
56
57@@ -551,13 +540,6 @@ func UnmapBlockVolume(
58 volumeMapName string,
59 podUID utypes.UID,
60 ) error {
61- // Release file descriptor lock.
62- err := blkUtil.DetachFileDevice(filepath.Join(globalUnmapPath, string(podUID)))
63- if err != nil {
64- return fmt.Errorf("blkUtil.DetachFileDevice failed. globalUnmapPath:%s, podUID: %s: %v",
65- globalUnmapPath, string(podUID), err)
66- }
67-
68 // unmap devicePath from pod volume path
69 unmapDeviceErr := blkUtil.UnmapDevice(podDeviceUnmapPath, volumeMapName, false /* bindMount */)
70 if unmapDeviceErr != nil {
71--
722.25.1
73