Add abstract_atomic.h

This header file moves atomic functions out of cache_inode, selects
the implementation of atomics based on the version of GCC being used,
expands the range of supported types, adds atomic fetch and store, and
regularizes naming.

Frank added atomic_add and atomic_sub and made all functions return
the updated value.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Fix issue with long running thread detection

Need to zero out worker data timer_start after request is complete
otherwise long running thread detection kicks in on now idle
worker threads.

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Fix issue with grace period skipped if no v4 clients in recovery dir

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Improve findlog.sh to find functions in if conditionals

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Remove --disable-nfs4*-locks and conditionals

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Add DisplayOpaqueValue routine

Display opaque values as hex string or ASCII string if printable
in log messages

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Use ServerEpoch for write verifier

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Improve HashTable debugging

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>

Conflicts:

	src/Cache_inode/cache_inode_fsal_hash.c
	src/HashTable/HashTable.c
	src/MainNFSD/nfs_init.c
	src/include/HashTable.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Make SAL defend against unlock and cancel  on non-regular files

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Move clientid and sessionid code into SAL

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Move sessionid and clientid data and functions into sal_data.h and sal_functions.h

And clean up a few related things including moving stateid hash table
parameters into nfs_core.h with the rest of the hash table parameters.

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Move release_lockstate and release_openstate into nfs4_state.c

Also move a couple prototypes in sal_functions.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Strip old clientid implementation out

Ganesha will NOT run after this patch!!!!

Look for the next set of patches to implement the new function!!!

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>

Conflicts:

	src/SAL/nfs4_clientid.c

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>

Conflicts:

	src/include/sal_functions.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Replace COMPONENT_CLIENT_ID_COMPUTE with COMPONENT_CLIENTID

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Cosmetic changes in MainNFSD/nfs_reaper_thread.c

This will make merge of new functionality cleaner.

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Rename fields in nfs_client_id_t

Make it easier to see when nfs_client_id_t fields are being used
and distinguish them from other similarly named fields.

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>

Conflicts:

	src/include/sal_data.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Rename na_r_netid and na_r_addr in nfsv41.h to get rid of some #ifdef _USE_NFS4_1

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Implement new clientid function

Use new abstract_mem.h

This is a pretty big change, many of the major points are
discussed below.

Convert SETCLIENTID and SETCLIENTID_CONFIRM to new clientid.

Convert EXCHANGE_ID and CREATE_SESSION to new clientid. These functions
now more closely follow RFC 5661. They are not perfect, but pass a
signiificant number of pynfs tests.

Make clientid owner part of client id structure. This allows each
clientid record to have it's own owner.

Add valid_lease function for EXCHANGE_ID to use.

Remove some unused clientid constants and cid_client_name field.

Remove obsolete clientid parameter from nfs4_Check_Stateid.

Extract confirmed and unconfirmed reaping into function to save dupe code.

Make NFS4 and NFS41 LOCK, LOCKU, and LOCKT code more alike. Add grace
period checking to v4.1. Fix up lock/open owner confusion in v4.1 LOCKT.
Fix up reuse of lock owner that didn't have attached open owner (LOCK
reusing lock owner from LOCKT). And several cosmetic changes (including
putting variables unique to v4 LOCK together for easier diff between
v4 and v4.1 code.

Use new lease expiry for operations that use SEQUENCE or pass a stateid.
Lease is reserved early, and when the compound is complete, then the
reservation is released and the lease time updated. All v4.1 operations
use this since they start with a SEQUENCE op. For v4.0 operations, this
is used when the operation looks up a stateid.

Add new functions to manage leases.

reserve_lease_lock atomically checks if lease is valid, and if so
also reserves the lease to prevent expiry while the lease is in
use by an operation. It returns with cid_mutex held.

update_lease releases a lease reservation and also actually
performs the lease renewal.

update_lease_locked must be called holding cid_mutex.

These operations make sure that once a lease renewing operation
starts, no matter how long it takes to complete, the lease will
not expire, and at the end of the operation, the lease will be
renewed.

valid_lease_locked allows checking lease validity while already
holding cid_mutex.

Also add pointer to reserved clientid in compound_data_t.

Split client id hash table into confirmed and unconfirmed tables. We need
to be able to look up both confirmed and unconfirmed client ids. The
assumption is that for any clientid4 value there is at most one confirmed
client id and one unconfirmed client id. For a given long form client id,
there might be multiple unconfirmed client ids, but still only a single
confirmed client id. Also add function for generating new
setclientid_confirm values.

Add function to compute new clientid4 .The short form clientid4 can not
just be a hash of the long form client id. The spec outlines conditions
under which a different clientid4 must be issued. We also need to know
when clientid4 is from another instance of Ganesha, old or in cluster
environment from a different node. To this extent, a new clientid4 will
be computed using a 32 bit counter and ServerEpoch.

Add hash table for long form client id values.

Add reference counting to nfs_client_id_t. The reference counting is not
perfect. There are some uses of nfs_client_id_t for example in the
PNFS code that may not be properly refcounted.

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>

Conflicts:

	src/include/sal_data.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>

Conflicts:

	src/include/sal_functions.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
TEMP 0521

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>