blob: c0da3e05e0888fa7f3dffcc4ff963544cdd6e26d [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
Lorenz Brun6211e4d2023-11-14 19:09:40 +010016From 83fe2858cbdff277e416f0ea50366811c81e2382 Mon Sep 17 00:00:00 2001
Lorenz Brun37050122021-03-30 14:00:27 +020017From: 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
Tim Windelschmidt9f21f532024-05-07 15:14:20 +020030does nothing for us, let's just nuke it instead of rewriting it against //osbase/loop.
Lorenz Brun37050122021-03-30 14:00:27 +020031---
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
Lorenz Brun6211e4d2023-11-14 19:09:40 +010036index 601dc646013..5dfdd1ecb02 100644
Lorenz Brun37050122021-03-30 14:00:27 +020037--- a/pkg/volume/util/util.go
38+++ b/pkg/volume/util/util.go
Lorenz Brun6211e4d2023-11-14 19:09:40 +010039@@ -511,17 +511,6 @@ func MapBlockVolume(
Lorenz Brun37050122021-03-30 14:00:27 +020040 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 }
Lorenz Brun6211e4d2023-11-14 19:09:40 +010056
57@@ -535,13 +524,6 @@ func UnmapBlockVolume(
Lorenz Brun37050122021-03-30 14:00:27 +020058 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 {
Lorenz Brun6211e4d2023-11-14 19:09:40 +010071--
722.41.0
Lorenz Brun37050122021-03-30 14:00:27 +020073