Skip to contentSkip to conversation

Using the ATA "trim" command to discard sectors in disk images

Qemu-devel Marc Bevand 1 participant 1 message Mar 24, 2009

lore
Share & tools
lore
#0 lore raw

The ATA command "trim", recently standardized by the T13 committee, has been designed to allow SSDs to do better wear-leveling. But there is an obvious fit for it in virtualizers such as Qemu: guests issuing trim commands would allow the host to deallocate block sectors in disk images.

In fact the trim command is already used by very recent Linux kernels: it is exported to the kernel via the block layer blkdev_issue_discard() call, and to userspace via the BLKDISCARD ioctl:

http://lwn.net/Articles/293658/

Swap allocation just started making use of it 2.6.29:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7992fde72ce06c73280a1939b7a1e903bc95ef85

I just wanted to raise awareness of that command. I hope sometime in the future we will see qcow files able to decrease in size when files are deleted in guests :-)

-marc