libnfs icon indicating copy to clipboard operation
libnfs copied to clipboard

Sparse file support (NFSv4.2 SEEK, ALLOCATE, DEALLOCATE, READPLUS, WRITESAME)

Open aureliencouderc opened this issue 7 months ago • 2 comments

Could you please implement sparse file support?

Typical users are databases, High Performance Computing, Big Data, distributed system and so on.

  • Required are:
  • NFSv4.2 support in libnfs
  • NFSv4.2 operation "SEEK", to list sections with data, and sections with holes
  • NFSv4.2 operation "ALLOCATE", to allocate disk space
  • NFSv4.2 operation "DEALLOCATE", to free/deallocate disk space, aka punching a hole (which does not alter a file's size)
  • NFSv4.2 operation "READPLUS", to read from sparse files. The returned data are a list of unions, each union either containing the block data, or the size of the hole
  • NFSv4.2 operation "WRITESAME", to fill (and thus allocate) files with repeated patterns (typical fill with zeros, or "empty pattern" for databases)
  • Cavats/notes:
  • Sparse files contain sections called "holes" which do not contain data, but for backwards compatibility read as 0x00 bytes. But valid data can contain long sequences of 0x00 bytes, which are NOT holes
  • NFSv4.2 READPLUS union branch for holes contain the full length of a hole, even if the length is bigger than the requested chunk size of the read operation

aureliencouderc avatar May 01 '25 20:05 aureliencouderc

This would be really nice but it would require fist I add full support for NFSv4.2 and then also all the new commands.

This is unfortunately a very major effort and pretty low on my priority list so we will likely need someone to sponsor and contribute this work.

I do no personally need this functionality so that is why it is low priority, but pull requests to add it is super welcome.

sahlberg avatar May 17 '25 10:05 sahlberg

This would be really nice but it would require fist I add full support for NFSv4.2 and then also all the new commands.

AFAIK you only need NFS4 minor protocol negotiation? You establish a connection, try to create a 4.2 session, and if it comes back with NFS4ERR_MINOR_VERS_MISMATCH you try again with 4.1.

Or do I miss something?

This is unfortunately a very major effort and pretty low on my priority list so we will likely need someone to sponsor and contribute this work.

I do no personally need this functionality so that is why it is low priority, but pull requests to add it is super welcome.

READ_PLUS should be at least of some importance, as it boosts reading from sparse files significantly.

aureliencouderc avatar May 20 '25 19:05 aureliencouderc