Skip to content

Commit 2afdeb2

Browse files
damien-lemoalaxboe
authored andcommitted
block: Improve blk_revalidate_disk_zones() checks
Improves the checks on the zones of a zoned block device done in blk_revalidate_disk_zones() by making sure that the device report_zones method did report at least one zone and that the zones reported exactly cover the entire disk capacity, that is, that there are no missing zones at the end of the disk sector range. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0eff1f1 commit 2afdeb2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

block/blk-zoned.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,29 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
508508
noio_flag = memalloc_noio_save();
509509
ret = disk->fops->report_zones(disk, 0, UINT_MAX,
510510
blk_revalidate_zone_cb, &args);
511+
if (!ret) {
512+
pr_warn("%s: No zones reported\n", disk->disk_name);
513+
ret = -ENODEV;
514+
}
511515
memalloc_noio_restore(noio_flag);
512516

517+
/*
518+
* If zones where reported, make sure that the entire disk capacity
519+
* has been checked.
520+
*/
521+
if (ret > 0 && args.sector != get_capacity(disk)) {
522+
pr_warn("%s: Missing zones from sector %llu\n",
523+
disk->disk_name, args.sector);
524+
ret = -ENODEV;
525+
}
526+
513527
/*
514528
* Install the new bitmaps and update nr_zones only once the queue is
515529
* stopped and all I/Os are completed (i.e. a scheduler is not
516530
* referencing the bitmaps).
517531
*/
518532
blk_mq_freeze_queue(q);
519-
if (ret >= 0) {
533+
if (ret > 0) {
520534
blk_queue_chunk_sectors(q, args.zone_sectors);
521535
q->nr_zones = args.nr_zones;
522536
swap(q->seq_zones_wlock, args.seq_zones_wlock);

0 commit comments

Comments
 (0)