From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388115; b=ls2letCkf/RUdgaxupZzmvloMD9v7RSBn+VyLP6ZqrjSSyOtI46zeBDTqJVkJlIWvKnr PCw0Imy7xwYMVCsLb5iOIrE/IQmLfUHxICZKVJBlptHySUCRCYKPHIgPkoG+DRfFn9Qzp tSBt4Ae7gyBAK4tNysyQdzRjIYWXH9f5eMDGt7/OFZd+fZXQpGHI55z0T/wqpwu/3Xx/J fVfZpi4iDGcaZVLwpbwEHNDKbwXAyFHDeEwOLtxWn3hxfkxTLlrWfGGdK8lB9j6qRzhwu hYg6XAxepvXBJOwIBQNxdxMlKGe28UnYSWygVL0vykzrADOMu49PcKY6hpOelo/AvOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388115; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4zhNEAoaxllaCDyrvOREze4+tnBih++v2xsVkcPO+FA=; b=AvxA18LlaA+M0jYne5gVgGuMiN1VsV2hMmD8DtWEBhfBVhxhky2mcsh3mG01myxzOPs8 EgY6eiuWiHP9F9VtwbU0W5S3af9Sap6pz0kbpwdz2vZ2XS2KGBzNYWrVllLzAvjG6iIv0 HCbfaFY4/6MIqHDh94TIDvxD5jz0KnTVeJB7vXzf9XvfiWlhYAQw3HUNBItoQ3SoDLfkr 7DGwIa4c3cwAlmLpT05s0EK9zu8HqoqrvSK6kaLGciQLtBlsy0ZBqgP5nXLhc4koEHGdY 0dB77ak4IjMW1qJGM1PqWCDqLX4lysuGRGqqg5bcsqStuyTfM+uy9QSCELZ26aBCiTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CRQPjywY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CFD0606A322; Fri, 4 Dec 2026 12:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CRQPjywY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C7C41F000CE; Fri, 4 Dec 2026 12:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388114; bh=4zhNEAoaxllaCDyrvOREze4+tnBih++v2xsVkcPO+FA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CRQPjywYL1y+RucUNO8S48P+B5IiWt9WT3rlG4IVI09aYMrB7urZAyBhHNKG5o58T hcTRuya8dG+MHzPZeNNsAsmMsb1whljAHq13qToSaVdvj1+K3IGqPq/d3UtoPY5jUx 5cFp+1ewpWNR/MvJgUbu7tCiCoDRhaqEYCxc6caI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , Jens Axboe , Sasha Levin Subject: [PATCH 6.1 0452/1059] blk-mq: exit the hctxs of a queue under tag_list_lock Date: Fri, 4 Dec 2026 18:59:43 +0900 Message-ID: <20261204100655.999021231@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit 89a2381482d8ff8e4fe0b7d32797bb4f77503b89 ] blk_mq_update_nr_hw_queues() exits and replaces the hctxs of every queue on set->tag_list under tag_list_lock. blk_mq_exit_queue() exits its hctxs without the lock and only then takes the queue off the list, so an update running at the same time exits them again and sets up new ones that nobody exits. del_gendisk() is kept away by update_nr_hwq_lock, disk_release() of a never added disk and blk_mq_destroy_queue() are not, and nvme_alloc_ns() drops such a disk when it finds the queues frozen by a reset. Hold tag_list_lock for both steps. Fixes: 630ef623ed26 ("blk-mq: Swap two calls in blk_mq_exit_queue()") Signed-off-by: Josef Bacik Link: https://patch.msgid.link/20261028164415.1262013-38-axboe@kernel.dk Signed-off-by: Jens Axboe [ sashal: Adapted the context to the older tree's plain list_del() and trailing INIT_LIST_HEAD() in blk_mq_del_queue_tag_set(), which has no RCU conversion. ] Signed-off-by: Sasha Levin --- block/blk-mq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index a918e1188f233..933ce75f4b965 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4057,7 +4057,8 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q) { struct blk_mq_tag_set *set = q->tag_set; - mutex_lock(&set->tag_list_lock); + lockdep_assert_held(&set->tag_list_lock); + list_del(&q->tag_set_list); if (list_is_singular(&set->tag_list)) { /* just transitioned to unshared */ @@ -4065,7 +4066,6 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q) /* update existing queue */ blk_mq_update_tag_set_shared(set, false); } - mutex_unlock(&set->tag_list_lock); INIT_LIST_HEAD(&q->tag_set_list); } @@ -4395,10 +4395,16 @@ void blk_mq_exit_queue(struct request_queue *q) { struct blk_mq_tag_set *set = q->tag_set; + /* + * As long as the queue is on set->tag_list, its hctxs belong to + * blk_mq_update_nr_hw_queues() as well, which exits and replaces them. + */ + mutex_lock(&set->tag_list_lock); /* Checks hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED. */ blk_mq_exit_hw_queues(q, set, set->nr_hw_queues); /* May clear BLK_MQ_F_TAG_QUEUE_SHARED in hctx->flags. */ blk_mq_del_queue_tag_set(q); + mutex_unlock(&set->tag_list_lock); } static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) -- 2.53.0