<div dir="ltr"><div dir="ltr">On Thu, Sep 2, 2021 at 1:47 PM Sean Mooney <<a href="mailto:smooney@redhat.com">smooney@redhat.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 2021-09-02 at 16:48 +0000, Sven Kieske wrote:<br>> Virtio-blk in upstream Kernel[2] and in qemu[3] does clearly support<br>
> discard/trim, which we discovered thanks to StackExchange[4].<br>
> <br>
> So my question is, has someone successfully used trim/discard with<br>
> virtio-blk in nova provisioned vms?<br>and there is an nova config option to enable it.<br>
<a href="https://docs.openstack.org/nova/latest/configuration/config.html#libvirt.hw_disk_discard" rel="noreferrer" target="_blank">https://docs.openstack.org/nova/latest/configuration/config.html#libvirt.hw_disk_discard</a><br>
so perhaps you just need to set that o unmap<br>
e.g. <br>
/etc/nova/nova.conf:<br>
[libvirt]<br>
hw_disk_discard=unmap<br></blockquote><div><br></div><div>With a recent enough qemu on hypervisor, and discard support on the block store, it can technically work. However, the guest was the problem for me. For example, I believe the RHEL/CentOS 8.x / 4.18 kernel does NOT provide support for this capability. But, Linux 5.4 works fine.<br></div><div><br></div><div>Other than this, it works fine. I have used it for a while now, and it is just bringing the guests up-to-date that prevented it from being more useful. For older guests, I have a simple script that basically fills the guests file system up to 95% full with zero blocks, and the zero block has the same effect on my underlying storage.</div><div><br></div><div>Finally, I would caveat that discard should not be a storage management solution. The storage should be the right size, and it should get naturally recycled. But, over time - perhaps every few months, or once a year, there is a consequence that guests don't pass through "free" information to the hypervisor on the regular, and it will capture dead blocks in the underlying storage that never get garbage collected, and this is an unfortunate waste. In our case, SolidFire stores the blocks 3X and it adds up. In five years, I've done the clean up with discard or zero only twice.</div><div></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Mark Mielke <<a href="mailto:mark.mielke@gmail.com" target="_blank">mark.mielke@gmail.com</a>><br><br></div></div>