Skip to content

Commit e732671

Browse files
damien-lemoalaxboe
authored andcommitted
block: Modify revalidate zones
Modify the interface of blk_revalidate_disk_zones() to add an optional driver callback function that a driver can use to extend processing done during zone revalidation. The callback, if defined, is executed with the device request queue frozen, after all zones have been inspected. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1392d37 commit e732671

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎block/blk-zoned.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,19 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
471471
/**
472472
* blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps
473473
* @disk: Target disk
474+
* @update_driver_data: Callback to update driver data on the frozen disk
474475
*
475476
* Helper function for low-level device drivers to (re) allocate and initialize
476477
* a disk request queue zone bitmaps. This functions should normally be called
477478
* within the disk ->revalidate method for blk-mq based drivers. For BIO based
478479
* drivers only q->nr_zones needs to be updated so that the sysfs exposed value
479480
* is correct.
481+
* If the @update_driver_data callback function is not NULL, the callback is
482+
* executed with the device request queue frozen after all zones have been
483+
* checked.
480484
*/
481-
int blk_revalidate_disk_zones(struct gendisk *disk)
485+
int blk_revalidate_disk_zones(struct gendisk *disk,
486+
void (*update_driver_data)(struct gendisk *disk))
482487
{
483488
struct request_queue *q = disk->queue;
484489
struct blk_revalidate_zone_args args = {
@@ -512,6 +517,8 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
512517
q->nr_zones = args.nr_zones;
513518
swap(q->seq_zones_wlock, args.seq_zones_wlock);
514519
swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
520+
if (update_driver_data)
521+
update_driver_data(disk);
515522
ret = 0;
516523
} else {
517524
pr_warn("%s: failed to revalidate zones\n", disk->disk_name);

‎drivers/block/null_blk_zoned.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ int null_register_zoned_dev(struct nullb *nullb)
7373
struct request_queue *q = nullb->q;
7474

7575
if (queue_is_mq(q))
76-
return blk_revalidate_disk_zones(nullb->disk);
76+
return blk_revalidate_disk_zones(nullb->disk, NULL);
7777

7878
blk_queue_chunk_sectors(q, nullb->dev->zone_size_sects);
7979
q->nr_zones = blkdev_nr_zones(nullb->disk);

‎include/linux/blkdev.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
358358
extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
359359
sector_t sectors, sector_t nr_sectors,
360360
gfp_t gfp_mask);
361-
extern int blk_revalidate_disk_zones(struct gendisk *disk);
361+
int blk_revalidate_disk_zones(struct gendisk *disk,
362+
void (*update_driver_data)(struct gendisk *disk));
362363

363364
extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
364365
unsigned int cmd, unsigned long arg);

0 commit comments

Comments
 (0)