Re: [PATCH 1/1] md: fix return value of mddev_trylock

Li Nan <[email protected]>
Newsgroups gmane.linux.raid
Message-ID <[email protected]>

在 2026/1/27 15:39, Xiao Ni 写道:
> A return value of 0 is treaded as successful lock acquisition. In fact, a
> return value of 1 means getting the lock successfully.
> 
> Fixes: 9e59d609763f ("md: call del_gendisk in control path")
> Reported-by: Bart Van Assche <[email protected]>
> Closes: https://lore.kernel.org/linux-raid/[email protected]/T/#mfa369ef5faa4aa58e13e6d9fdb88aecd862b8f2f
> Signed-off-by: Xiao Ni <[email protected]>
> ---
>   drivers/md/md.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index 6985f2829bbd..3bfbee595156 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -737,8 +737,8 @@ static inline int mddev_trylock(struct mddev *mddev)
>   	int ret;
>   
>   	ret = mutex_trylock(&mddev->reconfig_mutex);
> -	if (!ret && test_bit(MD_DELETED, &mddev->flags)) {
> -		ret = -ENODEV;
> +	if (ret && test_bit(MD_DELETED, &mddev->flags)) {
> +		ret = 0;
>   		mutex_unlock(&mddev->reconfig_mutex);
>   	}
>   	return ret;

LGTM

Reviewed-by:  Li Nan <[email protected]>

-- 
Thanks,
Nan
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.