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>
Call cache_inode_kill_entry on unlink failure

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Properly init rw locks in cache_entry_t

Since a recycled cache inode entry is cleaned first, which destroys the
rw locks, we must init them for recylced entries as well as newly
allocated entries.

Also, if the initialization of rw locks fails, we must destroy any
already initialized locks before releasing entry.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Check for NULL alloc in cih_hash_entry

cache_inode_new_entry will check the return code in the next patch.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fixup cache_inode_new_entry error paths and cleanup

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Keep track of all locks per export, not just NLM locks

For unexport purposes, we will need to know all the locks associated
with an export, not just the NLM locks.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Catch some ERR_FSAL_STALE conditions in SAL and call cache_inode_kill_entry

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