[PATCH v3 3/3] md-cluster: revert local resize and propagate cluster errors
From: <hidden>
Date: 2026-08-27 08:45:33
Also in:
lkml, stable
Subsystem:
software raid (multiple disks) support, the rest · Maintainers:
Song Liu, Yu Kuai, Linus Torvalds
From: Cao Guanghui <redacted>
In md.c:update_size(), the local array is resized via pers->resize()
before calling the cluster update_size() callback. If the cluster
operation fails, the local node has the new size while the rest of
the cluster does not, causing a split-brain state.
Propagate the cluster update_size() return value and revert the local
resize on failure. Also check the return value in the reshape
completion path (md_reap_sync_thread) and log a warning on failure.
Fixes: 818da59f97d6 ("md-cluster: add the support for resize")
Cc: stable@vger.kernel.org
Signed-off-by: Cao Guanghui <redacted>
---
drivers/md/md.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
--- a/drivers/md/md.c
+++ b/drivers/md/md.c@@ -8022,9 +8022,11 @@ static int update_size(struct mddev *mddev, sector_t num_sectors) } rv = mddev->pers->resize(mddev, num_sectors); if (!rv) { - if (mddev_is_clustered(mddev)) - mddev->cluster_ops->update_size(mddev, old_dev_sectors); - else if (!mddev_is_dm(mddev)) + if (mddev_is_clustered(mddev)) { + rv = mddev->cluster_ops->update_size(mddev, old_dev_sectors); + if (rv) + mddev->pers->resize(mddev, old_dev_sectors); + } else if (!mddev_is_dm(mddev)) set_capacity_and_notify(mddev->gendisk, mddev->array_sectors); }
@@ -10615,8 +10617,12 @@ void md_reap_sync_thread(struct mddev *mddev) */ if (mddev_is_clustered(mddev) && is_reshaped && mddev->pers->finish_reshape && - !test_bit(MD_CLOSING, &mddev->flags)) - mddev->cluster_ops->update_size(mddev, old_dev_sectors); + !test_bit(MD_CLOSING, &mddev->flags)) { + int ret = mddev->cluster_ops->update_size(mddev, old_dev_sectors); + + if (ret) + pr_warn("md: cluster update_size failed after reshape: %d\n", ret); + } /* flag recovery needed just to double check */ set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); sysfs_notify_dirent_safe(mddev->sysfs_completed);
--
2.34.1