nfsd4: fix open downgrade, again
authorJ. Bruce Fields <bfields@redhat.com>
Mon, 19 Sep 2011 19:07:41 +0000 (15:07 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 20 Sep 2011 18:43:39 +0000 (14:43 -0400)
commit3d02fa29dec920c597dd7b7db608a4bc71f088ce
tree797913e7135502f54d52fa48f1956a8ff7b640dd
parentf7a4d872078a5e143d88adb561627f637046b05a
nfsd4: fix open downgrade, again

Yet another open-management regression:

- nfs4_file_downgrade() doesn't remove the BOTH access bit on
  downgrade, so the server's idea of the stateid's access gets
  out of sync with the client's.  If we want to keep an O_RDWR
  open in this case, we should do that in the file_put_access
  logic rather than here.
- We forgot to convert v4 access to an open mode here.

This logic has proven too hard to get right.  In the future we may
consider:
- reexamining the lock/openowner relationship (locks probably
  don't really need to take their own references here).
- adding open upgrade/downgrade support to the vfs.
- removing the atomic operations.  They're redundant as long as
  this is all under some other lock.

Also, maybe some kind of additional static checking would help catch
O_/NFS4_SHARE_ACCESS confusion.

Cc: stable@kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c