diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-06-19 13:44:19 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-06-24 10:25:17 +0200 |
commit | 67af674e478054086f972811dd0a11289afa39a9 (patch) | |
tree | 9d1fbd115bc79b44f4ae73345158d623976e06ee /block/qcow2-refcount.c | |
parent | 6cfcb9b8b91d303ab51b78623f2299b5288d2d51 (diff) |
qcow2: Options to enable discard for freed clusters
Deleted snapshots are discarded in the image file by default, discard
requests take their default from the -drive discard=... option and other
places that free clusters must always be enabled explicitly.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r-- | block/qcow2-refcount.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 6d35e49d32..7488988a9a 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -488,6 +488,11 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, s->free_cluster_index = cluster_index; } refcount_block[block_index] = cpu_to_be16(refcount); + if (refcount == 0 && s->discard_passthrough[type]) { + /* Try discarding, ignore errors */ + /* FIXME Doing this cluster by cluster will be painfully slow */ + bdrv_discard(bs->file, cluster_offset, 1); + } } ret = 0; |