libnfs icon indicating copy to clipboard operation
libnfs copied to clipboard

Add support for trim/discard and writing zeroes.

Open rwmjones opened this issue 8 months ago • 1 comments

I'm not sure if trim/discard and write-zeroes are supported by the NFS protocol, but if it is the libnfs should support it.

A typical way to hole-punch a file on Linux is to use:

fallocate (fd, FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE,
    offset, count);

where offset and count must be multiples of the filesystem block size.

A typical way to write zeroes efficiently is the same fallocate call but setting flags to FALLOC_FL_ZERO_RANGE.

https://www.man7.org/linux/man-pages/man2/fallocate.2.html

rwmjones avatar Apr 10 '25 09:04 rwmjones

NFSv4.2 has both SEEK for SEEK_DATA and SEEK_HOLE as well as a DEALLOCATE operation.

Unfortunately it seems at least knfsd do not allow these operations unless we negotiate nfs v4.2 I currently use nfs v4.0 and session establish is a bit different, then all compound chains are also wrapped inside a SEQUENCE operation for 4.2.

I guess it is as good a time as any to start implementing NFSv4.2. That will be quite fun but it will take a little time.

So, give me some time and I will first add 4.2 support and the cherrypick the deallocate and seek patches into master.

sahlberg avatar Apr 12 '25 06:04 sahlberg