=== Packrat -- NFS client caching on non-volatile storage

Contact: Rick Macklem <rmacklem@freebsd.org>

NFSv4.1/4.2 provides support for a feature called delegations.
When a NFSv4.1/4.2 client holds a delegation, the client has certain rights to a file, including a guarantee that no other client will make changes to the file unless the delegation is recalled.
As such, when a client holds a delegation for a file, it can aggressively cache the file's data, knowing that it will not be modified by other clients until it returns the delegation.

This project is intended to allow the NFSv4.1/4.2 client to aggressively cache file data on client local non-volatile storage, when the client holds a delegation for the file.
I created a patch long ago to try and do this for NFSv4.0, but it was never at a stage where it was worth using.
This project is a complete rewrite of the patch, done in part because NFSv4.1/4.2 plus other recent NFSv4 related changes makes doing this more feasible.

The patch is getting stable now, but I am not sure if it will be ready for inclusion in FreeBSD 15 as an experimental feature enabled via a new mount option called "packrat".

The main thing I still need to do is code a writeback kernel thread.
Right now, dirty chunks stored on client local non-volatile storage get written back to the NFSv4.1/4.2 server upon umount.
This can result in the umount taking a long time (as in many minutes).
To alleviate this, I am planning on implementing a writeback kernel process that will walk the non-volatile storage and write the dirty chunks back.
The trick is to make it aggressive enough that most dirty chunks have been written back when a umount is done, but not so aggressive that it impedes the performance of synchronous NFSv4.1/4.2 RPCs.

This will be very much an experimental feature, but it is hoped it will allow NFS mounts to be used more effectively, particularly in WAN situations, such as a mobile laptop.

There is still work to be done, particularly with respect to recovery of delegations after a NFSv4.1/4.2 client restart.
