@@ -351,8 +351,14 @@ static int __devinit virtblk_probe(struct
virtio_device *vdev)
/* No need to bounce any requests */
blk_queue_bounce_limit(vblk->disk->queue, BLK_BOUNCE_ANY);
- /* No real sector limit. */
- blk_queue_max_sectors(vblk->disk->queue, -1U);
+ /* Host can optionally specify maximum total sectors in an I/O. */
+ err = virtio_config_val(vdev, VIRTIO_BLK_F_SECTOR_MAX,
+ offsetof(struct virtio_blk_config, sectors_max),
+ &v);
+ if (!err)
+ blk_queue_max_sectors(vblk->disk->queue, v);
+ else
+ blk_queue_max_sectors(vblk->disk->queue, -1U);
/* Host can optionally specify maximum segment size and number of
* segments. */
@@ -412,7 +418,7 @@ static struct virtio_device_id id_table[] = {
static unsigned int features[] = {
VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
- VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH
+ VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_SECTOR_MAX
};
/*
@@ -15,6 +15,7 @@
#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */
+#define VIRTIO_BLK_F_SECTOR_MAX 10 /* Maximum total sectors in an I/O */
struct virtio_blk_config {
/* The capacity (in 512-byte sectors). */
@@ -31,6 +32,7 @@ struct virtio_blk_config {
} geometry;
/* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
__u32 blk_size;
+ __u32 sectors_max;
} __attribute__((packed));
/*