diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-06-19 13:44:20 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-06-24 10:25:17 +0200 |
commit | 0b919fae31f4f80f78ebeab8388dc3a03cc5e4ed (patch) | |
tree | d28c579aa6c160de1efe1d46cf91c1c80f794e3f /block/qcow2.h | |
parent | 67af674e478054086f972811dd0a11289afa39a9 (diff) | |
download | qemu-0b919fae31f4f80f78ebeab8388dc3a03cc5e4ed.zip |
qcow2: Batch discards
This optimises the discard operation for freed clusters by batching
discard requests (both snapshot deletion and bdrv_discard end up
updating the refcounts cluster by cluster).
Note that we don't discard asynchronously, but keep s->lock held. This
is to avoid that a freed cluster is reallocated and written to while the
discard is still in flight.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/qcow2.h')
-rw-r--r-- | block/qcow2.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/block/qcow2.h b/block/qcow2.h index 6f91b9a016..3b2d5cda71 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -147,6 +147,13 @@ typedef struct Qcow2Feature { char name[46]; } QEMU_PACKED Qcow2Feature; +typedef struct Qcow2DiscardRegion { + BlockDriverState *bs; + uint64_t offset; + uint64_t bytes; + QTAILQ_ENTRY(Qcow2DiscardRegion) next; +} Qcow2DiscardRegion; + typedef struct BDRVQcowState { int cluster_bits; int cluster_size; @@ -199,6 +206,8 @@ typedef struct BDRVQcowState { size_t unknown_header_fields_size; void* unknown_header_fields; QLIST_HEAD(, Qcow2UnknownHeaderExtension) unknown_header_ext; + QTAILQ_HEAD (, Qcow2DiscardRegion) discards; + bool cache_discards; } BDRVQcowState; /* XXX: use std qcow open function ? */ @@ -374,6 +383,8 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs, int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); +void qcow2_process_discards(BlockDriverState *bs, int ret); + /* qcow2-cluster.c functions */ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, bool exact_size); |