From: Bart Van Assche <bvanassche@acm.org>
To: Xiao Ni <xni@redhat.com>, linux-raid@vger.kernel.org
Cc: yukuai3@huawei.com, ncroxon@redhat.com, song@kernel.org,
yukuai1@huaweicloud.com
Subject: Re: [PATCH 1/3] md: call del_gendisk in control path
Date: Mon, 26 Jan 2026 18:13:20 -0800 [thread overview]
Message-ID: <c0510f92-900d-4d63-aeae-85b2b8f5d59a@acm.org> (raw)
In-Reply-To: <20250611073108.25463-2-xni@redhat.com>
On 6/11/25 12:31 AM, Xiao Ni wrote:
> static inline int mddev_trylock(struct mddev *mddev)
> {
> - return mutex_trylock(&mddev->reconfig_mutex);
> + int ret;
> +
> + ret = mutex_trylock(&mddev->reconfig_mutex);
> + if (!ret && test_bit(MD_DELETED, &mddev->flags)) {
> + ret = -ENODEV;
> + mutex_unlock(&mddev->reconfig_mutex);
> + }
> + return ret;
> }
This change seems wrong to me. This change will cause mutex_unlock() to
be called if mutex_trylock() *failed*. Additionally, returning -ENODEV
from the failure path will cause the caller to call mutex_unlock() a
second time if mutex_trylock() failed. Please fix this!
As a reminder, from include/linux/mutex.h:
/*
* NOTE: mutex_trylock() follows the spin_trylock() convention,
* not the down_trylock() convention!
*
* Returns 1 if the mutex has been acquired successfully, and 0 on
contention.
*/
Bart.
next prev parent reply other threads:[~2026-01-27 2:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 7:31 [PATCH V6 0/3] md: call del_gendisk in sync way Xiao Ni
2025-06-11 7:31 ` [PATCH 1/3] md: call del_gendisk in control path Xiao Ni
2026-01-27 2:13 ` Bart Van Assche [this message]
2026-01-27 2:23 ` Yu Kuai
2025-06-11 7:31 ` [PATCH 2/3] md: Don't clear MD_CLOSING until mddev is freed Xiao Ni
2025-06-11 7:31 ` [PATCH 3/3] md: remove/add redundancy group only in level change Xiao Ni
2025-06-14 6:46 ` [PATCH V6 0/3] md: call del_gendisk in sync way Yu Kuai
2025-06-14 8:18 ` Yu Kuai
2025-06-15 3:21 ` Xiao Ni
2025-06-16 1:17 ` Yu Kuai
2025-06-16 1:43 ` Xiao Ni
-- strict thread matches above, loose matches on Subject: below --
2025-06-10 7:20 [PATCH V5 " Xiao Ni
2025-06-10 7:20 ` [PATCH 1/3] md: call del_gendisk in control path Xiao Ni
2025-06-11 6:09 ` Yu Kuai
2025-06-04 9:07 [PATCH V4 0/3] md: call del_gendisk in sync way Xiao Ni
2025-06-04 9:07 ` [PATCH 1/3] md: call del_gendisk in control path Xiao Ni
2025-06-06 8:46 ` Yu Kuai
2025-06-06 8:48 ` Yu Kuai
2025-06-09 9:15 ` Xiao Ni
2025-06-03 5:20 [PATCH V3 0/2] md: call del_gendisk in sync way Xiao Ni
2025-06-03 5:20 ` [PATCH 1/3] md: call del_gendisk in control path Xiao Ni
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=c0510f92-900d-4d63-aeae-85b2b8f5d59a@acm.org \
--to=bvanassche@acm.org \
--cc=linux-raid@vger.kernel.org \
--cc=ncroxon@redhat.com \
--cc=song@kernel.org \
--cc=xni@redhat.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/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