Added support for CLAIM_PREVIOUS

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Reviewed-by: Srikrishan Malik <srimalik@in.ibm.com>
Return Not Supported for both nfs4_op_delegpurge and CLAIM_DELEGATE_PREV

Currnt code mostly supports CLAIM_DELEGATE_PREV but there is lot more
needed to fully support it.

Some of the missing pieces are:
1. Fully supporting nfs4_op_delegpurge.
2. making sure that the delegations are not removed/cleaned on
   setclientid sequence.

This is helpful for those clients which uses persistent storage
for data cache, and these delegations are called client-persistent delegations
When there is needed we can address above mentioned issues and enable then.

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Reviewed-by: Srikrishan Malik <srimalik@in.ibm.com>
Set the pre-recalled flag for deleg reclaims.

This flag will be set for reclaim opens when for the delegation would not be
granted for non-reclaim opens.

Signed-off-by: Srikrishan Malik <srimalik@in.ibm.com>
Reviewed-by: Malahal Naineni <malahal@us.ibm.com>
Fix for coverity CID24725

The allocated string buffer is not enough to hold the original string
buffer, but we do copy only a partial string.  This is clearly a false
positive from coverity as it doesn't really look at how the string is
used! Use gsh_strdup as this is more cleaner, and as a bonus avoids
this false positive from coverity!

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Reviewed-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Don't try deleting dot and dotdot entries

Replaced the while statement with for statement that avoided a goto
label altogether as well.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Reviewed-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Don't give out delegation on a just recalled file

If a client's open causes recall of existing delegations, we respond to
the client with NFS4ERR_DELAY and recall the delegations asynchronously.
If delegations are recalled and another client were to open the file
before the original client that caused recalls, we should not give out
delegation to the latter client to avoid starving the former. We simply
avoid granting delegations for some time period from the last recall to
avoid this.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Reviewed-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Fix granting delegations based on client's behaviour

If a client has more than than couple revokes, we stop giving
delegations to the client.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Reviewed-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Remove unused fds_disabled field

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Reviewed-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Fix delegation states from flags to state values!

They are not really flags. Also changed them to enum type.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Remove unused DELEG_REVOKED definition

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Remove unneeded DELEG_RETURNED state

Delegation state DELEG_RETURNED is set when the state_t is about to be
deleted. This isn't needed, and removed DELEG_RETURNED as well.

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