Use state_lock while getting delegation

Removed delegation related code block from nfs4_op_open, and added it
into a new function called do_delegation(). Modified the existing
get_delegation() code to work while holding state_lock.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Check open conflicts before delegation recalls

Modified state_add_impl() to call state_conflict() before calling
check_deleg_conflict(). Also fixed freeing the state and releasing
pin_ref on the cache inode entry if delegations are recalled.

Also removed some conflict detection dead code!

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Use deleg_list for only REGULAR_FILE objects

nfs4_op_delegreturn() should check to make sure that it is a regular
file before using deleg_list as it is not initialized for any other file
type.  Also changed a check for non DIRECTORY to REGULAR_FILE in
do_delegation().

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Self deadlock in delegrecall_impl

The state_lock is pushed inside delegrecall_impl, so avoid acquiring
state_lock in queue_delegrecall while calling delegrecall_impl.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Acked-by: Srikrishan Malik <srimalik@in.ibm.com>
Use COPY_STATEID to copy stateid.

Removed an unused call to state_share_check_conflict(), used
COPY_STATEID to copy delegation stateid.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Clean up in nfs4_op_delegreturn

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Don't overwrite the delegation recall time

We should keep the first time when we attempt to recall the delegation
for calculating when to revoke. Don't overwrite that value with every
attempt to recall the delegation.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Set lock_reclaim in get_delegation

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>