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 D460749B448; Fri, 9 Oct 2026 09:09:49 +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=1791536991; cv=none; b=KMStK12/JT2lWExiKS2US3m0jv/YppqtfG2dOi01qMvRkYZaE/taVZ6vH5tvIr4RbE0gSm4CxG/sBgQzDnOuSKqhP3CkVpz+jWkQDlIdaPyMesE84DjfG+zQovK4g5qlQEVr/FNyGF9ojkq/eSQA9byJ2CdR1JqQv5IKy0+dtpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791536991; c=relaxed/simple; bh=YalvdjkybDmnhAmS9qExXjazq9gnZ/o/l19oL6nJebE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VqNduaksZlNZtNbJa9EyN7hP38zI8I+eJqfrLBRw4s8d+4H86+ZlkmZ0zNl6Vb32nd1D/ajkI4ElPK1uMaRiU348vgb6DHpdfRcneWZY+nxBMXSe4ijs6c76EU6ksUG9QwHqihiy7aNI0OUvYH8i6DRs+MbODDKAYioMoZAkBz8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oLLzFwNb; 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="oLLzFwNb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C45A21F00898; Fri, 9 Oct 2026 09:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791536989; bh=JTGah2tzcl7t+yk/xdZQ1RXG/B+uBEIodb82KBJDVQs=; h=From:To:Subject:Date:In-Reply-To:References; b=oLLzFwNbfPz5QnnHHuMQ4Ptua9pYuaeU4ySRY6rxCrys8IQCjgPjmanpB5yorJlj+ z48PlTSv59nkQ1fpGCNpAMEHRMfqi3lxFYVOsizhyXvGB6clYMxW8PYNr/tWvC969n x0qSTkBI/RF7qp5ULyqwNeYSXgIOD34f3c/OopJ+pNsV8NF6S7IXz7+P4dzpIUQZ96 wF6xFjjamvFBlj+0zzVWKNOvVesv3U4UoPjzVPx98HJ9q+2u6iE/YFUhQ4kDkudo1F 7/gzm8aHb6G+UD7WtjfNUjAx3XDP3snE0aN71oXK7wnZqbxEMgRWmhHQTpoNh93trt +6C9tTo5/7n2w== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 2/9] block: refactor blk_revalidate_disk_zones() Date: Fri, 9 Oct 2026 18:09:38 +0900 Message-ID: <20261009090945.1504194-3-dlemoal@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261009090945.1504194-1-dlemoal@kernel.org> References: <20261009090945.1504194-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 --- 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