mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
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>
This commit is contained in:
parent
6cfcb9b8b9
commit
67af674e47
3 changed files with 36 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue