Remove some extraneous glist_init

glist_init is to be called on glist_heads that are the actual head of the
list. An empty list is specified by {&head, &head}.

The glist_heads that link items into the list are set to {NULL, NULL} to'
indicate they are not in any list.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make cache_inode_put a static inline function

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

This function acquires an initial reference on the given cache entry from
a pointer from some object that implies the entry is pinned.

The caller MUST hold a lock that prevents the completion of the inline
cleanup code in cache_inode_lru_unref (for example, a lock that prevents
state_wipe_file from completing) AND the object must still be subject to
that cleanup (i.e. state_wipe_file MUST not have already processed the
object).

One simple way to assure this is to find the object on some list that
state_wipe_file MUST remove the object from. While holding the lock that
protects the list, call cache_inode_get_lru_ref_pinned.

It is possible the entry has already been killed, in which case there is
no point in proceeding.

There is a small window where the object has been killed, but the qid
has not yet been changed. The entry might not even be reachable from the
hash table (since killed entries are removed from the hash table first and
second put into the LRU_ENTRY_CLEANUP queue). But this window exists only
within the context of being inside the cache_inode_kill_entry function,
and the callers MUST hold an LRU reference. Therefore, while the entry is
about to be killed, it is actually safe to take additional LRU references
and do whatever work the caller was going to do.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Reorganize state_t and remove some typedefs

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

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
All NFS v4.0 ops that use an open/lock owner should check owner seqid the same

These ops all require the client to change the owner seqid, but also result
in a stateid seqid change. In order for the replay logic to work, we must
identify a potential replay based on the stateid seqid changing, and then
check the owner seqid for replay.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Replace FALSE with false and TRUE with true

FALSE and TRUE are ONLY used in XDR, otherwise we should stick with the
standard true and false constants.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Hold state_lock in write for nfs4_return_one_state and state_lookup_layout_state

nfs4_return_one_state does a glist_length which requires the state lock,
since most callers hold the lock, change so all callers hold the lock.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Change name of list of states in cache_entry_t for simpler cscope examination

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Eliminate separate deleg_data structue

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Simplify delegrecall_context and delegrecall_one

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Eliminate separate deleg_data structue

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Add refcount to state_t

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Free state_layout_recall_file list resources

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Eliminate separate deleg_data structue

Oops. accidentally deleted state_lock...

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
DELEGRETURN does not have an open/lock owner, don't call Copy_nfs4_state_req

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Use nfs4_sanity_check_FH for nfsa4_op_delegreturn

For correctness to RFC, replace NFS4ERR_ISDIR with NFS4ERR_INVAL.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Add refcount to state_t

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Use nfs4_sanity_check_FH for nfsa4_op_delegreturn

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make fsal in cache_inode_key_t void * to assure it's not dereferenced

the struct fsal_module pointer is just used as an element of the key and
should not be dereferenced since a key does not hold an fsal module reference
and thus the pointer is not guaranteed to be valid.

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