[PATCH 08/13] block: introduce blkdev_get_zone_info()

Bart Van Assche bvanassche at acm.org
Fri Oct 31 14:40:23 PDT 2025


On 10/30/25 11:13 PM, Damien Le Moal wrote:
> +static int blkdev_do_report_zones(struct block_device *bdev, sector_t sector,
> +				  unsigned int nr_zones,
> +				  struct blk_report_zones_args *args)
> +{
> +	struct gendisk *disk = bdev->bd_disk;
> +
> +	if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones))
> +		return -EOPNOTSUPP;
> +
> +	if (!nr_zones || sector >= get_capacity(disk))
> +		return 0;
> +
> +	return disk->fops->report_zones(disk, sector, nr_zones, args);
> +}
> +
>   /**
>    * blkdev_report_zones - Get zones information
>    * @bdev:	Target block device
> @@ -226,19 +242,12 @@ struct blk_report_zones_args {
>   int blkdev_report_zones(struct block_device *bdev, sector_t sector,
>   			unsigned int nr_zones, report_zones_cb cb, void *data)
>   {
> -	struct gendisk *disk = bdev->bd_disk;
>   	struct blk_report_zones_args args = {
>   		.cb = cb,
>   		.data = data,
>   	};
>   
> -	if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones))
> -		return -EOPNOTSUPP;
> -
> -	if (!nr_zones || sector >= get_capacity(disk))
> -		return 0;
> -
> -	return disk->fops->report_zones(disk, sector, nr_zones, &args);
> +	return blkdev_do_report_zones(bdev, sector, nr_zones, &args);
>   }
>   EXPORT_SYMBOL_GPL(blkdev_report_zones);

One change per patch please. Please split this patch into one patch that
introduces the blkdev_do_report_zones() function and another patch with
the remaining changes from this patch.
> +/**
> + * blkdev_get_zone_info - Get a zone information from cached data

"Get a zone information" -> "Get zone information"

> +	sector = sector & (~(zone_sectors - 1));

Please consider changing the above assignment into:

	sector -= bdev_offset_from_zone_start(bdev, sector);

> +	/*
> +	 * If the zone does not have a zone write plug, it is either full or
> +	 * empty, as we otherwise would have a zone write plug for it. In this
> +	 * case, set the write pointer accordingly and report the zone.
> +	 * Otherwise, if we have a zone write plug, use it.
> +	 */
> +	zwplug = disk_get_zone_wplug(disk, sector);
> +	if (!zwplug) {
> +		if (zone->cond == BLK_ZONE_COND_FULL)
> +			zone->wp = sector + zone_sectors;
> +		else
> +			zone->wp = sector;
> +		return 0;
> +	}

According to ZBC-2 the write pointer is invalid for full zones.

Thanks,

Bart.



More information about the Linux-nvme mailing list