return true;
}
-static int blk_report_zones(struct gendisk *disk, sector_t sector,
- struct blk_zone *zones, unsigned int *nr_zones)
-{
- struct request_queue *q = disk->queue;
- unsigned int z = 0, n, nrz = *nr_zones;
- sector_t capacity = get_capacity(disk);
- int ret;
-
- while (z < nrz && sector < capacity) {
- n = nrz - z;
- ret = disk->fops->report_zones(disk, sector, &zones[z], &n);
- if (ret)
- return ret;
- if (!n)
- break;
- sector += blk_queue_zone_sectors(q) * n;
- z += n;
- }
-
- WARN_ON(z > *nr_zones);
- *nr_zones = z;
-
- return 0;
-}
-
/**
* blkdev_report_zones - Get zones information
* @bdev: Target block device
struct blk_zone *zones, unsigned int *nr_zones)
{
struct request_queue *q = bdev_get_queue(bdev);
+ struct gendisk *disk = bdev->bd_disk;
unsigned int i, nrz;
int ret;
* report_zones method. If it does not have one defined, the device
* driver has a bug. So warn about that.
*/
- if (WARN_ON_ONCE(!bdev->bd_disk->fops->report_zones))
+ if (WARN_ON_ONCE(!disk->fops->report_zones))
return -EOPNOTSUPP;
if (!*nr_zones || sector >= bdev->bd_part->nr_sects) {
nrz = min(*nr_zones,
__blkdev_nr_zones(q, bdev->bd_part->nr_sects - sector));
- ret = blk_report_zones(bdev->bd_disk, get_start_sect(bdev) + sector,
- zones, &nrz);
+ ret = disk->fops->report_zones(disk, get_start_sect(bdev) + sector,
+ zones, &nrz);
if (ret)
return ret;
while (z < nr_zones) {
nrz = min(nr_zones - z, rep_nr_zones);
- ret = blk_report_zones(disk, sector, zones, &nrz);
+ ret = disk->fops->report_zones(disk, sector, zones, &nrz);
if (ret)
goto out;
if (!nrz)
goto out;
}
- /*
- * blkdev_report_zones() will loop and call this again to cover all the
- * zones of the target, eventually moving on to the next target.
- * So there is no need to loop here trying to fill the entire array
- * of zones.
- */
ret = tgt->type->report_zones(tgt, sector, zones, nr_zones);
out: