]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC: r310491
authorrmacklem <rmacklem@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 25 Apr 2017 11:36:25 +0000 (11:36 +0000)
committerrmacklem <rmacklem@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 25 Apr 2017 11:36:25 +0000 (11:36 +0000)
commit8f2a7b5ee5a85fc2fec4106200d50c10d25a6608
tree63cc880b742441f6d36e558bfc7f99cb145e78f8
parent9ae66d52c3ef4fa5c180c77a84f001219aec60e0
MFC: r310491
Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors.

For most NFSv4.1 servers, a NFS4ERR_BAD_SESSION error is a rare failure
that indicates that the server has lost session/open/lock state.
However, recent testing by cperciva@ against the AmazonEFS server found
several problems with client recovery from this due to it generating this
failure frequently.
Briefly, the problems fixed are:
- If all session slots were in use at the time of the failure, some processes
  would continue to loop waiting for a slot on the old session forever.
- If an RPC that doesn't use open/lock state failed with NFS4ERR_BAD_SESSION,
  it would fail the RPC/syscall instead of initiating recovery and then
  looping to retry the RPC.
- If a successful reply to an RPC for an old session wasn't processed
  until after a new session was created for a NFS4ERR_BAD_SESSION error,
  it would erroneously update the new session and corrupt it.
- The use of the first element of the session list in the nfs mount
  structure (which is always the current metadata session) was slightly
  racey. With changes for the above problems it became more racey, so all
  uses of this head pointer was wrapped with a NFSLOCKMNT()/NFSUNLOCKMNT().
- Although the kernel malloc() usually allocates more bytes than requested
  and, as such, this wouldn't have caused problems, the allocation of a
  session structure was 1 byte smaller than it should have been.
  (Null termination byte for the string not included in byte count.)

There are probably still problems with a pNFS data server that fails
with NFS4ERR_BAD_SESSION, but I have no server that does this to test
against (the AmazonEFS server doesn't do pNFS), so I can't fix these yet.

Although this patch is fairly large, it should only affect the handling
of NFS4ERR_BAD_SESSION error replies from an NFSv4.1 server.
Thanks go to cperciva@ for the extension testing he did to help isolate/fix
these problems.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317404 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/fs/nfs/nfs.h
sys/fs/nfs/nfs_commonkrpc.c
sys/fs/nfs/nfs_commonport.c
sys/fs/nfs/nfs_commonsubs.c
sys/fs/nfs/nfsclstate.h
sys/fs/nfsclient/nfs_clcomsubs.c
sys/fs/nfsclient/nfs_clport.c
sys/fs/nfsclient/nfs_clrpcops.c
sys/fs/nfsclient/nfs_clstate.c
sys/fs/nfsclient/nfs_clvfsops.c
sys/fs/nfsclient/nfsmount.h