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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>

Conflicts:
	src/FSAL/FSAL_PT/fsal_truncate.c
Build better faked up req_op_context when real one isn't available

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.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>
Signed-off-by: Adam C. Emerson <aemerson@linuxbox.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>
Fix up issues in cache_inode_hash.h

Check for NULL alloc in cih_hash_entry

cache_inode_new_entry will check the return code in the next patch.

Fix comparison in cih_fh_cmpf:

1. check hash first, if equal, then
2. check key len second, if equal then
3. compare key third

Old code didn't look at length at all, and worse, didn't actually
compare the keys...

Remove /n from log messages

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>
Signed-off-by: Anand Subramanian <anands@redhat.com>
Catch some ERR_FSAL_STALE conditions in SAL and call cache_inode_kill_entry

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Signed-off-by: Anand Subramanian <anands@redhat.com>
Don't count STATE_FSAL_ESTALE and STATE_DEAD_ENTRY as errors in notify and unlock all

These errors indicate the entry was stale/dead, and thus can not have
any state, so it is ok to continue, the state in question has definitely
been released (or will be released as soon as all LRU references on the
entry are released.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Signed-off-by: Anand Subramanian <anands@redhat.com>