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 AE49C34D93C; Wed, 14 Oct 2026 05:33:41 +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=1791956022; cv=none; b=eFIj4Jq8CgRapWn69N1Uo5FwEyDGPt66ZRSfgHkoDaz2MMLAYWmVWmk64ORSMTplg/jWpp6IcgW6p09eeozsqZHOlBTEMP8yKzAmPdDyxa7eSNS7PKtUZ2FrmNSW8bU/Y/yOOplLebw6hEbFH6EuLEApF493TZkQcGo9R/DDOJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791956022; c=relaxed/simple; bh=SuyWVau/aRNGFUJUb3OZseTErhQMoaxQOjAY7fTUKYE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kMeNKuK4cgzOjNeKDXQuit0xD6MvQNk+BiS8iBGC/cn6SLns8epldeVR9OGEta2V8QN9VwhVXh3lCBUoEq8zIdlhvJody71+AHOkTFyumbY19ChjsFekP9YxsbR/foc3mURqoILX1ZAFY8KpKJUMdltGDY2L0TpyUqV7nLJa8zU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IAvPW6Gn; 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="IAvPW6Gn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B76781F000FF; Wed, 14 Oct 2026 05:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791956021; bh=1JuwAH2uwbDnVZ/W/xKRQgetRrWQM3lu4Uq9yMJrc6Q=; h=From:To:Subject:Date:In-Reply-To:References; b=IAvPW6GncgrPUN12ahnZGeTm5HsFPupjv99TZZATwfRpIPi1inmsjcw7i0f9cp5hp hwxC/3XfSTE8bacvEJ15RqVDDG4FIRmGPpPgZXdAsJHLOsykQ5EoNEjgoLB8192wsO x/WpFpVvElj2YpNs1+omjfWzOgD6UOtJPDaLxU2fWIZMkZMafUuHehS5LK2UIDSZxZ O5jbRXDGC54+rLXQKNCdXWvUMLDi12pqjq2nt5A2gWIaq01EL9TKiYqNccx1TcW3N+ Tvr3y60NwVu242+2ISFqAdrUfZgw834BQ6FERBFty/xRfloM35SsRxkUYin2wi1Osv WYsr3AUs5RuKQ== From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v7 02/10] block: refactor blk_revalidate_disk_zones() Date: Wed, 14 Oct 2026 14:33:28 +0900 Message-ID: <20261014053337.2328544-3-dlemoal@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261014053337.2328544-1-dlemoal@kernel.org> References: <20261014053337.2328544-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 Reviewed-by: Martin K. Petersen --- 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