bhyve Is fstrim needed?

Hi,

Have created a Ubuntu VM on a FreeBSD 13.2-RELEASE host with NVME disk and:

Code:
disk0_type="virtio-blk"
disk0_name="disk0.img"

VM has its own ZFS subvolume. Unfortunately, it seems that the guest can't run fstrim, it says:

fstrim: /: the discard operation is not supported

I have two questions:
  1. Is that a problem? If yes, what kind of problem? (loosing space? performance?)
  2. Which drivers do support fstrim? Are they good fit for a NVME disk?
Thank you!
 
(looking at usr.sbin/bhyve/block_if.c)

With virtio-blk trim should work unless you explicitly pass nodelete as an option. The host disk type should not really matter here (unless you are giving the guest a real disk); what matters is the type of "device" you allocate for guest.

If it's zvol, it should likely depend on if it's thin provisioned or not.
If it's file (seems to be your case), it depends on if filesystem supports hole-punching.

I don't know the correct way to query FS support, so I did the following :)
Code:
#include <err.h>
#include <stdio.h>
#include <unistd.h>

int
main(void)
{
        long pc;

        pc = pathconf(".", _PC_DEALLOC_PRESENT);
        if (pc == -1)
                err(1, "pathconf");
        printf("%ssupported\n", pc == 1 ? "" : "not");

        return (0);
}
...and it seems to say "supported" for my ZFS home.
 
Looks like I spoke too soon, and trim for file-backed devices is only supported in -CURRENT; candelete is always 0 in 13.2 unless it's character device which supports trim.
 
I don't even have _PC_DEALLOC_PRESENT present in 13.2-RELEASE but what a great way to check that! :)
 
Back
Top