From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 BAE6E3382FC; Mon, 12 Oct 2026 13:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791810087; cv=none; b=iTPVkbx+bBcClx+WexMsVZ3a2fR2OiDIJlVsZByrZyhxNg3V00Lwp32XQYBmdWoctS/vccSW2zu+GzPCrsD9Fa31cYj0N6aCgifSvAOFhWvK7QTu7/MPua+vYE4Z8oDK1ZSKUy4jABKmeKZYJK5NGsPH5sw1fkSDzkg2ORMkEd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791810087; c=relaxed/simple; bh=w2qBbgRItf1jql6nTOjgCKDWLd0SgWCFvPS1Q9kvTAo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aDuFvEk8IxCJChc+/vg9aczPmNCfccvdntqlKdSUQz+vWnnx3tNWdW29cS2bw3jrX4SnE+A2GmoMtd8u8k3eZcuqXCQ3jRaNUywF99SIHG+UNPwyM35tLYTWiN3Lf9Ym4eAyz1ihoJg16hKWRQp9wX3e1Bm0b+Q6l6W3XAlIguI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZVVSMOz1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZVVSMOz1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4E421F0089D; Mon, 12 Oct 2026 13:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791810086; bh=kzR07JicWOf+Lho40AVxRRIR5ct0j2qRZ86kaWMF45k=; h=From:To:Subject:Date:In-Reply-To:References; b=ZVVSMOz1Pi/jvuF64qMC7cYvvHkAcuT/iUAEguobmsAagyQO+LdWTwK1EUWcDRIk2 lXG6mSOKjgSjCejeQ2xZA05fLj/Q3h+onnzc9TGZ7UtM4FYj67mDp1wguoQCUKUZfP kmE6xhJdUXFRwtX+HMZ0TiDXh7IZ6Kj7A/BRfBm8NxebCJUVaTLBwFfWnw5QGHdA8a Q0ESmQw75K6GFOp/Um2kdFNCM5h/m633OZbDEYPqojdgEhr7W0wYe0LQuhOQ9HLnPy OxlGK/4zqKF0XyensPel15PRG7rUDhrlA9TeX0QifatfSzD+/RlJpwrlo6YUD2mIDG sPMR/zFlUIppA== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v5 2/9] block: refactor blk_revalidate_disk_zones() Date: Mon, 12 Oct 2026 22:01:14 +0900 Message-ID: <20261012130121.1902634-3-dlemoal@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261012130121.1902634-1-dlemoal@kernel.org> References: <20261012130121.1902634-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Split out most of the code of blk_revalidate_disk_zones() into the internal function disk_revalidate_zones(). This will allow calling this new helper together with other code under the zone revalidation mutex. No functional change. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig --- block/blk-zoned.c | 63 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 44010be6876a..e7f48774ae17 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -2542,20 +2542,7 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx, return ret; } -/** - * blk_revalidate_disk_zones - (re)allocate and initialize zone write plugs - * @disk: Target disk - * - * Helper function for low-level device drivers to check, (re) allocate and - * initialize resources used for managing zoned disks. This function should - * normally be called by blk-mq based drivers when a zoned gendisk is probed - * and when the zone configuration of the gendisk changes (e.g. after a format). - * Before calling this function, the device driver must already have set the - * device zone size (chunk_sector limit) and the max zone append limit. - * BIO based drivers can also use this function as long as the device queue - * can be safely frozen. - */ -int blk_revalidate_disk_zones(struct gendisk *disk) +static int disk_revalidate_zones(struct gendisk *disk) { struct blk_revalidate_zone_args args = { }; struct blk_report_zones_args rep_args = { @@ -2566,19 +2553,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk) int retries = 2; int ret; - if (WARN_ON_ONCE(!blk_queue_is_zoned(disk->queue))) - return -EIO; - - /* - * Serialize calls to this function so that we can safely look at and - * eventually change the disk zone information. - */ - mutex_lock(&disk->zone_revalidate_mutex); - again: ret = disk_revalidate_capacity(disk, &args); if (ret) - goto unlock; + return ret; /* * Allocate zone resources if they are needed and we have not done @@ -2591,14 +2569,14 @@ int blk_revalidate_disk_zones(struct gendisk *disk) ret = disk_alloc_zone_resources(disk, args.capacity); if (ret) { memalloc_noio_restore(noio_flag); - goto unlock; + return ret; } } ret = disk_init_revalidate_args(disk, &args); if (ret) { memalloc_noio_restore(noio_flag); - goto unlock; + return ret; } ret = disk->fops->report_zones(disk, 0, UINT_MAX, &rep_args); @@ -2615,8 +2593,6 @@ int blk_revalidate_disk_zones(struct gendisk *disk) if (ret) goto free_args; - mutex_unlock(&disk->zone_revalidate_mutex); - return 0; free_args: @@ -2632,7 +2608,36 @@ int blk_revalidate_disk_zones(struct gendisk *disk) } pr_warn("%s: failed to revalidate zones\n", disk->disk_name); -unlock: + + return ret; +} + +/** + * blk_revalidate_disk_zones - (re)allocate and initialize zone write plugs + * @disk: Target disk + * + * Helper function for low-level device drivers to check, (re) allocate and + * initialize resources used for managing zoned disks. This function should + * normally be called by blk-mq based drivers when a zoned gendisk is probed + * and when the zone configuration of the gendisk changes (e.g. after a format). + * Before calling this function, the device driver must already have set the + * device zone size (chunk_sector limit) and the max zone append limit. + * BIO based drivers can also use this function as long as the device queue + * can be safely frozen. + */ +int blk_revalidate_disk_zones(struct gendisk *disk) +{ + int ret; + + if (WARN_ON_ONCE(!blk_queue_is_zoned(disk->queue))) + return -EIO; + + /* + * Serialize calls to this function so that we can safely look at and + * eventually change the disk zone information. + */ + mutex_lock(&disk->zone_revalidate_mutex); + ret = disk_revalidate_zones(disk); mutex_unlock(&disk->zone_revalidate_mutex); return ret; -- 2.55.0