qemu discard-zeroes=unmap should discard on backend storage?

amospalla

Member
May 15, 2019
6
1
8
23
Hello,

I am testing the meaning of discard-zeroes qemu's option, and from I've read it should detect that a bunch of zeroes are being written, and instead of writing zeros to the backend storage, discard/trim.

Is this the way it is supposed to work? Detect zeroes and discard them instead of writing them?

I have tried that but when writing zeroes to the virtual machine, the backend storage (ceph) stores zeroes instead of trimming. If I later within vm do a blkdiscard then the space where zeroes are written is discarded.

rbd du pool/vm-101-disk-1:

empty:
NAME PROVISIONED USED
vm-101-disk-1 9GiB 24MiB

after dd if=/dev/zero of=/dev/sdb1 bs=4M (64MiB partition)
NAME PROVISIONED USED
vm-101-disk-1 9GiB 88MiB

blkdiscard /dev/sdb1:
NAME PROVISIONED USED
vm-101-disk-1 9GiB 28MiB
 
Hi,

do you mean the discard option at the vdisk?
If yes this means that discard command will past to the underlying storage.
So you can free all unused blocks.
In the past, with HDD disk the cost of erasing blocks was very high and not necessary for reuse the block again.
Now with NAND based Disks and thin allocated storages like Ceph is you have to free a block so the disk image will get smaller.

In short, it makes fstrim work.
 
It is related, but not exactly plain discard passthrough.

I was talking about a qemu's parameter (not directly exposed on PVE): detetect_zeroes=on (equivalent to =unmap).

It is supposed to detect if a write is a bunch of zeroes, and in that case, do not write zeroes, but discard.

But after reading documentation and websites, and playing with it, or I missunderstood what it does or how, or it does not work.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!