summaryrefslogtreecommitdiffstats
path: root/include/linux/virtio_blk.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-09-17 19:57:42 +0200
committerRusty Russell <rusty@rustcorp.com.au>2009-09-23 22:26:36 +0930
commitf1b0ef062602713c2c7cfa12362d5d90ed01c5f6 (patch)
tree30a130141b7c4b69ff20d134734acd40f1ee0960 /include/linux/virtio_blk.h
parent3ca4f5ca73057a617f9444a91022d7127041970a (diff)
downloadlinux-f1b0ef062602713c2c7cfa12362d5d90ed01c5f6.tar.gz
linux-f1b0ef062602713c2c7cfa12362d5d90ed01c5f6.tar.bz2
linux-f1b0ef062602713c2c7cfa12362d5d90ed01c5f6.zip
virtio_blk: add support for cache flush
Recent qemu has added a VIRTIO_BLK_F_FLUSH flag to advertise that the virtual disk has a volatile write cache that needs to be flushed. In case we see this feature implement tell the Linux block layer about the fact and use the new VIRTIO_BLK_T_FLUSH to flush the cache when required. This allows for an correct and simple implementation of write barriers. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/virtio_blk.h')
-rw-r--r--include/linux/virtio_blk.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index 25fbabfa90d4..15cb666581d7 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -14,6 +14,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_IDENTIFY 8 /* ATA IDENTIFY supported */
+#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */
#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
@@ -35,6 +36,17 @@ struct virtio_blk_config {
__u8 identify[VIRTIO_BLK_ID_BYTES];
} __attribute__((packed));
+/*
+ * Command types
+ *
+ * Usage is a bit tricky as some bits are used as flags and some are not.
+ *
+ * Rules:
+ * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
+ * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own
+ * and may not be combined with any of the other flags.
+ */
+
/* These two define direction. */
#define VIRTIO_BLK_T_IN 0
#define VIRTIO_BLK_T_OUT 1
@@ -42,6 +54,9 @@ struct virtio_blk_config {
/* This bit says it's a scsi command, not an actual read or write. */
#define VIRTIO_BLK_T_SCSI_CMD 2
+/* Cache flush command */
+#define VIRTIO_BLK_T_FLUSH 4
+
/* Barrier before this op. */
#define VIRTIO_BLK_T_BARRIER 0x80000000