From: Cao Guanghui <[email protected]>
update_size() in md-cluster.c has a void return type, so the caller in
md.c cannot detect cluster resize failures. A capacity revert or
message delivery failure is silently lost, and the MD layer reports
success to userspace even when the cluster operation failed.
Change the update_size() callback in struct md_cluster_ops and its
implementation to return int, and propagate the error at the call sites
in md.c.
Fixes: 818da59f97d6 ("md-cluster: add the support for resize")
Cc: [email protected]
Signed-off-by: Cao Guanghui <[email protected]>
---
drivers/md/md-cluster.c | 11 ++++++-----
drivers/md/md-cluster.h | 2 +-
drivers/md/md.c | 7 +++++--
3 files changed, 12 insertions(+), 8 deletions(-)
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
@@ -1292,7 +1292,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
* let other nodes to perform it. If one node can't update sync_size
* accordingly, we need to revert to previous value.
*/
-static void update_size(struct mddev *mddev, sector_t old_dev_sectors)
+static int update_size(struct mddev *mddev, sector_t old_dev_sectors)
{
struct md_cluster_info *cinfo = mddev->cluster_info;
struct cluster_msg cmsg;
@@ -1303,7 +1303,7 @@ static int update_size(struct mddev *mddev, sector_t old_dev_sectors)
md_update_sb(mddev, 1);
if (lock_comm(cinfo, 1)) {
pr_err("%s: lock_comm failed\n", __func__);
- return;
+ return -1;
}
memset(&cmsg, 0, sizeof(cmsg));
@@ -1325,12 +1325,12 @@ static int update_size(struct mddev *mddev, sector_t old_dev_sectors)
pr_err("%s:%d: failed to send METADATA_UPDATED msg\n",
__func__, __LINE__);
unlock_comm(cinfo);
- return;
+ return ret;
}
} else {
pr_err("md-cluster: No good device id found to send\n");
unlock_comm(cinfo);
- return;
+ return -1;
}
/*
@@ -1355,6 +1355,7 @@ static int update_size(struct mddev *mddev, sector_t old_dev_sectors)
__func__, __LINE__);
}
unlock_comm(cinfo);
+ return ret;
}
static int resync_start(struct mddev *mddev)
diff --git a/drivers/md/md-cluster.h b/drivers/md/md-cluster.h
--- a/drivers/md/md-cluster.h
+++ b/drivers/md/md-cluster.h
@@ -34,7 +34,7 @@ struct md_cluster_operations {
int (*resize_bitmaps)(struct mddev *mddev, sector_t newsize, sector_t oldsize);
int (*lock_all_bitmaps)(struct mddev *mddev);
void (*unlock_all_bitmaps)(struct mddev *mddev);
- void (*update_size)(struct mddev *mddev, sector_t old_dev_sectors);
+ int (*update_size)(struct mddev *mddev, sector_t old_dev_sectors);
};
extern int md_setup_cluster(struct mddev *mddev, int nodes);
diff --git a/drivers/md/md.c b/drivers/md/md.c
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8023,7 +8023,7 @@ 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);
+ rv = mddev->cluster_ops->update_size(mddev, old_dev_sectors);
else if (!mddev_is_dm(mddev))
set_capacity_and_notify(mddev->gendisk,
mddev->array_sectors);
@@ -10615,8 +10615,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.