Skip to contentSkip to conversation

qcow2: Add bdrv_discard support

PATCH Jun Li 2 participants 2 messages Aug 24, 2014 – Aug 27, 2014

lore
Share & tools
lore

Jun Li

author
#0 lore raw

Hi Kevin and Stefan,

As the realize of bdrv_discard, and this patch has been received, but
I have some question.

This adds a bdrv_discard function to qcow2 that frees the discarded clusters. It does not yet pass the discard on to the underlying file system driver, but the space can be reused by future writes to the image.

Above content is on url: https://lists.gnu.org/archive/html/qemu-devel/2011-01/msg03100.html

I have following question:

Why bdrv_discard does not yet pass the discard on to the underlying file system driver? And this exist a potential issue: host cluster leak for qcow2. As qcow2 image can be created on RAW disk, so this is not just "does not yet pass the discard on to the underlying file system driver". Could you give some explanation why do not realize this function? Thx.

As I am trying to realize qcow2 shrinking, but hit bdrv_discard can not release the free cluster on host.

Best Regards,
Jun Li

#1 lore raw
Quoted 9 lines · Jun Li

Why bdrv_discard does not yet pass the discard on to the underlying file system driver? And this exist a potential issue: host cluster leak for qcow2. As qcow2 image can be created on RAW disk,
so this is not just "does not yet pass the discard on to the underlying file system driver". Could you give some explanation why do not realize this function? Thx.

As I am trying to realize qcow2 shrinking, but hit bdrv_discard can not release the free cluster on host.

qcow2 is capable of passing discards down to the image file. See qcow2_process_discards().

It is important that s->discard_passthrough[QCOW2_DISCARD_REQUEST] is true! Make sure to use the pass-discard-request=on or discard=unmap options.

Stefan