recovery: use normal OPEN/LOCK on ERR_NO_GRACE

if we see NFS4ERR_NO_GRACE from recovery operations, it means we lost our state due to a lease expiration rather than a server reboot.  in this case, it's possible that conflicting locks were granted to other clients, so we have to try normal OPEN/LOCK operations to recover our state.  because they're sent during recovery, nfs41_open() and nfs41_lock() take a new 'bool_t try_recovery' argument so we can avoid recursion

if these operations fail due to conflicting locks, we have no choice but to return errors to the application.  using a stateid that was revoked due to lease expiration results in NFS4ERR_EXPIRED, and we map this error to ERROR_FILE_INVALID: The volume for a file has been externally altered so that the opened file is no longer valid.

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2010-11-30 13:10:30 -05:00 committed by unknown
parent 222c1bf020
commit 0a309c4350
8 changed files with 46 additions and 17 deletions

View file

@ -2986,7 +2986,8 @@ static NTSTATUS map_close_errors(DWORD status)
switch (status) {
case NO_ERROR: return STATUS_SUCCESS;
case ERROR_NETNAME_DELETED: return STATUS_NETWORK_NAME_DELETED;
case ERROR_NOT_EMPTY: return STATUS_DIRECTORY_NOT_EMPTY;
case ERROR_NOT_EMPTY: return STATUS_DIRECTORY_NOT_EMPTY;
case ERROR_FILE_INVALID: return STATUS_FILE_INVALID;
default:
print_error("failed to map windows error %d to NTSTATUS; "
"defaulting to STATUS_INTERNAL_ERROR\n", status);
@ -4021,7 +4022,7 @@ static NTSTATUS map_readwrite_errors(DWORD status)
switch (status) {
case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
case ERROR_HANDLE_EOF: return STATUS_END_OF_FILE;
case ERROR_FILE_INVALID: return STATUS_FILE_CLOSED;
case ERROR_FILE_INVALID: return STATUS_FILE_INVALID;
case ERROR_INVALID_PARAMETER: return STATUS_INVALID_PARAMETER;
case ERROR_LOCK_VIOLATION: return STATUS_FILE_LOCK_CONFLICT;
case ERROR_NETWORK_ACCESS_DENIED: return STATUS_NETWORK_ACCESS_DENIED;
@ -4194,6 +4195,7 @@ static NTSTATUS map_lock_errors(DWORD status)
case ERROR_ATOMIC_LOCKS_NOT_SUPPORTED: return STATUS_UNSUCCESSFUL;
case ERROR_OUTOFMEMORY: return STATUS_INSUFFICIENT_RESOURCES;
case ERROR_SHARING_VIOLATION: return STATUS_SHARING_VIOLATION;
case ERROR_FILE_INVALID: return STATUS_FILE_INVALID;
/* if we return ERROR_INVALID_PARAMETER, Windows translates that to
* success!! */
case ERROR_INVALID_PARAMETER: return STATUS_LOCK_NOT_GRANTED;