aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/virtio_blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r--drivers/block/virtio_blk.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 258bc2ae288..2d6191aa594 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -366,12 +366,32 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
366 vblk->disk->driverfs_dev = &vdev->dev; 366 vblk->disk->driverfs_dev = &vdev->dev;
367 index++; 367 index++;
368 368
369 /* If barriers are supported, tell block layer that queue is ordered */ 369 if (virtio_has_feature(vdev, VIRTIO_BLK_F_FLUSH)) {
370 if (virtio_has_feature(vdev, VIRTIO_BLK_F_FLUSH)) 370 /*
371 * If the FLUSH feature is supported we do have support for
372 * flushing a volatile write cache on the host. Use that
373 * to implement write barrier support.
374 */
371 blk_queue_ordered(q, QUEUE_ORDERED_DRAIN_FLUSH, 375 blk_queue_ordered(q, QUEUE_ORDERED_DRAIN_FLUSH,
372 virtblk_prepare_flush); 376 virtblk_prepare_flush);
373 else if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER)) 377 } else if (virtio_has_feature(vdev, VIRTIO_BLK_F_BARRIER)) {
378 /*
379 * If the BARRIER feature is supported the host expects us
380 * to order request by tags. This implies there is not
381 * volatile write cache on the host, and that the host
382 * never re-orders outstanding I/O. This feature is not
383 * useful for real life scenarious and deprecated.
384 */
374 blk_queue_ordered(q, QUEUE_ORDERED_TAG, NULL); 385 blk_queue_ordered(q, QUEUE_ORDERED_TAG, NULL);
386 } else {
387 /*
388 * If the FLUSH feature is not supported we must assume that
389 * the host does not perform any kind of volatile write
390 * caching. We still need to drain the queue to provider
391 * proper barrier semantics.
392 */
393 blk_queue_ordered(q, QUEUE_ORDERED_DRAIN, NULL);
394 }
375 395
376 /* If disk is read-only in the host, the guest should obey */ 396 /* If disk is read-only in the host, the guest should obey */
377 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO)) 397 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))