From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 473CE2F5318; Fri, 31 Oct 2025 06:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761891417; cv=none; b=jPxagmmQSuA7BNbTRJfiCbKl2hZGCgFDkmiEtZ2q2tXlgxaE7zerUvbvtEiFmGXJBIoc7pOJf7/UMG1GtmP1Id53RNiO4zNF+3L8lqTglNaP05UE2RUbpxK2KasbVwW8BadG0dDQPxT9qjoSHHYEX5gsOwmiOfz+oIKJ+gWltc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761891417; c=relaxed/simple; bh=duBFtoPw9t/qNc2aCPdlDSxz6a5mXbzd+DjZAQAHWIA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XJO+QuXsLrHQ0VRBahHTAxezd0TMiDjqRxhXWkJhhnJr+Hh4+VSpCJXCbfTNYLcenGVKKhiPDRWnkVpm/TDMaVIE1Phsff7adti5weeSGmnPATd+npBphZVwsCvyipxHpOnx0V3IKQMlBvy+KNPVcNQs1Y365tU2b7+No/Rmdgg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lR9Y8FgT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lR9Y8FgT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66021C4CEE7; Fri, 31 Oct 2025 06:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761891416; bh=duBFtoPw9t/qNc2aCPdlDSxz6a5mXbzd+DjZAQAHWIA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lR9Y8FgTwdR7lPv5dY6s4PqQp/gg4HVPJPOBoBNhILHXuy6X6n61LnyK27zCjEdhZ pGfFmSAxBVGFCHytZeqb3oNrtKL3MN3AHuyJx9q2AAEPqu3bLTeUxRGnCGVc21E/2A eQgkZ4rkVAzZ+PceBJ7SPX9dZmiPun4FMSsY6YDW50rfjJuzIxakVHWIp+AylHZPbB 6IDOl5bOukQtXVEXVUvxY7llt7+QV+QZyH0eFSNOroFyPlWq8uea5pIeIbQz25quN5 5c69KoyhIMOGNj4M6GM/bZ5SU8c8pp3TzALweLXxl5wyjw9q2BDRaSrN0SMZ13GoEN tw05Af4QykGpg== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Keith Busch , Christoph Hellwig , dm-devel@lists.linux.dev, Mike Snitzer , Mikulas Patocka , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-xfs@vger.kernel.org, Carlos Maiolino , linux-btrfs@vger.kernel.org, David Sterba Subject: [PATCH 01/13] block: freeze queue when updating zone resources Date: Fri, 31 Oct 2025 15:12:55 +0900 Message-ID: <20251031061307.185513-2-dlemoal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031061307.185513-1-dlemoal@kernel.org> References: <20251031061307.185513-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Modify disk_update_zone_resources() to freeze the device queue before updating the number of zones, zone capacity and other zone related resources. The locking order resulting from the call to queue_limits_commit_update_frozen() is preserved, that is, the queue limits lock is first taken by calling queue_limits_start_update() before freezing the queue, and the queue is unfrozen after executing queue_limits_commit_update(), which replaces the call to queue_limits_commit_update_frozen(). This change ensures that there are no in-flights I/Os when the zone resources are updated due to a zone revalidation. Fixes: 0b83c86b444a ("block: Prevent potential deadlock in blk_revalidate_disk_zones()") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal --- block/blk-zoned.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 5e2a5788dc3b..f3b371056df4 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -1516,8 +1516,13 @@ static int disk_update_zone_resources(struct gendisk *disk, { struct request_queue *q = disk->queue; unsigned int nr_seq_zones, nr_conv_zones; - unsigned int pool_size; + unsigned int pool_size, memflags; struct queue_limits lim; + int ret; + + lim = queue_limits_start_update(q); + + memflags = blk_mq_freeze_queue(q); disk->nr_zones = args->nr_zones; disk->zone_capacity = args->zone_capacity; @@ -1527,11 +1532,10 @@ static int disk_update_zone_resources(struct gendisk *disk, if (nr_conv_zones >= disk->nr_zones) { pr_warn("%s: Invalid number of conventional zones %u / %u\n", disk->disk_name, nr_conv_zones, disk->nr_zones); - return -ENODEV; + ret = -ENODEV; + goto unfreeze; } - lim = queue_limits_start_update(q); - /* * Some devices can advertize zone resource limits that are larger than * the number of sequential zones of the zoned block device, e.g. a @@ -1568,7 +1572,12 @@ static int disk_update_zone_resources(struct gendisk *disk, } commit: - return queue_limits_commit_update_frozen(q, &lim); + ret = queue_limits_commit_update(q, &lim); + +unfreeze: + blk_mq_unfreeze_queue(q, memflags); + + return ret; } static int blk_revalidate_conv_zone(struct blk_zone *zone, unsigned int idx, -- 2.51.0