deleg: handle locks locally on write delegation

new flags for nfs41_lock_state: exclusive, delegated, and id
on lock, open_lock_delegate() attempts to register a delegated lock instead of sending a LOCK request to the server
on unlock, open_unlock_delegate() removes/frees delegated locks instead of sending a LOCKU request
on delegreturn, delegation_flush_locks() sends LOCK requests for all delegated locks before returning a delegation
on recovery, recover_locks() avoids lock state recovery for delegated locks

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2011-08-10 10:51:52 -04:00 committed by unknown
parent 284c273999
commit 9e556da92c
4 changed files with 302 additions and 117 deletions

View file

@ -233,18 +233,22 @@ static int recover_locks(
/* recover any locks for this open */
list_for_each(entry, &open->locks.list) {
lock = list_container(entry, nfs41_lock_state, open_entry);
if (lock->delegated)
continue;
if (*grace)
status = nfs41_lock(session, &open->file, &open->owner,
lock->type, lock->offset, lock->length, TRUE, FALSE, &stateid);
status = nfs41_lock(session, &open->file,
&open->owner, lock->exclusive ? WRITE_LT : READ_LT,
lock->offset, lock->length, TRUE, FALSE, &stateid);
else
status = NFS4ERR_NO_GRACE;
if (status == NFS4ERR_NO_GRACE) {
*grace = FALSE;
/* attempt out-of-grace recovery with a normal LOCK */
status = nfs41_lock(session, &open->file, &open->owner,
lock->type, lock->offset, lock->length, FALSE, FALSE, &stateid);
status = nfs41_lock(session, &open->file,
&open->owner, lock->exclusive ? WRITE_LT : READ_LT,
lock->offset, lock->length, FALSE, FALSE, &stateid);
}
if (status == NFS4ERR_BADSESSION)
break;