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 v3 1/3] md-cluster: fix lock_comm leak and __sendmsg error path
Date: Thu, 27 Aug 2026 16:44:51 +0800 [thread overview]
Message-ID: <20260827084453.124629-1-ghuicao@163.com> (raw)
In-Reply-To: <20260827061200.79753-1-ghuicao@163.com>
From: Cao Guanghui <caoguanghui@kylinos.cn>
Fix two error handling issues in cluster communication:
1. lock_comm() leaks MD_CLUSTER_SEND_LOCK if lock_token() fails.
The bit is set by test_and_set_bit but never cleared on error,
causing all subsequent cluster operations to hang permanently
in wait_event(). Clear the bit before returning the error.
2. __sendmsg() has two problems in the failed_ack cleanup path:
- ack_lockres is left in EX state if the down-conversion to CR
fails, causing a cluster-wide deadlock. Attempt to restore
it to CR and log if that also fails.
- The while loop for message_lockres unlock spins forever if
a previous DLM operation timed out and left a pending request
(dlm_unlock_sync returns -EBUSY immediately). Change to a
single attempt with error logging.
Fixes: 818da59f97d6 ("md-cluster: add the support for resize") (lock_comm)
Fixes: 601b515c5dcc ("Communication Framework: Sending functions") (__sendmsg)
Cc: stable@vger.kernel.org
Signed-off-by: Cao Guanghui <caoguanghui@kylinos.cn>
---
drivers/md/md-cluster.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 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
@@ -735,6 +735,8 @@ static int lock_comm(struct md_cluster_info *cinfo, bool mddev_locked)
wait_event(cinfo->wait,
!test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state));
rv = lock_token(cinfo);
+ if (rv)
+ clear_bit_unlock(MD_CLUSTER_SEND_LOCK, &cinfo->state);
if (set_bit)
clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state);
return rv;
@@ -801,7 +803,15 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
}
failed_ack:
- while ((unlock_error = dlm_unlock_sync(cinfo->message_lockres)))
+ if (error) {
+ int ack_ret = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR);
+
+ if (ack_ret)
+ pr_err("md-cluster: failed to restore ACK to CR (%d)\n",
+ ack_ret);
+ }
+ unlock_error = dlm_unlock_sync(cinfo->message_lockres);
+ if (unlock_error)
pr_err("md-cluster: failed convert to NL on MESSAGE(%d)\n",
unlock_error);
--
2.34.1
next prev parent reply other threads:[~2026-08-27 8:45 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 ` [PATCH v2 2/3] md-cluster: propagate update_size() errors to callers ghuicao
2026-08-27 6:23 ` 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 ` ghuicao [this message]
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=20260827084453.124629-1-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