Fix OPEN2 test for pynfs

the type attribute contains the file type but the mode attribute only
has the mode bits accepted by chmod.  Mask off these bits from the stat.st_mode.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Let cache_inode_create pass back the error from new_entry.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Fix NFS4 open op to return correct protocol errors

Return proper errors on attempted opens of non-regular files.  Fixes
pynfs open test failures.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Remove "Use_Test_Access" cache inode parameter.  No longer required.

This was an option added for GPFS support of alternate access checking.
This allowed GPFS to use its library for access checks rather than the
built in access check.  With the new api, this is now under the control of
the fsal which can substitute or stack whatever access checks it wants,
however it wants.  This choice is totally transparent to the cache inode
layer.

NOTE:
The attributes lock for the entry (and object handle) is held during the test
method call.  No other locks should be required.  This also guarantees
the access check on a specific object is safe regardless of  whether the
fsal or whatever the fsal calls is safely reentrant.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Fix fsal lock_op method args

Turn request_lock into a pointer and save the struct copy

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Fix uninitialized locktype in nfs4_op_lock

Somehow this got missed on merge?

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Reuse already open fd for VFS getattr method

Closing fds is hazardous to locks.  Only open an fd on a regular
file when none is already there.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
IdMapper - process numeric UID/GID in NFS4

As the source of last resort try checking if owner and owner_group in
NFSv4 attributes is purely numeric value. If the check passes then assume
that ID is good and add it to the in-core cache - this deals with servers
which return IDs in form 17@myhost.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
NFSv3 - respect size of cookie verifier

After times in attriblist grew extra nanoseconds they cannot
be used to set NFSv3 cookie verifier anymore - use just seconds,
it's better to return verifier which is less precise then to blow
the stack.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
NFS - initialise variables properly

Keep compiler happy - initialise variables

Signed-off-by: Max Matveev <makc@gmx.co.uk>
NFSv3 - make nfs_SetPostOpAttr sane

There is no need to call nfs3_FSALattr_to_Fattr twice if the attribute
pointer is NULL.

And make nfs_SetPostOpAttr return void - it cannot return any errors
because it deal with them by setting attributes_follow flag.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
Don't waste time printing socket address

If DUPREQ is not at full debug then printing sockaddr is
pure waste of time.
(cherry picked from commit 8b214a05115010e56c0af8d169cf03674294149b)
libcidr - avoid buffer underflow

Signed-off-by: Max Matveev <makc@gmx.co.uk>
NFS access check - don't convert IP to string unless necessary

When checking if a client can access an export delay conversion
of IP address to string until you're absolutely sure it is necessary,
i.e. you're about to check a wildcard entry. Doing it all the time
just burns extra CPU cycles for no gain.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
Don't cache idempotent requests

If a request is marked as idempotent then there is no
need to add it to DRC - this saves a lot of work
on read-mostly workloads.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
Remove lock_status processing in VFS fsal

Proper lock status is managed in SAL and cache inode.  Remove the
member and its logic.  This means that we just close the file and
assume that close gets called only when the server really means it.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Merge remote-tracking branch 'mmakc/new-api-misc3' into new_api-dev
Fix NFS4 LOCKT initialization

Initialize lock_desc.lock_type properly - it wasn't

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Make error return for not reg file on cache_inode_rdwr explicit

Signed-off-by: Jim Lieb <jlieb@panasas.com>