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 740F64F96D4; Tue, 13 Oct 2026 12:27:55 +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=1791894476; cv=none; b=h/Oc7eh4nUof7KSMdsm8V1XkPH1KJc34nXKvW93fB/170oQUMKF8Q9sxTvQlq277yniQctXqzJ2MvWcKdrkz19hbAPuP8UgYdX8GPBWacPHX4Z6TWzW9ihKx1pqpCbdE44aEkoa5NuvRFjIL3nWc4NZF7Ak5Uby4H1+dw8mjJFw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894476; c=relaxed/simple; bh=MPdZyLFOI/y+XfDwv13BPOcOShoQYOw+HKUgWf/fbN0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fcu1BvSOIwFgFJMJNPlABtN1W+SFO8Bzg5bIU2vurTV8oI/tExpMw0GcZk4scitJaJcFqjX2wNlkm/szNhgC5DMqVlNd6p0Sgcxr/ykr1EgQ3TftlKcn6W3v25aeXqbjRv59lKCUF5hhurKsIRJ3d1+ya9bF2l5hHRPZM9wKn8Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BkAJDOHG; 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="BkAJDOHG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 835A81F000FF; Tue, 13 Oct 2026 12:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791894475; bh=Uyo8zL7zsU0ZXrWac3MW8e0IHMniaC5ZoexSyPf+e1A=; h=From:To:Subject:Date:In-Reply-To:References; b=BkAJDOHGM0qM6TRU17re9HqnZkaFajJzPCaLgJg/djj7yG2bgu91sH890q/vCiF4O hadkCAHsSRu5A94Snsx3zQka8ETI/03q1LidF886etlGqB/xmE4rJjGnW3gDpd7ZMD ZHwqdP7Bu889gd5Kli+MFaItSJhlDkEqGUHVOWhSjgYBiPJmqS/h3gggdmOgqdlYuq KbReWYrY0Qb+nM7rW9cO0Jne8q+sWzum6iDm4YAFgJiIs3hlQYNHXTPFubE04BLNZ/ /snpG/+w3Rj8HGbv+sRSozoTE8NgWdHb/D7FYnZXoJ4A5ZWJ/J2bQ0wnRX4f+D0pyV YZwJE/ldaqaFQ== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v6 02/10] block: refactor blk_revalidate_disk_zones() Date: Tue, 13 Oct 2026 21:27:42 +0900 Message-ID: <20261013122750.2237843-3-dlemoal@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261013122750.2237843-1-dlemoal@kernel.org> References: <20261013122750.2237843-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-scsi@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 0d4b18290412..acec8a7e648e 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