Skip to content

Commit

Permalink
NLM: don't unlock on cancel requests
Browse files Browse the repository at this point in the history
 Currently when lockd gets an NLM_CANCEL request, it also does an unlock for
 the same range.  This is incorrect.

 The Open Group documentation says that "This procedure cancels an
 *outstanding* blocked lock request."  (Emphasis mine.)

 Also, consider a client that holds a lock on the first byte of a file, and
 requests a lock on the entire file.  If the client cancels that request
 (perhaps because the requesting process is signalled), the server shouldn't
 apply perform an unlock on the entire file, since that will also remove the
 previous lock that the client was already granted.

 Or consider a lock request that actually *downgraded* an exclusive lock to
 a shared lock.

 Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
 Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
J. Bruce Fields authored and Trond Myklebust committed Jan 6, 2006
1 parent f232142 commit 5996a29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
5 changes: 0 additions & 5 deletions fs/lockd/svclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ nlmsvc_delete_block(struct nlm_block *block, int unlock)
nlmsvc_remove_block(block);
if (fl->fl_next)
posix_unblock_lock(file->f_file, fl);
if (unlock) {
fl->fl_type = F_UNLCK;
posix_lock_file(file->f_file, fl);
block->b_granted = 0;
}

/* If the block is in the middle of a GRANT callback,
* don't kill it yet. */
Expand Down
13 changes: 2 additions & 11 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,19 +1961,10 @@ EXPORT_SYMBOL(posix_block_lock);
void
posix_unblock_lock(struct file *filp, struct file_lock *waiter)
{
/*
* A remote machine may cancel the lock request after it's been
* granted locally. If that happens, we need to delete the lock.
*/
lock_kernel();
if (waiter->fl_next) {
if (waiter->fl_next)
__locks_delete_block(waiter);
unlock_kernel();
} else {
unlock_kernel();
waiter->fl_type = F_UNLCK;
posix_lock_file(filp, waiter);
}
unlock_kernel();
}

EXPORT_SYMBOL(posix_unblock_lock);
Expand Down

0 comments on commit 5996a29

Please sign in to comment.