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 4/4] drbd: refuse to shrink on resize unless an explicit size is requested
Date: Thu, 26 Nov 2026 15:52:57 +0100 [thread overview]
Message-ID: <20261126145257.592085-5-christoph.boehmwalder@linbit.com> (raw)
In-Reply-To: <20261126145257.592085-1-christoph.boehmwalder@linbit.com>
From: Lars Ellenberg <lars.ellenberg@linbit.com>
There is a check for implicit shrinking, but it was only active
when _also_ changing the activity log on disk layout.
Make it active always.
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 | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index efa6e46326a2..5c8a3ab326d7 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -981,7 +981,7 @@ drbd_determine_dev_size(struct drbd_device *device, enum dds_flags flags, struct
struct drbd_md *md = &device->ldev->md;
void *buffer;
- int md_moved, la_size_changed;
+ bool md_moved, la_size_changed, al_layout_changed;
enum determine_dev_size rv = DS_UNCHANGED;
/* We may change the on-disk offsets of our meta data below. Lock out
@@ -1009,7 +1009,6 @@ drbd_determine_dev_size(struct drbd_device *device, enum dds_flags flags, struct
prev.al_stripe_size_4k = md->al_stripe_size_4k;
if (rs) {
- /* rs is non NULL if we should change the AL layout only */
md->al_stripes = rs->al_stripes;
md->al_stripe_size_4k = rs->al_stripe_size / 4;
md->al_size_4k = (u64)rs->al_stripes * rs->al_stripe_size / 4;
@@ -1064,8 +1063,11 @@ drbd_determine_dev_size(struct drbd_device *device, enum dds_flags flags, struct
md_moved = prev.md_offset != md->md_offset
|| prev.md_size_sect != md->md_size_sect;
+ al_layout_changed =
+ prev.al_stripes != md->al_stripes
+ || prev.al_stripe_size_4k != md->al_stripe_size_4k;
- if (la_size_changed || md_moved || rs) {
+ if (la_size_changed || md_moved || al_layout_changed) {
u32 prev_flags;
/* We do some synchronous IO below, which may take some time.
@@ -1098,7 +1100,7 @@ drbd_determine_dev_size(struct drbd_device *device, enum dds_flags flags, struct
md->flags = prev_flags;
drbd_md_write(device, buffer);
- if (rs)
+ if (al_layout_changed)
drbd_info(device, "Changed AL layout to al-stripes = %d, al-stripe-size-kB = %d\n",
md->al_stripes, md->al_stripe_size_4k * 4);
}
@@ -2861,7 +2863,6 @@ int drbd_nl_resize_doit(struct sk_buff *skb, struct genl_info *info)
struct drbd_device *device;
enum drbd_ret_code retcode;
enum determine_dev_size dd;
- bool change_al_layout = false;
enum dds_flags ddsf;
sector_t u_size;
int err;
@@ -2936,8 +2937,6 @@ int drbd_nl_resize_doit(struct sk_buff *skb, struct genl_info *info)
retcode = ERR_MD_LAYOUT_CONNECTED;
goto fail_ldev;
}
-
- change_al_layout = true;
}
if (device->ldev->known_size != drbd_get_capacity(device->ldev->backing_bdev))
@@ -2955,7 +2954,7 @@ int drbd_nl_resize_doit(struct sk_buff *skb, struct genl_info *info)
}
ddsf = (rs.resize_force ? DDSF_FORCED : 0) | (rs.no_resync ? DDSF_NO_RESYNC : 0);
- dd = drbd_determine_dev_size(device, ddsf, change_al_layout ? &rs : NULL);
+ dd = drbd_determine_dev_size(device, ddsf, &rs);
drbd_md_sync(device);
put_ldev(device);
if (dd == DS_ERROR) {
--
2.56.0
prev parent 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 ` [PATCH 1/4] drbd: assume a capable peer for the discard limit before the handshake Christoph Böhmwalder
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 ` Christoph Böhmwalder [this message]
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-5-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®