nfsd: Cache R, RW, and W opens separately
authorJ. Bruce Fields <bfields@redhat.com>
Fri, 17 Jul 2020 22:54:54 +0000 (18:54 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 25 Sep 2020 22:02:02 +0000 (18:02 -0400)
commitae3c57b5ca47665dc3416447a5534a9796096d86
tree9fda3211dbfb66ba2a43d7145e9405d2ea237510
parent0aa99c4d1f216318b1c4f4e4fe321868294a1d9f
nfsd: Cache R, RW, and W opens separately

The nfsd open code has always kept separate read-only, read-write, and
write-only opens as necessary to ensure that when a client closes or
downgrades, we don't retain more access than necessary.

Also, I didn't realize the cache behaved this way when I wrote
94415b06eb8a "nfsd4: a client's own opens needn't prevent delegations".
There I assumed fi_fds[O_WRONLY] and fi_fds[O_RDWR] would always be
distinct.  The violation of that assumption is triggering a
WARN_ON_ONCE() and could also cause the server to give out a delegation
when it shouldn't.

Fixes: 94415b06eb8a ("nfsd4: a client's own opens needn't prevent delegations")
Tested-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/filecache.c