mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 06:43:53 -06:00
vhost-user-blk: add discard/write zeroes features support
Linux commit 1f23816b8 "virtio_blk: add discard and write zeroes support" added the support in the Guest kernel, while here also enable the features support with vhost-user-blk driver. Also enable the test example utility with DISCARD and WRITE ZEROES commands. Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
a56de056c9
commit
caa1ee4313
3 changed files with 159 additions and 33 deletions
|
@ -38,6 +38,8 @@
|
|||
#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
|
||||
#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
|
||||
#define VIRTIO_BLK_F_MQ 12 /* support more than one vq */
|
||||
#define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */
|
||||
#define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */
|
||||
|
||||
/* Legacy feature bits */
|
||||
#ifndef VIRTIO_BLK_NO_LEGACY
|
||||
|
@ -84,6 +86,39 @@ struct virtio_blk_config {
|
|||
|
||||
/* number of vqs, only available when VIRTIO_BLK_F_MQ is set */
|
||||
uint16_t num_queues;
|
||||
|
||||
/* the next 3 entries are guarded by VIRTIO_BLK_F_DISCARD */
|
||||
/*
|
||||
* The maximum discard sectors (in 512-byte sectors) for
|
||||
* one segment.
|
||||
*/
|
||||
uint32_t max_discard_sectors;
|
||||
/*
|
||||
* The maximum number of discard segments in a
|
||||
* discard command.
|
||||
*/
|
||||
uint32_t max_discard_seg;
|
||||
/* Discard commands must be aligned to this number of sectors. */
|
||||
uint32_t discard_sector_alignment;
|
||||
|
||||
/* the next 3 entries are guarded by VIRTIO_BLK_F_WRITE_ZEROES */
|
||||
/*
|
||||
* The maximum number of write zeroes sectors (in 512-byte sectors) in
|
||||
* one segment.
|
||||
*/
|
||||
uint32_t max_write_zeroes_sectors;
|
||||
/*
|
||||
* The maximum number of segments in a write zeroes
|
||||
* command.
|
||||
*/
|
||||
uint32_t max_write_zeroes_seg;
|
||||
/*
|
||||
* Set if a VIRTIO_BLK_T_WRITE_ZEROES request may result in the
|
||||
* deallocation of one or more of the sectors.
|
||||
*/
|
||||
uint8_t write_zeroes_may_unmap;
|
||||
|
||||
uint8_t unused1[3];
|
||||
} QEMU_PACKED;
|
||||
|
||||
/*
|
||||
|
@ -137,6 +172,19 @@ struct virtio_blk_outhdr {
|
|||
__virtio64 sector;
|
||||
};
|
||||
|
||||
/* Unmap this range (only valid for write zeroes command) */
|
||||
#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001
|
||||
|
||||
/* Discard/write zeroes range for each request. */
|
||||
struct virtio_blk_discard_write_zeroes {
|
||||
/* discard/write zeroes start sector */
|
||||
uint64_t sector;
|
||||
/* number of discard/write zeroes sectors */
|
||||
uint32_t num_sectors;
|
||||
/* flags for this range */
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
#ifndef VIRTIO_BLK_NO_LEGACY
|
||||
struct virtio_scsi_inhdr {
|
||||
__virtio32 errors;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue