Fix nfs4_read_recov_clids() looping with dot or dotdot entries

The code doesn't go to the next entry. It just processes the same entry
in an infinite loop. Changed the code to use "for" loop, and removed
readdir calls inside the loop that advance to the next entry.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Return PATH_DOWN only if the client has active delegations.

Signed-off-by: Srikrishan Malik <srimalik@in.ibm.com>
Close the created file.

Signed-off-by: Srikrishan Malik <srimalik@in.ibm.com>
Use the clientid from deleg_entry.

Signed-off-by: Srikrishan Malik <srimalik@in.ibm.com>
Add a couple missing closedir() calls.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Reviewed-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Varibale name change and typo correction

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Check is the client is allowed to reclaim in
nfs4_can_deleg_reclaim_prev().

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Reviewed-by: Malahal Naineni <malahal@us.ibm.com>
When we are expiring the clientid we must first delete the stable
storage entry before releasing state to filesystem.
This avoids any races where the server may crash after rleasing the
state but before removing stable storage entry, which may allow the
client to reclaim locks erroneously.

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Race is possible between clientid expire and deleg revoke.
Hold the cid_mutex and check for cid_confirmed state before recording
the revoked handle.

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