mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Philipp Reisner" <philipp.reisner@linbit.com>,
	"Lars Ellenberg" <lars.ellenberg@linbit.com>,
	drbd-dev@lists.linux.dev, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
Subject: [PATCH 1/4] drbd: assume a capable peer for the discard limit before the handshake
Date: Thu, 26 Nov 2026 15:52:54 +0100	[thread overview]
Message-ID: <20261126145257.592085-2-christoph.boehmwalder@linbit.com> (raw)
In-Reply-To: <20261126145257.592085-1-christoph.boehmwalder@linbit.com>

From: Lars Ellenberg <lars.ellenberg@linbit.com>

Before the first handshake, agreed_features is 0, so
drbd_max_discard_sectors() limits discards to 4 MiB, the limit for
peers without WRITE_SAME support. Devices stacked on top of DRBD copy
that limit at setup and keep it, even after DRBD connects to a capable
peer and allows 128 MiB.

Assume a capable peer until a handshake has completed. If the
handshake finds an incapable peer, receive_sizes() lowers the limit
again before DRBD sends any request to that peer.

A discard that DRBD split at 128 MiB before the handshake, and that
DRBD submits to an incapable peer after it, exceeds the peer's limit.
The peer then drops the connection, and the resync after the reconnect
covers the range. A module parameter that rejects incapable peers
would avoid this, but adds a permanent interface for a rare case.

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

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 3511a943e4b1..efa6e46326a2 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1257,8 +1257,11 @@ static unsigned int drbd_max_peer_bio_size(struct drbd_device *device)
 static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection)
 {
 	/* when we introduced REQ_WRITE_SAME support, we also bumped
-	 * our maximum supported batch bio size used for discards. */
-	if (connection->agreed_features & DRBD_FF_WSAME)
+	 * our maximum supported batch bio size used for discards.
+	 * Until a handshake completed, assume a capable peer.
+	 */
+	if (connection->agreed_pro_version < PRO_VERSION_MIN ||
+	    connection->agreed_features & DRBD_FF_WSAME)
 		return DRBD_MAX_BBIO_SECTORS;
 	/* before, with DRBD <= 8.4.6, we only allowed up to one AL_EXTENT_SIZE. */
 	return AL_EXTENT_SIZE >> 9;
-- 
2.56.0


  reply	other threads:[~2026-11-26 14:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 14:52 [PATCH 0/4] drbd: assorted fixes for discard limits, bitmap IO and resize Christoph Böhmwalder
2026-11-26 14:52 ` Christoph Böhmwalder [this message]
2026-11-26 14:52 ` [PATCH 2/4] drbd: fix lost bitmap-work wakeup on weakly ordered CPUs Christoph Böhmwalder
2026-11-26 14:52 ` [PATCH 3/4] drbd: resize: do not silently "truncate" the effective size Christoph Böhmwalder
2026-11-26 14:52 ` [PATCH 4/4] drbd: refuse to shrink on resize unless an explicit size is requested Christoph Böhmwalder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126145257.592085-2-christoph.boehmwalder@linbit.com \
    --to=christoph.boehmwalder@linbit.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linux.dev \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipp.reisner@linbit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®