Re: [PATCH] nbd: fix false lockdep deadlock warning
- To: Yu Kuai <yukuai1@huaweicloud.com>, Ming Lei <ming.lei@redhat.com>
- Cc: josef@toxicpanda.com, axboe@kernel.dk, hch@infradead.org, hare@suse.de, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com, "yukuai (C)" <yukuai3@huawei.com>
- Subject: Re: [PATCH] nbd: fix false lockdep deadlock warning
- From: Nilay Shroff <nilay@linux.ibm.com>
- Date: Tue, 1 Jul 2025 18:58:57 +0530
- Message-id: <[🔎] 197b6dca-56be-438d-a60f-21011367c5ed@linux.ibm.com>
- In-reply-to: <c2fbaacc-62a1-4a98-4157-2637b7f242b7@huaweicloud.com>
- References: <20250627092348.1527323-1-yukuai1@huaweicloud.com> <aF56oVEzTygIOUTN@fedora> <c2fbaacc-62a1-4a98-4157-2637b7f242b7@huaweicloud.com>
On 6/28/25 6:18 AM, Yu Kuai wrote:
> Hi,
>
> 在 2025/06/27 19:04, Ming Lei 写道:
>> I guess the patch in the following link may be simper, both two take
>> similar approach:
>>
>> https://lore.kernel.org/linux-block/aFjbavzLAFO0Q7n1@fedora/
>
> I this the above approach has concurrent problems if nbd_start_device
> concurrent with nbd_start_device:
>
> t1:
> nbd_start_device
> lock
> num_connections = 1
> unlock
> t2:
> nbd_add_socket
> lock
> config->num_connections++
> unlock
> t3:
> nbd_start_device
> lock
> num_connections = 2
> unlock
> blk_mq_update_nr_hw_queues
>
> blk_mq_update_nr_hw_queues
> //nr_hw_queues updated to 1 before failure
> return -EINVAL
>
In the above case, yes I see that t1 would return -EINVAL (as
config->num_connections doesn't match with num_connections)
but then t3 would succeed to update nr_hw_queue (as both
config->num_connections and num_connections set to 2 this
time). Isn't it? If yes, then the above patch (from Ming)
seems good.
Thanks,
--Nilay
Reply to: