diff options
author | Christoph Hellwig <hch@lst.de> | 2009-09-17 13:57:42 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-09-23 08:56:36 -0400 |
commit | f1b0ef062602713c2c7cfa12362d5d90ed01c5f6 (patch) | |
tree | 30a130141b7c4b69ff20d134734acd40f1ee0960 /include/linux/virtio_blk.h | |
parent | 3ca4f5ca73057a617f9444a91022d7127041970a (diff) |
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.h | 15 |
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 @@ | |||
14 | #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ | 14 | #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ |
15 | #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ | 15 | #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ |
16 | #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */ | 16 | #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */ |
17 | #define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */ | ||
17 | 18 | ||
18 | #define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */ | 19 | #define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */ |
19 | 20 | ||
@@ -35,6 +36,17 @@ struct virtio_blk_config { | |||
35 | __u8 identify[VIRTIO_BLK_ID_BYTES]; | 36 | __u8 identify[VIRTIO_BLK_ID_BYTES]; |
36 | } __attribute__((packed)); | 37 | } __attribute__((packed)); |
37 | 38 | ||
39 | /* | ||
40 | * Command types | ||
41 | * | ||
42 | * Usage is a bit tricky as some bits are used as flags and some are not. | ||
43 | * | ||
44 | * Rules: | ||
45 | * VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or | ||
46 | * VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own | ||
47 | * and may not be combined with any of the other flags. | ||
48 | */ | ||
49 | |||
38 | /* These two define direction. */ | 50 | /* These two define direction. */ |
39 | #define VIRTIO_BLK_T_IN 0 | 51 | #define VIRTIO_BLK_T_IN 0 |
40 | #define VIRTIO_BLK_T_OUT 1 | 52 | #define VIRTIO_BLK_T_OUT 1 |
@@ -42,6 +54,9 @@ struct virtio_blk_config { | |||
42 | /* This bit says it's a scsi command, not an actual read or write. */ | 54 | /* This bit says it's a scsi command, not an actual read or write. */ |
43 | #define VIRTIO_BLK_T_SCSI_CMD 2 | 55 | #define VIRTIO_BLK_T_SCSI_CMD 2 |
44 | 56 | ||
57 | /* Cache flush command */ | ||
58 | #define VIRTIO_BLK_T_FLUSH 4 | ||
59 | |||
45 | /* Barrier before this op. */ | 60 | /* Barrier before this op. */ |
46 | #define VIRTIO_BLK_T_BARRIER 0x80000000 | 61 | #define VIRTIO_BLK_T_BARRIER 0x80000000 |
47 | 62 | ||