Skip to content

Commit dc2773b

Browse files
kvapsclaude
andcommitted
[linstor] Update piraeus-server patches with critical fixes
Update piraeus-server patches to address critical production issues: - Add fix-duplicate-tcp-ports.diff to prevent duplicate TCP ports after toggle-disk operations (upstream PR #476) - Update skip-adjust-when-device-inaccessible.diff with comprehensive fixes for resources stuck in StandAlone after reboot, Unknown state race condition, and encrypted LUKS resource deletion (upstream PR #477) ```release-note [linstor] Fix DRBD resources stuck in StandAlone state after reboot and encrypted resource deletion issues ``` Co-Authored-By: Claude <[email protected]> Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 8025657 commit dc2773b

3 files changed

Lines changed: 258 additions & 27 deletions

File tree

‎packages/system/linstor/images/piraeus-server/patches/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ Custom patches for piraeus-server (linstor-server) v1.32.3.
88
- Upstream: [#475](https://github.com/LINBIT/linstor-server/pull/475)
99
- **force-metadata-check-on-disk-add.diff** — Create metadata during toggle-disk from diskless to diskful
1010
- Upstream: [#474](https://github.com/LINBIT/linstor-server/pull/474)
11-
- **skip-adjust-when-device-inaccessible.diff** — Skip DRBD adjust/res file regeneration when child layer device is inaccessible
12-
- Upstream: [#471](https://github.com/LINBIT/linstor-server/pull/471)
11+
- **fix-duplicate-tcp-ports.diff** — Prevent duplicate TCP ports after toggle-disk operations
12+
- Upstream: [#476](https://github.com/LINBIT/linstor-server/pull/476)
13+
- **skip-adjust-when-device-inaccessible.diff** — Fix resources stuck in StandAlone after reboot, Unknown state race condition, and encrypted resource deletion
14+
- Upstream: [#477](https://github.com/LINBIT/linstor-server/pull/477)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
From 1250abe99d64a0501795e37d3b6af62410002239 Mon Sep 17 00:00:00 2001
2+
From: Andrei Kvapil <[email protected]>
3+
Date: Mon, 12 Jan 2026 13:44:46 +0100
4+
Subject: [PATCH] fix(drbd): prevent duplicate TCP ports after toggle-disk
5+
operations
6+
7+
Remove redundant ensureStackDataExists() call with empty payload from
8+
resetStoragePools() method that was causing TCP port conflicts after
9+
toggle-disk operations.
10+
11+
Root Cause:
12+
-----------
13+
The resetStoragePools() method, introduced in 2019 (commit 95cc17d0b8),
14+
calls ensureStackDataExists() with an empty LayerPayload. This worked
15+
correctly when TCP ports were stored at RscDfn level.
16+
17+
After the TCP port migration to per-node level (commit f754943463, May
18+
2025), this empty payload results in DrbdRscData being created without
19+
TCP ports assigned. The controller then sends a Pojo with an empty port
20+
Set to satellites.
21+
22+
On satellites, when DrbdRscData is initialized with an empty port list,
23+
initPorts() uses preferredNewPortsRef from peer resources. Since
24+
SatelliteDynamicNumberPool.tryAllocate() always returns true (no-op),
25+
any port from preferredNewPortsRef is accepted without conflict checking,
26+
leading to duplicate TCP port assignments.
27+
28+
Impact:
29+
-------
30+
This regression affects toggle-disk operations, particularly:
31+
- Snapshot creation/restore operations
32+
- Manual toggle-disk operations
33+
- Any operation calling resetStoragePools()
34+
35+
Symptoms include:
36+
- DRBD resources failing to adjust with "port is also used" errors
37+
- Resources stuck in StandAlone or Connecting states
38+
- Multiple resources on the same node using identical TCP ports
39+
40+
Solution:
41+
---------
42+
Remove the ensureStackDataExists() call from resetStoragePools() as it
43+
is redundant. The calling code (e.g., CtrlRscToggleDiskApiCallHandler
44+
line 1071) already invokes ensureStackDataExists() with the correct
45+
payload immediately after resetStoragePools().
46+
47+
This fix ensures:
48+
1. resetStoragePools() only resets storage pool assignments
49+
2. Layer data creation with proper TCP ports happens via the caller's
50+
ensureStackDataExists() with correct payload
51+
3. No DrbdRscData objects are created without TCP port assignments
52+
53+
Related Issues:
54+
---------------
55+
Fixes #454 - Duplicate TCP ports after backup/restore operations
56+
Related to user reports of resources stuck in StandAlone after node
57+
reboots when toggle-disk or backup operations were in progress.
58+
59+
Testing:
60+
--------
61+
Verified that:
62+
- Toggle-disk operations no longer create resources without TCP ports
63+
- Backup/restore operations complete without TCP port conflicts
64+
- Resources maintain unique TCP ports across toggle-disk cycles
65+
66+
Co-Authored-By: Claude <[email protected]>
67+
Signed-off-by: Andrei Kvapil <[email protected]>
68+
---
69+
.../linbit/linstor/layer/resource/CtrlRscLayerDataFactory.java | 2 --
70+
1 file changed, 2 deletions(-)
71+
72+
diff --git a/controller/src/main/java/com/linbit/linstor/layer/resource/CtrlRscLayerDataFactory.java b/controller/src/main/java/com/linbit/linstor/layer/resource/CtrlRscLayerDataFactory.java
73+
index 3538b380c..4f589145e 100644
74+
--- a/controller/src/main/java/com/linbit/linstor/layer/resource/CtrlRscLayerDataFactory.java
75+
+++ b/controller/src/main/java/com/linbit/linstor/layer/resource/CtrlRscLayerDataFactory.java
76+
@@ -276,8 +276,6 @@ public class CtrlRscLayerDataFactory
77+
78+
rscDataToProcess.addAll(rscData.getChildren());
79+
}
80+
-
81+
- ensureStackDataExists(rscRef, null, new LayerPayload());
82+
}
83+
catch (AccessDeniedException exc)
84+
{
85+
--
86+
2.39.5 (Apple Git-154)
87+

‎packages/system/linstor/images/piraeus-server/patches/skip-adjust-when-device-inaccessible.diff‎

Lines changed: 167 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
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(-)
1122

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-
{
2623
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
2825
--- a/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java
2926
+++ b/satellite/src/main/java/com/linbit/linstor/layer/drbd/DrbdLayer.java
3027
@@ -592,7 +592,29 @@ public class DrbdLayer implements DeviceLayer
@@ -116,3 +113,148 @@ index 01967a3..871d830 100644
116113
}
117114
}
118115

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

Comments
 (0)