block: Simplify blk_revalidate_disk_zones() interface

The only user of blk_revalidate_disk_zones() second argument was the
SCSI disk driver (sd). Now that this driver does not require this
update_driver_data argument, remove it to simplify the interface of
blk_revalidate_disk_zones(). Also update the function kdoc comment to
be more accurate (i.e. there is no gendisk ->revalidate method).

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Hans Holmberg <hans.holmberg@wdc.com>
Tested-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240408014128.205141-21-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Damien Le Moal 2024-04-08 10:41:20 +09:00 committed by Jens Axboe
parent 63b5385e78
commit 9b3c08b90f
8 changed files with 14 additions and 22 deletions

View File

@ -1713,21 +1713,17 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
/** /**
* blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps * blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps
* @disk: Target disk * @disk: Target disk
* @update_driver_data: Callback to update driver data on the frozen disk
* *
* Helper function for low-level device drivers to check and (re) allocate and * Helper function for low-level device drivers to check, (re) allocate and
* initialize a disk request queue zone bitmaps. This functions should normally * initialize resources used for managing zoned disks. This function should
* be called within the disk ->revalidate method for blk-mq based drivers. * 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 * Before calling this function, the device driver must already have set the
* device zone size (chunk_sector limit) and the max zone append limit. * 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 * BIO based drivers can also use this function as long as the device queue
* can be safely frozen. * can be safely frozen.
* If the @update_driver_data callback function is not NULL, the callback is
* executed with the device request queue frozen after all zones have been
* checked.
*/ */
int blk_revalidate_disk_zones(struct gendisk *disk, int blk_revalidate_disk_zones(struct gendisk *disk)
void (*update_driver_data)(struct gendisk *disk))
{ {
struct request_queue *q = disk->queue; struct request_queue *q = disk->queue;
sector_t zone_sectors = q->limits.chunk_sectors; sector_t zone_sectors = q->limits.chunk_sectors;
@ -1794,13 +1790,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
* referencing the bitmaps). * referencing the bitmaps).
*/ */
blk_mq_freeze_queue(q); blk_mq_freeze_queue(q);
if (ret > 0) { if (ret > 0)
ret = disk_update_zone_resources(disk, &args); ret = disk_update_zone_resources(disk, &args);
if (update_driver_data) else
update_driver_data(disk);
} else {
pr_warn("%s: failed to revalidate zones\n", disk->disk_name); pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
}
if (ret) if (ret)
disk_free_zone_resources(disk); disk_free_zone_resources(disk);
blk_mq_unfreeze_queue(q); blk_mq_unfreeze_queue(q);

View File

@ -177,7 +177,7 @@ int null_register_zoned_dev(struct nullb *nullb)
disk->disk_name, disk->disk_name,
queue_emulates_zone_append(q) ? "emulated" : "native"); queue_emulates_zone_append(q) ? "emulated" : "native");
return blk_revalidate_disk_zones(disk, NULL); return blk_revalidate_disk_zones(disk);
} }
void null_free_zoned_dev(struct nullb_device *dev) void null_free_zoned_dev(struct nullb_device *dev)

View File

@ -221,7 +221,7 @@ static int ublk_get_nr_zones(const struct ublk_device *ub)
static int ublk_revalidate_disk_zones(struct ublk_device *ub) static int ublk_revalidate_disk_zones(struct ublk_device *ub)
{ {
return blk_revalidate_disk_zones(ub->ub_disk, NULL); return blk_revalidate_disk_zones(ub->ub_disk);
} }
static int ublk_dev_param_zoned_validate(const struct ublk_device *ub) static int ublk_dev_param_zoned_validate(const struct ublk_device *ub)

View File

@ -1543,7 +1543,7 @@ static int virtblk_probe(struct virtio_device *vdev)
*/ */
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && lim.zoned) { if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && lim.zoned) {
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, vblk->disk->queue); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, vblk->disk->queue);
err = blk_revalidate_disk_zones(vblk->disk, NULL); err = blk_revalidate_disk_zones(vblk->disk);
if (err) if (err)
goto out_cleanup_disk; goto out_cleanup_disk;
} }

View File

@ -169,7 +169,7 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
* our table for dm_blk_report_zones() to use directly. * our table for dm_blk_report_zones() to use directly.
*/ */
md->zone_revalidate_map = t; md->zone_revalidate_map = t;
ret = blk_revalidate_disk_zones(disk, NULL); ret = blk_revalidate_disk_zones(disk);
md->zone_revalidate_map = NULL; md->zone_revalidate_map = NULL;
if (ret) { if (ret) {

View File

@ -2150,7 +2150,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
blk_mq_unfreeze_queue(ns->disk->queue); blk_mq_unfreeze_queue(ns->disk->queue);
if (blk_queue_is_zoned(ns->queue)) { if (blk_queue_is_zoned(ns->queue)) {
ret = blk_revalidate_disk_zones(ns->disk, NULL); ret = blk_revalidate_disk_zones(ns->disk);
if (ret && !nvme_first_scan(ns->disk)) if (ret && !nvme_first_scan(ns->disk))
goto out; goto out;
} }

View File

@ -572,7 +572,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
blk_queue_max_zone_append_sectors(q, 0); blk_queue_max_zone_append_sectors(q, 0);
flags = memalloc_noio_save(); flags = memalloc_noio_save();
ret = blk_revalidate_disk_zones(disk, NULL); ret = blk_revalidate_disk_zones(disk);
memalloc_noio_restore(flags); memalloc_noio_restore(flags);
if (ret) { if (ret) {
sdkp->zone_info = (struct zoned_disk_info){ }; sdkp->zone_info = (struct zoned_disk_info){ };

View File

@ -336,8 +336,7 @@ int blkdev_report_zones(struct block_device *bdev, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data); unsigned int nr_zones, report_zones_cb cb, void *data);
int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op, int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
sector_t sectors, sector_t nr_sectors); sector_t sectors, sector_t nr_sectors);
int blk_revalidate_disk_zones(struct gendisk *disk, int blk_revalidate_disk_zones(struct gendisk *disk);
void (*update_driver_data)(struct gendisk *disk));
/* /*
* Independent access ranges: struct blk_independent_access_range describes * Independent access ranges: struct blk_independent_access_range describes