[PATCH] md-cluster: check pers->resize() return value in update_size()
From: ghuicao
Date: Wed Aug 26 2026 - 22:53:12 EST
From: Cao Guanghui <caoguanghui@xxxxxxxxxx>
In update_size(), when cluster_check_sync_size() detects that not all
nodes have updated their sync_size, the initiator reverts the array
size via pers->resize(). However, the return value of resize() is
immediately overwritten by __sendmsg(), so a resize failure is
silently lost.
If the revert resize fails, the array remains at the new (larger)
size while other nodes have not confirmed the change, leaving the
cluster in an inconsistent state with no error logged.
Check the resize() return value and log an error before sending the
METADATA_UPDATED message, so that a resize failure is visible to the
user.
Signed-off-by: Cao Guanghui <caoguanghui@xxxxxxxxxx>
---
drivers/md/md-cluster.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1349,7 +1349,10 @@ static void update_size(struct mddev *mddev, sector_t old_dev_sectors)
} else {
/* revert to previous sectors */
ret = mddev->pers->resize(mddev, old_dev_sectors);
+ if (ret)
+ pr_err("%s:%d: failed to revert array size\n",
+ __func__, __LINE__);
ret = __sendmsg(cinfo, &cmsg);
if (ret)
pr_err("%s:%d: failed to send METADATA_UPDATED msg\n",
__func__, __LINE__);
--
2.34.1