[PATCH 3/4] drbd: resize: do not silently "truncate" the effective size

From: Christoph Böhmwalder

Date: Thu Nov 26 2026 - 09:53:38 EST


From: Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>

During the connection handshake, a node with an established "effective"
(aka last agreed to) size can detect that a peer has a "too small"
backing disk, and refuse to connect to that peer.

Unfortunately it still "caches" the maximum size that peer could
support. We remember that size so we could still grow to an agreeable
size on an unconnected node, if this node's backend size was the
limiting factor and the peer was known to be able to support more.

Now, if we remember a size we rejected because it was too small, that
same logic will silently truncate our own size if we are asked to
"resize" before that cached information is properly reset (by taking
DRBD down/up, or by connecting to a peer that has a backing device of
sufficient size).

Workaround: only ask DRBD to resize when the connection to the peer is
fully established.

Fix: reset that cached size to zero in the moment we refuse the
connection.

Signed-off-by: Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@xxxxxxxxxx>
---
drivers/block/drbd/drbd_receiver.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 101192d8398f..9cc41bc07ae5 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3931,6 +3931,11 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info
(device->state.conn < C_CONNECTED || device->state.pdsk == D_DISKLESS)) {
drbd_err(device, "The peer's disk size is too small! (%llu < %llu sectors)\n",
(unsigned long long)new_size, (unsigned long long)cur_size);
+ /* We rejected that size, reset to zero so it won't
+ * confuse the aggregation with min_not_zero() if
+ * someone requests a resize later.
+ */
+ device->p_size = 0;
conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD);
put_ldev(device);
return -EIO;
--
2.56.0