linux-nfs / nfsd

Linux kernel source tree
Other
0 stars 0 forks source link

Return a positive space limit in write delegations #86

Open chucklever opened 4 months ago

chucklever commented 4 months ago

Write delegations include a space limit, defined this way in Section 18.16.2 of RFC 8881:

nfs_space_limit4
           space_limit; /* Defines condition that
                           the client must check to
                           determine whether the
                           file needs to be flushed
                           to the server on close.  */

Unfortunately this is effectively all that RFC 8881 has to say about it. Right now we assume that this is the amount of data that a server guarantees can be written into this file without generating an ENOSPC. Clients want to use this feature so that, on CLOSE, they do not have to perform a waiting flush of dirty data -- close(2) can return to the application with a zero return code even though this data hasn't reached the server's disk. This can speed workflows such as untar.

We will need further research to understand the exact meaning/semantics of nfs_space_limit4 to understand how to implement it.

chucklever commented 3 months ago

RFC 8881 Section 10.4.1 explains:

With delegations, a client is able to avoid writing data to the server when the CLOSE of a file is serviced. The file close system call is the usual point at which the client is notified of a lack of stable storage for the modified file data generated by the application. At the close, file data is written to the server and, through normal accounting, the server is able to determine if the available file system space for the data has been exceeded (i.e., the server returns NFS4ERR_NOSPC or NFS4ERR_DQUOT). This accounting includes quotas. The introduction of delegations requires that an alternative method be in place for the same type of communication to occur between client and server.

In the delegation response, the server provides either the limit of the size of the file or the number of modified blocks and associated block size. The server must ensure that the client will be able to write modified data to the server of a size equal to that provided in the original delegation. The server must make this assurance for all outstanding delegations. Therefore, the server must be careful in its management of available space for new or modified data, taking into account available file system space and any applicable quotas. The server can recall delegations as a result of managing the available file system space. The client should abide by the server's state space limits for delegations. If the client exceeds the stated limits for the delegation, the server's behavior is undefined.

Based on server conditions, quotas, or available file system space, the server may grant OPEN_DELEGATE_WRITE delegations with very restrictive space limitations. The limitations may be defined in a way that will always force modified data to be flushed to the server on close