[Libguestfs] FYI: nbdfuse support for trim and writing zeroes

Richard W.M. Jones rjones at redhat.com
Tue May 11 12:54:58 UTC 2021


I added support for trimming to nbdfuse over the weekend:

  https://gitlab.com/nbdkit/libnbd/-/commit/800c021f39ddfa1dd40d8dcc8645463e662ea03b

This intercepts Linux fallocate(2) on the file and if the mode
parameter contains FALLOC_FL_PUNCH_HOLE then it will punch a hole
using nbd_trim.  This all appears to work fine.

As noted in the above commit, in theory we could also check for
mode & FALLOC_FL_ZERO_RANGE.  When I use "fallocate -z ..." on a file,
I see this is the mode parameter being passed to the system call:

  fallocate(3, FALLOC_FL_ZERO_RANGE, 512, 512) = 0

However it appears as if the fuse kernel module doesn't pass the flag
through to nbdfuse.  (I checked the kernel code too, and that *seems*
to agree with my assessment).  So for now I left support for zeroing
in there but disabled the test.

The fuse developer mailing list seems to be mostly spam.  There is
this closed github issue which says to contact the kernel developers
which I have not done:

  https://github.com/libfuse/libfuse/issues/395

Next step for nbdfuse is to add multithreading support which would
greatly improve performance but is rather complicated to implement.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list