linux-nfs / nfsd

Linux kernel source tree
Other
0 stars 0 forks source link

Return a write delegation for files opened O_WRONLY #88

Open chucklever opened 2 months ago

chucklever commented 2 months ago

Currently NFSD can return a write delegation for a file opened O_RDWR but it never returns a delegation for files opened O_WRONLY. Some common applications (such as "git clone") sequentially create files with "open(O_CREAT | O_WRONLY); write write write; close". In those case, having a write delegation might enable the client to avoid a waiting flush during the close(2). When a file is first created, we do not expect that other clients will have visibility of that file, so there is unlikely to be a forthcoming access conflict that would trigger an immediate delegation recall.

Parking this issue to document the reasons why NFSD does not currently emit a delegation on OPEN(O_WRONLY), and to see what can be done about adding it.

chucklever commented 2 days ago

Dai explains that the problem was that when the Linux NFS client gets a write delegation on a file it has opened WR_ONLY, it will send READ operations with the anonymous state ID. NFSD rejects these READ requests. Dai says the spec permits servers to honor such requests.

To enable handing out write delegations on WR_ONLY opens, we need to first adjust NFSD's READ implementation to allow READs with the anonymous stateID.