From: ghuicao@163.com
To: Song Liu <song@kernel.org>
Cc: Yu Kuai <yukuai@fygo.io>, Li Nan <magiclinan@didiglobal.com>,
Xiao Ni <xiao@kernel.org>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Cao Guanghui <caoguanghui@kylinos.cn>
Subject: [PATCH v2 2/3] md-cluster: propagate update_size() errors to callers
Date: Thu, 27 Aug 2026 14:11:59 +0800 [thread overview]
Message-ID: <20260827061200.79753-2-ghuicao@163.com> (raw)
In-Reply-To: <20260827061200.79753-1-ghuicao@163.com>
From: Cao Guanghui <caoguanghui@kylinos.cn>
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: stable@vger.kernel.org
Signed-off-by: Cao Guanghui <caoguanghui@kylinos.cn>
---
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
next prev parent reply other threads:[~2026-08-27 6:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 2:52 [PATCH] md-cluster: check pers->resize() return value in update_size() ghuicao
2026-08-27 3:07 ` sashiko-bot
2026-08-27 6:11 ` [PATCH v2 1/3] md-cluster: fix error handling and superblock update in update_size revert ghuicao
2026-08-27 6:11 ` ghuicao [this message]
2026-08-27 6:23 ` [PATCH v2 2/3] md-cluster: propagate update_size() errors to callers sashiko-bot
2026-08-27 6:12 ` [PATCH v2 3/3] md-cluster: fix ack_lockres leak in __sendmsg error path ghuicao
2026-08-27 6:24 ` sashiko-bot
2026-08-27 6:24 ` [PATCH v2 1/3] md-cluster: fix error handling and superblock update in update_size revert sashiko-bot
2026-08-27 8:44 ` [PATCH v3 1/3] md-cluster: fix lock_comm leak and __sendmsg error path ghuicao
2026-08-27 8:44 ` [PATCH v3 2/3] md-cluster: fix error handling and superblock consistency in update_size ghuicao
2026-08-27 8:58 ` sashiko-bot
2026-08-27 8:44 ` [PATCH v3 3/3] md-cluster: revert local resize and propagate cluster errors ghuicao
2026-08-27 9:04 ` sashiko-bot
2026-08-27 8:58 ` [PATCH v3 1/3] md-cluster: fix lock_comm leak and __sendmsg error path sashiko-bot
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=20260827061200.79753-2-ghuicao@163.com \
--to=ghuicao@163.com \
--cc=caoguanghui@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/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