freebsd-skq/sys/fs/nfs
Rick Macklem b2fc0141d9 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.

Reported by:	cperciva
Tested by:	cperciva
MFC after:	3 months
Differential Revision:	https://reviews.freebsd.org/D8745
2016-12-23 23:14:53 +00:00
..
nfs_commonacl.c Cleanup unnecessary semicolons from the kernel. 2016-04-10 23:07:00 +00:00
nfs_commonkrpc.c Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors. 2016-12-23 23:14:53 +00:00
nfs_commonport.c Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors. 2016-12-23 23:14:53 +00:00
nfs_commonsubs.c Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors. 2016-12-23 23:14:53 +00:00
nfs_var.h Make nfscl_getmyip() use new routing KPI. 2016-01-15 09:05:14 +00:00
nfs.h Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors. 2016-12-23 23:14:53 +00:00
nfscl.h
nfsclstate.h Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors. 2016-12-23 23:14:53 +00:00
nfsdport.h Make the size of the hash tables used by the NFSv4 server tunable. 2015-05-27 22:00:05 +00:00
nfskpiport.h
nfsm_subs.h Use M_SIZE() instead of hand-crafted (and mostly correct) NFSMSIZ() macro 2015-01-07 17:22:56 +00:00
nfsport.h Update the nfsstats structure to include the changes needed by 2016-08-12 22:44:59 +00:00
nfsproto.h Update the nfsstats structure to include the changes needed by 2016-08-12 22:44:59 +00:00
nfsrvcache.h Do not generate 1000 unique lock names for nfsrc hash chain locks. 2014-07-31 19:24:44 +00:00
nfsrvstate.h NFS: spelling fixes on comments. 2016-04-29 16:07:25 +00:00
nfsv4_errstr.h
rpcv2.h
xdr_subs.h