Increase number of pseudo fs nodes to 2048 and check limits

Also clean up some dead code.

The limit of 100 pseudo fs nodes is rather insufficient for 1000 exports...

To make it somewhat sane to test, I increased the number of path elements in
a pseudo path to 128.

Moved set up of pseudo fs until after creating root entries. This assures
that the pseudo fs only contains valid exports (previously, an export for
a path that didn't actually exist in the FSAL would be instantiated in the
pseudo fs, and then the export would have been discarded, leaving a dangling
pointer for someone to trip on).

Also improved the logging within the pseudo fs.

Also check pseudofs_id in pseudo fs handle before dereferencing array.

Ported from 1.5: a0de6fb4a764ca4d049436eda750f9f7cce71275

Apparently 2.0 somehow wound up with two calls to nfs4_ExportToPseudoFS.
The 1.5 patch moved the call to later in init, so this patch removes the
earlier call to match the 1.5 code.

Signed-off-by: Frank Filz <ffilzlnx@mindspring.com>
Fix up READDIR in pseudo fs so it handles NFS4ERR_WRONGSEC properly

Allow READDIR with just MOUNTED_ON_FILEID to succeed even if NFS4ERR_WRONGSEC.

Also clean up some out of memory handling for READDIR, don't bother trying
to recover, just LogFatal.

Ported from 1.5: b37c3372278a5c07a4b6192ebdda4d723648d2d4

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Don't check timestamp or length in creds when comparing v4 clientid verifiier

Confirmed ACE's comment. Clients create new creds so timestamp is a problem.

New creds might have a different group list, which changes length of cred, if
we don't care about group list, shouldn't care about cred length either.

Ported from 1.5: 2c309a762a38d58e660783ea7c264de02a3974d7

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Clean up use of NFS4ERR_BADHANDLE vs NFS4ERR_STALE

A handle that COULD be a valid Ganesha handle, that happens to not be
valid currently (for example, exportid doesn't reference a currently
valid export), or a PseudoFS ID that is in range, but not currently
valid should result in NFS4ERR_STALE.

NFS4ERR_BADHANDLE should be reserved for handles that are badly formed
or otherwise could not ever be a valid Ganesha handle. We also more
carefullly check handle validity, and make checks in order such that
there won't be any surprises, like indexing beyond end of provided
handle.

We must also properly validate PseudoFS handles by the same criteria.

NFS v3 and NLM validate handles during nfs_rpc_execute. If the handle
is bad or the exportid is bad, an SVC AUTH error was sent. This is
wrong, we must send NFS3ERR_BADHANDLE for bad handles and
NFS4ERR_STALE for invalid exportid. Because NLM has ASYNC procedures,
we allow a NULL pexport to be passed to NLM procedures that take
handles, and let the procedure handle responding. NFS procedures will
be responded to within nfs_rpc_execute.

Additionally, remove CACHE_INODE_UNAPPROPRIATED_KEY and
STATE_UNAPPROPRIATED_KEY since these errors are never used (and
were translated into NFS4ERR_BADHANDLE which is probably not the right
error if we ever did have that return code.

Several handle validation routines return an NFS4ERR, we now use the
returned value in most cases (except for RESTOREFH which has a specific
error code to report empty SavedFH.

Added nfs4_sanity_check_SavedFH to simplify checking of SavedFH and
remove duplicate code.

Fix PUBFH. We were not setting the length of it, so it was taking
maximum length and this was not equal to ROOTFH. The length of a
PseudoFS handle is also now computed the same way a normal handle
length is computed.

NFS v2/v3 LINK and RENAME operations should properly validate
the destination directory handle and properly report errors.

Clean up how handle errors are logged. LogInfo is used so that
sysadmins can debug handle issues without having to see gory
code internals.

Replace nfs4_sprint_fhandle with sprint_fhandle4 (remove duplicate
code).

Replace print_buff with new routine print_fhandle_fsal for FSAL handles
to be more informative.

Ported from 1.5 95bb50ea9cfe743c312cb325fe5739c67dc44d17

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>