| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 1 | Copyright 2020 The Monogon Project Authors. |
| 2 | |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | |
| 15 | |
| Lorenz Brun | 6211e4d | 2023-11-14 19:09:40 +0100 | [diff] [blame] | 16 | From 83fe2858cbdff277e416f0ea50366811c81e2382 Mon Sep 17 00:00:00 2001 |
| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 17 | From: Lorenz Brun <lorenz@brun.one> |
| 18 | Date: Mon, 29 Mar 2021 13:56:06 +0200 |
| 19 | Subject: [PATCH] Removed questionable block device pseudo-locks |
| 20 | |
| 21 | This code implements a weird sort of lock using Linux loop devices. It's not exclusive (multiple loop devices per |
| 22 | backing device are supported) and the devices themselves are not accessed. The lock is also not exclusive as multiple |
| 23 | loop devices per backing device are allowed. The only mention of why any of this is done is in the comment below, stating |
| 24 | that it is possible that a device can be removed and another device can be attached with the same name. In Metropolis |
| 25 | this is not a problem as our CSI/Provisioner setup exercises tight control over devices, thus silent removals are not |
| 26 | possible. |
| 27 | |
| 28 | Because this code calls the losetup utility which Metropolis doesn't want to ship and also repeatedly lists loop devices |
| 29 | in an inefficient manner which will cause problems with the anticipated density of VM-hosting Metropolis nodes and |
| Tim Windelschmidt | 9f21f53 | 2024-05-07 15:14:20 +0200 | [diff] [blame^] | 30 | does nothing for us, let's just nuke it instead of rewriting it against //osbase/loop. |
| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 31 | --- |
| 32 | pkg/volume/util/util.go | 18 ------------------ |
| 33 | 1 file changed, 18 deletions(-) |
| 34 | |
| 35 | diff --git a/pkg/volume/util/util.go b/pkg/volume/util/util.go |
| Lorenz Brun | 6211e4d | 2023-11-14 19:09:40 +0100 | [diff] [blame] | 36 | index 601dc646013..5dfdd1ecb02 100644 |
| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 37 | --- a/pkg/volume/util/util.go |
| 38 | +++ b/pkg/volume/util/util.go |
| Lorenz Brun | 6211e4d | 2023-11-14 19:09:40 +0100 | [diff] [blame] | 39 | @@ -511,17 +511,6 @@ func MapBlockVolume( |
| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 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 | } |
| Lorenz Brun | 6211e4d | 2023-11-14 19:09:40 +0100 | [diff] [blame] | 56 | |
| 57 | @@ -535,13 +524,6 @@ func UnmapBlockVolume( |
| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 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 { |
| Lorenz Brun | 6211e4d | 2023-11-14 19:09:40 +0100 | [diff] [blame] | 71 | -- |
| 72 | 2.41.0 |
| Lorenz Brun | 3705012 | 2021-03-30 14:00:27 +0200 | [diff] [blame] | 73 | |