From: Cao Guanghui <[email protected]>
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: [email protected]
Signed-off-by: Cao Guanghui <[email protected]>
---
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.