提交 5de0e502 编写于 作者: A Andy Adamson 提交者: Trond Myklebust

lockd: simplify nlmsvc_grant_blocked

Reorganize nlmsvc_grant_blocked() to make full use of posix_lock_file().  Note
that there's no need for separate calls to posix_test_lock(),
posix_locks_deadlock(), or posix_block_lock().
Signed-off-by: NAndy Adamson <andros@citi.umich.edu>
Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 15dadef9
...@@ -519,7 +519,6 @@ nlmsvc_grant_blocked(struct nlm_block *block) ...@@ -519,7 +519,6 @@ nlmsvc_grant_blocked(struct nlm_block *block)
{ {
struct nlm_file *file = block->b_file; struct nlm_file *file = block->b_file;
struct nlm_lock *lock = &block->b_call.a_args.lock; struct nlm_lock *lock = &block->b_call.a_args.lock;
struct file_lock *conflock;
int error; int error;
dprintk("lockd: grant blocked lock %p\n", block); dprintk("lockd: grant blocked lock %p\n", block);
...@@ -539,19 +538,15 @@ nlmsvc_grant_blocked(struct nlm_block *block) ...@@ -539,19 +538,15 @@ nlmsvc_grant_blocked(struct nlm_block *block)
} }
/* Try the lock operation again */ /* Try the lock operation again */
if ((conflock = posix_test_lock(file->f_file, &lock->fl)) != NULL) { error = posix_lock_file(file->f_file, &lock->fl);
/* Bummer, we blocked again */ switch (error) {
case 0:
break;
case -EAGAIN:
dprintk("lockd: lock still blocked\n"); dprintk("lockd: lock still blocked\n");
nlmsvc_insert_block(block, NLM_NEVER); nlmsvc_insert_block(block, NLM_NEVER);
posix_block_lock(conflock, &lock->fl);
goto out_unlock; goto out_unlock;
} default:
/* Alright, no conflicting lock. Now lock it for real. If the
* following yields an error, this is most probably due to low
* memory. Retry the lock in a few seconds.
*/
if ((error = posix_lock_file(file->f_file, &lock->fl)) < 0) {
printk(KERN_WARNING "lockd: unexpected error %d in %s!\n", printk(KERN_WARNING "lockd: unexpected error %d in %s!\n",
-error, __FUNCTION__); -error, __FUNCTION__);
nlmsvc_insert_block(block, 10 * HZ); nlmsvc_insert_block(block, 10 * HZ);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册