Use pin reference instead of LRU reference on export root and junction cache inodes

In order for cache_inode_kill_entry to work properly if an export root
or junction inode is deleted in the underlying file system, we must
pin the entries instead of taking an LRU reference.

Proper cleanup will be in the next patch.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fix definition of cache_inode_dec_pin_ref to be a void function

Also document the 2nd closefile parameter.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fix callers of cache_inode_dec_pin_ref to use false/true instead of FALSE/TRUE

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Convert gsh_client and gsh_export lock from mutex to rwlock

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

Conflicts:
	src/support/exports.c
Protect export root and junction fields with gsh_export lock

The fields so protected are:

exp_root_cache_inode
exp_mounted_on_file_id
exp_junction_inode
exp_parent_exp

Also fix a leaked fsal_obj_handle in mnt_Mnt

9p code takes a reference to exp_root_cache_inode without taking
an additional reference. That is something that must be fixed but'
is beyond the scope of this patch.

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

This routine enables taking a reference on a cache inode given a pointer
to one (that is guaranteed to not go bad based on the lock passed to
cache_inode_get_protected). The reference is taken by copying the
entry's key under the lock provided, and then doing a regular hash look
up using that key.

The passed lock MUST guarantee the inode can not proceed far enough
along being cleaned to have it's key released (nor the cache_entry_t
memory either).

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Use cache_inode_get_protected in nfs_export_get_root_entry

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make nfs3_FSALToFhandle and nfs2_FSALToFhandle be passed the relevant export

The handle must be converted using the relevant export_id, so we need to
pass the export in instead of relying on the export in the FSAL handle.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make nfs4_FSALToFhandle be passed the relevant export

The handle must be converted using the relevant export_id, so we need to
pass the export in instead of relying on the export in the FSAL handle.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Eliminate use of fsal_export exp_entry where easy to do so

We should use the gsh_export passed in req_op_context where possible.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Build better faked up req_op_context when real one isn't available

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Remove req_op_context from state async functions

Many of these functions have no need of a req_op_context.

If one of these functions actually needs a req_op_context it already is
building the best one it can given the information available to it.
There is no sense faking up a root context without an export.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Remove an extra cache_inode_lru_ref from state_owner_unlock_all

An extra reference was introduced by commit
fa00240948f85add87a8baf2c617394c22cddf04 though that reference is
actually in the right place, so remove the one that existed before that
is in the wrong place...

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fix calls to nfs4_return_one_state where lock is held

These calls indicated lock was not held, when in fact it was
held, guaranteeing a deadlock.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add req_op_context to FSAL commit op

Also since this is an API change, bump major API to 2

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make state_del, state_del_locked, and nfs4_State_Del void

There really is no failure here. If the HashTable_del fails, it is
because the entry actually is not in the hash table, which may signify
an inconsistency but isn't worth passing up the stack.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Remove exportid from cache inode key

Exportid is not needed in the cache inode key, and cache inodes are
going to be associated with multiple exports.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add req_op_context to cache_inode_new_entry

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add TODO notes in places with attribute races

Here are some places attributes are accessed without attr_lock.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Don't call cache_inode_lock_trust_attrs in cache_inode_get

Anyone who uses attributes calls cache_inode_lock_trust_attrs before
using them in any case.

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