Re: [PATCH 1/1] md: fix return value of mddev_trylock
Bart Van Assche <[email protected]>
| Newsgroups | gmane.linux.raid |
|---|---|
| Message-ID | <[email protected]> |
On 1/26/26 11:39 PM, Xiao Ni wrote:
> 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;
Maybe this is a good time to add some documentation above
mddev_trylock() that explains the meaning of the return value? Anyway:
Reviewed-by: Bart Van Assche <[email protected]>