Skip to content

Commit a3d96ed

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: block: virtio_blk: Set zone limits before revalidating zones
In virtblk_probe_zoned_device(), execute blk_queue_chunk_sectors() and blk_queue_max_zone_append_sectors() to respectively set the zoned device zone size and maximum zone append sector limit before executing blk_revalidate_disk_zones(). This is to allow the block layer zone reavlidation to check these device characteristics prior to checking all zones of the device. Signed-off-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Dmitry Fomichev <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent a442b89 commit a3d96ed

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

drivers/block/virtio_blk.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
781781
{
782782
u32 v, wg;
783783
u8 model;
784-
int ret;
785784

786785
virtio_cread(vdev, struct virtio_blk_config,
787786
zoned.model, &model);
@@ -836,6 +835,7 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
836835
vblk->zone_sectors);
837836
return -ENODEV;
838837
}
838+
blk_queue_chunk_sectors(q, vblk->zone_sectors);
839839
dev_dbg(&vdev->dev, "zone sectors = %u\n", vblk->zone_sectors);
840840

841841
if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) {
@@ -844,26 +844,22 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev,
844844
blk_queue_max_discard_sectors(q, 0);
845845
}
846846

847-
ret = blk_revalidate_disk_zones(vblk->disk, NULL);
848-
if (!ret) {
849-
virtio_cread(vdev, struct virtio_blk_config,
850-
zoned.max_append_sectors, &v);
851-
if (!v) {
852-
dev_warn(&vdev->dev, "zero max_append_sectors reported\n");
853-
return -ENODEV;
854-
}
855-
if ((v << SECTOR_SHIFT) < wg) {
856-
dev_err(&vdev->dev,
857-
"write granularity %u exceeds max_append_sectors %u limit\n",
858-
wg, v);
859-
return -ENODEV;
860-
}
861-
862-
blk_queue_max_zone_append_sectors(q, v);
863-
dev_dbg(&vdev->dev, "max append sectors = %u\n", v);
847+
virtio_cread(vdev, struct virtio_blk_config,
848+
zoned.max_append_sectors, &v);
849+
if (!v) {
850+
dev_warn(&vdev->dev, "zero max_append_sectors reported\n");
851+
return -ENODEV;
852+
}
853+
if ((v << SECTOR_SHIFT) < wg) {
854+
dev_err(&vdev->dev,
855+
"write granularity %u exceeds max_append_sectors %u limit\n",
856+
wg, v);
857+
return -ENODEV;
864858
}
859+
blk_queue_max_zone_append_sectors(q, v);
860+
dev_dbg(&vdev->dev, "max append sectors = %u\n", v);
865861

866-
return ret;
862+
return blk_revalidate_disk_zones(vblk->disk, NULL);
867863
}
868864

869865
#else

0 commit comments

Comments
 (0)