|
1 | | -diff --git a/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java b/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java |
2 | | -index abc123def..def456abc 100644 |
3 | | ---- a/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java |
4 | | -+++ b/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java |
5 | | -@@ -83,6 +83,8 @@ import java.util.TreeMap; |
6 | | - import java.util.TreeSet; |
7 | | - import java.util.concurrent.atomic.AtomicBoolean; |
8 | | - import java.util.function.Function; |
9 | | -+import java.nio.file.Files; |
10 | | -+import java.nio.file.Paths; |
| 1 | +From 6a556821b9a0996d34389a27b941694ce810a44c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Andrei Kvapil < [email protected]> |
| 3 | +Date: Mon, 12 Jan 2026 14:26:57 +0100 |
| 4 | +Subject: [PATCH 1/3] Fix: Skip DRBD adjust/res file regeneration when child |
| 5 | + layer device is inaccessible |
| 6 | + |
| 7 | +When deleting encrypted (LUKS) resources, the LUKS layer may close its device |
| 8 | +before the DRBD layer attempts to adjust the resource or regenerate the res |
| 9 | +file. This causes 'Failed to adjust DRBD resource' errors. |
| 10 | + |
| 11 | +This fix adds checks before regenerateResFile() and drbdUtils.adjust() |
| 12 | +to verify that child layer devices are accessible. If a child device doesn't |
| 13 | +exist or is not accessible (e.g., LUKS device is closed during resource |
| 14 | +deletion), these operations are skipped and the adjustRequired flag is cleared, |
| 15 | +allowing resource deletion to proceed successfully. |
| 16 | + |
| 17 | +Co-Authored-By: Claude < [email protected]> |
| 18 | +Signed-off-by: Andrei Kvapil < [email protected]> |
| 19 | +--- |
| 20 | + .../linbit/linstor/layer/drbd/DrbdLayer.java | 72 ++++++++++++++++--- |
| 21 | + 1 file changed, 61 insertions(+), 11 deletions(-) |
11 | 22 |
|
12 | | - @Singleton |
13 | | - public class DeviceHandlerImpl implements DeviceHandler |
14 | | -@@ -1646,7 +1648,10 @@ public class DeviceHandlerImpl implements DeviceHandler |
15 | | - private void updateDiscGran(VlmProviderObject<Resource> vlmData) throws DatabaseException, StorageException |
16 | | - { |
17 | | - String devicePath = vlmData.getDevicePath(); |
18 | | -- if (devicePath != null && vlmData.exists()) |
19 | | -+ // Check if device path physically exists before calling lsblk |
20 | | -+ // This is important for DRBD devices which might be temporarily unavailable during adjust |
21 | | -+ // (drbdadm adjust brings devices down/up, and kernel might not have created the device node yet) |
22 | | -+ if (devicePath != null && vlmData.exists() && Files.exists(Paths.get(devicePath))) |
23 | | - { |
24 | | - if (vlmData.getDiscGran() == VlmProviderObject.UNINITIALIZED_SIZE) |
25 | | - { |
26 | 23 | diff --git a/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java b/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java |
27 | | -index 01967a3..871d830 100644 |
| 24 | +index 01967a31f..871d830d1 100644 |
28 | 25 | --- a/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java |
29 | 26 | +++ b/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java |
30 | 27 | @@ -592,7 +592,29 @@ public class DrbdLayer implements DeviceLayer |
@@ -116,3 +113,148 @@ index 01967a3..871d830 100644 |
116 | 113 | } |
117 | 114 | } |
118 | 115 |
|
| 116 | +-- |
| 117 | +2.39.5 (Apple Git-154) |
| 118 | + |
| 119 | + |
| 120 | +From afe51ea674c4a350c27d1f2cacfecf6fe42b8a7a Mon Sep 17 00:00:00 2001 |
| 121 | +From: Andrei Kvapil < [email protected]> |
| 122 | +Date: Mon, 12 Jan 2026 14:27:52 +0100 |
| 123 | +Subject: [PATCH 2/3] fix(satellite): skip lsblk when device path doesn't |
| 124 | + physically exist |
| 125 | + |
| 126 | +Add physical device path existence check before calling lsblk in updateDiscGran(). |
| 127 | +This prevents race condition when drbdadm adjust temporarily brings devices down/up |
| 128 | +and the kernel hasn't created the device node yet. |
| 129 | + |
| 130 | +Issue: After satellite restart with patched code, some DRBD resources ended up in |
| 131 | +Unknown state because: |
| 132 | +1. drbdadm adjust successfully completes (brings devices up) |
| 133 | +2. updateDiscGran() immediately tries to check discard granularity |
| 134 | +3. /dev/drbd* device node doesn't exist yet (kernel hasn't created it) |
| 135 | +4. lsblk fails with exit code 32 "not a block device" |
| 136 | +5. StorageException interrupts DeviceManager cycle |
| 137 | +6. DRBD device remains in incomplete state |
| 138 | + |
| 139 | +Solution: Check Files.exists(devicePath) before calling lsblk. If device doesn't |
| 140 | +exist yet, skip the check - it will be retried in the next DeviceManager cycle |
| 141 | +when the device node is available. |
| 142 | + |
| 143 | +Co-Authored-By: Claude < [email protected]> |
| 144 | +Signed-off-by: Andrei Kvapil < [email protected]> |
| 145 | +--- |
| 146 | + .../linbit/linstor/core/devmgr/DeviceHandlerImpl.java | 9 +++++++-- |
| 147 | + 1 file changed, 7 insertions(+), 2 deletions(-) |
| 148 | + |
| 149 | +diff --git a/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java b/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java |
| 150 | +index 49138a8fd..1c13cfc9d 100644 |
| 151 | +--- a/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java |
| 152 | ++++ b/satellite/src/main/java/com/linbit/linstor/core/devmgr/DeviceHandlerImpl.java |
| 153 | +@@ -68,6 +68,8 @@ import javax.inject.Inject; |
| 154 | + import javax.inject.Provider; |
| 155 | + import javax.inject.Singleton; |
| 156 | + |
| 157 | ++import java.nio.file.Files; |
| 158 | ++import java.nio.file.Paths; |
| 159 | + import java.util.ArrayList; |
| 160 | + import java.util.Collection; |
| 161 | + import java.util.Collections; |
| 162 | +@@ -1645,8 +1647,11 @@ public class DeviceHandlerImpl implements DeviceHandler |
| 163 | + |
| 164 | + private void updateDiscGran(VlmProviderObject<Resource> vlmData) throws DatabaseException, StorageException |
| 165 | + { |
| 166 | +- String devicePath = vlmData.getDevicePath(); |
| 167 | +- if (devicePath != null && vlmData.exists()) |
| 168 | ++ @Nullable String devicePath = vlmData.getDevicePath(); |
| 169 | ++ // Check if device path physically exists before calling lsblk |
| 170 | ++ // This is important for DRBD devices which might be temporarily unavailable during adjust |
| 171 | ++ // (drbdadm adjust brings devices down/up, and kernel might not have created the device node yet) |
| 172 | ++ if (devicePath != null && vlmData.exists() && Files.exists(Paths.get(devicePath))) |
| 173 | + { |
| 174 | + if (vlmData.getDiscGran() == VlmProviderObject.UNINITIALIZED_SIZE) |
| 175 | + { |
| 176 | +-- |
| 177 | +2.39.5 (Apple Git-154) |
| 178 | + |
| 179 | + |
| 180 | +From de1f22e7c008c5479f85a3b1ebdf8461944210f4 Mon Sep 17 00:00:00 2001 |
| 181 | +From: Andrei Kvapil < [email protected]> |
| 182 | +Date: Mon, 12 Jan 2026 14:28:23 +0100 |
| 183 | +Subject: [PATCH 3/3] fix(drbd): only check child devices when disk access is |
| 184 | + actually needed |
| 185 | +MIME-Version: 1.0 |
| 186 | +Content-Type: text/plain; charset=UTF-8 |
| 187 | +Content-Transfer-Encoding: 8bit |
| 188 | + |
| 189 | +The previous implementation blocked `drbdadm adjust` whenever child |
| 190 | +device paths were unavailable, even for operations that don't require |
| 191 | +disk access (like network reconnect from StandAlone to Connected). |
| 192 | + |
| 193 | +After node reboot, DRBD resources often remain in StandAlone state |
| 194 | +because: |
| 195 | +1. updateResourceToCurrentDrbdState() correctly detects StandAlone |
| 196 | + and sets adjustRequired=true |
| 197 | +2. However, canAdjust check fails because child volumes may have |
| 198 | + devicePath=null (due to INACTIVE flag, cloning state, or |
| 199 | + initialization race) |
| 200 | +3. adjust is skipped → adjustRequired=false → resources stay StandAlone |
| 201 | + |
| 202 | +Root cause: The canAdjust check was added to protect LUKS deletion |
| 203 | +scenarios but was applied to ALL cases, including network reconnect |
| 204 | +which doesn't need disk access. |
| 205 | + |
| 206 | +Fix: Check child device accessibility only when disk access is actually |
| 207 | +required (volume creation, resize, metadata operations). Network |
| 208 | +reconnect operations (StandAlone → Connected) now proceed without |
| 209 | +checking child devices. |
| 210 | + |
| 211 | +This ensures automatic DRBD reconnection after reboot while preserving |
| 212 | +protection for LUKS deletion scenarios. |
| 213 | + |
| 214 | +Co-Authored-By: Claude < [email protected]> |
| 215 | +Signed-off-by: Andrei Kvapil < [email protected]> |
| 216 | +--- |
| 217 | + .../linbit/linstor/layer/drbd/DrbdLayer.java | 27 ++++++++++++++++++- |
| 218 | + 1 file changed, 26 insertions(+), 1 deletion(-) |
| 219 | + |
| 220 | +diff --git a/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java b/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java |
| 221 | +index 871d830d1..78b8195a4 100644 |
| 222 | +--- a/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java |
| 223 | ++++ b/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java |
| 224 | +@@ -792,7 +792,32 @@ public class DrbdLayer implements DeviceLayer |
| 225 | + // This is important for encrypted resources (LUKS) where the device |
| 226 | + // might be closed during deletion |
| 227 | + boolean canAdjust = true; |
| 228 | +- if (!skipDisk && !drbdRscData.getAbsResource().isDrbdDiskless(workerCtx)) |
| 229 | ++ |
| 230 | ++ // IMPORTANT: Check child volumes only when disk access is actually needed. |
| 231 | ++ // For network reconnect (StandAlone -> Connected), disk access is not required. |
| 232 | ++ boolean needsDiskAccess = false; |
| 233 | ++ |
| 234 | ++ // Check if there are pending operations that require disk access |
| 235 | ++ for (DrbdVlmData<Resource> drbdVlmData : drbdRscData.getVlmLayerObjects().values()) |
| 236 | ++ { |
| 237 | ++ Volume vlm = (Volume) drbdVlmData.getVolume(); |
| 238 | ++ StateFlags<Volume.Flags> vlmFlags = vlm.getFlags(); |
| 239 | ++ |
| 240 | ++ // Disk access is needed if: |
| 241 | ++ // - creating a new volume |
| 242 | ++ // - resizing |
| 243 | ++ // - checking/creating metadata |
| 244 | ++ if (!drbdVlmData.exists() || |
| 245 | ++ drbdVlmData.checkMetaData() || |
| 246 | ++ vlmFlags.isSomeSet(workerCtx, Volume.Flags.RESIZE, Volume.Flags.DRBD_RESIZE)) |
| 247 | ++ { |
| 248 | ++ needsDiskAccess = true; |
| 249 | ++ break; |
| 250 | ++ } |
| 251 | ++ } |
| 252 | ++ |
| 253 | ++ // Check child volumes only if disk access is actually needed |
| 254 | ++ if (needsDiskAccess && !skipDisk && !drbdRscData.getAbsResource().isDrbdDiskless(workerCtx)) |
| 255 | + { |
| 256 | + AbsRscLayerObject<Resource> dataChild = drbdRscData.getChildBySuffix(RscLayerSuffixes.SUFFIX_DATA); |
| 257 | + if (dataChild != null) |
| 258 | +-- |
| 259 | +2.39.5 (Apple Git-154) |
| 260 | + |
0 commit comments